---
description: "Transform a rough feature idea into a structured engineering spec: Requirements → Design → Tasks. Produces a SPEC.md ready for team handoff."
alwaysApply: true
---

# Feature Spec Writer

> **Purpose:** Transform a rough feature idea into a structured implementation spec using the Kiro-style Requirements → Design → Tasks breakdown. Produces a `SPEC.md` document ready for engineering handoff — no more half-baked tickets.

---

## Invocation

```
/spec <feature-idea>
```

**Example:** `/spec Add OAuth login with GitHub and Google`

---

## Process

### Phase 1: Requirements Analysis

Formalize requirements from the raw feature description.

**Functional Requirements (what it MUST do)**
- Extract concrete behaviors the feature must support
- Write in user story format: "As a [user], I can [action] so that [outcome]"
- Assign IDs: FR-1, FR-2, ...

**Non-Functional Requirements**
- Performance targets (latency, throughput, data volume)
- Security constraints (auth model, data handling, compliance)
- Accessibility (WCAG 2.1 AA minimum)
- Browser / platform / device targets

**Out of Scope**
- Explicitly list what this spec does NOT cover — prevents scope creep

---

### Phase 2: Technical Design

**Architecture Overview**
- Which layers are touched: frontend, API, database, third-party services
- New components vs modified existing components
- Data flow (text-based ASCII diagram if helpful)

**Data Model Changes**
- New tables, columns, or indexes
- Migration strategy and rollback plan

**API Changes**
- New or modified endpoints with request/response shapes
- Auth requirement per endpoint (public / authenticated / admin)

**UI/UX Changes**
- Pages and components affected
- New routes if applicable
- State management implications

---

### Phase 3: Task Breakdown

Produce a numbered task checklist in implementation order:

```
TASKS
[ ] 1. Database: Create migration for [table/column]
[ ] 2. API: Add POST /[resource] with [auth requirement]
[ ] 3. Frontend: Build [Component] in [location]
[ ] 4. Tests: Unit tests for [function/route]
[ ] 5. Tests: E2E test for [user flow]
[ ] 6. Docs: Update [doc] with new behavior
[ ] 7. Deploy: Feature flag rollout or straight deploy
```

Each task must be completable in ≤ 4 hours. Break down anything larger.

---

## Output Format

Produce a `SPEC.md` file with this structure:

```markdown
# [Feature Name] — Engineering Spec

**Status:** Draft
**Author:** @[username]
**Date:** [today]
**Estimated effort:** [X days / Y tasks]

---

## Requirements

### Functional
[FR-1 through FR-N as user stories]

### Non-Functional
[Performance, security, accessibility]

### Out of Scope
[Explicit exclusions]

---

## Design

### Architecture
[Overview + data flow]

### Data Model
[Schema changes + migration plan]

### API
[Endpoints + auth]

### UI/UX
[Component changes + routes]

---

## Tasks

[Numbered, ordered checklist]

---

## Open Questions

[Unresolved decisions — list even if none to show they were considered]

---

## Security Checklist

- [ ] Auth required on all mutation endpoints
- [ ] Input validation on all user-supplied fields
- [ ] No PII in logs or error messages
- [ ] Rate limiting on high-frequency endpoints
```

---

## Rules

- Requirements must be testable — if you cannot write a test for it, rewrite it
- Every API change must state its auth requirement explicitly
- Tasks must be ordered by dependency (no task references a later task)
- Flag all unresolved decisions as Open Questions — never silently assume
- If the feature touches auth, payments, or data deletion: add an explicit Security Checklist section
- Estimate effort in tasks, not hours — estimates in hours are always wrong

## Playground

<!DOCTYPE html><html><head><meta charset='utf-8'><style>*{box-sizing:border-box;margin:0;padding:0}body{background:#0d1117;color:#e6edf3;font-family:monospace;font-size:12px;height:100vh;display:flex;flex-direction:column;overflow:hidden}.header{background:#161b22;border-bottom:1px solid #30363d;padding:8px 14px;font-size:11px;color:#8b949e;display:flex;justify-content:space-between;align-items:center;flex-shrink:0}.title{color:#58a6ff;font-weight:bold;font-size:13px}.panels{display:flex;flex:1;overflow:hidden}.panel{flex:1;overflow:auto;padding:12px;border-right:1px solid #30363d}.panel:last-child{border-right:none}.label{font-size:10px;color:#8b949e;text-transform:uppercase;letter-spacing:.08em;margin-bottom:6px}pre{white-space:pre-wrap;word-break:break-word;line-height:1.5}</style></head><body><div class='header'><span class='title'>Feature Spec Writer</span><span>Example · SkillSlap</span></div><div class='panels'><div class='panel'><div class='label'>Input: Feature request</div><pre><span style='color:#8b949e'>Feature: Users should be able to</span>
<span style='color:#8b949e'>export their skill collection as</span>
<span style='color:#8b949e'>a ZIP file containing all their</span>
<span style='color:#8b949e'>SKILL.md files, one per folder.</span></pre></div><div class='panel'><div class='label'>Output: Feature spec</div><pre><span style='color:#58a6ff'>## Feature: Skill Collection Export</span>

<span style='color:#58a6ff'>User story</span>
<span style='color:#8b949e'>As a skill author, I want to download</span>
<span style='color:#8b949e'>all my skills as a ZIP so I can back</span>
<span style='color:#8b949e'>them up or use them offline.</span>

<span style='color:#58a6ff'>Acceptance criteria</span>
<span style='color:#8b949e'>- [ ] GET /api/users/me/export returns</span>
<span style='color:#8b949e'>      a ZIP with Content-Disposition</span>
<span style='color:#8b949e'>- [ ] ZIP contains one folder per skill</span>
<span style='color:#8b949e'>      named by skill slug</span>
<span style='color:#8b949e'>- [ ] Each folder contains SKILL.md</span>
<span style='color:#8b949e'>- [ ] Max 500 skills per export</span>

<span style='color:#58a6ff'>Out of scope</span>
<span style='color:#8b949e'>- Importing from ZIP (separate ticket)</span>
<span style='color:#8b949e'>- Including demo media files</span></pre></div></div></body></html>