Refactor high-complexity React components in Dify frontend. Use when `pnpm analyze-component...
npx skills add Bosh-Kuo/awesome-agent-toolkit --skill "spec-writer"
Install specific skill from multi-skill repository
# Description
Generates feature specification documents based on provided code and functional descriptions. Focuses on system analysis and product logic rather than implementation details. Code is treated as the single source of truth.
# SKILL.md
name: spec-writer
description: "Generates feature specification documents based on provided code and functional descriptions. Focuses on system analysis and product logic rather than implementation details. Code is treated as the single source of truth."
You are an expert Software Engineer and System Analyst. Your goal is to write a Feature Specification Document (Spec) for a specific page or functionality.
Core Philosophy: Code as the Single Source of Truth
The most critical rule is that the code is the absolute truth. When writing a spec, you must:
1. Analyze Provided Code: Deeply trace the provided code (frontend components, hooks, backend controllers, services, etc.) to understand the actual behavior.
2. Contextual Reasoning: If certain logic is missing from the prompt's description but exists in the code, the code's implementation determines the spec.
3. Cross-Reference: Ensure that the functional description in the spec matches the actual logic implementation in the codebase.
Benchmarks for a Good Spec
- Conciseness: Keep it brief and focused. Avoid fluff.
- Functional Focus: Focus on what the system does and why, rather than the low-level how (technical implementation details like variable names or specific library calls should be omitted unless they define a business rule).
- Alignment: The document should be easily understood by PMs, Designers, Developers, and QA.
- Rules & Logic: Emphasize business rules, edge cases, and user flows.
- Readability: Use tables for rules, validation, and error mapping.
Writing Process & Guidelines
1. Identify the Project Type
Before writing, determine the project scope to select the appropriate sections from the template:
- Frontend-Only: Focus on UI/UX, interactions, states, and design system alignment. (Sections 1, 2, 3, 4, 6)
- Backend-Only: Focus on logic flow, data processing, and API contracts. (Sections 1, 2, 3, 5, 6)
- Full-stack: Include both UI interactions and API/System integration. (All Sections)
- Other (ML, CLI, etc.): Adapt as needed, focusing on data flow and logic rules.
2. Drafting the Spec
Use references/spec-template.md as the foundation. Maintain consistent section headers.
| Section | Importance | Notes |
|---|---|---|
| 1. Overview | Mandatory | Define the "Why" and "What". |
| 2. User/System Flow | Mandatory | Use Mermaid for complex logic. |
| 3. Functional Rules | Mandatory | Validation, limits, and edge cases. |
| 4. Interaction | Adaptive | Essential for Frontend. |
| 5. Integration/API | Adaptive | Essential for Backend/Full-stack. |
| 6. Error Handling | Mandatory | Map errors to user feedback. |
3. Execution Steps
- Read the Prompt: Understand the user's intent and identify the target feature.
- Trace the Code:
- Trace the provided code paths.
- Follow imports/calls to understand peripheral dependencies.
- Identify hidden business rules (e.g., a regex in a schema, a conditional return in a hook).
- Draft the Doc: Fill in the template based on your findings.
- Refine: Remove technical jargon that doesn't contribute to functional understanding.
File Naming & Location
Save all specifications in the docs/specs/ directory using the following naming convention:
{feature-or-page-name}-spec.md
Examples:
- user-login-spec.md
- dashboard-analytics-spec.md
- order-processing-spec.md
Reference Guide by Project Type
When generating a spec, refer primarily to the example that matches the type of feature you are writing about to maintain consistency in depth and focus:
| Project Type | Key Focus | Best Reference Example |
|---|---|---|
| Frontend-Only | Interaction, State, UI, Feedback | examples/theme-editor-frontend-spec.md |
| Backend-Only | API Contracts, Logic Flow, Jobs | examples/notification-service-backend-spec.md |
| Full-stack (Auth) | Auth flow, JWT, Multi-role logic | examples/login-spec.md |
| Full-stack (Data) | CRUD, Permissions, Lists | examples/account-management-spec.md |
- Use
examples/theme-editor-frontend-spec.mdfor tools, editors, or heavy interactive dashboards. - Use
examples/notification-service-backend-spec.mdfor microservices, background workers, or CLI tools. - Use
examples/login-spec.mdandaccount-management-spec.mdfor typical web applications with both UI and Data Persistence.
# Supported AI Coding Agents
This skill is compatible with the SKILL.md standard and works with all major AI coding agents:
Learn more about the SKILL.md standard and how to use these skills with your preferred AI coding agent.