plugins/spectre/skills/test/SKILL.md
👻 | Risk-aware test coverage & commit - primary agent
npx skillsauth add codename-inc/spectre testInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Treat the current command arguments as this workflow's input. When invoked from a slash command, use the forwarded $ARGUMENTS value.
Optional scope hint or specific files to focus on.
<ARGUMENTS> $ARGUMENTS </ARGUMENTS>
100% line coverage is a vanity metric that:
Risk-weighted coverage instead:
Identification patterns:
auth, payment, security, crypto, session, token@critical JSDoc/comment annotationCoverage requirements:
Test quality bar:
// ✅ GOOD P0 test - tests behavior and catches real bugs
it('rejects payment when card is expired', async () => {
const result = await processPayment({ card: expiredCard, amount: 100 });
expect(result.status).toBe('DECLINED');
expect(result.reason).toBe('CARD_EXPIRED');
expect(chargeService.charge).not.toHaveBeenCalled(); // Side effect prevented
});
// ❌ BAD test - tests implementation, not behavior
it('calls validateCard', async () => {
await processPayment({ card, amount: 100 });
expect(validateCard).toHaveBeenCalledWith(card);
});
Identification patterns:
Coverage requirements:
Test quality bar:
// ✅ GOOD P1 test - covers the behavior users care about
it('fetches and caches user profile', async () => {
const profile = await getUserProfile(userId);
expect(profile.name).toBe('Joe');
// Second call uses cache
await getUserProfile(userId);
expect(api.get).toHaveBeenCalledTimes(1);
});
// ❌ SKIP - internal implementation detail
it('calls normalizeUserData internally', () => { ... });
Identification patterns:
Coverage requirements:
Test quality bar:
// ✅ GOOD P2 test - public util with actual logic
it('formats currency correctly', () => {
expect(formatCurrency(1234.5, 'USD')).toBe('$1,234.50');
expect(formatCurrency(1234.5, 'EUR')).toBe('€1,234.50');
});
// ❌ SKIP - trivial wrapper with no logic
// export const getFullName = (u) => `${u.first} ${u.last}`;
Identification patterns:
.d.ts)index.ts that just re-exports)Coverage requirements:
when_[condition]_then_[outcome] or [action]_should_[result]For every test, ask: "If I changed the implementation to return a wrong value, would this test catch it?"
// ✅ Mutation-resistant — changing the discount calculation would fail this
it('applies 20% discount for premium users', () => {
expect(calculateTotal({ items: [100], userTier: 'premium' })).toBe(80);
});
// ❌ NOT mutation-resistant — always passes regardless of implementation
it('calls calculateDiscount', () => {
calculateTotal({ items: [100], userTier: 'premium' });
expect(calculateDiscount).toHaveBeenCalled();
});
When your code is consumed by other teams/modules, add contract tests:
// API Contract Test
describe('UserAPI contract', () => {
it('GET /users/:id returns UserResponse schema', async () => {
const response = await request(app).get('/users/123');
expect(response.body).toMatchSchema(UserResponseSchema);
});
it('returns standard APIError shape on 404', async () => {
const response = await request(app).get('/users/nonexistent');
expect(response.status).toBe(404);
expect(response.body).toMatchSchema(APIErrorSchema);
});
});
// Event Contract Test
describe('UserCreated event contract', () => {
it('emits event matching UserCreatedEvent schema', async () => {
await createUser({ name: 'Test' });
expect(eventBus.lastEvent).toMatchSchema(UserCreatedEventSchema);
});
});
OUT_DIR/working_set.jsonAction — InlineRiskCheck: Quick mental triage of changed files
P0 Critical (thorough coverage required):
auth, payment, security, crypto, session, token@critical annotationP1 Core (key behaviors):
P2 Supporting (public surface only):
P3 Skip (no tests):
.d.ts), configs, styles, index barrels, simple wrappersAction — CreateTestPlan: Write 3-7 bullet test plan
- [P{tier}] {file}: {behavior to test}Action - UpdateOUT_DIR/working_set.json with risk tier categorization.
Action — DispatchTestWriter: Spawn MULTIPLE @spectre:tester subagents IN PARALLEL
Action — RunLint: Execute linter; fix violations
Action — RunTests: Execute full test suite
Action — VerifyQuality: Spot-check 1-2 tests
Action — CommitPlanningArtifacts: Gather and commit planning/working docs FIRST
OUT_DIR/:
working_set.json (scope and risk tier categorization).md or .json artifacts created during this flowdocs/tasks/{branch_name}/ or related planning directoriesgit add docs/tasks/{branch_name}/ OUT_DIR/docs(test): add test planning artifacts for {branch_name}Action — GroupChanges: Organize code changes into logical commits
Action — CommitAll: Create conventional commits for code changes
type(scope): descriptionAction — RenderFooter: Render Next Steps footer using @skill-spectre:spectre-guide skill (contains format template and spectre command options)
See @skill-spectre:spectre-guide skill for footer format and command options.
Step 1 - Analyze Diff:
[ ] Scope identified (files changed) and documented
[ ] Behaviors changed listed (not just file names)
Step 2 - Risk Assessment & Test Plan:
[ ] Each changed file assigned P0-P3 tier
[ ] Test plan created with 3-7 bullets
[ ] P3 files explicitly marked SKIP
Step 3 - Write Tests & Verify:
[ ] Multiple @spectre:tester agents dispatched in parallel (not sequential)
[ ] Test plan partitioned into independent batches
[ ] All agents launched in single message (parallel tool calls)
[ ] P0 files have thorough behavioral coverage
[ ] P1 files have key path coverage
[ ] P2 files have public surface coverage
[ ] P3 files have NO tests (confirmed skipped)
[ ] Lint passes
[ ] All tests pass
[ ] Test quality spot-checked
Step 4 - Commit:
[ ] Changes grouped logically
[ ] Conventional commit format used
[ ] Single Next Steps footer rendered
[ ] Next steps guide read and options sourced
testing
👻 | Independent multi-lens review of plan.md and/or tasks.md — finds overengineering, missing verification, hallucinated deps, weak references
data-ai
👻 | Unified planning entry point - researches, assesses complexity, routes to workflow - primary agent
data-ai
👻 | Transform requirements into executable tasks - primary agent
testing
👻 | Independent multi-lens review of plan.md and/or tasks.md — finds overengineering, missing verification, hallucinated deps, weak references