Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

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от 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:

  1. What observable behavior or independent contract does it protect?
  2. What plausible regression would make it fail for the intended reason?
  3. Is that contract already covered at a stronger boundary? If so, what distinct risk does this test cover?
  4. 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__; a tsconfig.json enables type checks.
  • Python: test_*.py / *_test.py files (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-types for 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 typescript package; without a tsconfig it degrades to syntactic categories.
  • If the project already produces coverage (or you can cheaply run it), pass --coverage <file> (lcov / istanbul coverage-final.json / coverage.py coverage json). This is the dynamic half of the ICSE'19 rotten-green analysis: a conditional-assert whose 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

Полный SKILL.md на GitHub

Установить captain-obvious в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

references/detectors.mdreferences/prevention.mdscripts/captain_obvious_py.pyscripts/captain_obvious_ts.mjsscripts/co_py/__init__.pyscripts/co_py/analyzer.pyscripts/co_py/ast_utils.pyscripts/co_py/coverage.pyscripts/co_py/discovery.pyscripts/co_py/duplicates.pyscripts/co_py/fixer.pyscripts/co_py/gitguard.pyscripts/co_py/models.pyscripts/co_py/mypy_pass.pyscripts/co_ts/analyzer.mjsscripts/co_ts/ast_utils.mjsscripts/co_ts/classifier.mjsscripts/co_ts/coverage.mjsscripts/co_ts/discovery.mjsscripts/co_ts/duplicates.mjsscripts/co_ts/expect_parser.mjsscripts/co_ts/fixer.mjsscripts/co_ts/gitguard.mjsscripts/co_ts/laundering.mjsscripts/co_ts/mock_echo.mjsscripts/co_ts/type_predicates.mjs

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 запускает скрипты?

Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.

Похожие скиллы

Сравнить captain-obvious с