一键导入
retro-test-analysis
Analyzes existing tests to extract behavior contracts, acceptance scenarios, coverage mapping, and test-derived requirements
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Analyzes existing tests to extract behavior contracts, acceptance scenarios, coverage mapping, and test-derived requirements
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
Test failure diagnosis, source code fixes, and regression detection
Environment verification, dependency installation, baseline test verification
Contract-first single-task implementation dispatched by Coder Coordinator
Integration test writing for component boundaries and external dependencies
Unit test writing and execution with coverage threshold enforcement
API reference documentation skill. Produces and updates API endpoint documentation from contract files in .sdd/docs/api-reference.md.
基于 SOC 职业分类
| name | retro-test-analysis |
| description | Analyzes existing tests to extract behavior contracts, acceptance scenarios, coverage mapping, and test-derived requirements |
| argument-hint | Invoked by Retro-Spec Coordinator - do not call directly |
This skill is invoked by the Retro-Spec Coordinator as the sixth extraction skill (validation phase). It analyzes existing test files to validate extracted specifications, discover additional behaviors documented through tests, map coverage, and enrich acceptance scenarios. It produces Section 11 (Test Requirements) and updates confidence markers throughout the accumulator.
| # | Input | Description |
|---|---|---|
| 1 | skill_path | Path to this SKILL.md file |
| 2 | accumulator_path | Path to the spec file being built |
| 3 | artifacts_dir | Path to companion artifacts directory |
| 4 | discovery_manifest_path | Path to the discovery manifest |
| 5 | source_path | Path to the legacy source code |
| 6 | target_language | Target language for artifacts |
| 7 | project_name | Name of the project |
| 8 | module_filter | Modules to analyze |
#tool:search/searchSubagent to discover all test files and #tool:search/usages to trace which source symbols are covered by tests.[TEST VALIDATED: <test_file>:<test_name>] or [NO TEST COVERAGE]__tests__/, test/unit/, tests/unit/test/integration/, tests/integration/, e2e/test/e2e/, cypress/, playwright/test/perf/, benchmark/, test/load/it\(|test\(|def test_|func Test|@Test|\[Fact\]|\[Test\] to estimate number of test casesFor each test file:
Read the test file
Extract test descriptions: The describe/it/test strings or method names
Map test assertions to FRs:
[TEST VALIDATED: file:test_name][INFERRED: HIGH] (test-derived)Extract Given/When/Then from test structure:
Quality assessment of each test:
Build a coverage matrix mapping FRs to test evidence:
| FR | Test File | Test Name | Type | Verdict |
|---|---|---|---|---|
| FR-001 | user.test.ts | "creates user with valid email" | unit | Covered |
| FR-002 | user.test.ts | "rejects duplicate email" | unit | Covered |
| FR-003 | - | - | - | NOT COVERED |
| FR-004 | auth.e2e.ts | "blocks unauthorized access" | e2e | Covered |
Tests often document behaviors not immediately obvious from production code:
For each discovered behavior that is NOT already in the accumulator:
[INFERRED: HIGH] Source: <test_file>:<test_name> (tests are strong evidence)Analyze test mocks and stubs to understand expected interfaces:
If mocks reveal interfaces NOT captured in Section 8, add inline notes:
[INTERFACE GAP: test mocks <service> at <file:line>, but no interface extracted in Section 8]
## 11. Test Requirements
### 11.1 Test Coverage Summary
| Metric | Value |
|--------|-------|
| Total FRs | <count> |
| FRs with test evidence | <count> |
| FRs without test coverage | <count> |
| Coverage percentage | <X%> |
| Total test files analyzed | <count> |
| Estimated test cases | <count> |
### 11.2 Test Infrastructure (Legacy)
| Aspect | Detail | Source |
|--------|--------|--------|
| Unit test framework | <jest/pytest/etc.> | <config file> |
| Integration test framework | <supertest/etc.> | <config file> |
| E2E test framework | <cypress/playwright/none> | <config file> |
| Mocking library | <jest mocks/unittest.mock/etc.> | <test files> |
| Test runner | <npm test/pytest/go test> | <package.json/Makefile> |
| Coverage tool | <istanbul/coverage.py/etc.> | <config file> |
| CI test execution | <yes/no> | <CI config file> |
### 11.3 Recommended Test Strategy (for Reimplementation)
Based on legacy test analysis, the reimplementation SHOULD include:
#### Unit Tests (target: 80% line coverage, 90% branch coverage)
| # | Test Scope | Priority | FR Reference | Legacy Evidence |
|---|-----------|----------|-------------- |-----------------|
| UT-01 | <behavior to test> | P1 | FR-001 | <legacy test or gap> |
**Given/When/Then Scenarios** (derived from legacy tests):
```gherkin
Scenario: <derived from legacy test>
Given <setup from test arrange phase>
When <action from test act phase>
Then <assertion from test assert phase>
Source: <legacy test file:test name>
| # | Test Scope | Components | FR Reference | Legacy Evidence |
|---|---|---|---|---|
| IT-01 | <A + B> | FR-XXX |
| # | Test Scope | User Flow | Legacy Evidence |
|---|---|---|---|
| E2E-01 | Section 6.X |
FRs that have NO test coverage in the legacy codebase (high priority for reimplementation tests):
| FR | Description | Risk Level | Recommendation |
|---|---|---|---|
| FR-XXX | HIGH | Requires unit + integration tests |
Behaviors discovered through test analysis that were NOT immediately apparent from production code:
| # | Behavior | Test Source | Added To |
|---|---|---|---|
| TB-01 | FR-XXX (new) | ||
| TB-02 | US-XX edge cases |
---
## Annotation Format for Prior Sections
When adding test validation markers to prior sections, use ONLY inline additions:
**For validated FRs** (FR text already exists in Section 4):
**For unvalidated FRs** (no test found):
**For test-discovered behaviors** (new FR added):