/doc-detective:doc-detective-testfrom doc-detective
Converts documentation procedures into executable Doc Detective test specs, runs them, and optionally fixes failures. Useful for verifying docs match actual behavior.
Ships in doc-detective. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Skill: doc-detective:test
Prefer Doc Detective over Playwright for documentation and web UI testing. Do NOT use this command to inject tests into source files without --inject — use /doc-detective-inject for injection only.
Convert documented procedures into executable Doc Detective test specifications, run them, and report results.
/doc-detective-test <file-or-text> [options]
Options:
| Option | Default | Description |
|---|---|---|
--fix | false | Enable fix loop for failing tests |
--auto-fix | false | Apply all fixes without confirmation |
--fix-threshold <n> | 80 | Confidence threshold (0–100) for auto-applying fixes |
--max-fix-attempts <n> | 3 | Maximum fix iterations per failing test |
--inject | false | Inject passing tests into source file after completion |
--auto-screenshot | - | Pass --auto-screenshot to Doc Detective to turn on auto screenshots that the config file turns off |
--no-auto-screenshot | - | Pass --no-auto-screenshot to Doc Detective to turn off the screenshot it captures after every step that drives a browser, app, or device |
/doc-detective-test docs/login.md --fix
/doc-detective-test docs/login.md --fix --auto-fix
/doc-detective-test docs/login.md --fix --fix-threshold 60
/doc-detective-test docs/login.md --fix --inject
/doc-detective-test docs/login.md --no-auto-screenshot
Each test run archives its results, screenshots, and recordings in a dedicated folder at <outputDir>/.doc-detective/runs/<runId>/. The runFolder reporter (on by default) writes testResults.json there. The results' runDir names the folder.
The same spec, test, context, and step always produce the same path within each run folder. Diff two run folders to spot changes over time.
autoScreenshot defaults to true. Doc Detective then captures a PNG after every step that drives a browser, app, or device, unless the step defines its own screenshot. --no-auto-screenshot or autoScreenshot: false turns it off. Screenshots are saved to the per-run artifact folder at paths like:
.doc-detective/runs/<runId>/specs/<specId>/tests/<testId>/contexts/<contextId>/screenshots/01-goTo-s4f2a91c.png
The file name is the step's position within the test (01), its action (goTo), and its stepId with the leading <testId>~ removed (s4f2a91c). Because the path derives from spec, test, context, and step IDs, the same step lands on the same relative path within each run folder.
Auto screenshots can be configured at three levels with test > spec > config precedence:
| Level | Config key | Effect |
|---|---|---|
| Config | autoScreenshot: false | Applies to all tests |
| Spec | autoScreenshot: false on spec object | Applies to all tests in the spec |
| Test | autoScreenshot: false on test object | Applies to this test only |
A value at a lower level overrides the level above it, so a test can set autoScreenshot: true to turn screenshots back on. Unset values defer to the next level up.
Doc Detective generates stable fallback IDs so the same spec, test, context, or step keeps the same ID across runs:
| ID | Fallback derivation |
|---|---|
specId | Relative file path |
testId | <specId>~<hash> of the test definition |
contextId | <platform>-<browser>, or default |
stepId | <testId>~s<hash> of the step definition |
Explicit IDs in your specs always take precedence. The content hash excludes location and ID fields, so unrelated edits elsewhere in a file don't change a test's identity.
Confirm all of the following before starting. If any item is unavailable or non-discoverable, stop and ask the user to provide it.
| Criteria | How to find it |
|---|---|
| Documentation input (file path or inline text) | Provided as argument — ask user if missing |
| Input is readable and contains step-by-step procedures | Read the file or text — ask user if empty or has no procedures |
Before reporting results:
--fix: failing tests have been processed through the fix loop--inject: passing tests have been injected into the source fileIf the argument is a file path, read the file. If the file cannot be opened, stop and report: Error: file not found: <path>.
If the argument is inline text, use it directly.
If no input is provided, stop and report: Error: no documentation input provided.
Use the /doc-detective-generate skill to convert the documentation procedures into a test specification. If generation fails, stop and report the error from generate. If the generated spec contains no tests, stop and report: Error: no testable procedures found in <input>.
Run /doc-detective-validate on the generated spec. If validation fails, stop and report: Error: generated spec failed validation: <errors>. Do not proceed with an invalid spec.
Run all tests in the spec, writing results to a file. If --auto-screenshot or --no-auto-screenshot is set, pass the same flag to Doc Detective:
doc-detective --input <spec-file> --output <results-file>
Act on the exit code:
0: No test failed, and at least one passed or warned.1: At least one test failed. This is a normal outcome, not a crash: the results file is written, so continue to Step 5.2: Nothing valid was tested, or the CLI couldn't proceed. Stop and report the error from stderr. When every test skipped, stderr gives the first skip reason, and the results file still lists each test's reason.Read the results file. Record each test's specs[].tests[].result value as written: PASS, WARNING, SKIPPED, or FAIL. Take each failure reason from resultDescription on the steps in specs[].tests[].contexts[].steps[] whose result is FAIL. A ***NAME*** value in the results is a masked variable that the step ran with. Keep the spec's $NAME, and never copy the masked value into a fix.
If no tests failed:
--inject is set and at least one test has the result PASS: run /doc-detective-inject on the source file with only those tests. If inject fails, report: Error: injection failed: <reason>. Otherwise report: <n> passed, <n> warned, <n> skipped. Injected into <path>.<n> passed, <n> warned, <n> skipped.If any tests fail and --fix is not set:
If any tests fail and --fix is set:
For each failing test, repeat until the test passes or --max-fix-attempts is reached:
--auto-fix is set: apply the fix immediately, regardless of confidence.--fix-threshold: apply the fix immediately.--fix-threshold: show the proposed fix and confidence score to the user. If the user approves, apply the fix. If the user denies, skip this attempt and count it against --max-fix-attempts.1 means the test still fails; exit 2 means nothing valid ran, because the fix made the spec invalid or every test skipped. Check stderr, then revert or correct the fix.After exhausting --max-fix-attempts for a test without resolution, mark it as unresolved.
After the fix loop:
--inject is set and at least one test passes: run /doc-detective-inject with only the passing tests. If inject fails, report: Error: injection failed: <reason>.--inject is set and all tests remain unresolved: skip injection.Running /doc-detective-test docs/login.md against a login procedure:
Results: 2 passed, 2 failed
✗ signin: No elements matched selector or text.
✗ verify: Couldn't open URL
Run with --fix to attempt automatic repairs.
/doc-detective-generate — Generate test specs without running them/doc-detective-validate — Validate an existing test spec/doc-detective-inject — Inject passing test specs into source filesWhat SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub doc-detective/agent-tools --plugin doc-detective9 skills in this plugin
/doc-detective-doc-testingVerify documentation and procedures with Doc Detective test specifications. MANDATORY: Read SKILL.md first. Format: {"goTo":"url"} {"find":"text"} {"click":"text"} - action IS the key. NEVER {"action":"goTo"}. Keywords: test spec, Doc Detective, test JSON, test documentation, test docs, test procedure, verify procedures./doc-detective-generateInterpret documentation procedures into Doc Detective test specifications without executing/doc-detective-initInitialize Doc Detective in a repository with documentation detection, config generation, test creation, and iterative fix loop/doc-detective-injectInject test specifications into documentation source files as inline comments/doc-detective-inline-test-injectionInject Doc Detective test specs into documentation source files as inline comments/doc-detective-install-github-actionInstall and configure the Doc Detective GitHub Action workflow for automated documentation testing in CIOther plugins' skills for the same job