Master the TokenCap command-line interface. A powerful, local-first utility designed to package codebase context for AI tools.
Get started by installing the TokenCap CLI globally via npm. This provides the tokencap executable.
Ask about any part of your codebase and get a unified intelligence view: files, risk, architecture, dependencies, review group, recent changes, and git timeline — all from a single command.
Analyze your repository and automatically generate a complete Self-Loading Universal Context Layer (AGENTS.md, START_HERE.md) or Execution Contract (v1.1.0) under .tokencap/agent/ to teach AI agents engineering discipline.
Ask a natural language question and TokenCap automatically retrieves only the relevant files.
Manually compile prompt-optimized context files for a specific keyword or topic.
Generate all three files: main snapshot, project knowledge graph, and developer context memory in one command.
Start a background watcher that regenerates all snapshot files automatically whenever a file changes.
Pack your project workspace into a token-budgeted, importance-scored context pack for LLMs.
Perform semantic change analysis to determine risk rating, breaking changes, and suggested tests.
Inspect permanent codebase laws, view compliance ratings, verify schema rules, or search for rules by severity or category.
Initialize a local project configuration or print the currently resolved configuration including profile defaults.
INITIALIZE CONFIG
tokencap initCreates a default config file .tokencap.json in your workspace root.
RESOLVE CONFIG
tokencap configPrints resolved configuration tree combined with CLI overrides.
| Flag | Description | Default |
|---|---|---|
| --profile <name> | Select context profile (compact, balanced, deep, gpt-4o, etc.). | balanced |
| --root <path> | Specify the workspace root directory. | . |
| --out <path> | Snapshot output path (for main snapshot). | TOKENCAP.md |
| --max-files <n> | Maximum number of files to include in snapshot. | 90 |
| --max-bytes <n> | Total source byte budget for files combined. | 220000 |
| --max-file-bytes <n> | Per-file content byte limit. | 14000 |
| --no-diff | Skip including Git diff snippets in the snapshot. | false |
| --no-contents | Skip selected source file contents (outline only). | false |
| --debounce <ms> | Regeneration debounce delay in watch mode. | 3000 |
| --mode <name> | Retrieval/pack mode: review | debug | architecture | minimal. | review |
| --budget <number> | Custom token budget for ask/context/pack commands. | 12000 / 8000 / 20000 |
| --staged | Analyze only staged changes (for diff command). | false |
| --last | Analyze changes in the last commit (for diff command). | false |
| --pr | Generate PR summary description (for diff command). | false |
| --prompt | Generate AI prompt/review prompt (for ask/context/diff commands). | true (ask) |
| --no-prompt | Skip prompt.md generation (for ask command). | false |
| --json | Output machine-readable JSON (for ask/context/diff/graph/agent/constitution commands). | false |
| --open | Open interactive HTML graph viewer in browser (for graph command). | false |
| --ai | Generate detailed narrative AI summary (for graph command). | false |
| --diff | Generate graph structural diff vs last run (for graph command) or constitution diff (for constitution command). | false |
| --full | Run full 8-phase pipeline (for agent command). | true |
| --export <target> | Export rules directly to Cursor, Windsurf, Cline, or Roo Code formats (for agent command). | false |
| --execution | Generate the Execution Contract lifecycle suite under .tokencap/agent/execution-contract/ (for agent command). | false |
| --strict | Strict mode: enables scope drift confirmation and gating rules (for agent command). | false |
| --history | Show snapshot history and score tracking over time (for constitution command). | false |
| --impact <file> | Query which constitution laws are affected by a file (for constitution command) or show affected file/feature count and risk summary (for brain command). | N/A |
| --architecture | Render dependency chain ASCII view (brain) or architecture mapping (agent). | false |
| --rules | Focused generation of coding rules (for agent command). | false |
| --skills | Focused generation of agent skill definitions (for agent command). | false |
| --review | Show review group files and grouping reasons (for brain command). | false |
| --timeline | Show git commit history for cluster files (for brain command). | false |
| --risk | Show risk areas and affected files (for brain command). | false |
| --deps | Show depends-on and used-by lists (for brain command). | false |
Highly optimized JS parser engine ensures execution times in milliseconds.