External Project Setup
This page is where you go after install-and-run.md when you want to attach Agent Tracer to another project — not the agent-tracer repo itself.
1. What is supported today
| Runtime | Automated setup | Still manual | Next doc |
|---|---|---|---|
| Claude Code | yes (npm run setup:external) | MCP server registration | claude-setup.md |
| Codex | yes (npm run setup:external) | none for the normal interactive path | codex-setup.md |
| Other runtimes | no | HTTP + MCP calls directly | runtime-capabilities.md |
Important points:
setup:externalnow bootstraps both Claude Code and Codex.- It does not vendor hook source files or install a permanent Codex plugin, because Codex does not expose an equivalent plugin surface today.
- The Agent Tracer source stays in this repository. The target project gets generated config files and runtime references back to this checkout.
2. Prerequisites
- You have already finished install-and-run.md.
- The monitor server is running and
curl -sf http://127.0.0.1:3847/api/v1/overviewreturns 200. - You have a target project path (e.g.
/absolute/path/to/your-project). - For Claude Code, you can launch the
claudeCLI in that target directory.
3. Run setup:external
From the Agent Tracer repository root:
npm run build # only needed if you haven't built yet
npm run setup:external -- --target /absolute/path/to/your-projectThe only required argument is --target. The script currently bootstraps:
- Claude Code
- creates or merges
target-project/.claude/settings.json - strips any legacy
hooksblock (the plugin owns registration now) - sets
permissions.defaultMode = "acceptEdits"andpermissions.allow = ["WebSearch", "WebFetch"] - prints the absolute path of the Agent Tracer plugin and the
claude --plugin-dir …command to use
- creates or merges
- Codex
- creates or merges
target-project/.codex/config.toml - creates or merges
target-project/.codex/hooks.json - enables repo-local Codex hooks for plain
codexusage - hydrates the manifest at
packages/runtime/hooks/hooks-codex.jsoninto absolute-path commands. Currently registersSessionStart,UserPromptSubmit,PreToolUse(Bash|apply_patch|Edit|Write),PermissionRequest,PostToolUse(Bash),PostToolUse(apply_patch|Edit|Write),PostToolUse(mcp__.*), andStop.
- creates or merges
Expected output:
[claude] Plugin path: /absolute/path/to/agent-tracer/packages/runtime
[claude] Run Claude Code with: claude --plugin-dir /absolute/path/to/agent-tracer/packages/runtimeThe script also parses
--monitor-base-url,--source-repo,--source-ref, and--source-root, but these are not currently used for vendoring — the plugin is referenced directly from this repository.
4. Attach Claude Code
Follow claude-setup.md sections 2 and 3 to:
- Launch Claude Code with
claude --plugin-dir …(or via the marketplace). - Register the
monitorMCP server withclaude mcp add monitor ….
5. Attach Codex
Follow codex-setup.md.
After setup, the intended flow is simply:
cd /abs/path/to/target
codexThe generated .codex/config.toml enables codex_hooks, and .codex/hooks.json provides the monitor hook commands.
6. Attach other runtimes (manual)
There is no automated bootstrap for non-Claude runtimes. Instead, call Agent Tracer's HTTP API or MCP tools directly. Minimum implementation order:
/ingest/v1/sessions/ensure(or/ingest/v1/tasks/start)/ingest/v1/conversation(user.message)/ingest/v1/tool-activity(tool.used)/ingest/v1/tool-activity(exploration or terminal events)/ingest/v1/conversation(assistant.response)/ingest/v1/sessions/end
Add /ingest/v1/workflow, /ingest/v1/coordination, /ingest/v1/lifecycle, /ingest/v1/telemetry, and /ingest/v1/tasks/link as the runtime's capability allows.
References:
- api-integration-map.md — every endpoint mapped to the hook that calls it and its manual-runtime meaning
- runtime-api-flow-and-preprocessing.md — preprocessing rules applied inside each endpoint
- runtime-capabilities.md — what capability flags mean when you register a new runtime
7. Common pitfalls
- Stale
npm run build— after modifying the MCP server entry underpackages/serveror the plugin, rebuild before launching Claude. - Missing
nodeon GUI PATH — when launching Claude Code from a macOS launcher, use the absolute node binary path inclaude mcp add. - Env vars not inherited — Claude Code launched from a GUI does not see shell env vars; launch it from a terminal, or use
launchctl setenvon macOS. - Changes to
.claude/settings.json— restart Claude Code after editing so it picks up the new permissions and plugin path. - Running plain
codexwithout repo-local config — hooks are only guaranteed whencodex_hooksis enabled.setup:externalwrites.codex/config.tomlso plaincodexin the target project uses hooks by default. - Expecting hook parity with Claude Code — Codex hooks currently intercept Bash directly. File edits, MCP calls, and web search/fetch are observed from rollout JSONL after Codex writes those response items.
8. Quick end-to-end check
- Monitor server running and healthy.
npm run setup:external -- --target /abs/path/to/target.claude mcp add monitor …completed.- Run
codexinside the target project and trigger one Bash command. - Open the target project with
claude --plugin-dir …. - Do one read or edit inside Claude.
- The dashboard at
http://127.0.0.1:5173shows a new task with the matching event in its timeline.