/osprey:test-auditfrom osprey
Gates and audits OSPREY tests (pytest and vitest) with three modes: authoring gate for new/changed tests, audit mode for low-value or implementation-coupled tests, and campaign mode for pruning entire subsystem test surfaces.
Ships in osprey. 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.
Read when SKILL.md points to them.
Adapted from the test-audit skill of
openclaw/openclaw
(.agents/skills/test-audit, commit 80930af4), MIT License, Copyright (c) 2026
OpenClaw Foundation. The upstream notice is in LICENSE.txt.
Three modes, one value bar. Authoring mode gates every new or changed test at
write time. Audit mode runs focused sweeps of tests that re-assert source,
duplicate stronger proof, couple behavior to implementation, or keep test-only
production seams alive. Continue broad audits as separate coherent follow-up
PRs; optimize for confidence, not deletion count. Campaign mode prunes one
whole subsystem's test surface (every test file one src/osprey/<area> or
packages/ owner has); before starting one, read CAMPAIGN.md.
Before adding any test, answer four questions; a missing answer means do not add it yet:
@pytest.mark.parametrize row (it.each/test.each
in vitest) or a shared fixture
(tests/_*.py, the area conftest.py) over a near-duplicate test;
consolidate duplicated setup in the same change.reset_*, injection
parameter) that no production caller needs? If yes, move the test to the
real boundary instead. Exception: a named reset seam next to new global
state is sanctioned (the reset-seam list in tests/README.md §2, "Isolation
fixtures"); add it, do not hand-roll one.Then check the test against every junk pattern; a match fails
the gate unless the retention bar names the contract it
independently guards. A test that would break under behavior-preserving
refactoring is asserting implementation, not behavior; rewrite it at the
owning boundary before landing it. Also pass every item of the tests/README.md
§7 checklist ("Adding a batch of new tests"), including: unique basename;
reuse the shared helpers (the reserve_port fixture in tests/conftest.py,
patch_subprocess() in tests/cli/_scoped_subprocess.py, isolated_home in
tests/cli/conftest.py, the named reset seams); new global state gets a public reset seam plus an autouse
fixture; no import-time side effects; no new xdist_group; almost no flaky
markers; assert on result.stdout; green serially and in the parallel sweep
(check.py quick --changed HEAD -- <files>).
Bug fixes are test-first: the regression test must fail on the pre-fix code for the intended reason and pass after the owner-boundary repair. A regression test that never demonstrably failed proves the mock, not the fix. One regression at the owner boundary covers the bug; do not replay the same scenario at every layer it crosses.
The shared checklist for both modes: the authoring gate rejects a new test that matches one, and audits hunt for existing tests that do. Python shape in parentheses.
assert, pytest.raises or
mock.assert_*; a # should not raise comment in place of a check);f(x) == f(x) in one process,
helper(obj) is obj, Dataclass(a) == Dataclass(a));EXPECTED_* repeating a production tuple, often in several files; a frozen
replica of old production code kept as the baseline);inspect.getsource(fn) or
Path(mod.__file__).read_text() with in, not in, or
source.index(a) < source.index(b) to pin call order);obj._attr = ...; obj._validate() while a sibling drives the public entry);mock.called or "no exception", the other the real output);"""For tests.""",
_reset_*, _clear(), re-exports marked # noqa: F401 (re-exported for tests));expected = render(...), or json.dumps with production's own kwargs);get_config_value as MagicMock(return_value=X) for
every key; an unspec'd MagicMock(); a global patch("importlib.import_module"));permissions_allow, enabled, or mock_init.called);pytest.raises(Exception) where a typo's AttributeError also passes;
"msg" not in caplog.text, which passes when the wording changes);OSPREY-specific:
StrEnum equality) that
re-test Python; keep only when immutability is a documented safety property,
then pin dataclasses.FrozenInstanceError;assert mock.called as the only assertion, usually on an unspec'd mock;--help smokes checking only exit_code == 0 and the verb name;connect() when a cheap public path exists (fine as a hardware-transport
fixture seam);if __name__ == "__main__": pytest.main([__file__]) boilerplate;Tests justify their maintenance cost by protecting behavior, a credible regression, or an independently meaningful contract. In an audit, an existing test that must change for behavior-preserving source reorganization is suspect, not automatically deletable; the authoring gate still rejects new ones.
Before judging a candidate, read the complete test and production owner, its
entry point, callers, callees, sibling implementations, overlapping tests, CI
routing (.github/workflows/ci.yml), and relevant history (git log -L,
git log -S). Read tests/README.md and, for e2e, tests/e2e/README.md first,
plus any scoped README next to the test data. Read tests/conftest.py, and the
harness it imports its guards from
(packages/osprey-connectors/tests/osprey_connectors_tests/_harness/_guards.py),
before judging any test touching global state: its autouse guards may be the
real isolation. When the test claims dependency-backed behavior (pyepics, p4p,
click, FastMCP, litellm), inspect the dependency source in .venv directly.
Keep discovery read-only and report evidence before editing. Use
uv run pytest --collect-only -q <path> and uv run pytest --markers; never
the full suite, e2e or a container run. For broad scope, run parallel
discovery lanes when available:
src/osprey/, packages/osprey-connectors/);tests/connectors, tests/mcp_server,
tests/bridges, tests/services/<svc>, tests/hooks, tests/va);grep -rnE 'for tests|test seam|test hook|tests only|test-only|re-exported for tests' src/osprey packages --include='*.py'.Outside campaign mode, prefer a few high-confidence candidates over a large
speculative inventory. Hunt for the junk patterns. Before
presenting candidates, check origin/main and recently merged PRs for work
that already moved them.
Keep a test when it independently enforces a public API, protocol, config, migration, storage, security, platform, default, prompt-byte, package, release, or architecture contract. In OSPREY that includes:
permissions_ask lists, write limits, verification,
fail-closed paths, write posture — per connector where each connector
implements it;ControlSystemConnector, WriteOutcome
vocabulary, sys.modules alias shims that production imports still use);result.stdout);_static_conformance seams in bridges/*/ops.py.Also keep:
Static or slow is not a deletion reason. A test that resembles implementation may still be the independent contract; prove otherwise before removing it. A flaky test is deflaked robustly, never weakened or deleted for flakiness; unit flakes are presumed leaks (the flaky-marker item of the tests/README.md §7 checklist).
Record every field below before editing. A missing field means the candidate is not ready for deletion:
tests/<area>/test_x.py::TestCls::test_name);src/
and packages/; a seam with any production caller is not test-only);frontend-js
job for vitest files, WHITELIST,
scripts/benchmark/matrix_e2e_config.json, markers);Choose one coherent owner-boundary batch. Delete obsolete test-only exports,
globals, wrappers, and dead production paths instead of preserving aliases.
Remove a reset hook only when its global state is gone or a sanctioned seam or
autouse fixture already covers the isolation; otherwise keep it, or promote it
to a public seam next to the state (tests/README.md §2). Never replace it
with test code monkeypatching the module global. Move retained regressions to
their canonical owners.
Consolidate repeated assertions into one parametrized contract. Tighten weak
negatives to the exact exception type instead of deleting them. Migrate any
unscoped patch("mod.subprocess.run") you touch to patch_subprocess().
Prefer net-negative production LOC. Do not add replacement tests that restate the same implementation, and do not convert uncertain candidates into cleanup to increase deletion counts.
When a test file is moved, renamed or deleted, update every registry that names
it: the unit-lane --ignore line in ci.yml, the e2e-tests --ignore list and
the dedicated e2e jobs that run the ignored files, the WHITELIST in
tests/infrastructure/test_import_time_audit.py, scripts/benchmark/matrix_e2e_config.json,
and the pyproject.toml marker list. Check find tests -name <basename>.py
first: a basename collision silently drops tests under xdist.
Never edit source or tests, and never commit, while pytest or a gate is running
in the checkout. Run gates in the foreground. Run e2e only by path
(uv run pytest tests/e2e/<file>).
Run the smallest owner and sibling tests twice, serially then parallel:
uv run pytest tests/<area>/test_x.py, then, for a unit area,
uv run python scripts/check.py quick --changed HEAD -- tests/<area>
(the files the pytest check ignores run in their own CI jobs, such as
tests/va/test_apply_fault.py — run them by path). Run the serial checks alone:
uv run python scripts/check.py run pytest-pty pytest-wallclock pytest-wallclock-unit
(the pty suite, then the wall-clock budgets in tests/integration and in the
rest of the tree outside tests/e2e). For e2e,
run one file by path, serially or with -n 4 --dist loadfile. Neither run
is evidence for the other. For vitest files, run
npm run test:js -- <path>, then
npm run typecheck and npm run lint (the frontend-js CI job).
For removed source greps or plan assertions, run the command that owns the
real contract (the CLI verb, the render, the MCP tool call, or the owning
scripts/ check).
Run uv run ruff format . and uv run ruff check . --fix, then
git diff --check.
Run the gates the diff demands:
uv run python scripts/check.py quick --changed origin/main --worktree.
It runs the checks the diff touches (mypy, the changelog gate, the tests
the changed paths map to) and names the CI lanes to run. Beside it, run
what is not a check: uv run pytest tests/deployment/test_ci_workflow_wiring.py
and tests/infrastructure/test_import_time_audit.py for routing or file
moves, and uv run python scripts/benchmark/check_e2e_coverage.py --check-lanes
for e2e changes. A change the changelog gate covers needs a NEW
changelog.d/<ref>.internal.md (the quick tier above runs that gate).
Inspect git diff --numstat; report src/, packages/, scripts/ and .github/
separately from tests/ and tests/_*.py support.
After final audit edits, have the diff reviewed, with a code-review skill if one is installed.
Commit, push, open a PR, or land only when authorized. Branch test/<topic>
(CONTRIBUTING.md), commits test(<scope>): .... Keep audit ledgers and working
notes out of tracked files; the durable record is the tests and their docs.
Ship with /osprey:contribute. Mind the CI budget of three concurrent PR runs;
prefer gh run rerun <id> --failed to a re-push. The model-spending lanes run
on a pull request only under the full-ci label. Land one coherent PR at a
time; after landing, refresh from current main and rerun read-only discovery
for the next high-confidence batch.
Report:
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
12 skills in this plugin
/build-appBuild an OSPREY app: a panel in the web terminal's sidebar, the backend container behind it, and the agent tools that reach the same backend, all declared in one app.yml. Use whenever someone wants to create, scaffold, extend or fix an OSPREY app or application, runs or asks about `osprey app new` / `osprey app check`, edits an app.yml, adds a tool, a route, a write with an approval card, or a skill or subagent to an app, or wants an operator screen that the agent can also read and drive, even when they only say "panel with a backend" or "give the agent a tool for X". Works in a facility deployment repo with OSPREY installed and in an OSPREY checkout. Starts by checking itself against the installed OSPREY's app contract. For a static themed page with no backend and no tools, use the panel skill instead.
/contributeGuides a contributor through the OSPREY GitHub Flow contribution journey from a working-tree change to a merged PR on main. Use when someone says "I want to contribute X to osprey", "help me commit/push this", "prep this branch for a PR", "open a PR", "my CI is failing on this branch", "rebase onto main", or wants help following the contributing workflow. Auto-detects whether they have push access to als-apg/osprey or are contributing from a fork. Composes with /osprey:pre-commit and /osprey:release, and with the external commit-organize skill when it is installed — invoke this whenever someone is contributing code to OSPREY, even if they haven't named the workflow explicitly.
/design-philosophyOSPREY's design and architecture principles — the rules that define how OSPREY code should be structured, and the anti-pattern each one prevents. Consult before designing, adding, or reviewing any feature (connectors, MCP servers, providers, capabilities, CLI, registry, runtime, config), and when redirecting work that is drifting from these principles. Trigger when the user says "is this the right direction", "does this fit OSPREY", "this feels wrong", "check the design philosophy", or points an agent at how OSPREY code should look. Apply before adding a config knob, a new abstraction, a new subsystem, or anything touching hardware-write safety./doc-syncUse when a maintainer wants to know where a page under docs/source says something the code no longer does — before cutting a release, after a long stretch of merges, or when one page is suspected of describing a flag, key, default, or procedure that has moved on. Triggers: "run doc-sync", "sync the docs", "do the docs match the code", "is this page still right", "check the how-to guides", "validate the docs", "doc drift", "audit the docs", "which pages went stale". Prefer it over reading a page and forming an opinion whenever the question is "is what this page says still true". Config comments, shipped prompts, runtime messages, and pinned versions are not doc pages; those are osprey:housekeeping.
/facility-reviewResolves what the OSPREY facility build flags, with the person who maintains the facility repository: runs `osprey facility validate`, investigates every stop and warning it prints, groups the ones that share a cause, asks one evidence-backed question per group, writes each confirmed answer into `fixes.yaml` or `policy.yaml` (or proposes a diff to an authored facility file), rebuilds, and shows the finding gone. Use whenever a facility build stops or warns, whenever someone pastes a `facility: <kind>: ...` line, after `osprey facility import` brings in a cable schedule, rack layout, MML export or channel list, and when someone says "review my facility", "clean up the facility warnings", "two sources disagree", "contested relations", "layer-conflict", "which source wins", or asks why a relation is contested or superseded, even if they do not name this skill.
/housekeepingUse when a maintainer wants to know where OSPREY tells its users something that is no longer true — before cutting a release, after a long stretch of merges without one, or when the generated project, a shipped skill, a runtime message, or a pinned version is suspected of having fallen behind the code — or when the shipped presets, which are supposed to agree (hello-world and demo), may have drifted apart. Triggers: "run housekeeping", "check for drift", "what has rotted", "is anything stale", "housekeeping report", "sweep the repo", "preset parity", "do the presets still agree", "what maintainer chores are outstanding", "pre-release drift check". Prefer it over ad-hoc grepping whenever the question is "has anything drifted" rather than "fix this one thing". Doc-page prose is not this skill's job; that is osprey:doc-sync.
npx claudepluginhub als-apg/osprey --plugin ospreyOther plugins' skills for the same job