codesessioncodesession (codesession-cli, code session, code-session) ā Track AI agent session costs, tokens, file changes, and git commits. Works with Claude Code, Open...
Install via ClawdBot CLI:
clawdbot install brian-mwirigi/codesessionTrack agent session costs, file changes, and git commits. Enforces budget limits and provides detailed session analytics with a full web dashboard.
Latest: v2.0.0 - Alerts dashboard, start fresh, insights page, alarm mode.
š¦ npm ⢠ā GitHub ⢠š Changelog
```bash
npm install -g codesession-cli
clawhub install codesession
```
After installing, the cs command is available globally. The OpenClaw agent will automatically use it to track sessions.
Requirements: Node.js 18+ and C/C++ build tools (needed to compile the embedded SQLite module).
>
| OS | Install build tools |
|---|---|
| Ubuntu/Debian | sudo apt-get install -y build-essential python3 |
| macOS | xcode-select --install |
| Windows | npm install -g windows-build-tools or install Visual Studio Build Tools |
| Alpine | apk add build-base python3 |
>
Data is stored locally at ~/.codesession/sessions.db.
cs dashboard to review session data in a browser```bash
cs start "task description" --json --close-stale
cs start "task description" --json --resume
cs start "task description"
```
Agent mode vs interactive mode: With--json, the session is created in the database, JSON is printed, and the process exits immediately -- the session stays "active" and tracks git changes when you runcs end. Without--json, the process stays running with a live file watcher and git commit poller until you press Ctrl+C or runcs endin another terminal.
```bash
cs log-ai -p anthropic -m claude-sonnet-4 --prompt-tokens 8000 --completion-tokens 2000 --json
cs log-ai -p anthropic -m claude-sonnet-4 --prompt-tokens 8000 --completion-tokens 2000 --agent "Code Review Bot" --json
cs log-ai -p anthropic -m claude-opus-4-6 -t 15000 -c 0.30 --json
cs log-ai -p openai -m gpt-4o --prompt-tokens 5000 --completion-tokens 1500 -c 0.04 --agent "Research Agent" --json
```
Providers: anthropic, openai, google, mistral, deepseek
Cost is auto-calculated from a configurable pricing table (17+ built-in models). Use cs pricing list --json to see known models. If a model is unknown, provide -c manually.
Agent Name (optional): Use --agent "Agent Name" to track which agent performed the work. Perfect for multi-agent systems, A/B testing, and cost attribution. Agent names appear in the dashboard and can be used to filter/analyze costs per agent.
```bash
cs status --json
```
Returns JSON with current session cost, tokens, files changed, duration. All JSON responses include schemaVersion and codesessionVersion fields.
```bash
cs end -n "completion notes" --json
```
When ending, codesession automatically scans git for all files changed and commits made since the session started -- even if --json mode was used (no live watcher needed).
```bash
cs dashboard
cs dashboard --port 4000 # custom port
cs dashboard --no-open # don't auto-open browser
```
The dashboard shows:
```bash
cs show --json --files --commits
```
```bash
cs stats --json
```
```bash
cs export --format json --limit 10
cs export --format csv
```
```bash
cs note "Starting refactor phase"
cs note "Tests passing, moving to cleanup"
```
Timestamped annotations appear in cs show --json under annotations.
```bash
cs recover --max-age 12
```
Auto-ends any active sessions older than 12 hours.
Agents should always use --json on every command for structured, parseable output.
cs start "Fix authentication bug" --json --close-stalecs note "analyzing auth flow" --jsoncs log-ai -p anthropic -m claude-sonnet-4 --prompt-tokens 8000 --completion-tokens 2000 --agent "Bug Fixer" --jsoncs status --json -- read aiCost fieldcs end -n "Fixed the auth bug, added tests" --jsoncs dashboardTip: Use the --agent flag to identify your agent's work, especially useful in multi-agent systems where different agents handle different tasks (e.g., "Code Review Bot", "Test Writer", "Documentation Agent").
Pricing is configurable. Run cs pricing list to see all known model prices. Override or add models:
```bash
cs pricing set my-model 5.00 15.00
cs pricing set gpt-4o 2.50 10.00 --provider openai
```
If the model isn't in the pricing table, you must provide -c when logging.
If the user has set a budget or you detect high spending:
cs status --json before expensive operationsaiCost exceeds $5.00 in a single session--close-stale on cs start to avoid "session_active" errors from prior crashescs is not installed, skip session tracking ā don't block the user's task--json on every command ā agents must use structured output--json, cs start creates the session and exits (no long-running process needed)--json mode, exit code is always 1 and the response has { "error": { "code": "...", "message": "..." } }schemaVersion in JSON responses to detect breaking changesPeriodically check if the CLI is up to date (e.g. at session start or once per day):
```bash
cs --version # installed version
npm view codesession-cli version # latest on npm
```
If the installed version is behind, notify the user:
"codesession-cli update available: v1.9.4 -> v2.0.0. Run npm install -g codesession-cli to update."
Don't block the workflow for an update ā just inform and continue.
All commands support --json for machine-readable output. Use this when you need to parse session data programmatically.
Generated Mar 1, 2026
Agency uses codesession to track costs across multiple client projects and developer agents. They enforce per-client budget limits and use the dashboard to generate detailed billing reports showing AI usage, file changes, and commit activity for transparent client invoicing.
Large tech company implements codesession across their CI/CD pipeline to monitor AI-assisted code review costs. Different agent types (security reviewer, performance optimizer, style checker) are tracked separately to analyze which AI tools provide the best ROI for specific review tasks.
Coding bootcamp uses codesession to help students understand AI tool costs while learning programming. Instructors set session budgets for exercises, and the dashboard helps students visualize how different coding approaches affect AI usage costs and efficiency.
Independent developers use codesession to track AI-assisted project work across multiple clients. They use the alerts dashboard to prevent budget overruns and export session data to include in project documentation and progress reports for clients.
University research lab uses codesession to track AI model usage across different research projects and team members. The insights page helps identify cost patterns, while agent tracking allows proper attribution of AI expenses to specific research papers and grant-funded projects.
Offer codesession as a cloud-hosted service with team collaboration features, advanced analytics, and integration with popular development tools. Charge monthly per developer seat with tiered pricing based on features like unlimited session history, custom reporting, and API access.
Sell annual enterprise licenses to large organizations with custom deployment options, on-premise installation, dedicated support, and integration with existing enterprise systems like Jira, GitHub Enterprise, and internal billing systems.
Offer basic tracking features for free to individual developers, then charge for advanced features like team dashboards, historical data retention beyond 30 days, custom alert rules, and export capabilities. The free tier drives adoption while premium features target professional teams.
š¬ Integration Tip
Always use --json flag for structured output in automated workflows, and implement cs recover in cron jobs to handle unexpected agent terminations and prevent stale sessions.
Guide for creating effective skills. This skill should be used when users want to create a new skill (or update an existing skill) that extends Claude's capabilities with specialized knowledge, workflows, or tool integrations.
Provides a 7-step debugging protocol plus language-specific commands to systematically identify, verify, and fix software bugs across multiple environments.
A comprehensive skill for using the Cursor CLI agent for various software engineering tasks (updated for 2026 features, includes tmux automation guide).
Write, run, and manage unit, integration, and E2E tests across TypeScript, Python, and Swift using recommended frameworks.
Control and operate Opencode via slash commands. Use this skill to manage sessions, select models, switch agents (plan/build), and coordinate coding through Opencode.
Coding style memory that adapts to your preferences, conventions, and patterns for consistent coding.