cs run is the zero-configuration approach to tracking any agent script or one-off command. You hand it a command, and it handles the entire session lifecycle — no environment variable setup, no manual start/end calls, no forgotten sessions.
How it works
When you runcs run <command>, CostHQ executes the following sequence automatically:
- Creates a new session — the session name defaults to the command string you passed (e.g.,
python my_agent.py). Override it with--name. - Starts the local proxy on port 3739 — a lightweight HTTP proxy that sits in front of the Anthropic and OpenAI APIs.
- Launches your command with
ANTHROPIC_BASE_URLandOPENAI_BASE_URLalready pointing at the proxy — no shell exports needed. - Intercepts and logs all API calls — every request your command makes to Anthropic or OpenAI is captured and associated with the active session.
- Ends the session and prints a cost summary — when your command exits (success or failure), CostHQ closes the session and prints duration, file changes, commits, and total AI cost.
Usage
-- before commands that have their own flags so the shell doesn’t try to parse them as cs run flags.
Options
Example output
When your command exits, CostHQ prints a summary like this:Running the proxy separately
If you need the proxy running independently of a single command — for example, while you work across multiple terminals or editor sessions — see Local Proxy. You can start the proxy once and leave it running while you usecs start and cs end to control session boundaries yourself.