Get the FREE Ultimate OpenClaw Setup Guide →

spec-writer

Scanned
npx machina-cli add skill Bosh-Kuo/awesome-agent-toolkit/spec-writer --openclaw
Files (1)
SKILL.md
4.8 KB

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.

SectionImportanceNotes
1. OverviewMandatoryDefine the "Why" and "What".
2. User/System FlowMandatoryUse Mermaid for complex logic.
3. Functional RulesMandatoryValidation, limits, and edge cases.
4. InteractionAdaptiveEssential for Frontend.
5. Integration/APIAdaptiveEssential for Backend/Full-stack.
6. Error HandlingMandatoryMap errors to user feedback.

3. Execution Steps

  1. Read the Prompt: Understand the user's intent and identify the target feature.
  2. 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).
  3. Draft the Doc: Fill in the template based on your findings.
  4. 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 TypeKey FocusBest Reference Example
Frontend-OnlyInteraction, State, UI, Feedbackexamples/theme-editor-frontend-spec.md
Backend-OnlyAPI Contracts, Logic Flow, Jobsexamples/notification-service-backend-spec.md
Full-stack (Auth)Auth flow, JWT, Multi-role logicexamples/login-spec.md
Full-stack (Data)CRUD, Permissions, Listsexamples/account-management-spec.md
  • Use examples/theme-editor-frontend-spec.md for tools, editors, or heavy interactive dashboards.
  • Use examples/notification-service-backend-spec.md for microservices, background workers, or CLI tools.
  • Use examples/login-spec.md and account-management-spec.md for typical web applications with both UI and Data Persistence.

Source

git clone https://github.com/Bosh-Kuo/awesome-agent-toolkit/blob/main/skills/spec-writer/SKILL.mdView on GitHub

Overview

Spec-writer generates a concise Feature Specification Document by analyzing the provided code and functional descriptions. It treats code as the single source of truth, tracing behavior, rules, and data flows to produce a spec aligned with PM, design, and QA needs.

How This Skill Works

It deeply traces code paths, imports, and service calls to uncover actual behavior. It cross-references this with the stated functional description and outputs a structured document using the project's template, highlighting business rules, edge cases, and user flows while omitting low-level implementation details.

When to Use It

  • When you need a spec anchored in code for a new feature.
  • When there are missing details in the narrative but code implements them.
  • For frontend UI flows that must align with backend behavior.
  • For API contracts and data processing logic in full-stack features.
  • For handoff to PM/QA or during code refactors to update specifications.

Quick Start

  1. Step 1: Gather the feature name, code references, and functional description.
  2. Step 2: Run or invoke spec-writer to generate a draft spec using the code as truth.
  3. Step 3: Review the draft with PM/QA, adjust requirements or edge cases, and finalize.

Best Practices

  • Start with the code as the truth and extract business rules directly from code paths.
  • Use the prescribed template sections (Overview, User/System Flow, Functional Rules, Interaction, Integration/API, Error Handling).
  • Capture edge cases, error mappings, and validation rules in a clear table.
  • Keep language concise and aligned with stakeholder needs (PM/Design/QA).
  • Cross-check the draft spec against the codebase to ensure traceability and accuracy.

Example Use Cases

  • Spec for a login feature derived from the authentication module, capturing success/failure flows and security checks.
  • Spec for an order processing workflow from backend services, detailing state transitions and error states.
  • Spec for a feature-flag gated flow, outlining when and how UI and API behavior change.
  • Spec for a dashboard data fetch page, defining data sources, caching rules, and rendering expectations.
  • Spec for a file upload component with validation, size limits, and virus-scan integration.

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers