codebase-snapshot 0.20.12 → 0.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/CHANGELOG.md +44 -6
  2. package/README.md +46 -19
  3. package/SECURITY.md +2 -2
  4. package/dist/bin.js +12173 -9823
  5. package/dist/{chunk-TUKY6KLH.js → chunk-TDPYLX7X.js} +6312 -4472
  6. package/dist/cli.cjs +12074 -9744
  7. package/dist/cli.d.cts +76 -2
  8. package/dist/cli.d.ts +76 -2
  9. package/dist/cli.js +549 -14
  10. package/dist/{generate-worker-DMzNbsAW.d.cts → generate-worker-D56JeXwx.d.cts} +2 -2
  11. package/dist/{generate-worker-CRMESc0b.d.ts → generate-worker-DakxZs-l.d.ts} +2 -2
  12. package/dist/index.cjs +6292 -4466
  13. package/dist/index.d.cts +281 -63
  14. package/dist/index.d.ts +281 -63
  15. package/dist/index.js +1 -1
  16. package/dist/mcp.cjs +10486 -4393
  17. package/dist/mcp.d.cts +26 -11
  18. package/dist/mcp.d.ts +26 -11
  19. package/dist/mcp.js +1 -1
  20. package/dist/{types-C5ytHMYz.d.ts → types-D5XYzksd.d.cts} +50 -2
  21. package/dist/{types-C5ytHMYz.d.cts → types-D5XYzksd.d.ts} +50 -2
  22. package/docs/about.md +86 -0
  23. package/docs/agent.md +28 -6
  24. package/docs/answer.md +99 -48
  25. package/docs/benchmarks.md +34 -34
  26. package/docs/brief.md +80 -81
  27. package/docs/cli.md +103 -27
  28. package/docs/codebase-token-budget.md +14 -13
  29. package/docs/configuration.md +1 -1
  30. package/docs/contents.md +66 -0
  31. package/docs/deploy.md +2 -2
  32. package/docs/faq.md +112 -0
  33. package/docs/glossary.md +152 -0
  34. package/docs/health.md +1 -1
  35. package/docs/how-to-feed-a-repo-to-claude.md +6 -0
  36. package/docs/impact.md +102 -0
  37. package/docs/install.md +4 -3
  38. package/docs/llm-codebase-context.md +166 -0
  39. package/docs/mcp-server-for-codebase.md +155 -0
  40. package/docs/mcp.md +81 -82
  41. package/docs/migration.md +83 -85
  42. package/docs/output.md +1 -3
  43. package/docs/security-review.md +20 -9
  44. package/docs/slice.md +1 -1
  45. package/docs/tools.md +159 -185
  46. package/docs/troubleshooting.md +11 -11
  47. package/docs/vs-code2prompt.md +7 -0
  48. package/docs/vs-gitingest.md +7 -0
  49. package/docs/vs-repomix.md +10 -1
  50. package/docs/workspace.md +1 -1
  51. package/package.json +9 -2
