/harness-claude:harness:test-craft runs instead · from harness-claude
Critiques test quality across vitest/jest/mocha/playwright/pytest using LLM judgment. Per-block analysis with source-pairing and 3-axis findings (tier, impact, confidence).
This skill never runs in Claude Code
It ships in harness-claude at agents/, but /harness-claude:harness:test-craft (a command, or a skill Claude Code finds first) has the same name: typing it, or Claude choosing it, runs that one instead.
LLM-judgment critique of test quality across vitest / jest / mocha / playwright / pytest. Fourth member of the craft-pipeline initiative. Per-
it/testblock critique with best-effort source pairing for contract-vs-implementation rubrics. Tests are often the worst-written code in a codebase precisely because the rule-based floor (coverage threshold) is so easy to clear. Emits 3-axis findings (tier × impact × confidence per ADR 0019).
vitest --coverage or harness-tdd — that's the floor)align-test may add safe renames).test-d.ts type tests in v1 (v1.x — different rubric vocabulary)packages/cli/src/shared/craft/) — LlmProvider + finding/axes schema + run store — shared across all *-craft skills. This skill implements, and does not own, that contract.packages/cli/src/test-craft/).craft-fleet (the craft-pipeline elevation sweep) and the harness natural-language router, which invoke every *-craft provider uniformly through the shared critique/finding shapeRead project configuration. Check harness.config.json for:
craft.test.enabled — gate (default true)craft.test.maxFiles (default 100), craft.test.maxTestsPerFile (default 20)craft.test.frameworks — restrict to subset (default: all five)craft.test.sourcePair — toggle source-pairing (default true)Glob test files under project root: **/*.{test,spec}.{ts,tsx,js,jsx,mjs,cjs,mts,cts} plus pytest naming (test_*.py / *_test.py). Skip node_modules, dist, build, coverage, __pycache__, venv, vendor, dotdirs. The extension list is defined once in extract/test-file-exts.ts and shared by discovery and extraction — a private second copy is what made *.test.mjs suites invisible (#1347).
Detect framework per file via import signatures (order matters; most-specific first):
@playwright/test → playwright@jest/globals → jestvitest → vitestimport 'mocha' → mocha.py files → pytest (extraction is light-parse, not TS AST)Single TS Compiler API walk per file. For each CallExpression:
testName (first string-literal arg), capture current nesting, capture callback body text (truncated to 1500 chars in prompt).skip, .only, .todo (todo excluded from critique — no body to critique)For each test file, try in order:
foo.test.ts → foo.ts (same dir)tests/foo.test.ts → ../src/foo.tstests/foo.test.ts → ../../src/foo.tsWhen source resolves, content (truncated to 2000 chars) is added to the LLM prompt under Source under test:. This enables TEST-R007 (contract-not-implementation) to actually compare assertions against the function's public surface. When no source resolves, test-file-only rubrics still fire.
8 seed rubrics:
| Rubric | Description |
|---|---|
TEST-R001 contract-not-narrative-name | Test name describes the contract ("returns null when empty"), not narrative |
TEST-R002 meaningful-assertion | Assertion proves something the implementation could plausibly violate |
TEST-R003 arrange-act-assert | Three visually distinct phases, not interleaved |
TEST-R004 fixture-earns-setup-cost | Heavy beforeEach must be justified by what's asserted |
TEST-R005 single-responsibility | One assertion target per it; multiple unrelated assertions split poorly |
TEST-R006 deleting-loses-something | Would removing this test lose specific coverage, or is it redundant? |
TEST-R007 contract-not-implementation | Tests the documented behaviour, not the internal structure |
TEST-R008 explicit-failure-mode | Failure message narrates what went wrong without reading the test |
For each (test, rubric) pair:
null (rubric doesn't apply / test is fine) OR { tier, impact, confidence, message }.TestFinding with cite.rubricId for ADR 0020 traceability.Emit TestCraftOutput:
{
findings: TestFinding[];
summary: {
phaseRun: ['critique'];
durationMs: number;
llmCalls: { provider, model, count, costUsd };
catalog: { rubricsApplied: string[] };
// critiqueErrors > 0 or testsTruncated > 0 means the run is partly
// unmeasured: findings are a floor, not a total.
counts: { filesScanned, testsExtracted, testsSkippedOrTodo, sourcePaired,
critiqueErrors, testsTruncated };
frameworksDetected: Record<TestFramework, number>;
runId: string;
}
}
harness test-craft — CLI entry. --files / --frameworks / --max-files / --max-tests-per-file / --no-source-pair / --json / --verbose.mcp__harness__test_craft — MCP tool. Same input/output. Consumed by agents.critiqueTestsInFile(file, opts) exported. Works on a single test file without project walk; honours framework filter and source-pairing toggle.LlmProvider + 3-axis types + derivePriority from packages/cli/src/shared/craft/.test-craft auto-activates as an advisory review hook whenever a diff touches the surface it
owns — harness-autopilot at after:REVIEW / after:FINAL_REVIEW, and harness-code-review at
after:mechanical. The domain table is CRAFT_REVIEW_DOMAINS and the per-host events are
CRAFT_REVIEW_EVENTS_BY_HOST, both in packages/core/src/hooks/craft-review-hooks.ts. The host
forwards the subset of the diff this domain owns:
files — this domain's owned subset of the changed files, as ABSOLUTE paths. The host
reads it from plan.files["test-craft"], which holds repo-relative POSIX paths, and resolves each
entry against the project root before calling mcp__harness__test_craft. Absolute is the
recommended form, not a correctness requirement for this domain: its collector resolves a
relative entry against the tool's path (never the process CWD), so a repo-relative entry
forwarded unresolved still reads the in-diff file (pinned by
packages/cli/tests/shared/craft/relative-files-scope.test.ts). Only
mcp__harness__design_craft still requires absolute paths.promptBudget — accepted; raises the prompt ceiling for the forwarded scope when the diff subset is large.Findings from a hook-triggered run are advisory: reported, never blocking, never counted toward review severity, and never entered into a host's mechanical exclusion set. A hook-triggered run that fails is a missing opinion, not a broken gate.
See docs/changes/craft-pipeline/test-craft/proposal.md for the full 36 success criteria. Highlights:
catalog/rubrics/<id>.ts (file-per-rubric, matches naming/spec/copy-craft)cite.rubricId populated on every finding (ADR 0020)@playwright/test / @jest/globals / vitest / mocha import signatures; vitest fallback.skip / .only / .todo with metadata; describe-chain nesting capturedThese are common rationalizations that sound reasonable but lead to incorrect results. When you catch yourself thinking any of these, stop and follow the documented process instead.
| Rationalization | Why It Is Wrong |
|---|---|
| "This test is green and coverage went up, so it's a good test." | Coverage is the floor (vitest --coverage). Test-craft asks whether the assertion proves something the implementation could plausibly violate (TEST-R002). A green tautology adds zero signal. |
"expect(user).toBeDefined() after createUser(...) confirms it works, so R002 passes." | The return is defined by the signature — the assertion cannot fail. That is the tautology TEST-R002 targets. Assert the contract (user.name), not mere existence. |
| "The test asserts the mock returned exactly what I stubbed, so behaviour is verified." | Asserting the mock echoes your own setup, not the unit's behaviour. TEST-R007 wants assertions against the source's public contract, not the test's own scaffolding. |
| "Source pairing didn't resolve, so I'll still critique TEST-R007 from the test body." | Without resolved source, contract-not-implementation has nothing to compare against and should skip. Inventing a contract from the test body inverts the rubric it is meant to enforce. |
| "The test name reads like a full sentence, so TEST-R001 passes." | Contract-not-narrative-name wants the contract ("returns null when empty"), not readable narrative ("works correctly"). A grammatical sentence that names no contract is the failure mode. |
Input: src/parse.test.ts:
describe('parseTokens', () => {
it('works correctly', () => {
expect(parseTokens('a,b,c')).toEqual(['a', 'b', 'c']);
});
});
Output (mock LLM):
src/parse.test.ts
TEST-R001 [polish/medium/high] vitest:2
parseTokens > works correctly
"works correctly" narrates the test without naming the contract. Try
"splits comma-separated input into trimmed segments" or "preserves
order across the split".
Input:
it('returns a user', () => {
const user = createUser({ name: 'a' });
expect(user).toBeDefined();
});
Output:
TEST-R002 [foundational/medium/high] vitest:8
createUser > returns a user
`toBeDefined()` after `createUser(...)` cannot fail — the return is
always defined by the function's signature. Assert the contract:
`expect(user.name).toBe('a')` or `expect(user).toMatchObject({...})`.
Input:
it('handles input', () => {
// 47 lines of beforeEach setup that mocks 6 collaborators
const result = handler.handle({});
expect(result).toBeTruthy();
});
Output:
TEST-R004 [polish/large/medium] vitest:142
handler > handles input
47-line beforeEach + 6 mocks produce a result that's asserted with
`toBeTruthy`. The fixture's complexity exceeds the test's signal —
either drop the fixture and use a simpler stub, or assert the
specific outcome that justified the setup (e.g., which collaborator
was called with what arguments).
align-test.vitest --coverage)..test-d.ts type tests (v1.x).agent.backends + HARNESS_CRAFT_LLM, or set HARNESS_CRAFT_LLM=mock for tests. It refuses rather than critiquing nothing and reporting zero findings (#1346).critiqueErrors or testsTruncated above zero: the run is partly unmeasured — findings are a floor, not a total.maxTestsPerFile (default 20) or scope to specific frameworks with --frameworks vitest. Disable source-pairing with --no-source-pair to halve prompt size on every test.--files to exclude. v1.x adds // test-craft:skip annotation.TEST-R007. Use --no-source-pair to fall back to test-file-only rubrics, or v1.x's harness.config.json test→source mapping.import { describe, it } from '@jest/globals' to make the signature explicit.it.each / test.each blocks get critiqued as a single test: v1 captures the each invocation as one item with a generic name pattern. v1.x adds per-iteration critique.v1 — in implementation. See:
docs/changes/craft-pipeline/test-craft/proposal.mdcraft-pipeline initiativenaming-craft, spec-craft, copy-craftpackages/cli/src/shared/craft/align-test (FIX side, v2), docs-craft, code-craftWhat SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub intense-visions/harness-engineering --plugin harness-claude793 skills in this plugin
/a11y-aria-patternsARIA Patterns> Apply ARIA roles, states, and properties correctly to enhance assistive technology support for custom widgets/a11y-color-contrastColor Contrast and Color Independence> Ensure sufficient color contrast ratios and never use color as the sole means of conveying information/a11y-form-patternsAccessible Form Patterns> Build accessible forms with proper labeling, grouped controls, inline validation, and clear error communicationOther plugins' skills for the same job