document-tests
User-invoked as /document-tests [path]. Documents every automated test under path (default tests/) - classifies each as Unit, Mock, Integration, or E2E and inserts a standardized Scenario/Boundaries/O
SKILL.md.claude/skills/document-tests/SKILL.md
GitHubDocument Tests
Document every test_* function under $ARGUMENTS (default tests/) with a
standardized classification + Scenario/Boundaries/On-failure docstring.
When resolving Ambiguous classification items (step 2 below), use
references/classification-guide.md — it
gives the semantic Unit/Mock/Integration/E2E definitions the script cannot infer,
the resolution rules of thumb, and the exact docstring format (with a good/bad
example) the codemod emits.
Steps
- Preview:
python scripts/document_tests.py $ARGUMENTS --checkRead the summary: total tests, classification counts, anySkipped (custom docstring present)andAmbiguous classificationlists. - Decide whether the agent is needed:
- If there are zero
Skippedand zeroAmbiguousentries, the change is purely mechanical - apply directly:python scripts/document_tests.py $ARGUMENTS. - Otherwise, spawn the
test-documenteragent with the target path and the preview output. It applies the script, then hand-resolves everyAmbiguousitem by reading the test body, and leaves everySkipped(custom docstring) item untouched unless the user asked to standardize that specific file.
- If there are zero
- Verify no regressions:
uv run pytest $ARGUMENTS --collect-only -q- a broken insertion shows up as a collection error, not a passing/failing test, so this check is cheap and catches it immediately.
- Report the summary the agent (or the direct script run) produced.
Output
## Test Documentation - <path>
Scanned: N files, M tests
[Unit] a [Mock] b [Integration] c [E2E] d
Documented: X new/updated
Skipped (custom docstring, left as-is): <list, or none>
Ambiguous - resolved: <file::test -> classification>
Verification: pytest <path> --collect-only -> <pass/fail>
If --collect-only fails, stop and hand the failure to python-expert before
re-running this skill - do not re-apply the codemod over a file that's already
broken. If the user wants hand-written docstrings standardized too, re-run
with the test-documenter agent and explicit permission to --force the
specific files named.
Completion checklist
-
--checkpreview run before any apply - counts,Skipped, andAmbiguouslists reviewed - Every
Skipped (custom docstring present)item left untouched, unless the user explicitly asked to--forcethat specific file - Every
Ambiguous classificationitem resolved by reading the actual test body - not left at the script's best-effort guess -
pytest <path> --collect-only -qrun after apply and passed (no collection errors) - Diff is docstrings only - no test logic, fixtures, assertions, or imports changed
- Classification counts, skipped list, and ambiguous resolutions all included in the final report