Subspan is a coding-agent observatory. It scans git history to detect sessions authored by AI coding agents (Claude Code, Cursor, Copilot, Codex, etc.), lets Claude Code push live tool-call and cost data via hooks, and presents everything in a real-time dashboard.
- Installation
- First Run
- Tracking Repositories
- Scanning for Sessions
- Claude Code Hook Integration
- Dashboard Overview
- Sessions Page
- Session Detail
- Cost Budgets
- Team Management
- Exporting Data
- CLI Reference
- Troubleshooting
Requirements: Node.js 22 LTS, Git, a GitHub account (for OAuth).
git clone <repo-url>
cd subspan
npm install- Go to GitHub → Settings → Developer settings → OAuth Apps → New OAuth App
- Set:
- Homepage URL:
http://localhost:3000 - Authorization callback URL:
http://localhost:3000/api/auth/callback/github
- Homepage URL:
- Copy the Client ID and generate a Client Secret
cp .env.local.example .env.localEdit .env.local:
GITHUB_CLIENT_ID=your_client_id_here
GITHUB_CLIENT_SECRET=your_client_secret_here
AUTH_SECRET=any-random-32-character-string
NEXTAUTH_URL=http://localhost:3000Build and start the server:
npm run build
npm startOpen http://localhost:3000 and sign in with GitHub.
Important: Always use
npm start(ornpm run devfor development). Never runnext devdirectly — the custom HTTP server (server.ts) is required for WebSocket live-update support.
Node version: Subspan requires Node 22 LTS for the dev server. If you have multiple Node versions installed via Homebrew, use
PATH="/opt/homebrew/opt/node@22/bin:$PATH" npm run dev.
With the server running on port 3000:
node scripts/seed.mjsThis creates 11 simulated sessions across two demo projects so you can explore the dashboard without needing real agent data.
A "tracked repository" is a git repo that Subspan will scan for agent-authored commits.
- Go to Settings (gear icon in the sidebar)
- Enter the absolute path to your repository
- Click Add Repository
./node_modules/.bin/tsx cli/index.ts track /path/to/your-repo
./node_modules/.bin/tsx cli/index.ts track /path/to/your-repo --name "My Project"./node_modules/.bin/tsx cli/index.ts list./node_modules/.bin/tsx cli/index.ts untrack my-projectScanning reads git commit history and groups agent-authored commits into sessions.
Subspan checks each commit in order:
Co-Authored-By:tags in the commit message (highest confidence)- Commit message patterns (e.g.
🤖 Generated with Claude) - Author email patterns
- Custom rules from config
Commits with low confidence are grouped as agent: unknown.
Commits by the same (author, branch) pair are grouped into sessions. A new session starts when the gap between commits exceeds 120 minutes (configurable).
Via UI: Go to Settings and click Scan Now.
Via CLI:
# Scan all tracked repositories
./node_modules/.bin/tsx cli/index.ts scan
# Scan a specific project
./node_modules/.bin/tsx cli/index.ts scan my-project./node_modules/.bin/tsx cli/index.ts watch
./node_modules/.bin/tsx cli/index.ts watch --interval 10m # every 10 minutes
./node_modules/.bin/tsx cli/index.ts watch --interval 1h # every hourInterval format: 30s, 5m, 1h. Default is 5m.
Hooks give Subspan real-time visibility into your Claude Code sessions — every tool call, token cost, and context usage is streamed live as it happens.
./node_modules/.bin/tsx cli/index.ts hooks installThis writes four hooks (PreToolUse, PostToolUse, Notification, Stop) into ~/.claude/settings.json. No server restart or npm link required.
./node_modules/.bin/tsx cli/index.ts hooks status| Hook | Data captured |
|---|---|
PreToolUse |
Tool name, input, subagent spawns (Task calls) |
PostToolUse |
Tool output, duration, success/error status |
Notification |
Context window usage (input tokens, cache tokens, model) |
Stop |
Session end; triggers cost + subagent metric aggregation |
Hooks use Claude Code's session_id and the current working directory to associate tool calls with the right project. Make sure to run Claude Code from inside a tracked repository directory.
./node_modules/.bin/tsx cli/index.ts hooks uninstallThe dashboard (/dashboard) gives a live overview of all agent activity.
| Card | What it shows |
|---|---|
| Total Sessions | All-time session count; live count in sublabel |
| Total Cost | Cumulative USD cost across all sessions |
| Tool Calls | Total tool invocations tracked via hooks |
| Success Rate | Completed sessions as a percentage of all finished sessions |
| Cache Hit Rate | Prompt cache efficiency: read tokens / (read + write tokens) |
| Budget Usage | Current month spend vs your org-wide budget; links to Budgets page |
The cache hit rate card colors green (≥70%), amber (40–69%), or red (<40%) to signal whether sessions are reaping cache savings.
If any budget is at 80%+ of its limit, a banner appears above the KPIs. It turns red at 100%.
Sessions currently running appear as cards with a pulsing live indicator. Click any card to open the live session detail.
Donut chart showing the share of sessions per agent type (claude-code, cursor, copilot, etc.). Hover for exact counts and costs.
30-day rolling cost history. Useful for spotting spending spikes.
The most-spawned subagent types (e.g. Explore, Plan, code-reviewer). Populated from Task tool calls in hook data.
Horizontal bar chart of the most-used tools, with failure rate pills:
- Green — <5% failure rate
- Amber — 5–20%
- Red — >20%
7-day × 24-hour grid showing session density. Darker/brighter cells = more sessions at that day+hour combination.
The sessions page (/sessions) lists all sessions with filtering and search.
- Project — filter by tracked repository
- Agent — filter by agent type
- Status — running / completed / failed / unknown
- Author — filter by commit author email
Use the chip buttons to jump to common time windows:
- Last 24h — sessions from the past 24 hours
- Last 7d — past week
- Last 30d — past month
- Click the active chip again to clear it back to "All time"
The search box filters sessions by summary, branch name, author, or project name. Matching text is highlighted in amber in the results.
Click the Download button next to the search box to export the current filtered view:
- CSV — opens in Excel/Numbers, 14 columns (id, agent, author, project, branch, status, model, start/end times, duration, cost, tokens, tool calls)
- JSON — full structured data, useful for scripting
The export respects all active filters and caps at 1000 rows.
Click any session row to open the detail view.
Shows token and cost metrics for the session:
- Input/output/cache tokens
- Total cost in USD
- Tool call count and failure count
- Subagent count
A horizontal bar showing peak context window usage for the session. Colors:
- Blue — under 60% of the model's context window
- Amber — 60–85%
- Orange/Red — above 85%
All events in chronological order:
- Commits — git commits included in the session
- Tool Calls — individual tool invocations from hooks (collapsible; shows input/output)
- Subagent Cards — Task tool calls that spawned subagents; expand to see the prompt, result, and nested tool calls
- Notes — any manual notes attached to the session
The sidebar shows other sessions on the same project and branch that overlap in time — useful for spotting parallel or follow-up work.
Budgets let you set monthly USD spending caps at four levels of granularity.
| Scope | What it covers |
|---|---|
| Org | All sessions across all projects and users |
| Project | All sessions in a specific tracked repository |
| User | All sessions authored by a specific user (matched by email) |
| Agent | All sessions by a specific agent type (e.g. claude-code) |
Go to Budgets in the sidebar. Use the Add Budget form to choose a scope and set an amount. Budgets reset at the start of each calendar month.
# Set an org-wide monthly budget of $100
./node_modules/.bin/tsx cli/index.ts budget set org 100
# Set a per-project budget
./node_modules/.bin/tsx cli/index.ts budget set project my-project 50
# Set a per-user budget
./node_modules/.bin/tsx cli/index.ts budget set user alice@example.com 25
# Set a per-agent budget
./node_modules/.bin/tsx cli/index.ts budget set agent claude-code 200
# List all budgets with current month spend
./node_modules/.bin/tsx cli/index.ts budget list
# Delete a budget (get the ID from budget list)
./node_modules/.bin/tsx cli/index.ts budget delete <id>When a budget reaches 80%, the dashboard banner turns amber and the Budget KPI card shows "approaching limit". At 100%, both turn red.
The Budget KPI card also shows a projected month-end spend based on a linear extrapolation of your current burn rate.
Subspan supports multi-user teams via shareable magic invite links — no email/SMTP required. The first person to sign in claims ownership of the default organization; after that, owners and admins can mint invite links for anyone else.
| Role | Can do |
|---|---|
| owner | Everything. Promote/invite admins. Remove any member. |
| admin | Create/revoke invites (member role only), remove members (except owners), edit budgets, delete projects, change scan config. |
| member | Read-only across dashboard, sessions, projects, budgets, profile, export. Cannot create or delete budgets, cannot delete projects, cannot see the invite form. |
Server-side enforcement is centralized in requireRole(['owner','admin']) — even if a member scripts a mutation directly, the API returns 403 Forbidden.
- Sign in as owner or admin.
- Settings → Team → scroll to Create invite link.
- Pick a role (
memberalways available;adminonly visible to owners). - Pick an expiry:
1 day,7 days(default),30 days, ornever. - Set max uses (default 1, up to 100). Keep at 1 for single-person invites; raise it for team-onboarding links.
- Click Create invite. A modal appears with the one-time URL — copy it immediately. The raw token is never stored on disk (only its SHA-256 hash), so there's no way to retrieve it after you close the modal.
The invitee opens the link in any browser:
- If signed out → redirected to
/login?callbackUrl=/invite/<token>→ GitHub OAuth → automatically returned to the accept page. - If signed in → instantly enrolled into the organization with the role embedded in the invite → redirected to
/dashboard?joined=1. - If the link is dead (revoked, expired, or exhausted) → a friendly "Invite [state]" card renders with guidance to ask for a new link.
The accept is transactional — two browser tabs racing the last seat of a maxUses=1 invite will have exactly one succeed and one receive a 410.
In Settings → Team, click Revoke next to any pending invite. Revocation is immediate; existing members keep their access (it only blocks future accepts). If you need to evict an already-joined member, use Remove on the Members table instead.
- Remove is visible to owners and admins, hidden for the current user's own row.
- Admins cannot remove owners; only owners can.
- The system refuses to remove the last owner (409) to prevent locking out of your own org.
Short answer: one user, one org, for now. The orgMembers composite primary key (userId, orgId) allows one user to belong to many orgs at the DB level, and an invite accept will happily insert a new membership for each org. However, several layers of the app assume single-tenant:
- The nav sidebar has no org switcher — the team page / dashboard / budgets always render the first membership returned by SQLite.
requireRole()authorizes against "any org the user is in" rather than an active org.- Sessions, projects, and budgets are not org-scoped in the query layer.
Practical effect: if a user accepts invites to two different orgs, everything keeps working but both orgs' data effectively merges in the UI. This is acceptable for the current local-first deployment where a Subspan instance serves one team. Proper multi-org support (org switcher in sidebar, active-org JWT claim, org-scoped queries, requireRole(orgId, ...)) is tracked as part of the cloud-deployment roadmap.
If you need to split workspaces today, run a second Subspan instance with a different DATABASE_URL.
There are two ways to export session data.
On the Sessions page, apply any filters/search you want, then click Download → CSV or Download → JSON. The export matches exactly what's visible in the table, capped at 1000 rows.
# Export all sessions as JSON to stdout
./node_modules/.bin/tsx cli/index.ts export sessions
# Export with date range
./node_modules/.bin/tsx cli/index.ts export sessions --from 2026-04-01 --to 2026-04-30
# Export as CSV
./node_modules/.bin/tsx cli/index.ts export sessions --format csv
# Write directly to a file
./node_modules/.bin/tsx cli/index.ts export sessions --format csv --output sessions.csv
# Pipe into other tools
./node_modules/.bin/tsx cli/index.ts export sessions | jq '.[].cost | tonumber' | awk '{sum+=$1} END {print sum}'CSV columns: id, agent, author, project, branch, status, model, startedAt, endedAt, durationMinutes, cost, inputTokens, outputTokens, toolCalls.
All CLI commands talk directly to the local SQLite database. No running server is required.
Prefix:
./node_modules/.bin/tsx cli/index.ts <command>For convenience, add an alias:
alias subspan='./node_modules/.bin/tsx /path/to/subspan/cli/index.ts'
subspan init # Initialize .subspan/ in current directorysubspan track <path> # Track a git repository
subspan track <path> --name "Name" # Track with a custom display name
subspan untrack <name-or-id> # Stop tracking
subspan list # List all tracked repositoriessubspan scan # Scan all tracked repositories once
subspan scan <project-name> # Scan a specific project
subspan watch # Continuous scan (default: every 5 minutes)
subspan watch --interval 30s # Scan every 30 seconds
subspan watch --interval 1h # Scan every hoursubspan stats # Colored summary: today / this week / all-time
subspan stats --json # Same data as JSON (pipe-friendly)
subspan top # Live view of running sessions (Ctrl+C to exit)subspan stats output:
Subspan Stats
Today
Sessions 8
Cost $0.26
Top agent claude-code
This Week
Sessions 8
Cost $0.26
All Time
Sessions 98
Cost $13.94
Top Agents
claude-code 57 sessions $12.63
cursor 19 sessions $0.61
Top Subagent Types
Explore 13 spawns
Plan 4 spawns
subspan budget list # Table: scope, limit, spent, % used, status
subspan budget set org 100 # Set org-wide limit to $100/month
subspan budget set project <name> 50 # Set project limit
subspan budget set user <email> 25 # Set per-user limit
subspan budget set agent claude-code 200 # Set per-agent limit
subspan budget delete <id> # Delete a budgetsubspan budget list output:
Scope Label Limit Spent % Used Status
------- -------- -------- -------- ------- ------
org org-wide $100 $14 14% OK
project subspan $50 $12 25% OK
subspan export sessions # All sessions as JSON to stdout
subspan export sessions --from 2026-04-01 # From a date
subspan export sessions --to 2026-04-30 # To a date
subspan export sessions --format csv # As CSV
subspan export sessions --output out.csv # Write to file (stderr shows count)subspan hooks install # Wire Claude Code hooks into ~/.claude/settings.json
subspan hooks uninstall # Remove hooks
subspan hooks status # Show which hook types are installedsubspan log --agent claude-code --project my-project --summary "Refactored auth module"
subspan log --agent cursor --project my-api --summary "Fixed rate limit bug" --duration 45subspan dashboard # Start the dashboard server and open it in your browser
subspan dashboard --port 8080Run subspan init in your project directory, or ensure you're running the CLI from the directory that contains .subspan/.
- Check that the repository is tracked:
subspan list - Confirm the repo has git history:
git log --oneline | head -5 - Make sure commits have agent signatures (Co-Authored-By, message patterns, or author email patterns)
- Lower confidence threshold or add custom rules in Settings
- Verify hooks are installed:
subspan hooks status - Confirm the server is running on port 3000 before starting Claude Code
- Check that you're working inside a tracked repository directory
- View server logs — the
POST /api/ingest/hookendpoint logs every hook payload
Error: The module ... was compiled against a different Node.js version
Rebuild the native module for your Node version:
# If you have Homebrew Node 22:
PATH="/opt/homebrew/opt/node@22/bin:$PATH" npm rebuild better-sqlite3
# Or switch your default Node to 22 via your version managerThe web server always runs correctly under Node 22. The CLI and web server share the same native module, so both need the same Node version.
The stats endpoint failed. Check:
- Is the server running? (
curl http://localhost:3000/api/dashboard/stats) - Are you signed in? The endpoint requires an active session.
- Check the terminal where
npm startis running for error output.
This is a known browser quirk when the Content-Disposition header is not picked up. Use the CLI export instead:
./node_modules/.bin/tsx cli/index.ts export sessions --format csv --output sessions.csvThe WebSocket server runs on the same port as the HTTP server via the custom server.ts. If you ran next dev directly instead of npm run dev, WebSockets won't be available. Stop the server and restart with npm run dev or npm start.