# Agents

> Share sessions from inside your coding agent with skills and hooks.

You can run `traces share` by hand, but it is more useful when your agent does it. There are three building blocks.

| Mechanism | What it does | Command |
| --- | --- | --- |
| Skills | The agent answers "share this to traces" | `traces setup skills` |
| Agent hooks | Sessions upload while you work | `traces setup hooks` |
| Git hooks | Trace IDs are attached to commits as git notes | `traces setup git` |

`traces setup` runs the interactive version of all three.

## Claude Code

```bash
traces setup skills --global --agent claude-code
traces setup hooks --agent claude-code     # run inside a project; refuses to install in $HOME
```

Hooks run in the environment of Claude Code, not of your shell. Set the instance URLs in `~/.claude/settings.json`:

```json
{
  "env": {
    "TRACES_HTTP_URL": "https://adtraces.adfactory.app",
    "TRACES_URL": "https://adtraces.adfactory.app",
    "TRACES_API_URL": "https://adtraces.adfactory.app"
  }
}
```

The hooks (`SessionStart`, `UserPromptSubmit`, `Stop`, `SessionEnd`) call `traces hook agent <event> --agent claude-code`. Other agents have equivalent files, see [Supported agents](/docs/cli/supported-agents); give each of them the same three variables.

## Git hooks

```bash
traces setup git
```

A post-commit hook writes the IDs of the active traces into `refs/notes/traces` on the commit and shares unshared traces in the background. Notes travel with pushes, so a reviewer can look up the session that produced a change. One trace per line: `traces:<externalId> <sharedUrl>`.

## Let an agent set itself up

`https://adtraces.adfactory.app/start.md` is a short instruction document for agents. Tell your agent: "Read https://adtraces.adfactory.app/start.md and set me up on traces."
