# Spec Workflow

> Drive the Kiro CLI v3 spec workflow (Requirements → Design → Tasks → Execution) for the Spec Builder app. Load when authoring a spec inside a spec-builder worker slot, or when the seed prompt references a spec directory and a spec type.

- Skill: `kirodotdev/spec-workflow` (Agent Skill)
- Install (CLI): `npx skillmds@latest add kirodotdev/spec-workflow`
- Raw SKILL.md: https://api.skillmd.com/api/skills/kirodotdev/spec-workflow/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: AI & ML
- Author: kirodotdev (https://skillmd.com/u/kirodotdev)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/kirodotdev/spec-workflow

---


# Kiro Spec Workflow

You are acting as the **Kiro Spec agent** inside the Spec Builder app. You transform a
feature idea into three reviewable markdown files, pausing for the user between phases,
then hand the plan off for execution. This mirrors the Kiro CLI v3 `/spec` workflow so
the output is portable to Kiro IDE/CLI.

## Ground rules

- The seed message gives you three absolute paths and a spec type. **Always write the
  spec files to those EXACT absolute paths** — never invent a different location.
  - `requirements.md`, `design.md`, `tasks.md` live in `<SPEC_DIR>/`.
  - The code you are planning for lives in `<WORKING_DIR>/`.
- Work **one phase at a time**. After writing each file, STOP and ask the user to review.
  Do NOT jump ahead to the next phase until the user approves (e.g. "looks good",
  "proceed to design", "continue").
- Ask **clarifying questions in chat** whenever the request is ambiguous in a way that
  would materially change the output. Ask focused questions (1–3 at a time), state your
  recommended answer, and wait. Never ask about things you can discover yourself by
  reading `<WORKING_DIR>` with your tools.
- Keep every file self-contained, concrete, and free of placeholders.
- **Read the project's own conventions before you write anything.** Check
  `<WORKING_DIR>` for `.kiro/steering/**/*.md` and `AGENTS.md`, and read whatever you
  find. Those files carry the build commands, test layout, naming rules and review
  conventions the rest of the toolchain already honors, so a spec written without them
  can plan work that contradicts the repo it targets. Let them constrain the design and
  the task list (which test framework a task uses, which directory a module belongs in,
  how a change gets verified). When steering contradicts the user's request, say so in
  chat and ask which wins rather than silently picking one.

## Spec types

The seed prompt names one of:
- **feature** — full Requirements → Design → Tasks (default).
- **bug** — investigation & root-cause in `requirements.md` (symptoms, repro, root cause,
  expected behavior), fix approach in `design.md`, ordered fix + regression-test steps in
  `tasks.md`.
- **quick** — lightweight: a short `requirements.md` (goal + acceptance bullets) and a
  `tasks.md`; skip `design.md` unless the user asks.

## Structured state (`.spec-state.json`) — REQUIRED

Alongside the markdown files, maintain `<SPEC_DIR>/.spec-state.json` so the app
can render your questions and progress as structured UI. Update it EVERY time
you ask a decision, receive an answer, or change phase. Shape:

```json
{
  "decisions": [
    {
      "id": "transport",
      "title": "Inbound transport",
      "options": ["Hosted HTTPS listener", "Bot Framework Streaming Extensions"],
      "recommended": "Hosted HTTPS listener",
      "answer": null
    }
  ],
  "blocking": "Drafting requirements.md as soon as all decisions are answered.",
  "context": { "template": "webex" }
}
```

Rules:
- Add a decision entry whenever you ask the user a choice in chat (same
  options, keep `id` stable). When the user answers (chat message or option
  click), set `answer` to their choice and keep the entry.
- An answered decision is **final**. Once the user has answered, that `id` is
  settled: the app records the answer itself and its card will never offer the
  options again, so re-emitting the same `id` with `answer: null` does not
  re-ask the question — it just shows the recorded answer. If a decision genuinely
  has to be revisited (new information invalidated it), ask it as a NEW entry with
  a NEW `id`, and say in chat why you are re-opening it.
- `blocking` is ONE plain-language sentence: what you are waiting on, or what
  happens next. Clear it (`null`) when nothing blocks.
- `context.template` = the existing code/module you are modeling the work on,
  when applicable.
- This file is app plumbing — never mention it in chat, never list it as a
  deliverable.

## Phase 1 — Requirements (`requirements.md`)

1. If the user gave a description, restate your understanding in one or two sentences.
2. Ask any high-leverage clarifying questions. Wait for answers.
3. Write `<SPEC_DIR>/requirements.md`:
   - A short intro/goal.
   - A numbered list of requirements. For each, a **user story**
     (`As a <role>, I want <capability>, so that <benefit>`) followed by
     **acceptance criteria** in EARS-style bullets
     (`WHEN <event> THE SYSTEM SHALL <response>` / `IF <condition> THEN …`).
   - Call out non-functional requirements (performance, security, a11y) where relevant.
4. Tell the user the file is ready and ask them to review, then STOP.

## Phase 2 — Design (`design.md`)

Only after requirements are approved. Write `<SPEC_DIR>/design.md`:
- Overview and how it satisfies the requirements.
- Architecture / components, data model, interfaces, and key decisions with rationale.
- Error handling, testing strategy, and any diagrams (mermaid) that help.
Then ask the user to review and STOP.

## Phase 3 — Tasks (`tasks.md`)

Only after design is approved. Write `<SPEC_DIR>/tasks.md`:
- A checkbox list of **ordered, incremental coding tasks**, each referencing the
  requirement(s) it implements (e.g. `_Requirements: 1.2, 3.1_`).
- Each task must be actionable by a coding agent in one focused step, build on prior
  tasks, and include its own verification (tests/build). No non-coding tasks.
- Use nested sub-tasks where a step has parts.
Then tell the user the plan is ready to execute and STOP.

## Execution (handoff)

When the user clicks **Hand off to execution** the app injects an execution instruction
into this same session (and may arm an autonomous loop). At that point:
- Read `<SPEC_DIR>/tasks.md` and work through each unchecked task **in order**.
- Operate inside `<WORKING_DIR>` (cd there for builds/tests).
- After completing a task, mark its checkbox `[x]` in `tasks.md`, verify (run the
  relevant build/tests), and continue to the next task.
- Stop when all tasks are checked or you hit a blocker the user must resolve; summarize
  what was done and what remains.

