TokenCap provides a simplified 11-command CLI for generating AI-ready project context, retrieving semantic files from questions, analyzing code changes, debugging, packing token-budgeted prompt files, generating AI Agent Skill Packs, querying cluster intelligence, and serving local MCP requests.
---
Installation
Install TokenCap globally:
Verify installation:
---
tokencap mcp
Model Context Protocol (MCP) server & host IDE configuration.
Options
--init — Auto-detect host IDE and write workspace configuration.--client <host> — Specify client host explicitly (vscode | antigravity | codex | cursor | claude | windsurf | cline).--tools — List all 11 MCP tool endpoints and descriptions.--test — Run self-test suite calling all endpoints.--health — Run one-shot server health check.
---
tokencap brain
Project Brain — unified intelligence query about any part of your codebase.
Options
--impact — Show affected file/feature count, critical files, and risk level.--architecture — Render dependency chain ASCII view for the cluster.--review — Show review group files and reason for grouping.--timeline — Show git commit history (date + message) for cluster files.--risk — Show risk areas and affected files.--deps — Show full depends-on and used-by lists.
---
tokencap agent
Generate the Self-Loading Universal Context Layer.
Options
--full — Run the full pipeline (default)--architecture — Focused generation of architecture details--rules — Focused generation of project coding rules and conventions--skills — Focused generation of agent skill definitions and instructions--no-agents-file — Skip generating the root-level AGENTS.md file--export <target> — Export rules directly to Cursor, Windsurf, Cline, or Roo Code formats.--execution — Generate the Execution Contract (v1.1.0) under .tokencap/agent/execution-contract/--strict — Strict mode: enables scope drift confirmation and gating rules (v1.1.0)
---
tokencap constitution
Repository Constitution management.
Options
--json — Output raw JSON rule list and graph data.--diff — Diff current constitution rules against the last run.--history — Show snapshot history and score tracking over time.--impact <file> — Query which constitution laws are affected by a specific file.
Subcommands
search <query> — Search constitution rules by keyword, ID, severity, or category.
---
tokencap ask
Smart context retrieval from a natural language question.
tokencap ask "How does authentication work?"
Options
--mode <name> — review | debug | architecture (override auto-detected mode)--budget <number> — Custom token budget. Default: 12000--json — Also export context.json--no-prompt — Skip generating the prompt.md file
---
tokencap context
Manual context generation by topic keyword.
Options
--mode <name> — Override mode: review | debug | architecture--budget <number> — Custom token budget. Default: 8000--json — Also export context.json--prompt — Generate prompt.md file
---
tokencap make
Generate a complete AI-ready project context snapshot.
What it does
Scans your repository and generates the main snapshot files:
TOKENCAP.md — main workspace snapshot containing file content, Git context, diffs, TODOs, and redacted secretsTOKENCAP_GRAPH.md — project knowledge graphTOKENCAP_MEMORY.md — developer context memory
Options
--profile <name> — compact | balanced | deep | gpt-4o | claude-3-5-sonnet | gemini-1.5-flash | gemini-1.5-pro | llama-3-8b--max-files <n> — Maximum number of files to include--max-bytes <n> — Total source byte budget--max-file-bytes <n> — Per-file content byte limit--max-diff-bytes <n> — Git diff byte budget--no-diff — Skip Git diff snippets--no-contents — Skip selected file contents (structure outline only)
---
tokencap graph
Analyze the code knowledge graph and dependency topology.
Presets & Options
--open — Opens the Obsidian-style three-panel interactive viewer in default browser--full — Runs full intelligence (JSON export + AI narrative summary + graph diff + viewer)--minimal — Generates only JSON exports (graph-data.json, nodes.json, edges.json)--quiet — Suppresses verbose logs and shows only a clean stats block--diff — Generates graph-diff.md comparing current relationships vs last run--ai — Generates AI narrative summary only--json — Exports raw JSON files to .tokencap/graph/
---
tokencap diff
Perform a semantic Change Intelligence analysis on your edits.
Options
--staged — Analyze only staged changes (prior to a commit)--last — Analyze changes in the last commit (HEAD~1..HEAD)--pr — Generate a pull request summary description--prompt — Generate an optimized AI code review prompt--json — Output machine-readable JSON analysis
---
tokencap debug
Unified debug session management.
Debug Flags
--start — Start a new debug session (append '-- <command>' to run command and auto-capture stderr, failed tests, and traces)--end — End the active debug session, compile final handoff report, and archive it--log "message" — Add a timestamped update or discovery note to the active session timeline
Example Workflow
tokencap debug --start -- npm test
# (investigate and edit files based on active debug notes)
tokencap debug --log "Reverted middleware changes - test still failing"
tokencap debug --end
# (paste .tokencap/debug/active.md into your AI assistant)
---
tokencap pack
Generate a token-budgeted, importance-scored context pack for LLM prompts.
Options
<topic> — Optional topic or cluster keyword (queries Brain to scope context pack)--mode <name> — Select compression mode: review | debug | architecture | minimal--budget <number> — Set maximum token budget. Default: 20000
---
tokencap watch
Automatically regenerate TokenCap snapshots on file saves.
Options
--debounce <ms> — Milliseconds to wait after a file change before regenerating. Default: 30000
---
Recommended Workflow
Self-Maintaining MCP Service (v1.5)
---
Understand any part of your codebase instantly (v0.9)
---
Teach an AI Agent (v0.8)
---
Teach an AI Agent Engineering Discipline (v1.1)
tokencap agent --execution
---
Teach an AI Agent Permanent Engineering Laws (v1.2)
---
Ask about any part of your codebase (v0.7)
tokencap ask "How does authentication work?"
---
Quick topic context (v0.7)
tokencap context payments
---
Daily Development
---
Before Asking AI
---
During Debugging
tokencap debug --start -- npm test
tokencap debug --log "Tested middleware"
tokencap debug --end
---
Before Deployment