codesession-cli
See exactly what every AI agent run costs — tokens, files, commits, duration.
Works with Claude Code, OpenClaw, Codex, Cursor, Windsurf, Cline & any AI agent.
Auto-track via skill/MCP · wrap any script with cs run · local API proxy · manual cs log-ai · budget alerts · web dashboard · JSON export · programmatic API
📖 Full Documentation
What's New in v2.6
cs run <command> — one command wraps everything: session + proxy + run + cost summary
cs proxy --session "name" — auto-start a session when starting the proxy
cs today — pick up where you left off: git state, TODOs, PRs, session history across all projects
- Dashboard Help tab — full command reference right in the web UI
- Dashboard Changelog tab — see release history right in the dashboard
- Smarter proxy output — shows live session name, auto-detects Windows vs Unix env var syntax
Full Changelog →
Install
npm install -g codesession-cli
Requires Node.js 18+ and C/C++ build tools (details).
Using Claude Code, OpenClaw, or Codex?
Install the skill once. The agent tracks itself so that you never have to run a command manually.
clawhub install codesession
Every agent task is now automatically tracked: session start/end, every AI call, cost, files changed, commits. Open the dashboard any time:
cs dashboard
No ClawHub? Add the MCP server to Claude Code's settings:
cs mcp # starts Model Context Protocol server
Or copy the skill manually: cp -r $(npm root -g)/codesession-cli/skills/codesession ~/.openclaw/skills/
Running your own agent script?
Wrap it with cs run — one command, zero config:
cs run python my_agent.py
cs run node agent.js
cs run -- npx my-agent --task "fix the bug"
What happens automatically:
- Session started
- Local proxy launched — Anthropic + OpenAI calls intercepted
- Command runs with the proxy pre-configured (no env vars to export)
- Session ended, cost summary printed on exit
● codesession python my_agent.py
↳ proxy active http://127.0.0.1:3739 (API calls auto-tracked)
↳ tracking files, commits, AI usage
[your agent runs here]
✓ Done python my_agent.py
14m • 8 files • 2 commits • $1.43 AI cost
top model: claude-sonnet-4 (38,000 tokens)
cs show full breakdown
cs dashboard
Options:
cs run --name "Fix auth bug" python agent.py # custom session name
cs run --port 4000 node agent.js # custom proxy port
cs run --no-proxy python agent.py # session only, no proxy
What's tracked
| Data | How |
|---|
| AI cost + tokens | Auto-captured through the proxy (or cs log-ai manually) |
| Files changed | Filesystem watcher + git diff on close |
| Git commits | Git log polling during the session |
| Duration | Wall clock, start to end |
Everything stored locally at ~/.codesession/sessions.db. No cloud. No telemetry.
Manual flow
For long-running interactive sessions or when you need more control:
cs start "my task"
# In another terminal — auto-starts a session too:
cs proxy --session "my task"
# In your agent shell
export ANTHROPIC_BASE_URL=http://127.0.0.1:3739
export OPENAI_BASE_URL=http://127.0.0.1:3739/v1
python agent.py
cs end
cs show