Report only some projects
init sets up your tools for all projects on your machine by default.
To report only from selected projects, remove the global setup once and then
opt in per project:
costpilot-agent remove --global # once
cd ~/code/my-project
costpilot-agent init --project --endpoint https://costpilot.example.com
Then restart the tool, send one prompt and verify from the same directory:
costpilot-agent check
--project writes the project-level files: ./.claude/settings.json plus
./.envrc, ./.gemini/settings.json (plus ./.gemini/.env with a token),
./.codex/config.toml plus ./.codex/hooks.json, and
./.cursor/hooks.json. Once the global setup is gone, projects without
them export nothing and run no hook. init --project takes endpoint and
token only from the same checkout, so pass --endpoint (and --token) the
first time; without them it writes http://localhost:8787.
These files usually live in the repository. With --token the secret lands
in every one of them, including the hook command in settings.json and
hooks.json. Keep them out of version control (for example via
.git/info/exclude), or run init --project without --token and provide
OTEL_EXPORTER_OTLP_HEADERS=Authorization=Bearer <secret> in the shell that
starts the tool: Claude Code's exporter and the hook fall back to it. Codex
CLI and Gemini CLI need the token in their files.
Claude Code needs direnv
Claude Code ignores CLAUDE_CODE_ENABLE_TELEMETRY and the OTEL_*
variables in project-level settings (settings.json and
settings.local.json alike). A project setup there would register the hook
but never export any usage. init --project therefore writes the telemetry
variables as export lines into ./.envrc and only the hook into
./.claude/settings.json.
Once per machine:
- Install direnv and hook it into your shell, for
example
eval "$(direnv hook zsh)". - Run
direnv allowin the project, and again after everyinit --project.
Start claude from a shell inside the project. In VS Code use the direnv
extension or launch the editor with code . from that shell.
costpilot-agent check tells you whether the variables arrived. direnv also
covers subdirectories, so one .envrc in a parent folder serves every
repository below it that has no .envrc of its own.
Windows
direnv evaluates .envrc with bash, so a Claude Code project setup only
reports when claude is started from a shell that has the direnv hook: Git
Bash, MSYS2 or WSL. Started from PowerShell, cmd, the Start menu or the VS
Code extension, it registers the hook but sends no usage, and nothing warns
about it. Prefer the global setup for Claude Code on Windows. If you edit
.envrc by hand, save it with LF line endings. Gemini CLI, Codex CLI and
Cursor project setups do not need direnv.
Going back
remove is the inverse of init: it strips the telemetry config and the
costpilot hook from the given scope (--global by default, --project for
./) and leaves everything else in the settings files as it was. It takes
the same --tool and --all selection as init.