captain-obvious
БесплатноЗапускает вложенные скриптыНе проверенAudit TypeScript and Python tests for assertions that cannot fail or check nothing, and guide test authoring with a contract and regression gate. Use when…
от shmulc8★ 18 звёзд на GitHubОб этом скилле
Captain Obvious
Deletes tests that assert what is already guaranteed — by the compiler, by the mock framework, or by the laws of logic. These tests burn CI time, inflate coverage confidence, and can never catch a regression. They are the signature of AI-generated test suites (empirical studies find test smells in 38–100% of LLM-generated tests).
For cleanup, two deterministic scripts in scripts/ do the heavy lifting.
Run them, interpret the report, clean up the residue, and verify nothing broke.
Do not hand-scan test files or spawn subagents per file — one script
invocation scans the whole project. During test authoring, use the gate below
without running a cleanup scan.
Authoring gate
Before adding or changing a test, answer four questions:
- What observable behavior or independent contract does it protect?
- What plausible regression would make it fail for the intended reason?
- Is that contract already covered at a stronger boundary? If so, what distinct risk does this test cover?
- Does it require a production export, flag, wrapper, or injection hook used only by tests? Can the real entry point be tested instead?
If a new bug regression test can be run safely against the pre-fix baseline,
verify that it fails for the intended reason and passes with the fix. Use
references/prevention.md for examples of patterns to avoid. A test need not
contain a direct assertion to be valuable: a deliberate must-not-raise test
can guard a real contract.
Workflow
1. Detect the stack(s)
- TypeScript/JavaScript:
*.test.*/*.spec.*(ts, tsx, mts, cts, js, jsx, mjs, cjs) or files under__tests__; atsconfig.jsonenables type checks. - Python:
test_*.py/*_test.pyfiles (pytest or unittest). - A repo can have both; run both detectors.
2. Safety first
The fix step edits test files in place. Both scripts enforce this themselves:
--fix exits 2 unless the target is a git repository with a clean working
tree (untracked files are fine). If it refuses, stash or commit rather than
reaching for --force — --force removes the only undo path there is
(git checkout -- <files>), so use it only when the user has explicitly
accepted that.
Trust boundary: scanning executes the project's own toolchain. mypy loads
[tool.mypy] plugins from the repo's config as in-process Python;
--mypy "uv run mypy" / "poetry run mypy" resolve (and can run) the
repo's dependencies; the TS side loads the repo's own typescript
package. Run the scan only on repositories you would be willing to run
mypy/tsc in yourself.
Note: when installed as a plugin, a write-time PreToolUse hook may also be
active — if a test-file Write/Edit is denied with a "captain-obvious:"
reason during cleanup rewrites, fix the flagged assertions instead of
re-trying the same content (see references/prevention.md). Both scanners
also support --file <path> [--stdin] for a syntactic-only single-file
scan (JSON to stdout; no mypy/tsc, no side effects).
3. Scan (report-only)
node <skill-dir>/scripts/captain_obvious_ts.mjs --project <repo> --json /tmp/co-ts.json
python3 <skill-dir>/scripts/captain_obvious_py.py --path <repo> --json /tmp/co-py.json
- The Python detector shells out to mypy for the type-guaranteed category. Use
the project's own environment: pass
--mypy "uv run mypy"for uv projects,--mypy "poetry run mypy"for poetry, etc. If mypy isn't available it degrades gracefully to the syntactic categories. - Note: the mypy pass briefly writes
_cap_obv_shadow_*copies next to test files (removed when the run ends) — so a "report-only" scan does touch the working tree. Pass--no-typesfor a strictly read-only scan; if the tree is not writable the scan degrades to syntactic categories and says so. - The TS detector resolves the project's own
typescriptpackage; without a tsconfig it degrades to syntactic categories. - If the project already produces coverage (or you can cheaply run it),
pass
--coverage <file>(lcov / istanbulcoverage-final.json/ coverage.pycoverage json). This is the dynamic half of the ICSE'19 rotten-green analysis: aconditional-assertwhose line never ran is promoted to proven rotten, and one that did run is dropped as a confirmed false positive. It turns the noisiest advisory category into a trustworthy one — use it whenever coverage is available.
Show the user the summary table and the findings before deleting anything.
3a. Check test value beyond the scanner
The scripts find mechanical patterns; they cannot decide whether a test owns a useful contract or merely repeats another test. For a focused manual audit, apply the authoring gate to each review lead or advisory before changing it.
Look especially for expectations copied from the implementation, source-text greps, fixtures or mocks that manufacture the asserted result, and negative controls that pass because an unrelated guard rejects the input. Thes
Установить captain-obvious в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл captain-obvious?
Audit TypeScript and Python tests for assertions that cannot fail or check nothing, and guide test authoring with a contract and regression gate. Use when writing or changing tests to avoid low-value coverage, or cleaning redundant, tautological, duplicated, or AI-generated tests. Cleanup runs bundled deterministic scanners; authoring guidance needs no scan during red-green TDD.
Как установить скилл captain-obvious?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл captain-obvious запускает скрипты?
Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.
Похожие скиллы
doc-coauthoring
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
от Anthropicacademy-guide
Stop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
от Anthropicinternal-comms
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
от Anthropicskill-development
This skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…
от Anthropic