package/docs/cli.md CHANGED
@@ -57,7 +57,11 @@ as it makes it.
57
57
  - [Commands](#commands)
58
58
  - [`generate`](#generate)
59
59
  - [`validate` / `check`](#validate--check)
60
+ - [`serve`](#serve)
61
+ - [`health`](#health)
60
62
  - [`report`](#report)
63
+ - [`impact`](#impact)
64
+ - [`brief`](#brief)
61
65
  - [`setup`](#setup)
62
66
  - [`init`](#init)
63
67
  - [`explain <path>`](#explain-path)
@@ -65,6 +69,7 @@ as it makes it.
65
69
  - [`describe`](#describe)
66
70
  - [`update`](#update)
67
71
  - [`skill`](#skill)
72
+ - [`mcp`](#mcp)
68
73
  - [Options](#options)
69
74
  - [Exit codes](#exit-codes)
70
75
  - [Output streams](#output-streams)
@@ -98,7 +103,7 @@ Exit `0` when the snapshot passes its own integrity check, `1` when it does not.
98
103
 
99
104
  ```
100
105
  📸 Generating snapshot for: /path/to/repo
101
- Branch: main (fallback) | Part budget: 300 KB | Generator: 0.20.12 (project dependency ^0.20.12)
106
+ Branch: main (fallback) | Part budget: 300 KB | Generator: 0.21.0 (project dependency ^0.21.0)
102
107
 
103
108
  ✅ Snapshot generated in 0.14s:
104
109
  - Tracked files: 121 included of 128 paths found — 7 skipped (default-ignore 5, binary 1, sensitive-file 1); every one is listed in snapshot/reports/audit.md
@@ -199,6 +204,56 @@ It takes `--cwd`, `--out-dir`, `--no-config`, `--format` and `--no-update-check`
199
204
  generation settings are rejected, not ignored: `report --max-part-bytes 120k` exits `2` with a
200
205
  message naming the commands that do accept it.
201
206
 
207
+ ### `impact`
208
+
209
+ ```bash
210
+ codebase-snapshot impact --diff main
211
+ codebase-snapshot impact --paths src/lib/jwt.ts,src/routes/login.ts --format json
212
+ ```
213
+
214
+ Builds a live index from `manifest.json` when one is current, overlays changed and new files in
215
+ memory when the working tree has moved, or scans the confined working tree when no snapshot exists.
216
+ It resolves the change through the same import resolver the generator used and reports the
217
+ reverse-import closure (what imports the changed files, then what imports those) plus the tests that
218
+ directly import a changed or affected file. Test files are kept out of `affected[]` and listed in
219
+ `tests[]`, so the production blast radius is not inflated by every test that imports a barrel. It
220
+ never writes into the repository.
221
+
222
+ Use exactly one source for the change:
223
+
224
+ - `--diff <ref>` compares the working tree with that git ref, including staged, unstaged and
225
+ untracked changes. A ref beginning with `-` is refused.
226
+ - `--paths <a,b>` treats the named repository-relative paths as the change. Absolute paths and
227
+ `..` segments are refused.
228
+
229
+ The report separates what it knows: `changed[]` says whether each path is in the snapshot,
230
+ `affected[]` carries the distance and the exact import specifier for every hop, `tests[]` lists
231
+ candidate tests (never coverage), `unresolved[]` names repository-internal imports that did not
232
+ resolve (bare packages and Node built-ins are not counted), and
233
+ `warnings[]` says when the snapshot is dirty or the result was truncated. `--depth` (default 3,
234
+ max 8) bounds the reverse walk; `--max-results` (default 200, max 1000) bounds `affected[]`.
235
+
236
+ Exit `0` when the report was produced, `1` when the live index cannot be built or an existing
237
+ manifest is unreadable, and `2` for a usage error. `--format json` writes the stable report object to stdout; text mode writes the
238
+ human report to stderr, like every other human-facing command.
239
+
240
+ → [Impact reports](impact.md): the field contract, resolution rules and what the report does not claim.
241
+
242
+ ### `brief`
243
+
244
+ ```bash
245
+ codebase-snapshot brief "how does authentication work?"
246
+ codebase-snapshot brief --diff main --copy
247
+ codebase-snapshot brief --paths src/router.ts --out notes/review.md --format pr-comment
248
+ ```
249
+
250
+ Pack one redacted, bounded Markdown brief for a reviewer or a model. With a question it uses the
251
+ planner; with `--diff` or `--paths` it uses the impact report. The diff hunks pass through the
252
+ same redaction as every artifact, the trust envelope is stamped at the top, and every file that did
253
+ not fit is named rather than dropped. `--copy` copies the result, `--out` writes it inside the
254
+ repository, and `--format json` returns `{ markdown, usedTokens, files, omitted }` without
255
+ printing the Markdown first.
256
+
202
257
  ### `setup`
203
258
 
204
259
  ```bash
@@ -224,7 +279,7 @@ The whole first run in one command, with defaults and no prompts. This is the sa
224
279
  🚀 Setup for: /path/to/repo
225
280
  ✅ Created snapshot.config.json (preset: nextjs)
226
281
  Added npm scripts: snapshot, snapshot:validate
227
- Added devDependency: codebase-snapshot ^0.20.12
282
+ Added devDependency: codebase-snapshot ^0.21.0
228
283
  Added to .gitignore: /snapshot/, /snapshot.tmp/
229
284
  ⏳ Installing dependencies…
230
285
  ✅ Installed dependencies (npm install, 2.1s)
@@ -276,7 +331,7 @@ It also has three side effects on files you own, and it says so when it does the
276
331
  ```
277
332
  ✅ Created snapshot.config.json (preset: node-lib)
278
333
  Added npm scripts: snapshot, snapshot:validate
279
- Added devDependency: codebase-snapshot ^0.20.12
334
+ Added devDependency: codebase-snapshot ^0.21.0
280
335
  Added to .gitignore: /snapshot/, /snapshot.tmp/
281
336
  ```
282
337
 
@@ -426,13 +481,12 @@ agent](agent.md).
426
481
  Ask the npm registry whether a newer release exists, and print the version it compared against:
427
482
 
428
483
  ```bash
429
- npx codebase-snapshot@0.20.9 update # is 0.20.12 current? print the answer
430
- npx codebase-snapshot@0.20.9 update --format json
484
+ npx codebase-snapshot@0.21.0 update # is this build current? print the answer
485
+ npx codebase-snapshot@0.21.0 update --format json
431
486
  ```
432
487
 
433
488
  ```text
434
- ↑ codebase-snapshot 0.20.12 is available — you have 0.20.9.
435
- npm install -g codebase-snapshot
489
+ You are on codebase-snapshot 0.20.13, and the registry publishes 0.20.13. No update is available.
436
490
  ```
437
491
 
438
492
  Exit `0` when the installed version is current, `1` when a newer release exists, `2` when the
@@ -448,14 +502,17 @@ finds a release, an hour when it finds none, and five minutes after a failed req
448
502
 
449
503
  ```bash
450
504
  codebase-snapshot skill # print on stdout
451
- codebase-snapshot skill --install # write both registries
505
+ codebase-snapshot skill --install # write all three registries
452
506
  codebase-snapshot skill --install --target claude
507
+ codebase-snapshot skill --install --with-mcp
453
508
  ```
454
509
 
455
510
  Prints or installs the bundled agent skill. Installation writes
456
- `.claude/skills/codebase-snapshot/SKILL.md` and `.cursor/rules/codebase-snapshot.mdc`;
457
- `--target claude` or `--target cursor` limits it to one. Both are **registries keyed by
458
- skill name**, so the file cannot be mistaken for your own documentation.
511
+ `.agents/skills/codebase-snapshot/SKILL.md`, `.claude/skills/codebase-snapshot/SKILL.md` and
512
+ `.cursor/rules/codebase-snapshot.mdc`; `--target` limits it to one registry. All three are
513
+ **registries keyed by skill name**, so the file cannot be mistaken for your own documentation.
514
+ `--with-mcp` merges one `codebase-snapshot` entry into `.mcp.json` without removing other servers
515
+ and keeps an existing different entry, with a note.
459
516
 
460
517
  It does not write `AGENTS.md`. That file is your project's agent contract — build commands,
461
518
  conventions, house rules — and a tool has no business editing it. If you want the skill
@@ -479,10 +536,12 @@ codebase-snapshot mcp # serve the current directory over stdio
479
536
  codebase-snapshot mcp --cwd <path> # serve another repository
480
537
  ```
481
538
 
482
- Serves the repository to a Model Context Protocol client over stdio: 26 tools, `snapshot://`
483
- resources and seven prompts. Stdout carries JSON-RPC messages and nothing else; every note goes to
539
+ Serves the repository to a Model Context Protocol client over stdio: 7 tools, `snapshot://`
540
+ resources and seven prompts, with live reads by default. Stdout carries JSON-RPC messages and nothing else; every note goes to
484
541
  stderr. It speaks both protocol eras — the legacy `initialize` handshake and the stateless
485
- `2026-07-28` revision — and answers whichever the client starts with.
542
+ `2026-07-28` revision — and answers whichever the client starts with. With `--http`, modern
543
+ requests carry `MCP-Protocol-Version`, `Mcp-Method` and (for named calls) `Mcp-Name`;
544
+ mismatches are refused with `-32020` before dispatch.
486
545
 
487
546
  `--cwd` is the only directory it will read. A tool's `root` argument can name a sub-directory of it
488
547
  and nothing outside, symlinks included. It never installs packages and never writes a config file.
@@ -499,8 +558,8 @@ for the two install flags, and the init-and-setup flags list both commands.
499
558
 
500
559
  | Option | Type | Default | Applies to | Meaning |
501
560
  | :--- | :--- | :--- | :--- | :--- |
502
- | `--cwd <path>` | path | current directory | generate, validate, report, explain, init, setup, skill, mcp | Repository to operate on. Must exist and be a directory. `diff` and `describe` take no `--cwd`; for `mcp` it chooses the one repository the server serves. |
503
- | `--out-dir <path>` | path | `snapshot` | generate, validate, report, explain, init, setup | Where the snapshot is written or read. May be absolute. |
561
+ | `--cwd <path>` | path | current directory | generate, validate, report, impact, brief, explain, init, setup, skill, mcp, health, serve | Repository to operate on. Must exist and be a directory. `diff` and `describe` take no `--cwd`; for `mcp` it chooses the one repository the server serves. |
562
+ | `--out-dir <path>` | path | `snapshot` | generate, validate, report, impact, brief, explain, init, setup, health | Where the snapshot is written or read. May be absolute. |
504
563
  | `--max-part-bytes <n>` | size | `307200` (300 KB) | generate, validate, init, setup | Hard ceiling per markdown part. Accepts `120k`, `1.5mb`. Minimum 4096. |
505
564
  | `--max-part-tokens <n>` | size | unset | generate, validate, setup | A per-part ceiling in **tokens**, for a context window rather than a disk. Narrows `--max-part-bytes` to the equivalent byte count (`tokens × 4`); the smaller of the two ceilings always wins, and both are recorded in the manifest. Accepts `32k`. Minimum 1024 — below that it is a usage error, not a value quietly raised to the floor. The byte ceiling is what is enforced: `estimatedTokens` is an estimate, and a part whose estimate exceeds the token ceiling is named in a warning rather than silently accepted. |
506
565
  | `--large-file-bytes <n>` | size | the part budget (307200) | generate, validate, explain, setup | Above this, a file becomes a head/tail preview. It may not exceed `--max-part-bytes`: a file between the two could not fit a part. |
@@ -508,7 +567,7 @@ for the two install flags, and the init-and-setup flags list both commands.
508
567
  | `--brief <path>` | path | unset | generate, validate | The owner-written half of `PROMPT.md`: `Stakes`, `The system`, `What came before`, `The bar`, `Calibration`. Unknown headings are kept as Owner notes; measured headings cannot be redefined; the file is digested, so editing it is drift. |
509
568
  | `--remote <url>` | url | unset | generate | Fetch a repository instead of scanning the current directory. https only, public addresses only, shallow clone; the manifest records the URL and the commit. See [remote](remote.md). |
510
569
  | `--ref <branch>` | string | unset | generate | With `--remote`: the branch or tag to clone. |
511
- | `--allow-private` | flag | off | generate | With `--remote`: allow private addresses and `file:` URLs. Refused by default. |
570
+ | `--allow-private` | flag | off | generate, serve | With `--remote`: allow private addresses and `file:` URLs. Refused by default. |
512
571
  | `--keep-clone` | flag | off | generate | With `--remote`: keep the temporary clone and print where it is. |
513
572
  | `--http` | flag | off | mcp | Serve MCP over HTTP (Streamable HTTP: POST a JSON-RPC message to `/mcp`) instead of stdio. Loopback by default; a bearer token is generated and printed unless `--token` or `--no-auth` is given. Health endpoint: `GET /healthz`. |
514
573
  | `--port <n>` | string | `4789` | mcp, serve | `mcp --http`: port to bind. `0` picks an ephemeral port and prints it. |
@@ -519,7 +578,7 @@ for the two install flags, and the init-and-setup flags list both commands.
519
578
  | `--all-members` | flag | off | health | Audit every snapshot a `--workspace` run wrote, not only the one at `outDir`. The combined score is the weakest member. |
520
579
  | `--deep` | flag | off | health | Replay every full body from the source bytes on disk and compare it with the part. The only allowed difference is a redaction marker. Off by default because it re-reads the repository. |
521
580
  | `--strict` | flag | off | health | `health` only: exit 2 when a critical check fails, and 1 when a warning is the only thing left. Without it a critical check exits 1 and warnings exit 0. |
522
- | `--mode <command>` | string | unset | generate, validate, report, explain, init, setup, diff, describe, skill | Select the command when no command word is given. A command word and `--mode` must name the same command; a contradiction is a usage error (exit 2). |
581
+ | `--mode <command>` | string | unset | generate, validate, report, impact, brief, explain, init, setup, diff, describe, skill, mcp, health, update, serve | Select the command when no command word is given. A command word and `--mode` must name the same command; a contradiction is a usage error (exit 2). |
523
582
  | `--no-update-check` | flag | off | all commands except `update` | Skip the check for a newer published version. Already skipped when stdout is not a terminal, in CI, in a JSON invocation, and in `mcp`, which makes no network requests. `update` exists to contact the registry, so it has no check to skip. |
524
583
  | `--prompt-task <task>` | string | `audit` | generate, validate | `audit`, `review` or `explain` — which job the brief is written for. Changes the opening section, not the standard. |
525
584
  | `--budget-tokens <n>` | count | unset | generate | Fit the snapshot into n tokens by selecting whole files (entry points, then the most-imported). Records a `budget` block; the rest are `not-selected`. See [budget](budget.md). |
@@ -533,19 +592,36 @@ for the two install flags, and the init-and-setup flags list both commands.
533
592
  | `--slice <question>` | string | unset | generate | Narrow the snapshot to what the retrieval planner picks for this question. Records a `slice` block and `skipped[]` reasons `not-selected`. See [slices](slice.md). |
534
593
  | `--slice-tokens <n>` | count | `30000` | generate | The token budget for `--slice`. |
535
594
  | `--delta <path>` | path | unset | generate | Narrow the snapshot to what changed since a base snapshot, plus the one-hop importers. Unchanged files are recorded in `delta.unchanged` and `skipped[]`. See [delta](delta.md). |
536
- | `--include-diffs` | flag | off | generate | Also write `reports/diff.md`: the unstaged and staged diff, with the commands, bounded to 200 KiB. Absent when the tree is clean; outside a git repository the run warns and writes nothing. |
537
- | `--include-logs <n>` | count | unset | generate | Also write `reports/log.md`: the last n commits (1–500), one line each; outside a git repository the run warns and writes nothing. |
538
- | `--token-tree` | flag | off | generate | Also write `reports/tokens.md`: per-file token estimates sorted by cost, with directory rollups. |
595
+ | `--include-diffs` | flag | off | generate, validate | Also write `reports/diff.md`: the unstaged and staged diff, with the commands, bounded to 200 KiB. Absent when the tree is clean; outside a git repository the run warns and writes nothing. |
596
+ | `--include-logs <n>` | count | unset | generate, validate | Also write `reports/log.md`: the last n commits (1–500), one line each; outside a git repository the run warns and writes nothing. |
597
+ | `--token-tree` | flag | off | generate, validate | Also write `reports/tokens.md`: per-file token estimates sorted by cost, with directory rollups. |
539
598
  | `--max-parts <n>` | count | unset | generate, validate | **Experimental.** Grow the per-part budget until the snapshot has at most `n` parts, so the file count stays fixed as the code grows. The budget it settles on is recorded in `manifest.budgets.maxPartBytes` and may exceed `--max-part-bytes`; a warning says so. `0` is a usage error. |
540
599
  | `--attachment-slots <n>` | count | `10` | generate | Files the destination accepts in one message; `0` means no limit. `PROMPT.md` plans the delivery against it — which parts to attach, what to leave behind, and the `--max-part-bytes` value that would merge them. It changes no part and no file, so it is recorded in the manifest but is not part of the config digest. |
541
600
  | `--include-monolith` | flag | off | generate, validate, setup | Also write `full-codebase.json` and `full-codebase.md`. |
542
601
  | `--include-sensitive-files` | flag | off | generate, validate, explain, init, setup | Emit `.env`, `*.pem`, `.npmrc` and similar. Off by default; they are reported as skipped. |
543
602
  | `--skip-artifacts <names>` | list | unset | generate, validate, init, setup | Comma-separated artifacts to omit. |
544
603
  | `--only-artifacts <names>` | list | unset | generate, validate, init, setup | Write *only* these, and **turn on** any this names: a config with `artifacts: { audit: false }` still gets `reports/audit.md` from `--only-artifacts audit`, because "only these" is a statement about the whole selection rather than a suppression list. Cannot be combined with `--skip-artifacts`. |
545
- | `--format <text\|json>` | enum | `text` | generate, validate, report, explain, init, setup, diff, describe, skill | `json` writes a pure JSON payload to stdout. Every command except `mcp` honours it — stdout there is the JSON-RPC protocol stream — and `describe` reports the same nine-command list. |
604
+ | `--format <text\|json\|markdown\|pr-comment>` | enum | `text` | generate, validate, report, impact, brief, explain, init, setup, diff, describe, skill, health, update | `json` writes a pure JSON payload to stdout. `impact` and `brief` also accept `markdown`; `pr-comment` renders the same brief with collapsible sections. Every command except `mcp` and `serve` honours `--format` — stdout there is the JSON-RPC protocol stream. |
546
605
  | `--sarif` | flag | off | generate, validate, setup | Also write `reports/audit.sarif`: the redaction findings as SARIF 2.1.0, for upload to GitHub Code Scanning. The artefact carries the path, the line and the rule — never the value. Works with `--skip-artifacts audit`, because a CI gate does not read markdown. Rule ids are fixed per rule name, so adding a custom rule never re-points an existing alert. |
547
606
  | `--skeleton` | flag | off | generate, validate, setup | Emit signatures instead of bodies: each function or method body becomes `{ /* ... */ }` in place, so formatting and comments around it are untouched. Covers `.ts`, `.tsx`, `.mts`, `.cts`, `.js`, `.jsx`, `.mjs` and `.cjs`; `.d.ts` files are left alone because they are already declarations. The summary still describes the whole file, and affected entries carry `inclusionMode: "signatures"`. `--include-monolith` still writes the whole body, so the monolith's `inclusionMode: "full"` stays true. |
548
607
  | `--changed-since <ref>` | git ref | unset | generate, validate, explain | Include only files changed since this ref, plus untracked ones. Every other file is recorded in `manifest.skipped[]` with reason `unchanged` and is never opened. `validate` re-resolves the scope: a skipped file that has changed since is reported as drift, and one that has not is left alone — and with `--with-dependents`, so is a file that now imports one that changed. `explain` answers with the same rule. A ref beginning with `-` is refused. |
608
+ | `--diff <ref>` | git ref | unset | impact, brief | Compare the working tree against this ref for the impact report or change brief. Includes committed, staged, unstaged and untracked changes relative to it. Mutually exclusive with `--paths`; a ref beginning with `-` is refused. |
609
+ | `--paths <a,b>` | list | unset | impact, brief | Comma-separated repository-relative paths to treat as the change. Absolute paths and `..` segments are refused. Mutually exclusive with `--diff`. |
610
+ | `--depth <n>` | count | `3` | impact, brief | Reverse-import hops to follow for the impact report or change brief. Minimum 1, maximum 8. |
611
+ | `--max-results <n>` | count | `200` | impact, brief | Maximum files in `affected[]`. Minimum 1, maximum 1000; a hit sets `truncated` and adds a warning. |
612
+ | `--no-cache` | flag | off | impact, brief | Bypass the optional OS live-index summary cache. No cache file is written, and nothing is ever written inside the repository. |
613
+ | `--no-live` | flag | off | impact, brief | Require the generated snapshot instead of building or overlaying the live index. |
614
+ | `--tests-paths` | flag | off | impact | Print candidate test paths, one per line, instead of the report. |
615
+ | `--run` | flag | off | impact | Run the repository's own Vitest, Jest or `node --test` entry against the candidate tests. Uses `shell: false`; a build or test configuration change adds a full-suite warning. |
616
+ | `--precise` | flag | off | impact | Add compiler-resolved symbol references to the report. Requires the live index. |
617
+ | `--include-imports` | flag | off | impact | Add outgoing dependencies of every changed file. |
618
+ | `--include-cycles` | flag | off | impact | Add import cycles in the impacted subgraph. |
619
+ | `--copy` | flag | off | brief | Copy the finished brief to the platform clipboard. |
620
+ | `--out <path>` | path | unset | brief | Write the brief to this repository-relative path. A path that resolves outside the repository is refused. |
621
+ | `--max-tokens <n>` | count | `12000` | brief | Token budget for the assembled brief. |
622
+ | `--lines-per-file <n>` | count | `80` | brief | Line window per file in the brief. |
623
+ | `--include-tests` | flag | off | brief | Include candidate test files. |
624
+ | `--with-mcp` | flag | off | skill | With `skill --install`, merge a `codebase-snapshot` server entry into `.mcp.json` without clobbering other servers. |
549
625
  | `--staged` | flag | off | generate, validate, explain | Include only files staged for the next commit. The bytes are read from the **index**, not the working tree, so a file with staged changes plus later unstaged edits is snapshotted at what `git commit` will write; a staged deletion is recorded in `manifest.skipped[]` with reason `deleted`. |
550
626
  | `--with-dependents` | flag | off | generate, validate, explain | With either of the two above, also include the files that import a changed one — a one-hop closure, not a transitive walk. Needs a scope; alone it is a usage error. |
551
627
  | `--install-hook` | flag | off | init, setup | Write `.git/hooks/pre-commit` so a commit is refused while the snapshot is out of date. The hook checks the `outDir` the config names, so it works for a project that does not use `snapshot/`. An existing hook is never replaced; the note says what to add to it instead. |
@@ -553,7 +629,7 @@ for the two install flags, and the init-and-setup flags list both commands.
553
629
  | `--watch` | flag | off | generate | Regenerate on every change until interrupted. Redaction and parsing are cached per file across runs in the same process, keyed on the content hash, so a one-file edit regenerates from that one file instead of from the whole repository. The cache is memory only and is dropped when the process exits. |
554
630
  | `--autopilot` | flag | off | generate | Set the project up without asking — config, `.gitignore`, npm scripts, devDependency, install — then generate. Never overwrites an existing config; refuses an empty directory (exit `1`); contradicts `--no-config` (exit `2`). |
555
631
  | `--no-install` | flag | off | setup, generate `--autopilot` | Skip the dependency install. Anywhere else it is a usage error, because it would change nothing. |
556
- | `--no-config` | flag | off | generate, validate, report, explain, diff, mcp | Ignore every `snapshot.config.*` file and run on the built-in defaults. `diff` never loads a config anyway and accepts the flag for consistency; `mcp` uses it when a repository config cannot be read or should not be trusted. |
632
+ | `--no-config` | flag | off | generate, validate, report, impact, brief, explain, diff, mcp | Ignore every `snapshot.config.*` file and run on the built-in defaults. `diff` never loads a config anyway and accepts the flag for consistency; `mcp` uses it when a repository config cannot be read or should not be trusted. |
557
633
  | `--discovery <mode>` | enum | `auto` | generate, validate, explain, setup | How files are found: `auto` lists through git when git works and refuses when a `.git` directory cannot be listed; `git` requires git; `walk` scans the tree and reads `.gitignore` files directly. The escape hatch for a broken `.git`. |
558
634
  | `--preset <name>` | name | detected | init, setup | Force a preset instead of detecting one. |
559
635
  | `--include <globs>` | list | unset | init, setup | Allow-list recorded in the generated config. |
@@ -561,7 +637,7 @@ for the two install flags, and the init-and-setup flags list both commands.
561
637
  | `--yes` | flag | off | init, setup | Never prompt; accept every default. |
562
638
  | `--force` | flag | off | init, setup | Replace an existing JSON-family config in place. An executable `.ts`/`.js`/`.mjs` config is refused, naming the file to remove. |
563
639
  | `--install` | flag | off | *skill only* | Write the skill into the repository instead of printing it. |
564
- | `--target <name>` | enum | `all` | *skill only* | `claude`, `cursor` or `all`. |
640
+ | `--target <name>` | enum | `all` | *skill only* | `agents`, `claude`, `cursor` or `all`. |
565
641
  | `-h`, `--help` | flag | — | every command | Print usage. |
566
642
  | `-v`, `--version` | flag | — | every command | Print the version on stdout: a bare `v`-prefixed semver (for example `v1.2.3`), with no package name. |
567
643
 
@@ -599,15 +675,15 @@ same run. With `--mode`, the remaining positionals are that command's arguments,
599
675
  `--mode explain src/server.ts` and `--mode diff old-snapshot snapshot` work the same way the
600
676
  positional form does.
601
677
 
602
- It accepts the ten commands plus the `check` alias — the eleven names the error lists — and it is
678
+ It accepts the fifteen commands plus the `check` alias — the sixteen names the error lists — and it is
603
679
  deliberately strict: asking for two different commands is an error rather than a silent winner.
604
680
 
605
681
  ```
606
682
  ❌ --mode validate contradicts the command "generate". Pass one or the other.
607
- ❌ Unknown --mode "bogus". Expected one of: generate, validate, check, report, init, setup, explain, diff, describe, skill, mcp.
683
+ ❌ Unknown --mode "bogus". Expected one of: generate, validate, check, report, impact, brief, init, setup, explain, diff, describe, skill, mcp, health, update, serve.
608
684
  ```
609
685
 
610
- `describe` does list `--mode` in its option table (`appliesTo` names the ten canonical commands),
686
+ `describe` does list `--mode` in its option table (`appliesTo` names every command that accepts it),
611
687
  but `--help` does not: the positional form is the documented one for people, and the flag exists
612
688
  for wrappers and for the contract.
613
689
 
@@ -16,17 +16,17 @@ This repository, measured rather than estimated:
16
16
 
17
17
  | | |
18
18
  | :--- | ---: |
19
- | TypeScript files under `src/` | 88 |
20
- | Lines | 28,992 |
21
- | Bytes | 1,191,949 |
22
- | **Estimated tokens** | **≈ 340,000** |
23
-
24
- That single number decides the whole conversation. 340k tokens does not fit in an 8k window, it
25
- does not fit a 200k window at all — it is the whole window and two thirds of another — and it fits
26
- in a 1M window with room for the question. Measured on 2026-11-17 with `git ls-files src` plus the
27
- tool's own `countLines`, over the files present that day. The count moves with every commit — the
28
- order of magnitude does not, which is what the number is for; run `codebase-snapshot report` on a
29
- snapshot of this repository to re-measure a checkout.
19
+ | Included files | 221 |
20
+ | Lines | ≈59,000 |
21
+ | Source bytes | ≈2.5 MB |
22
+ | **Estimated tokens** | **≈764,000** |
23
+
24
+ That single number decides the whole conversation. 764k tokens does not fit in an 8k window, it
25
+ does not fit a 200k window at all, and it is three quarters of a 1M window before the question is
26
+ asked. Measured on 2026-11-30 at 0.21.0, from `snapshot/manifest.json`; the source-only part (116
27
+ TypeScript files under `src/`) is smaller, and the documentation is the rest. The count moves with
28
+ every commit — the order of magnitude does not, which is what the number is for; run
29
+ `codebase-snapshot report` on a snapshot of this repository to re-measure a checkout.
30
30
 
31
31
  ## What the default part budget means
32
32
 
@@ -64,8 +64,8 @@ budget of any single part.
64
64
 
65
65
  ## When the repository does not fit
66
66
 
67
- It usually does not. 340k tokens is a small library; a real application is five to twenty times
68
- that. In order of preference:
67
+ It usually does not. 763k tokens is a documentation-heavy repository; a real application is
68
+ several times that, and a large monorepo more still. In order of preference:
69
69
 
70
70
  1. **Scope the run, not the budget.** `include`/`exclude` patterns, or the wizard's "only
71
71
  specific folders" option, cut more than any budget change. Packing the thing you are asking
@@ -100,3 +100,4 @@ intended to fill, the budget was not the problem — the selection was.
100
100
  - [Budgeting LLM context](how-to-context-budget.md) — choosing ceilings per layer
101
101
  - [Feeding a repo to an LLM](how-to-feed-a-repo-to-claude.md) — the end-to-end recipe
102
102
  - [Configuration](configuration.md) — `maxPartBytes`, `largeFileBytes`, `maxMonolithBytes`
103
+ - [Glossary](glossary.md) — token, context window, byte budget and the other terms
@@ -469,7 +469,7 @@ either.
469
469
  A credential assigned to a name inside a string is also masked — a connection string is a string:
470
470
 
471
471
  ```js
472
- const dsn = "password=MySuperSecret123;host=db.internal";
472
+ const dsn = "password=<redacted-example>;host=db.internal";
473
473
  ```
474
474
 
475
475
  What is left alone is a credential *name* in a literal, with nothing assigned to it:
@@ -0,0 +1,66 @@
1
+ # All codebase-snapshot documentation
2
+
3
+ Every page on this site, grouped by the job you are doing. If you are new, start with the
4
+ [overview](../README.md), then [installation](install.md), then the [CLI reference](cli.md).
5
+
6
+ ## Start here
7
+
8
+ - [Overview and quick start](../README.md) — what the tool does, install, first run and the shape
9
+ of the output.
10
+ - [Installation](install.md) — npm, yarn, pnpm, bun, npx, version pinning and a shadowed npx.
11
+ - [CLI reference](cli.md) — every command, option, default and exit code.
12
+ - [Configuration](configuration.md) — every setting, the 25 project presets, budgets and hooks.
13
+ - [Snapshot output](output.md) — parts, manifest, reports and the schema.
14
+ - [AI agents](agent.md) — the machine-readable contract and the installable skill.
15
+
16
+ ## Core workflows
17
+
18
+ - [Impact reports](impact.md) — what a change reaches and which tests to run.
19
+ - [Briefs](brief.md) — one redacted, bounded review pack.
20
+ - [MCP server](mcp.md) — transports, sessions, resources and protocol details.
21
+ - [MCP server for a codebase](mcp-server-for-codebase.md) — setup for Claude, Cursor and generic
22
+ clients, the seven tools, security and limits.
23
+ - [MCP tools](tools.md) — every tool schema and an example call.
24
+ - [snapshot_context](answer.md) — cited, line-numbered context in one call.
25
+ - [Health](health.md) — hashes, secrets, host paths, accounting and freshness.
26
+ - [Serve](serve.md) — the browser page and the MCP endpoint on one local port.
27
+ - [Remote sources](remote.md) — shallow, SSRF-safe cloning.
28
+ - [Delta snapshots](delta.md) — send only what changed since a base.
29
+ - [Slices](slice.md) — a snapshot for one question.
30
+ - [Token budgets](budget.md) — fit a repository into a window by selecting whole files.
31
+ - [Benchmarks](benchmarks.md) — measured tokens and time on ten public repositories.
32
+ - [Workspaces](workspace.md) — one snapshot per member, plus an index.
33
+ - [Signing](signing.md) — Ed25519 signatures and verification.
34
+
35
+ ## Guides and concepts
36
+
37
+ - [LLM codebase context](llm-codebase-context.md) — what it is, why raw dumps fail, and the four
38
+ practical approaches.
39
+ - [How to feed a repository to Claude or ChatGPT](how-to-feed-a-repo-to-claude.md) — the end-to-end
40
+ recipe.
41
+ - [Budgeting LLM context](how-to-context-budget.md) — choose maxPartBytes from the destination.
42
+ - [How many tokens is a codebase?](codebase-token-budget.md) — the arithmetic and a budget table.
43
+ - [Stale context is your bug](stale-context-is-your-bug.md) — detect drift and gate it in CI.
44
+ - [Glossary](glossary.md) — codebase snapshot, token budget, manifest, drift, MCP, AX and more.
45
+ - [FAQ](faq.md) — direct answers about MCP, tokens, secrets, CI and comparisons.
46
+
47
+ ## Comparisons
48
+
49
+ - [vs repomix](vs-repomix.md) — two ways to pack a repository, and when repomix is the better fit.
50
+ - [vs gitingest](vs-gitingest.md) — a CLI artefact versus a URL-to-text trick.
51
+ - [vs code2prompt](vs-code2prompt.md) — a prompt versus an indexed artefact.
52
+
53
+ ## Operations and trust
54
+
55
+ - [Migration to 0.21](migration.md) — the seven-tool MCP surface, live impact and every breaking
56
+ change.
57
+ - [Deploy](deploy.md) — a container, compose file and systemd timer.
58
+ - [Security review](security-review.md) — the threat model, controls and residual risks.
59
+ - [Troubleshooting](troubleshooting.md) — every message and its one-line fix.
60
+ - [About this project](about.md) — who maintains it, how claims are tested and the editorial policy.
61
+
62
+ ## Machine-readable
63
+
64
+ - [llms.txt](https://ankurhalder.github.io/codebase-snapshot/llms.txt) — a compact index for agents.
65
+ - [llms-full.txt](https://ankurhalder.github.io/codebase-snapshot/llms-full.txt) — every page in one file.
66
+ - [Sitemap](https://ankurhalder.github.io/codebase-snapshot/sitemap.xml) — every canonical URL.
package/docs/deploy.md CHANGED
@@ -61,8 +61,8 @@ After=network.target
61
61
  Type=oneshot
62
62
  User=deploy
63
63
  WorkingDirectory=/srv/app
64
- ExecStart=/usr/bin/npx -y codebase-snapshot@0.20.9 generate --cwd /srv/app
65
- ExecStartPost=/usr/bin/npx -y codebase-snapshot@0.20.9 validate --cwd /srv/app
64
+ ExecStart=/usr/bin/npx -y codebase-snapshot@0.21.0 generate --cwd /srv/app
65
+ ExecStartPost=/usr/bin/npx -y codebase-snapshot@0.21.0 validate --cwd /srv/app
66
66
  ```
67
67
 
68
68
  ```ini
package/docs/faq.md ADDED
@@ -0,0 +1,112 @@
1
+ # Codebase snapshot FAQ
2
+
3
+ Short answers to the questions people ask before using codebase-snapshot. Each answer links to
4
+ the page with the full detail.
5
+
6
+ ## What is a codebase snapshot?
7
+
8
+ A codebase snapshot is a bounded, indexed copy of a repository prepared for a language model:
9
+ source files are packed into Markdown parts under a byte budget, and a manifest records every
10
+ included file, every skipped path with the reason, and every file that had to be shortened. The
11
+ point is not to copy the repository; it is to produce context a reader can inspect and a pipeline
12
+ can validate.
13
+
14
+ ## How is this different from repomix or gitingest?
15
+
16
+ repomix and gitingest pack a repository into one AI-readable document. codebase-snapshot also
17
+ partitions the output, records why each path was included or skipped, redacts secret-shaped values,
18
+ and can prove the snapshot still matches the tree. That last property is the main difference: a
19
+ packed file cannot tell you it is stale. See the honest comparisons with
20
+ [repomix](vs-repomix.md), [gitingest](vs-gitingest.md) and [code2prompt](vs-code2prompt.md).
21
+
22
+ ## Does codebase-snapshot send my code anywhere?
23
+
24
+ No. The CLI and the MCP server run locally. They read a directory you name and write a directory
25
+ you name. There is no account, no upload and no telemetry. A remote source is fetched only when you
26
+ explicitly pass a URL with --remote, and that path is documented in
27
+ [remote sources](remote.md).
28
+
29
+ ## Which languages are supported?
30
+
31
+ TypeScript and JavaScript get the deepest parser and symbol support. Python, Go, Rust, Java/Kotlin,
32
+ C#/.NET, PHP, Ruby, C/C++, Vue, Svelte and Astro have language profiles for classification, imports
33
+ and previews. Every file type can still be included as text when the profile has nothing to add.
34
+ See [configuration](configuration.md) for the preset and layer rules.
35
+
36
+ ## How do I feed a whole repository to Claude or ChatGPT?
37
+
38
+ Generate a snapshot, attach the parts the prompt tells you to attach, and paste the instructions
39
+ from PROMPT.md. If the repository does not fit the destination's file limit, increase the part
40
+ budget or scope the run to the folders you are asking about. The end-to-end recipe is
41
+ [Feeding a codebase to an LLM](how-to-feed-a-repo-to-claude.md).
42
+
43
+ ## How many tokens is my codebase?
44
+
45
+ A rough estimate is bytes divided by 3.5, or lines multiplied by 11. Source code is denser than
46
+ English prose, so a 1 MB repository is usually around 285,000 tokens, not 250,000. The tool reports
47
+ the estimate it actually used in manifest.totals.estimatedTokens. The arithmetic and a table of
48
+ budgets are in [How many tokens is a codebase?](codebase-token-budget.md).
49
+
50
+ ## What is the MCP server for?
51
+
52
+ The MCP server exposes the repository to an MCP client as seven tools (six read-only): impact, context,
53
+ locate, read, validate, explain and generate. Instead of attaching a 12-part snapshot, an agent can
54
+ ask for the one part, symbol or changed-file report it needs. Setup, tool schemas and the security
55
+ boundary are in [MCP server for a codebase](mcp-server-for-codebase.md).
56
+
57
+ ## How do I keep a snapshot from going stale?
58
+
59
+ Run validate after the code changes. It re-hashes the files and exits non-zero when the snapshot no
60
+ longer matches the tree, so a CI job or a pre-commit hook can refuse stale context. The MCP read
61
+ tools use the live tree by default, so an agent sees uncommitted edits without regenerating. See
62
+ [Stale context is your bug](stale-context-is-your-bug.md).
63
+
64
+ ## Does it include .env files or secrets?
65
+
66
+ Credential files such as .env, .pem, .npmrc, .ssh and .tfstate are excluded by default and recorded
67
+ as skipped. Secret-shaped values inside ordinary files are replaced with a marker; the audit
68
+ artifact names the file and line but never the value. If you explicitly pass
69
+ --include-sensitive-files, the MCP and serve transports refuse to serve that snapshot. Read the
70
+ [security review](security-review.md) for the exact guarantees and residual risks.
71
+
72
+ ## Can I use it in CI?
73
+
74
+ Yes. generate writes the snapshot, validate exits non-zero on drift, and health --strict fails on a
75
+ critical integrity or secret finding. The CLI keeps progress on stderr and JSON on stdout, so a
76
+ pipeline can parse it. A typical job is: generate once on the base branch, validate on every pull
77
+ request, and upload the parts as an artifact only when they are current.
78
+
79
+ ## Does it work with monorepos and Windows?
80
+
81
+ Yes. A workspace run writes one snapshot per member plus a WORKSPACE.json index; Windows paths,
82
+ junctions and OneDrive rename failures are handled explicitly. The output directory is only
83
+ replaced when the tool can prove it wrote it. See [workspaces](workspace.md) and the
84
+ [troubleshooting guide](troubleshooting.md).
85
+
86
+ ## Is it free, and how is it maintained?
87
+
88
+ MIT licensed, with no paid tier and no hosted service. The project is maintained in public; the
89
+ test suite, security review, changelog and source are all in the repository. If you need a
90
+ guarantee for a regulated environment, commission your own review rather than treating a README
91
+ as one.
92
+
93
+ ## What is a token budget?
94
+
95
+ A token budget is the number of model tokens a run is allowed to spend on context. In this tool it
96
+ is expressed as a byte ceiling per part (maxPartBytes), because the partitioner enforces bytes and
97
+ estimates tokens. The budget is a hard ceiling: a file that does not fit is shortened with an
98
+ explicit omission record, never silently overflowed. See
99
+ [Budgeting LLM context](how-to-context-budget.md).
100
+
101
+ ## What is agent experience?
102
+
103
+ Agent experience (AX) is whether an agent can fetch, read and act on a site or tool without a human
104
+ translating for it. For documentation that means static HTML, clear headings, stable URLs, a
105
+ machine-readable contract and bounded responses. The evidence behind that claim is summarised in
106
+ [AX is the New AEO](https://arxiv.org/abs/2609.34951) and [What Drives AI Citations?](https://arxiv.org/abs/2610.15033).
107
+
108
+ ## Related
109
+
110
+ - [About this project](about.md)
111
+ - [All documentation](contents.md)
112
+ - [Glossary](glossary.md)