claude-roi
v0.8.2
Published
Correlate Claude Code token usage with git output to measure AI coding agent ROI
Maintainers
Readme
Codelens AI
Agent Productivity-to-Cost Correlator — Is your AI coding agent actually shipping code?
Codelens AI ties Claude Code token usage to actual git output. It reads your local Claude Code session files, correlates them with git commits by timestamp, and serves a dashboard answering: "Am I getting ROI from my AI coding agent?"
- One command, zero config
- All data stays local
- Works with any git repo where you've used Claude Code
Installation
Option 1: Run directly (no install)
npx claude-roiOption 2: Install globally
# npm
npm install -g claude-roi
# pnpm
pnpm add -g claude-roi
# yarn
yarn global add claude-roiThen run anywhere:
claude-roiOption 3: Clone and run from source
git clone https://github.com/Akshat2634/Codelens-AI.git
cd Codelens-AI
# Install dependencies (pick one)
npm install
# or
pnpm install
# or
yarn install
# Run it
node src/index.jsPrerequisites
- Node.js >= 18 — Download
- Git — installed and configured with
user.nameanduser.email - Claude Code — you must have used Claude Code at least once so session data exists at
~/.claude/projects/
Quick Start
npx claude-roiThis parses your ~/.claude/projects/ session data, analyzes your git repos, and opens a dashboard at http://localhost:3457.
What It Measures
| Metric | Description | | --------------------- | --------------------------------------------------------------- | | Cost per Commit | How much each AI-assisted commit costs in tokens | | Line Survival Rate| % of AI-written lines that survive 24h without being rewritten | | Orphaned Sessions | Sessions with 10+ messages that produced zero commits | | ROI Grade (A-F) | Composite score based on tokens-per-commit and survival rate | | Model Comparison | Efficiency breakdown across Opus, Sonnet, and Haiku | | Branch Awareness | What % of AI commits landed on production | | Peak Hours | Hour-of-day x day-of-week productivity heatmap | | Autonomy Score | Composite A-F grade measuring how independently the agent works | | Autopilot Ratio | Assistant messages per user prompt (higher = more autonomous) | | Self-Heal Score | % of bash calls that are test/lint commands (self-verification) | | Toolbelt Coverage | % of available tools used per session (workflow breadth) | | Commit Velocity | Tool calls per commit (lower = more efficient) |
CLI Options
claude-roi # default: last 30 days, port 3457
claude-roi --days 90 # look back 90 days
claude-roi --port 8080 # custom port
claude-roi --no-open # don't auto-open browser
claude-roi --json # dump all metrics as JSON to stdout
claude-roi --project techops # filter to a specific project
claude-roi --refresh # force full re-parse (ignore cache)
claude-roi --autonomy # print autonomy score to terminal and exitDashboard
The dashboard includes:
- Hero stats — total cost, commits shipped, cost per commit, ROI grade
- Smart insights — auto-generated observations about your usage patterns
- Cost vs Output timeline — dual-axis chart of daily cost and lines added
- Model comparison — cost breakdown by Claude model
- Session length analysis — which session sizes have the best ROI
- Productivity heatmap — GitHub-style grid showing when you're most productive
- Agent Autonomy — autonomy score badge, autopilot ratio, self-heal score, toolbelt coverage, commit velocity, and top verification commands
- Sessions table — sortable, expandable table with per-session metrics, matched commits, and autopilot ratio
How It Works
- Parses JSONL session files from
~/.claude/projects/ - Analyzes git history from each repo you've worked in with Claude
- Correlates sessions to commits by timestamp (during session + 30min buffer)
- Calculates cost using Anthropic token pricing (input, output, cache read/write)
- Serves an interactive dashboard on localhost
Caching
Parsed session data is cached at ~/.cache/claude-roi/parsed-sessions.json. On subsequent runs, only new or modified JSONL files are re-parsed, making startup near-instant. Use --refresh to force a full re-parse.
Cost Calculation
Token costs are version-aware and calculated per model (see Anthropic pricing):
| Model | Input | Output | Cache Read | Cache Write | | --- | --- | --- | --- | --- | | Opus 4.6 | $5/M | $25/M | $0.50/M | $6.25/M | | Opus 4.5 | $5/M | $25/M | $0.50/M | $6.25/M | | Opus 4.0/4.1 (legacy) | $15/M | $75/M | $1.50/M | $18.75/M | | Sonnet 3.7/4.0/4.5/4.6 | $3/M | $15/M | $0.30/M | $3.75/M | | Haiku 4.5 | $1/M | $5/M | $0.10/M | $1.25/M | | Haiku 3.5 | $0.80/M | $4/M | $0.08/M | $1.00/M | | Haiku 3 | $0.25/M | $1.25/M | $0.03/M | $0.30/M |
Line Survival
Line survival uses an approximate heuristic: if lines added in commit A are deleted by a subsequent commit on the same file within 24 hours, they're counted as "churned." This is not git-blame-based tracking and survival rates are rounded to the nearest 5%.
Project Structure
Codelens-AI/
├── package.json
├── README.md
├── .gitignore
└── src/
├── index.js # CLI entry point
├── claude-parser.js # Parse Claude Code JSONL session files
├── cache.js # Parsed data caching layer
├── git-analyzer.js # Parse git log with branch awareness
├── correlator.js # Match sessions to commits by timestamp
├── metrics.js # Calculate ROI metrics and insights
├── server.js # Express server + API routes
└── dashboard.html # Single-file dashboard (inline CSS/JS)Releasing
Releases are automated via GitHub Actions. To publish a new version:
npm version patch # or minor / major
git push --follow-tagsThis automatically publishes to npm and creates a GitHub Release with auto-generated notes.
Setup (one-time): Configure trusted publishing on npm for the claude-roi package, linking it to the GitHub Actions workflow. No tokens or secrets needed.
Contributing
Contributions are welcome! Please see CONTRIBUTING.md for development setup, guidelines, and ideas for contributions.
Privacy
All data stays on your machine. The only network requests are for Chart.js and Inter font from CDNs. No telemetry, no data collection.
License
MIT
