Capture session context. Resume with intent.
ContextLedger is a local-first CLI for tracking AI-assisted work across coding agents and carrying useful context into the next session.

Install globally from npm:
npm install -g context-ledgerThen run:
# One-command onboarding (recommended)
ctx-ledger onboardonboard defaults:
- turns prompt capture on
- enables Claude + Codex integrations
- runs initial sync
- launches dashboard in the background (default port
4173, auto-fallback if busy)
You can handoff sesssions across different agents as well
# Analyze and generate memory handoff
ctx-ledger handoff --agent claude --from latest --no-launch --out ./handoff.md
Works from the web dashboard too!
- TypeScript + Node.js
- SQLite (
better-sqlite3) - Commander CLI
ctx-ledger enable claude installs async command hooks into Claude settings.
It also performs a one-time backfill from local Claude session logs so existing sessions are available immediately after setup.
- User scope (default):
~/.claude/settings.json - Project scope:
.claude/settings.local.json - Backfill source:
~/.claude/projects/**/*.jsonl(customizable via--projects-path)
Captured events:
SessionStartUserPromptSubmitPreToolUsePostToolUseStopSessionEnd
ctx-ledger enable codex enables incremental ingestion from Codex session rollouts.
- Primary source (rich events):
~/.codex/sessions/**/rollout-*.jsonl - Fallback source:
~/.codex/history.jsonlwhen rollout files are unavailable - Custom sources:
ctx-ledger enable codex --sessions-path /path/to/.codex/sessionsctx-ledger enable codex --history-path /path/to/history.jsonl
ctx-ledger enable gemini enables incremental ingestion from Gemini history JSONL.
- Default source:
~/.gemini/history.jsonl - Custom source:
ctx-ledger enable gemini --history-path /path/to/history.jsonl
ctx-ledger sync all
ctx-ledger sync claude
ctx-ledger sync codex
ctx-ledger sync gemini
# Optional for codex:
ctx-ledger sync codex --sessions-path /path/to/.codex/sessions
# Optional for claude:
ctx-ledger sync claude --projects-path /path/to/.claude/projects --forcestats, summarize, resume, handoff, and dashboard automatically run sync for enabled integrations.
For Claude, this automatic sync runs the one-time backfill (if pending) and then ongoing capture continues via hooks.
Configure privacy settings:
ctx-ledger configure privacy \
--capture-prompts on \
--redact-secrets on \
--redact-emails on \
--allow-remote-prompt-transfer offDefaults:
capturePrompts:offredactSecrets:onredactEmails:offallowRemotePromptTransfer:off
Custom regex redaction patterns:
ctx-ledger configure privacy --add-redaction-pattern "my-secret-pattern"ctx-ledger configure summarizer --provider ollama --model llama3.1ctx-ledger configure summarizer --provider openai --model gpt-4.1-mini
export OPENAI_API_KEY=...ctx-ledger configure summarizer --provider anthropic --model claude-3-7-sonnet-latest
export ANTHROPIC_API_KEY=...If remote prompt transfer is disabled, captured prompt samples are excluded from remote summarizer requests.
ctx-ledger stats --range 7d
ctx-ledger stats --range 30d --group-by tool
ctx-ledger stats --range all --format json
ctx-ledger stats --range all --group-by agent --agent claude
ctx-ledger stats --range all --group-by phase
ctx-ledger stats --range all --group-by projectSupported groups:
intenttoolagentdayphase(planning vs execution)project(working directory / repo path)all
summary now includes planningMinutes and executionMinutes alongside totalMinutes.
Agent filter values:
claudecodexgemini
ctx-ledger summarize --session latest
ctx-ledger summarize --pending --limit 20This stores:
capsules(session summary, outcomes, files/commands/errors/todos, activity timeline, handoff notes, session facts)intent_labels(primary intent + confidence)task_breakdowns(estimated time split)
Intent labels support granular paths. Examples:
codingcoding/frontendcoding/frontend/designresearchresearch/tech-qnasql,deploy,incident,docs,other
Automatic behavior:
- Claude sessions auto-summarize on
Stop(turn-level) andSessionEndhook events. - Codex sessions auto-summarize after Codex turn completion (
task_complete) is imported. - Gemini sessions auto-summarize after sync imports new events.
summarizeremains available as a manual/force command.
ctx-ledger resume --from latest --budget 2000
ctx-ledger resume --from session-a --from session-b --format json
ctx-ledger resume --from latest --out ./resume.mdresume builds a handoff document for your next session by combining saved capsule data (summary/outcomes/todos/files/commands/errors/activity/handoff-notes/session-facts), task breakdowns, and captured prompt samples when available.
Stored in resume_packs.
List saved packs:
ctx-ledger resume-packsStart a coding agent with verify-first context injected from stored session data:
ctx-ledger handoff --agent claude --from latest
ctx-ledger handoff --agent codex --from latest --from session-aGenerate only (without launching an agent):
ctx-ledger handoff --agent claude --from latest --no-launch --format markdown --out ./handoff.md
ctx-ledger handoff --agent codex --from latest --no-launch --format jsonctx-ledger dashboard --port 4173Open:
http://127.0.0.1:4173/- API:
/api/stats,/api/sessions,/api/resume-packs,/healthz - Optional API filter:
?agent=claude|codexon/api/statsand/api/sessions - UI includes planning vs execution and project-time breakdowns, plus project path in recent sessions
- Dashboard auto-refreshes every 3s and keeps syncing enabled integrations in the background
Real Claude capture test (requires authenticated Claude CLI):
npm run test:e2e:claude-captureFull workflow test (stats + summarize + resume + dashboard + codex/gemini sync with fixtures):
npm run test:e2e:fullKeep temporary artifacts for inspection:
npm run test:e2e:full -- --keep-artifactsctx-ledger enable <claude|codex|gemini>ctx-ledger sync <claude|codex|gemini|all>ctx-ledger configure summarizerctx-ledger configure privacyctx-ledger configure showctx-ledger summarizectx-ledger resumectx-ledger handoffctx-ledger resume-packsctx-ledger statsctx-ledger dashboardctx-ledger doctor
Default data directory:
~/.context-ledger
Default database:
~/.context-ledger/context-ledger.db
Override with:
--data-dir <path>
