Spec Kit Baseline Skill
When to Use
- You need a spec for existing or legacy code.
- You want to document a feature before refactoring.
- You inherited a codebase without written requirements.
Inputs
- A target path, file list, or glob pattern describing the code to analyze.
- Repo context with
.specify/ scripts and templates.
If the target is missing or ambiguous, ask a focused question before continuing.
Goal
Generate a technology-agnostic spec for existing code, then create the feature branch/spec file using the standard Spec Kit templates.
Workflow
Parse target input: Identify files, directories, or patterns to analyze.
- Accept file paths, glob patterns, or directory paths.
- If empty: stop and ask for a concrete target.
Discover and read source files:
- Expand globs to a file list.
- Read file contents for analysis.
- Identify primary language(s) and frameworks.
- Map key file relationships and dependencies.
Analyze code structure:
- Identify entry points and public interfaces.
- Extract function/method signatures and behaviors.
- Find data models and entities.
- Detect API endpoints and routes.
- Identify user-facing functionality.
Generate a short name (2-4 words) from the analyzed code:
- Use action-noun format (e.g., "user-auth", "payment-processing").
- Base on primary functionality discovered.
- Preserve technical terms where meaningful.
Create the feature branch and spec file:
- Find the highest existing feature number for this short name (branches/specs).
- Run
.specify/scripts/bash/create-new-feature.sh --json with the calculated number and short name.
- Read BRANCH_NAME, FEATURE_DIR, and SPEC_FILE paths from the script JSON output.
- For single quotes in args like "I'm Groot", use escape syntax: e.g 'I'''m Groot' (or double-quote if possible: "I'm Groot").
Load the spec template from .specify/templates/spec-template.md.
Draft the specification using the template structure:
- User Stories: Infer from user-facing code paths and interactions.
- Acceptance Scenarios: Derive from validation logic, error handling, and tests.
- Functional Requirements: Extract from business rules and constraints.
- Key Entities: Identify from data models and schemas.
- Success Criteria: Infer from metrics, logging, or performance-related code.
- Assumptions: Document inferences made during analysis.
Abstract implementation details:
- Convert technical patterns to user-focused requirements.
- Remove framework-specific terminology.
- Focus on WHAT the code does, not HOW it does it.
Create spec quality checklist at FEATURE_DIR/checklists/requirements.md.
Report completion with:
- Branch name and spec file path.
- Summary of analyzed files.
- Key features discovered.
- Areas needing clarification or review.
Outputs
specs/<feature>/spec.md
specs/<feature>/checklists/requirements.md
Key rules
- Focus on extracting WHAT and WHY from HOW.
- Abstract away implementation details in the generated spec.
- Document assumptions made during code analysis.
- Flag areas where code behavior is unclear.
- Preserve discovered business rules and constraints.
- Use
[NEEDS CLARIFICATION] for ambiguous code sections (max 3).
- Generated specs should be validated by someone who knows the feature.
Examples
Code Pattern → Spec Requirement:
if (user.role === 'admin') → "System MUST restrict action to administrator users"
password.length >= 8 → "Passwords MUST be at least 8 characters"
cache.set(key, value, 3600) → "System MUST cache results for improved performance"
try { ... } catch (e) { notify(e) } → "System MUST notify users when errors occur"
Code Pattern → User Story:
- Login endpoint with OAuth → "As a user, I can sign in using my social account"
- Shopping cart logic → "As a customer, I can add items to my cart for later purchase"
- Report generation → "As an analyst, I can generate reports on system activity"
Next Steps
After generating spec.md:
- Clarify with domain experts using speckit-clarify.
- Plan modernization/refactoring with speckit-plan.
- Compare the generated spec with actual requirements to identify gaps.
国内适配
- 支持中文文档和中文注释
- 示例代码兼容国内开发环境
- 提供中文 FAQ 和常见问题解答
能力边界
✅ 适用场景
- 当你需要使用此技能对应的技术栈时
- 当项目需要遵循最佳实践时
- 当需要快速上手或深入理解核心概念时
⚠️ 需要注意
- 复杂业务逻辑需要结合具体场景调整
- 性能优化需要根据实际数据量评估
❌ 不适用场景
使用流程
Step 1: 环境准备
确保开发环境已安装必要的依赖和工具。
Step 2: 配置初始化
根据项目需求进行基础配置。
Step 3: 核心功能使用
按照示例代码实现核心功能。
Step 4: 测试验证
运行测试确保功能正常。
Step 5: 部署上线
完成开发后进行部署和监控。
1---2name: speckit-baseline3description: Generate feature specifications by analyzing existing source code.4---56# Spec Kit Baseline Skill78## When to Use910- You need a spec for existing or legacy code.11- You want to document a feature before refactoring.12- You inherited a codebase without written requirements.1314## Inputs1516- A target path, file list, or glob pattern describing the code to analyze.17- Repo context with `.specify/` scripts and templates.1819If the target is missing or ambiguous, ask a focused question before continuing.2021## Goal2223Generate a technology-agnostic spec for existing code, then create the feature branch/spec file using the standard Spec Kit templates.2425## Workflow26271. **Parse target input**: Identify files, directories, or patterns to analyze.28 - Accept file paths, glob patterns, or directory paths.29 - If empty: stop and ask for a concrete target.30312. **Discover and read source files**:32 - Expand globs to a file list.33 - Read file contents for analysis.34 - Identify primary language(s) and frameworks.35 - Map key file relationships and dependencies.36373. **Analyze code structure**:38 - Identify entry points and public interfaces.39 - Extract function/method signatures and behaviors.40 - Find data models and entities.41 - Detect API endpoints and routes.42 - Identify user-facing functionality.43444. **Generate a short name** (2-4 words) from the analyzed code:45 - Use action-noun format (e.g., "user-auth", "payment-processing").46 - Base on primary functionality discovered.47 - Preserve technical terms where meaningful.48495. **Create the feature branch and spec file**:50 - Find the highest existing feature number for this short name (branches/specs).51 - Run `.specify/scripts/bash/create-new-feature.sh --json` with the calculated number and short name.52 - Read BRANCH_NAME, FEATURE_DIR, and SPEC_FILE paths from the script JSON output.53 - For single quotes in args like "I'm Groot", use escape syntax: e.g 'I'''m Groot' (or double-quote if possible: "I'm Groot").54556. **Load the spec template** from `.specify/templates/spec-template.md`.56577. **Draft the specification** using the template structure:58 - **User Stories**: Infer from user-facing code paths and interactions.59 - **Acceptance Scenarios**: Derive from validation logic, error handling, and tests.60 - **Functional Requirements**: Extract from business rules and constraints.61 - **Key Entities**: Identify from data models and schemas.62 - **Success Criteria**: Infer from metrics, logging, or performance-related code.63 - **Assumptions**: Document inferences made during analysis.64658. **Abstract implementation details**:66 - Convert technical patterns to user-focused requirements.67 - Remove framework-specific terminology.68 - Focus on WHAT the code does, not HOW it does it.69709. **Create spec quality checklist** at `FEATURE_DIR/checklists/requirements.md`.717210. **Report completion** with:73 - Branch name and spec file path.74 - Summary of analyzed files.75 - Key features discovered.76 - Areas needing clarification or review.7778## Outputs7980- `specs/<feature>/spec.md`81- `specs/<feature>/checklists/requirements.md`8283## Key rules8485- Focus on extracting WHAT and WHY from HOW.86- Abstract away implementation details in the generated spec.87- Document assumptions made during code analysis.88- Flag areas where code behavior is unclear.89- Preserve discovered business rules and constraints.90- Use `[NEEDS CLARIFICATION]` for ambiguous code sections (max 3).91- Generated specs should be validated by someone who knows the feature.9293## Examples9495**Code Pattern → Spec Requirement**:9697- `if (user.role === 'admin')` → "System MUST restrict action to administrator users"98- `password.length >= 8` → "Passwords MUST be at least 8 characters"99- `cache.set(key, value, 3600)` → "System MUST cache results for improved performance"100- `try { ... } catch (e) { notify(e) }` → "System MUST notify users when errors occur"101102**Code Pattern → User Story**:103104- Login endpoint with OAuth → "As a user, I can sign in using my social account"105- Shopping cart logic → "As a customer, I can add items to my cart for later purchase"106- Report generation → "As an analyst, I can generate reports on system activity"107108## Next Steps109110After generating spec.md:111112- **Clarify** with domain experts using speckit-clarify.113- **Plan** modernization/refactoring with speckit-plan.114- **Compare** the generated spec with actual requirements to identify gaps.115116## 国内适配117118- 支持中文文档和中文注释119- 示例代码兼容国内开发环境120- 提供中文 FAQ 和常见问题解答121122## 能力边界123124### ✅ 适用场景125- 当你需要使用此技能对应的技术栈时126- 当项目需要遵循最佳实践时127- 当需要快速上手或深入理解核心概念时128129### ⚠️ 需要注意130- 复杂业务逻辑需要结合具体场景调整131- 性能优化需要根据实际数据量评估132133### ❌ 不适用场景134- 不相关的技术栈或框架135- 需要完全自定义的特殊场景136137## 使用流程138139### Step 1: 环境准备140确保开发环境已安装必要的依赖和工具。141142### Step 2: 配置初始化143根据项目需求进行基础配置。144145### Step 3: 核心功能使用146按照示例代码实现核心功能。147148### Step 4: 测试验证149运行测试确保功能正常。150151### Step 5: 部署上线152完成开发后进行部署和监控。