codesession-cli
Know exactly how long your sessions take, which files you touched, and what your AI calls cost.
Automatic. Local. No config.
WHAT IT TRACKS
FOUR
THINGS.
Time
Named sessions with start/stop timestamps. Duration, concurrent sessions, stale session recovery.
cs start "task" · cs end -n "notes"Files
Chokidar filesystem watcher. Detects add, change, unlink. Deduped within 1-second windows. Scoped to git root.
342 files across 45 sessionsCommits
Git polling every 10 seconds. Backfills on session end via git log and git diff. Hash, message, author captured.
156 commits · auto-capturedAI Cost
Log per-call with provider, model, and token counts. 17+ models built-in. Custom pricing support. Hard budget caps.
$2.34 · anthropic / claude-sonnet-4-6CS DASHBOARD
SEE THE
FULL PICTURE
One command launches a local analytics server. Real-time KPIs, 30-day projections, per-model breakdowns, and activity heatmaps.
$ cs dashboard
AGENT READY
BUILT FOR
AGENTS TOO
Full programmatic TypeScript API. Wrap your agent loop. Set hard budget caps. Ships as an OpenClaw skill on ClawHub.
BudgetExceededErrorhard caps via thrown exceptionsession.canAfford(n)check before expensive calls--json flagmachine-readable, never promptsclawhub install codesessionone-line OpenClaw setupimport { AgentSession, BudgetExceededError } from 'codesession-cli/agents' const session = new AgentSession( 'Refactor auth', { budget: 5.00, git: true } ) session.start() // mid-session affordability check if (!session.canAfford(2.00)) { // switch to cheaper model } const summary = session.end() // → { duration, cost, files, commits }
codesession-cli — Free CLI to Track Coding Sessions and AI Costs
codesession-cli (also written as codesession cli or code session cli) is an open-source Node.js command-line tool published on npm. It tracks developer coding sessions including session duration, file changes, git commits, and AI API costs. Supported AI providers include Anthropic (Claude), OpenAI (GPT-4o, GPT-4), Google (Gemini), Azure OpenAI, and Cohere — with built-in pricing for 17+ models.
Install with: npm install -g codesession-cli. Use cs start to begin a session, cs log-ai to record AI usage costs, cs end to finish and summarize, and cs dashboard to open the real-time web analytics UI at localhost:3737.
All data is stored locally in a SQLite database at ~/.codesession/sessions.db. No cloud sync, no telemetry. codesession-cli also ships with a full programmatic TypeScript API for AI agent workflows, budget enforcement via BudgetExceededError, and an OpenClaw skill available on ClawHub.
Keywords
codesession-cli, codesession cli, coding session tracker, code session tracker, AI cost tracking CLI, AI API cost tracker, track AI costs developer, claude cost tracker, openai cost tracker cli, anthropic cost tracker, gpt4 cost tracking, llm cost tracker, developer session tracker, coding time tracker, terminal session tracker, npm session tracker, git commit session tracker, file change tracker cli, developer productivity cli, ai agent session manager, openclaw codesession, free developer time tracker cli, open source coding session tracker