一键导入
validate-tests
Detects test anti-patterns based on behavior testing principles
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Detects test anti-patterns based on behavior testing principles
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Plan-then-execute sprint orchestrator. Works like a real delivery team: split work into sprints (~1 human-week each), plan them all up front WITH the user, then autonomously run each sprint through a full cycle (research→plan→design→do→QA→fix→deploy) to completion. Multiple sprints can run at once (concurrent dispatch). The leader (main session) dynamically scaffolds project-local agents for whatever domain — not dev-only (marketing, research, ops, data all fit). bkit-aware: borrows bkit agents/skills internally when present, runs fully standalone otherwise. Not for single-file edits, one-shot bug fixes, or work under ~a few hours.
Invoke for "/cowork-insights" command or when the user asks to summarize, review, or report on past Claude Code sessions. Analyzes sessions to show key prompts (verbatim), structured assessments (goal/outcome/friction), tool usage patterns, and actionable insights. Produces HTML report + shareable Markdown for Jira/Notion/Slack. Three report formats — full (deep narrative), standard (core insights), minimal (quick team share). Supports --from/--to with absolute (2026-03-01) or relative (7d, 2w, 1m) dates. Trigger on phrases like weekly status update, sprint recap, what did I do with Claude, AI usage patterns, session history, minimal recap, what I worked on today, share with team, cowork-insights. DO NOT invoke for active tasks (debugging, refactoring, code review, project setup) or for commit-time recaps (use cowork-commit instead).
Trigger whenever the user asks to commit AND wants the commit message enriched with AI collaboration history. Creates a lightweight commit message (key decision highlights + link) and a full directive-log file with conversation transcript + recap. The key signal is the combination of (1) making a commit with (2) capturing how AI contributed. Trigger on phrases like commit with AI recap, attach collaboration history to commit, record AI work in commit, cowork-commit. DO NOT trigger for plain commits without AI documentation, standalone time-period recaps (use cowork-insights instead), PR reviews, or general git operations.
One-time bootstrap of an existing project's docs/ and source into the cowork-doc-sync taxonomy structure. After a detailed gap analysis, relocate docs to match the standard. Phase 1 = relocation only (no new creation, includes moving content between docs), Phase 2 = analyze source to create new docs (only after user approval). For ongoing maintenance use /cowork-doc-sync. Triggers: cowork-doc-init, /cowork-doc-init, init doc structure, relocate docs, organize existing docs, doc init, doc bootstrap
Ongoing doc-sync skill that aligns a project's docs/ with the current code/decision state. Call once at the very end, after implementation/refactoring is complete. Enforces a numbered taxonomy (00-reference~99-misc) + status model (LIVING/ACTIVE/FROZEN) + migration rules. To fit an existing project into this structure for the first time, use /cowork-doc-init. Triggers: cowork-doc-sync, /cowork-doc-sync, sync docs, align docs, organize docs, doc sync, doc alignment
Compare DevMD files against actual source code. Measures coverage, accuracy, and consistency with deterministic counting and evidence-backed findings.
| name | validate-tests |
| description | Detects test anti-patterns based on behavior testing principles |
| triggers | ["validate tests","check tests"] |
| user-invocable | true |
| allowed-tools | ["Read","Write","Glob","Grep","Bash"] |
Corresponding rule: testing.md
Statically detect anti-patterns in test code based on behavior-driven testing principles (testing.md). Identify patterns that hurt maintainability, such as implementation-detail testing, excessive mocking, and shared global state.
*.test.*, *.spec.*, test_*, *_test.*)Detect patterns where test names provide no clue to the cause of failure.
Search patterns:
test_\d+$ (names ending only in a number: test_1, test_2)test_it_workstest_functiontest_oktest_successit\(["']works["'] (JS/TS: it('works'))it\(["']should work["']test\(["']test["'] (JS/TS: test('test'))Severity: WARN
Detect patterns that verify call count/existence of internal methods.
Search patterns:
.call_count.called.assert_called_with.assert_called_once.assert_called_once_with.assert_any_call.toHaveBeenCalledTimes (Jest).toHaveBeenCalledWith (Jest)verify(.*).times( (Java Mockito)Severity: WARN
Detect patterns where a single test function uses 4 or more Mock objects.
Search patterns:
Mock() or mock.patch appears 4+ times in a single test functionjest.fn() or jest.mock appears 4+ times in a single test@mock.patch decorators: 4+ on a single test functionSeverity: WARN (when 4 or more)
Detect patterns where test files create instances at module level, sharing state across tests.
Search patterns:
= new (instance creation) -- at the top level of a test file (outside functions/classes)shared_ prefixlet declarations that are mutated by tests (JS/TS)global keyword at the top level of a test fileSeverity: WARN
Detect patterns where unit test files directly call DB connections/queries. Exclude integration test files whose names contain integration, e2e, or integ.
Search patterns:
db.querydb.executedb.sessiondb.connectprisma. (query methods)mongoose.connectconnection.executepool.queryExclusion condition: file name contains integration, e2e, or integ
Severity: WARN
Glob to collect test files (*.test.*, *.spec.*, test_*, *_test.*)Grep each pattern across all test filesRead test files and tally Mock count per functionRead test files and detect instance creation at module level (outside functions/classes)Output the matrix below before generating the final report. Do not proceed until every category has been scanned.
| Category | Status | Items Checked | Findings | Severity | Evidence |
|---|---|---|---|---|---|
| Vague Test Names | ? | ? | ? | WARN | {Glob/Grep, files, pattern} |
| Implementation-Detail Tests | ? | ? | ? | WARN | {Glob/Grep, files, pattern} |
| Excessive Mocks | ? | ? | ? | WARN | {Read, scanned files} |
| Shared Global State | ? | ? | ? | WARN | {Read, scanned files} |
| DB Dependency | ? | ? | ? | WARN | {Grep, files, pattern} |
Status values: PASS (verification complete, no issues), NOT_APPLICABLE (no test files), SKIPPED (plugin issue), SHALLOW (partial scan)
Check every item before writing the report. If any item is unchecked, go back and complete it.
Before writing to .ww-w-ai/devtools/validate-tests/, verify the JSON output:
Generate the validation report in the user's conversation language.
Output detection results as a Markdown table in this format:
===== Test Validation Report =====
| File:Line | Type | Description |
|-----------|------|-------------|
| `src/services/auth.test.ts:15` | Vague Name | `test_1` -- cannot identify failure cause |
| `src/services/order.test.ts:42` | Implementation Detail | `.assert_called_once_with` -- internal-call verification |
| `src/services/payment.test.ts:20` | Excessive Mocks | 6 Mocks used -- design review needed |
| `test_user.py:5` | Global State | `shared_cart = Cart()` -- state shared across tests |
| `src/utils/calc.test.ts:30` | DB Dependency | Direct `db.query` call -- unit test depends on DB |
Total anti-patterns: {N}
Vague Names: {A}
Implementation Detail: {B}
Excessive Mocks: {C}
Global State: {D}
DB Dependency: {E}
===============================
When no anti-patterns are found:
===== Test Validation Report =====
No anti-patterns.
===============================
After generating the test validation report, save results to .ww-w-ai/devtools/validate-tests/:
.ww-w-ai/devtools/validate-tests/ if missinglatest.json -- structured result following templates/schema.jsonlatest.md -- human-readable report following templates/report.template.mdhistory/ -- copy latest.json to .ww-w-ai/devtools/validate-tests/history/{timestamp}.jsonlatest.md is generated in the user's conversation language. JSON field names stay in English regardless of language.
The JSON output enables machine-parseable history tracking and cross-run comparison.
The history/ directory preserves previous executions for trend analysis.
mkdir -p .ww-w-ai/devtools/validate-tests/history). The validation itself is read-only and does not modify project files.legacy, migration, or compat, annotate the result with "(legacy allowance).".toHaveBeenCalledWith can also be used for external-dependency verification (e.g., API calls), so results are presented as advisory.beforeEach/setUp are distributed and tallied against each test.For detailed validation criteria, evidence tables, and examples:
../../docs/specs/testing.md