Snippet verify
Every other check in this plugin produces a judgement. This one produces a fact: the number
of documented code samples that execute, and the exact error for each one that does not.
That number is not arguable, which is what makes it useful. A broken quickstart is the most
expensive defect a developer product can ship, and it is invisible to code review because
the code that broke lives in prose.
Applies to
|
|
| Project types |
Anything documenting code — SDKs, APIs, CLIs, frameworks, libraries, developer platforms |
| Stage |
Any product with published examples. Highest value right after a major release, before a launch, and on a schedule thereafter — samples rot silently between releases |
| Needs |
Documentation containing fenced code blocks, plus a runtime for the languages used (node, python, go, curl) |
| Skip if |
The docs are conceptual only, with no executable samples. It will report that and stop rather than manufacture findings |
Most valuable on the quickstart. A failing sample on page forty costs one reader; a failing
sample on the first page costs every reader.
How to use
/agentrel:snippet-verify verify this repository's docs
/agentrel:snippet-verify ./docs/quickstart.mdx verify one page
/agentrel:snippet-verify https://docs.acme.com verify a public docs site
/agentrel:snippet-verify --lang python verify one language
Takes several minutes — dependency installation dominates. Produces
snippet-verify-report.md plus a printed pass rate.
Nothing in the project is modified. All execution happens in a throwaway workspace
outside the project tree, and the skill never overwrites a file in the repository being
checked. The one file it writes is the report.
1. Inventory the snippets
Collect every fenced block with its source location. The location is what makes a failure
actionable — a pass rate with no file:line is a statistic, not a bug report.
| Source |
Where to look |
| Repository docs |
docs/, README.md, *.md, *.mdx, examples/ |
| Framework docs |
docusaurus, mint.json, fern.config.json, .vitepress, astro content collections |
| Docstrings |
Python docstrings, JSDoc @example, Rust doc tests |
| Public site |
Fetch the docs root, follow the quickstart and reference paths |
Record for each block: source path and line, declared language, and any surrounding
instruction that changes how it runs — a preceding "install this first", a filename comment,
a # in a new terminal.
Blocks with no language tag are still inventoried. An untagged block is itself a finding:
no syntax highlighting, and no way for a tool or an agent to know how to run it.
2. Classify before running
This is the step that decides whether the report is credible. Not every fenced block is
meant to execute, and running an illustrative fragment to declare it broken makes the tool a
liar. Read references/classification.md for the full rules. In summary:
| Class |
Means |
Counted in the score |
runnable |
Self-contained, or completable from documented prior steps, with no secret required |
Yes |
needs-credentials |
Correct code that cannot run without an account, key, or paid resource |
No — reported separately |
illustrative |
A fragment, a schema, a response payload, pseudocode, output of another command |
No |
unsafe |
Would delete data, spend money, or execute a remote script |
No — never run, always reported |
State the class and the reason for every block. The pass rate is computed over runnable
blocks only, and the report says so on the same line as the number. A tool that quietly
counts illustrative fragments as failures is worse than no tool.
3. Build a throwaway workspace
One directory per language, outside the project tree, created fresh:
WORK="$(mktemp -d)" # never inside the repository being checked
Pin the versions the product actually publishes, not latest — the point is to verify what
a reader gets today:
- read the published version from
package.json, pyproject.toml, the registry, or the
install line in the docs themselves
- install into the workspace only, never globally, never into the project
- record every install command and its resolved versions in the report
Ask before installing. Dependency installation uses network and disk. Say what will be
installed and how large it is, then wait. If the user declines, verify what runs without
installation and mark the rest skipped — install declined.
4. Run them
Execute each runnable block in its workspace, in documentation order, carrying forward the
state earlier blocks established — a snippet that depends on a variable defined two blocks
up is only valid in sequence, and testing it in isolation invents a failure.
Capture for each: exit status, stdout, stderr, and duration. Record the first error line,
verbatim. Paraphrased errors are useless to the person fixing them.
Rules that are not negotiable:
- No writes outside the workspace. Not to the repository, not to the home directory, not
to a global cache the project shares.
- No real credentials. Never read
.env, never use an existing shell token, never prompt
for a key. A block needing auth is needs-credentials, not a failure.
- No live mutation. A documented
POST, DELETE, or destructive CLI command against a
real service is unsafe unless the docs name a sandbox host and the snippet uses it.
- No remote execution.
curl … | sh, iex, and equivalents are unsafe, reported and
never run, however common they are in install instructions.
- Timeout everything. A hung snippet is a finding — record it as a failure with the
timeout, do not wait.
5. Diagnose each failure
A pass rate alone tells a team they have a problem. The cause tells them which line to edit.
Classify every failure:
| Cause |
Signature |
Typical fix |
| Stale API |
Method or field does not exist |
Update the sample to the current signature |
| Missing prerequisite |
Import, install, or setup step absent from the page |
Add the missing step to the page |
| Version drift |
Works on an older release, not the published one |
Re-generate the sample, or pin in the docs |
| Wrong order |
Depends on a block that appears later |
Reorder the page |
| Placeholder |
A value the reader is expected to replace, unmarked |
Mark it, or use an obviously fake value |
| Broken syntax |
Never ran anywhere |
Fix or delete the block |
"Placeholder" and "wrong order" are documentation defects, not code defects. Report them as
such — the fix belongs to whoever owns the page.
6. Write the report
Write snippet-verify-report.md with these sections, in order:
- Scope — what was scanned, which languages, which versions were installed
- Pass rate — over
runnable blocks, with every other class counted separately
- Failures — each with
file:line, class, the verbatim first error, and the cause
- Not run —
needs-credentials, illustrative, unsafe, skipped, each with the reason
- Method — commands, resolved versions, date, and the limits of this run
Then print this summary. Keep the format exact; other tools parse it.
SNIPPET VERIFY
Blocks found 128
Runnable 74
Passed 61 82%
Failed 13
Not run 54 illustrative 38 · needs-credentials 14 · unsafe 2
Worst page docs/quickstart.mdx 4 of 6 runnable blocks fail
Top cause stale API signature 7 failures
Report → ./snippet-verify-report.md
7. Close honestly
Lead with the quickstart. A product whose reference pages are perfect and whose quickstart
fails is in worse shape than the aggregate suggests, so say that explicitly when it is true.
If every runnable block passes, report it in two lines and stop. A clean run is a real
result, and reporting it plainly is what makes a bad run credible.
Notes
- Never overwrite anything. Execution happens in a fresh temporary workspace; the only
file written is the report, in the working directory. If a report already exists, write
alongside it rather than replacing it.
- The score covers runnable blocks only, and every statement of the score must carry that
qualifier. Silent denominators are how these tools lose trust.
- Public-site runs see less than repository runs. A fetched page loses the surrounding
setup instructions that make a block runnable. Prefer the repository, and label remote
runs as such.
- This is the one skill here that executes code. It is opt-in per run, it asks before
installing, and it refuses the four unsafe categories above without exception.
- No telemetry. Results stay on the machine.
1---2name: snippet-verify3description: Execute the code in your documentation and report which blocks actually run. Extracts every fenced snippet from a docs directory, README, MDX tree, or public docs URL, classifies each as runnable, credential-blocked, or illustrative, runs the runnable ones in a throwaway workspace against the versions you actually publish, and reports a pass rate with the real error for every failure. Use when asked whether the documentation still works, to verify code samples or quickstart steps, to check examples against a new release, before a launch, or when developers report that the docs do not run.4---56# Snippet verify78Every other check in this plugin produces a judgement. This one produces a fact: the number9of documented code samples that execute, and the exact error for each one that does not.1011That number is not arguable, which is what makes it useful. A broken quickstart is the most12expensive defect a developer product can ship, and it is invisible to code review because13the code that broke lives in prose.1415## Applies to1617| | |18|---|---|19| **Project types** | Anything documenting code — SDKs, APIs, CLIs, frameworks, libraries, developer platforms |20| **Stage** | Any product with published examples. Highest value right after a major release, before a launch, and on a schedule thereafter — samples rot silently between releases |21| **Needs** | Documentation containing fenced code blocks, plus a runtime for the languages used (`node`, `python`, `go`, `curl`) |22| **Skip if** | The docs are conceptual only, with no executable samples. It will report that and stop rather than manufacture findings |2324Most valuable on the quickstart. A failing sample on page forty costs one reader; a failing25sample on the first page costs every reader.2627## How to use2829```30/agentrel:snippet-verify verify this repository's docs31/agentrel:snippet-verify ./docs/quickstart.mdx verify one page32/agentrel:snippet-verify https://docs.acme.com verify a public docs site33/agentrel:snippet-verify --lang python verify one language34```3536Takes several minutes — dependency installation dominates. Produces37`snippet-verify-report.md` plus a printed pass rate.3839**Nothing in the project is modified.** All execution happens in a throwaway workspace40outside the project tree, and the skill never overwrites a file in the repository being41checked. The one file it writes is the report.4243## 1. Inventory the snippets4445Collect every fenced block with its source location. The location is what makes a failure46actionable — a pass rate with no `file:line` is a statistic, not a bug report.4748| Source | Where to look |49|--------|---------------|50| Repository docs | `docs/`, `README.md`, `*.md`, `*.mdx`, `examples/` |51| Framework docs | `docusaurus`, `mint.json`, `fern.config.json`, `.vitepress`, `astro` content collections |52| Docstrings | Python docstrings, JSDoc `@example`, Rust doc tests |53| Public site | Fetch the docs root, follow the quickstart and reference paths |5455Record for each block: source path and line, declared language, and any surrounding56instruction that changes how it runs — a preceding "install this first", a filename comment,57a `# in a new terminal`.5859Blocks with no language tag are still inventoried. An untagged block is itself a finding:60no syntax highlighting, and no way for a tool or an agent to know how to run it.6162## 2. Classify before running6364**This is the step that decides whether the report is credible.** Not every fenced block is65meant to execute, and running an illustrative fragment to declare it broken makes the tool a66liar. Read `references/classification.md` for the full rules. In summary:6768| Class | Means | Counted in the score |69|-------|-------|----------------------|70| `runnable` | Self-contained, or completable from documented prior steps, with no secret required | Yes |71| `needs-credentials` | Correct code that cannot run without an account, key, or paid resource | No — reported separately |72| `illustrative` | A fragment, a schema, a response payload, pseudocode, output of another command | No |73| `unsafe` | Would delete data, spend money, or execute a remote script | No — never run, always reported |7475State the class and the reason for every block. The pass rate is computed over `runnable`76blocks only, and the report says so on the same line as the number. A tool that quietly77counts illustrative fragments as failures is worse than no tool.7879## 3. Build a throwaway workspace8081One directory per language, outside the project tree, created fresh:8283```bash84WORK="$(mktemp -d)" # never inside the repository being checked85```8687Pin the versions the product actually publishes, not `latest` — the point is to verify what88a reader gets today:8990- read the published version from `package.json`, `pyproject.toml`, the registry, or the91 install line in the docs themselves92- install into the workspace only, never globally, never into the project93- record every install command and its resolved versions in the report9495**Ask before installing.** Dependency installation uses network and disk. Say what will be96installed and how large it is, then wait. If the user declines, verify what runs without97installation and mark the rest `skipped — install declined`.9899## 4. Run them100101Execute each `runnable` block in its workspace, in documentation order, carrying forward the102state earlier blocks established — a snippet that depends on a variable defined two blocks103up is only valid in sequence, and testing it in isolation invents a failure.104105Capture for each: exit status, stdout, stderr, and duration. Record the **first** error line,106verbatim. Paraphrased errors are useless to the person fixing them.107108Rules that are not negotiable:109110- **No writes outside the workspace.** Not to the repository, not to the home directory, not111 to a global cache the project shares.112- **No real credentials.** Never read `.env`, never use an existing shell token, never prompt113 for a key. A block needing auth is `needs-credentials`, not a failure.114- **No live mutation.** A documented `POST`, `DELETE`, or destructive CLI command against a115 real service is `unsafe` unless the docs name a sandbox host and the snippet uses it.116- **No remote execution.** `curl … | sh`, `iex`, and equivalents are `unsafe`, reported and117 never run, however common they are in install instructions.118- **Timeout everything.** A hung snippet is a finding — record it as a failure with the119 timeout, do not wait.120121## 5. Diagnose each failure122123A pass rate alone tells a team they have a problem. The cause tells them which line to edit.124Classify every failure:125126| Cause | Signature | Typical fix |127|-------|-----------|-------------|128| Stale API | Method or field does not exist | Update the sample to the current signature |129| Missing prerequisite | Import, install, or setup step absent from the page | Add the missing step to the page |130| Version drift | Works on an older release, not the published one | Re-generate the sample, or pin in the docs |131| Wrong order | Depends on a block that appears later | Reorder the page |132| Placeholder | A value the reader is expected to replace, unmarked | Mark it, or use an obviously fake value |133| Broken syntax | Never ran anywhere | Fix or delete the block |134135"Placeholder" and "wrong order" are documentation defects, not code defects. Report them as136such — the fix belongs to whoever owns the page.137138## 6. Write the report139140Write `snippet-verify-report.md` with these sections, in order:1411421. **Scope** — what was scanned, which languages, which versions were installed1432. **Pass rate** — over `runnable` blocks, with every other class counted separately1443. **Failures** — each with `file:line`, class, the verbatim first error, and the cause1454. **Not run** — `needs-credentials`, `illustrative`, `unsafe`, `skipped`, each with the reason1465. **Method** — commands, resolved versions, date, and the limits of this run147148Then print this summary. Keep the format exact; other tools parse it.149150```151SNIPPET VERIFY152153 Blocks found 128154 Runnable 74155 Passed 61 82%156 Failed 13157158 Not run 54 illustrative 38 · needs-credentials 14 · unsafe 2159160 Worst page docs/quickstart.mdx 4 of 6 runnable blocks fail161 Top cause stale API signature 7 failures162163Report → ./snippet-verify-report.md164```165166## 7. Close honestly167168Lead with the quickstart. A product whose reference pages are perfect and whose quickstart169fails is in worse shape than the aggregate suggests, so say that explicitly when it is true.170171If every runnable block passes, report it in two lines and stop. A clean run is a real172result, and reporting it plainly is what makes a bad run credible.173174## Notes175176- **Never overwrite anything.** Execution happens in a fresh temporary workspace; the only177 file written is the report, in the working directory. If a report already exists, write178 alongside it rather than replacing it.179- **The score covers runnable blocks only**, and every statement of the score must carry that180 qualifier. Silent denominators are how these tools lose trust.181- **Public-site runs see less than repository runs.** A fetched page loses the surrounding182 setup instructions that make a block runnable. Prefer the repository, and label remote183 runs as such.184- **This is the one skill here that executes code.** It is opt-in per run, it asks before185 installing, and it refuses the four unsafe categories above without exception.186- **No telemetry.** Results stay on the machine.