ワンクリックで
retro-business-logic
Infers functional requirements, business rules, validation logic, workflows, and user stories from legacy code behavior
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Infers functional requirements, business rules, validation logic, workflows, and user stories from legacy code behavior
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
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.
| name | retro-business-logic |
| description | Infers functional requirements, business rules, validation logic, workflows, and user stories from legacy code behavior |
| argument-hint | Invoked by Retro-Spec Coordinator - do not call directly |
This skill is invoked by the Retro-Spec Coordinator as the fourth extraction skill. It analyzes the legacy codebase to infer functional requirements, business rules, validation logic, workflows, and user stories from actual code behavior. It produces Sections 4 (Functional Requirements), 5 (User Stories), and 6 (User Flows).
| # | 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/usages to trace function call chains and #tool:search/searchSubagent for broad logic flow discovery.This skill supports two extraction depth modes:
Standard extraction across all modules in the project. Produces FRs, user stories, and flows at feature-area granularity. Suitable for project-level specs.
Triggered when the dispatch prompt contains Extraction depth: MODULE-DEEP. This mode performs exhaustive extraction within a SINGLE module:
MODULE-DEEP produces additional subsections beyond standard FRs:
[INFERRED: confidence] for every FR, user story, and flow[INFERRED: HIGH][INFERRED: MEDIUM][INFERRED: LOW]The primary source of business rules is the service/use-case layer. For each service class/module identified in Section 9:
Beyond the service layer, analyze domain-rich code to understand the business deeply:
Search for all validation logic to infer business constraints:
Input validation patterns:
grep: "validate|isValid|check|assert|throw.*invalid|raise.*invalid|BadRequest|422|validateSync|safeParse|parse\("
Conditional business rules:
grep: "if.*throw|if.*raise|if.*return.*error|guard|require\(|precondition"
For each validation found:
Classify validations:
Identify multi-step processes and workflows:
For each workflow, document:
Extract role-based or permission-based access control:
user.id === resource.ownerIdBuild a permission matrix:
| Action | Role A | Role B | Role C | Source |
|---|---|---|---|---|
| Create User | yes | no | no | file:line |
From the extracted FRs, API endpoints, and workflows, infer user stories:
From workflows and endpoint sequences, construct user flows:
## 4. Functional Requirements
### 4.1 <Feature Area>
- **FR-001**: The system SHALL <obligation statement>.
[INFERRED: confidence] Source: <file:line>
- Precondition: <condition>
- Postcondition: <result state>
- Error: <failure behavior>
- **FR-002**: The system SHALL validate that <business rule>.
[INFERRED: MEDIUM] Source: <validation file:line>
- Precondition: <input received>
- Postcondition: <input accepted and processed>
- Error: Return 422 with error key <KEY> when <condition>
#### Implementation Contract -- <Feature Area>
**Inputs**: <description with types, from Section 8>
**Outputs**: <description with types, from Section 7>
**Error behaviors**:
- <condition> -> <response> (Source: <file:line>)
## 5. User Stories
### US-01 -- <Title> (Priority: P1) MVP
**As a** <role>, **I want** <capability>, **so that** <benefit>.
[INFERRED: confidence]
**Why P1**: <rationale based on code evidence -- e.g., heavily used endpoint, core entity>
**Independent Test**: <how to verify>
**Acceptance Scenarios**:
1. **Given** <precondition>, **When** <action>, **Then** <result> (happy path)
Source: <test file or handler:line>
2. **Given** <precondition>, **When** <action>, **Then** <result> (error path)
Source: <error handling code:line>
### Edge Cases
- <edge case from code analysis>
## 6. User Flows
### 6.1 <Flow Name>
**Actor**: <role>
**Precondition**: <initial state>
**Trigger**: <initiating action>
1. **<Actor>** <action>
- System: <response> [Source: <endpoint/handler:line>]
2. **System** <processing>
- Calls: <service method> [Source: <file:line>]
3. **System** <response to actor>
- Returns: <response shape from Section 8>
**Error paths**:
- At step N, if <condition>: <error handling>
Since we cannot ask users about priority, infer from code signals:
| Signal | Inferred Priority | Confidence |
|---|---|---|
| Endpoint has extensive test coverage | P1 | HIGH |
| Entity is referenced by many other entities | P1 | HIGH |
| Feature has dedicated error handling | P1 | MEDIUM |
| Endpoint exists but has no tests | P2 | MEDIUM |
| Code exists but is behind a feature flag | P2 | MEDIUM |
Code is commented out or in a TODO branch | P3 | LOW |
Code exists in a /experimental/ directory | P3 | LOW |
When operating in MODULE-DEEP mode, produce these additional sections AFTER Section 6:
## 4B. Business Rules & Invariants
### Invariants (must ALWAYS hold)
- **INV-001**: <invariant statement>
Enforcement: <where/how the code enforces this>
Violation handling: <what happens if violated>
[INFERRED: confidence] Source: <file:line>
### Business Rules
- **BR-001**: <business rule statement>
Trigger: <when this rule is evaluated>
Condition: <the logical condition>
Action: <what happens when the condition is true>
Otherwise: <what happens when the condition is false>
Business meaning: <why this rule exists in domain terms>
[INFERRED: confidence] Source: <file:line>
### Authorization Rules
- **AR-001**: <who can do what>
Resource: <entity/endpoint>
Required: <role/permission/ownership>
Enforcement: <middleware/guard/inline check>
[INFERRED: confidence] Source: <file:line>
## 4C. Decision Logic
### DL-001: <Decision Name>
**Context**: <when this decision is made>
**Source**: <file:line range>
[INFERRED: confidence]
| # | Condition A | Condition B | Condition C | Outcome | Side Effects |
|---|------------|------------|------------|---------|-------------|
| 1 | true | true | * | <result> | <events/calls> |
| 2 | true | false | true | <result> | <events/calls> |
| 3 | true | false | false | <result> | <events/calls> |
| 4 | false | * | * | <result> | <events/calls> |
**Business interpretation**: <what this decision means in domain terms>
For simpler decisions (single condition), use inline format:
- **DL-002**: If <condition>, then <outcome A>; otherwise <outcome B>.
Business meaning: <domain interpretation>
[INFERRED: confidence] Source: <file:line>
## 4D. Computed Values & Transformations
- **CV-001**: <computed_field_name>
Formula: <computation logic in pseudocode or formula>
Inputs: <list of input fields/values with types>
Output: <result type and range>
Business meaning: <why this value is computed, what it represents>
Used by: <which FRs, endpoints, or other computations depend on this>
[INFERRED: confidence] Source: <file:line>
- **CV-002**: <transformation_name>
Input shape: <source data structure>
Output shape: <target data structure>
Mapping:
- source.fieldA -> target.fieldX (rename)
- source.fieldB + source.fieldC -> target.fieldY (computed)
- "default_value" -> target.fieldZ (constant)
Business meaning: <why this transformation exists>
[INFERRED: confidence] Source: <file:line>
## 4E. Side Effects & Events
### Events Produced
- **EVT-001**: <event_name>
Trigger: <operation that produces this event>
Payload: <event data shape>
Consumers: <who/what listens for this event>
Business meaning: <what this event signifies in domain terms>
[INFERRED: confidence] Source: <file:line>
### External Calls
- **EXT-001**: <external_service_call>
Trigger: <when this call is made>
Request: <data sent>
Response handling: <how response is used>
Failure handling: <retry/fallback/error propagation>
Business meaning: <why this external call is necessary>
[INFERRED: confidence] Source: <file:line>
### Notifications & Messaging
- **NTF-001**: <notification_type>
Trigger: <condition>
Channel: <email/push/sms/webhook/queue>
Recipient: <who receives it>
Template/Content: <what is communicated>
[INFERRED: confidence] Source: <file:line>
### Cache Operations
- **CACHE-001**: <cache_operation>
Trigger: <when cache is read/written/invalidated>
Key pattern: <cache key structure>
TTL: <expiration>
Invalidation: <what causes cache invalidation>
[INFERRED: confidence] Source: <file:line>
When in MODULE-DEEP mode, follow this systematic approach for EVERY public and significant internal function:
Map each phase to the appropriate output section (FR, BR, DL, CV, SE, EVT, etc.).