Loading...
Loading...
Reverse-engineer a SPEC document from an existing project. Analyzes code, config, tests, and structure to produce a comprehensive specification. Triggers on: code-to-spec, reverse spec, generate spec, 逆向规格, 生成规格文档, 生成设计文档, 生成设计方案, extract spec, document this project, what does this project do.
npx skill4agent add smallnest/goal-workflow code-to-specWhat should I analyze?
A. Entire repository (recommended for small-medium projects)
B. Specific directory or module: [path]
C. Specific aspect only (e.g., API surface, data model, auth flow)
Depth level:
1. Overview — high-level architecture + tech stack + key features (fast, ~5 min)
2. Standard — includes API contracts, data models, config, dependencies (default)
3. Deep — adds internal module interactions, error handling patterns, test coverage analysispackage.jsongo.modCargo.tomlpyproject.tomlpom.xml# SPEC: [Project Name]
> Reverse-engineered specification — generated [date] from commit [short-hash]
## 1. Overview
### 1.1 Purpose
[One paragraph: what problem this project solves and for whom]
### 1.2 Key Capabilities
- [Bullet list of what the system can do, from a user's perspective]
### 1.3 Architecture Style
[e.g., "Monolithic Express.js API with React SPA frontend", "CLI tool with plugin system", "Microservices communicating over gRPC"]
---
## 2. Tech Stack
| Layer | Technology | Version |
|-------|-----------|---------|
| Language | ... | ... |
| Framework | ... | ... |
| Database | ... | ... |
| Build | ... | ... |
| Test | ... | ... |
| Deploy | ... | ... |
---
## 3. Project Structure
[Directory tree with annotations explaining each top-level directory's purpose]
---
## 4. Data Model
### 4.1 Core Entities
[For each entity: name, fields, relationships, constraints]
### 4.2 State Transitions
[If applicable: lifecycle states and valid transitions]
---
## 5. API Surface
### 5.1 [Interface Type: REST / CLI / Library / etc.]
[For each endpoint/command/function:]
| Method | Path/Command | Description | Auth |
|--------|-------------|-------------|------|
| ... | ... | ... | ... |
### 5.2 Request/Response Schemas
[Key request/response shapes with field types]
---
## 6. Configuration
| Variable / Key | Required | Default | Description |
|---------------|----------|---------|-------------|
| ... | ... | ... | ... |
---
## 7. External Dependencies
| Service | Purpose | Failure Impact |
|---------|---------|----------------|
| ... | ... | ... |
---
## 8. Business Rules & Constraints
- [Numbered list of invariants, validation rules, and business logic constraints discovered in the code]
---
## 9. Non-Functional Characteristics
### 9.1 Performance
[Observed patterns: caching, pagination, batch processing, etc.]
### 9.2 Security
[Auth mechanism, input validation patterns, secrets management]
### 9.3 Error Handling
[Error strategy: custom error types, error codes, retry policies]
---
## 10. Testing Strategy
| Type | Framework | Coverage Pattern |
|------|-----------|-----------------|
| Unit | ... | ... |
| Integration | ... | ... |
| E2E | ... | ... |
---
## 11. Known Gaps & Assumptions
- [Things that are unclear from the code alone]
- [Assumptions made during analysis]
- [Areas with no tests or documentation]
---
## 12. Appendix
### A. Dependency Graph
[Key module dependencies, import relationships]
### B. Environment Setup
[Steps to run the project locally, derived from config and scripts]SPEC generated. Please review:
- Are there sections that need more detail?
- Are there inaccuracies I should correct?
- Should I add/remove any sections?
- Is the depth level appropriate?
Reply OK to save, or provide feedback for iteration.Where should I save the SPEC?
A. docs/SPEC.md (recommended)
B. SPEC.md (project root)
C. Custom path: [specify]importrequirecontrollersservicesmodelsrouteshandlersdomaininfraapp.get()@app.get()mux.HandleFunc()| Scenario | Handling |
|---|---|
| Project has no README or documentation | Note this in "Known Gaps"; infer purpose from code |
| Monorepo with multiple services | Ask user which service(s) to analyze; produce one SPEC per service or a unified SPEC with clear boundaries |
| Project uses code generation | Document the generated code's purpose but focus on the source of truth (schemas, proto files, templates) |
| Legacy project with mixed patterns | Document all observed patterns, note inconsistencies in "Known Gaps" |
| Project is a library (no runtime) | Focus on exported API surface, type contracts, and usage patterns from tests |
| Incomplete or broken code | Document what exists, mark broken/incomplete areas explicitly |
| Project >1000 files | Start with entry points and trace key flows; don't exhaustively read every file |
| Multiple languages in one repo | Document each language's role and how they interact |