Install
openclaw skills install spec-stateflowStructured software engineering workflow with state-driven execution: requirement analysis → technical design → task planning → execution with state navigation and session recovery. Triggers: new feature, complex architecture, multi-module integration, database/UI design, or any task requiring structured planning and execution. Trigger words: new feature, architecture design, requirement implementation, spec workflow, state recovery, task tracking, 新功能, 复杂架构, 多模块, 需求实现, spec工作流, 状态恢复, 任务追踪
openclaw skills install spec-stateflowImportant: You must follow these rules. Each phase must be confirmed by the user before proceeding to the next phase.
Use this skill for structured development workflow when you need to:
Do NOT use for:
Fix vs Simple bug fix boundary: A "Fix" task (use Spec) involves cross-module impact, systematic tech debt, or requires design before coding. A "Simple bug fix" (no Spec) is a localized, obvious fix in ≤1 file with no architectural implications.
requirements.mddesign.mdtasks.mdtasks.md updates — After completing each small task, you MUST immediately update {SPEC_PATH}/tasks.md, before compilation, testing, or starting the next task. Not updated = not done. See Phase 4 State Assurance for detailsTesting: This skill includes test-prompts.json with 10 test scenarios covering all phases and edge cases. Use them to validate skill behavior.
All Spec files use the following placeholders. Actual paths are defined in the user's project configuration:
| Placeholder | Meaning |
|---|---|
{SPEC_DIR} | Spec file root directory |
{SPEC_NAME} | Current spec name |
{SPEC_PATH} | Full path = {SPEC_DIR}/{SPEC_NAME} |
Spec file list:
| File | Description |
|---|---|
{SPEC_PATH}/requirements.md | Requirements document (Phase 1 output) |
{SPEC_PATH}/design.md | Technical design document (Phase 2 output) |
{SPEC_PATH}/tasks.md | Task breakdown & progress tracker (Phase 3 output, single source of truth) |
| Your situation | Start here |
|---|---|
| New feature / complex task | Phase 1 (full workflow: Phase 1 → 2 → 3 → 4) |
| Ready to execute (user confirmed plan) | Phase 4 → Quick Start |
| User authorized continuous batch / driver-monitor automation | Phase 4 → Continuous Operation Mode |
| Session compressed / interrupted | Phase 4 → Compression Recovery |
| User says "updatecode" / "continue" / "resume" | Phase 4 → Quick Start (read tasks.md → locate breakpoint → continue) |
For all runtime states (error, context switch, task completion, etc.), see Phase 4 → State Navigation.
When you determine that the user's input implies a new requirement (not explicitly stated), you may work independently following standard software engineering practices. Confirm with the user when necessary.
When the user explicitly states a new requirement, you must follow the full workflow: understand the problem and requirements clearly, and confirm with the user before proceeding to the next phase.
First complete the requirements design using EARS (Easy Approach to Requirements Syntax) method. You must confirm requirement details with the user. After final confirmation, the requirements are finalized, then proceed to the next phase.
Save to {SPEC_PATH}/requirements.md. After confirming with the user, proceed to the next phase.
If user rejects or requests changes: Update requirements.md and re-confirm. Do NOT proceed to Phase 2 until user explicitly approves.
Reference format:
# Requirements Document
## Introduction
Requirement description
## Requirements
### Requirement 1 - Requirement Name
**User Story:** User story content
#### Acceptance Criteria
1. Use EARS syntax: While <optional precondition>, when <optional trigger>, the <system name> shall <system response>. For example: When "Mute" is selected, the laptop shall suppress all audio output.
2. ...
...
After completing the requirements design, based on the current technical architecture and the confirmed requirements above, design the technical solution. It should be concise but accurately describe the technical architecture (e.g., architecture, tech stack, technology selection, database/interface design, test strategy, security). Use mermaid diagrams when necessary.
Must include chapters: Background, Design Goals, Business Model, System Design (precise to package path, class name, method signature), Refactoring Design (if applicable), Deployment Plan (for large tasks), Risk Assessment (for large tasks).
Save to {SPEC_PATH}/design.md. You must confirm with the user clearly, then proceed to the next phase.
If user rejects or requests changes: Update design.md and re-confirm. Do NOT proceed to Phase 3 until user explicitly approves.
Reference format:
# Technical Solution Design
## Background
Why this design is needed — business context and problem statement
## Design Goals
- Goal 1: ...
- Goal 2: ...
## Business Model
Core domain models, entity relationships, key data flows
## System Design
### Architecture Overview
(mermaid diagram or component description)
### Module: {module-name}
- **Package:** `com.example.module`
- **New classes:**
- `ClassName` — responsibility description
- `InterfaceName` — method signatures: `ReturnType methodName(ParamType param)`
- **Modified classes:**
- `ExistingClass` — add method `newMethod()`, change field `field` scope
### API Design
| Endpoint | Method | Request | Response |
|----------|--------|---------|----------|
| `/api/xxx` | POST | `{field: type}` | `{field: type}` |
### Database Design
Table name, columns, indexes, migration steps
### Test Strategy
Unit test scope, integration test plan, verification methods
## Refactoring Design (if applicable)
What to refactor, why, and how to do it incrementally
## Deployment Plan (for large tasks)
Environments, rollout steps, rollback plan
## Risk Assessment (for large tasks)
| Risk | Probability | Impact | Mitigation |
|------|------------|--------|------------|
| ... | High/Med/Low | High/Med/Low | ... |
After completing the technical solution design, based on the requirements document and technical solution, break down specific tasks. You must confirm with the user clearly, then save to {SPEC_PATH}/tasks.md. After confirming with the user, proceed to the next phase.
If user rejects or requests changes: Adjust task breakdown and re-confirm. Do NOT proceed to Phase 4 until user explicitly approves.
Every task in {SPEC_PATH}/tasks.md must contain the following fields:
| Field | Specification | Example |
|---|---|---|
| Task name | Verb-object structure, ≤10 words | Remove unused methods from IMultiAppInfo |
| Scope | Files directly modified by this task | IMultiAppInfoProxyInterface.java, MultiAppInfoProxy.java |
| Affected | Files that need sync changes due to this task (imports, calls, etc.) | NoticeService.java, BpmService.java |
| Specifics | Most critical field. Precise down to method/field level | Interface remove methodA(), methodB(); add methodC(String) |
| Status | [✓] Done / [ ] Not started / [~] In progress or paused / [⏭] Skipped (user decision only; dependencies not auto-blocked, flag in final summary) | [✓] |
| Verification | How to verify (compile, test, grep, etc.) | grep signatures + compile verification |
| Commit | Backfill after git commit: actual commit message + short hash | feat(proxy): remove unused methods (a1b2c3d) |
| User corrections | Count of user corrections; ≥2 triggers escalation | 0 |
| Notes | Dependencies, blockers, scope changes | Depends on task 1 |
Critical field — Specifics: Must be precise down to method/field level. After session compression, recovery depends entirely on this field to reconstruct what was done and what remains.
Status values:
[ ] — Not started[~] — In progress[✓] — Done[⏭] — Skipped (only when user explicitly decides to skip; agent cannot self-skip; skipped tasks are excluded from execution — dependencies are not auto-blocked, but flag them in the final task summary)# Implementation Plan
- [✓] 1. Remove unused methods from IMultiAppInfo
- Scope: `IMultiAppInfoProxyInterface.java`, `MultiAppInfoProxy.java`
- Affected: `NoticeService.java`
- Specifics: Interface remove getCachedV2AppInfo(), listV1OfflineApps(); impl class sync
- Verification: grep signatures + compile verification
- Commit: feat(proxy): remove unused methods (a1b2c3d)
- User corrections: 0
- Notes: User requested keeping getV1AppInfo 3-param overload
- _Requirement: R1
- [ ] 2. Add getAppName method
- Scope: `IMultiAppInfoProxyInterface.java`, `MultiAppInfoProxy.java`
- Affected: —
- Specifics: Interface add getAppName(String); impl class add getAppName(String)
- Verification: —
- Commit: —
- User corrections: —
- Notes: Depends on task 1 completion
- _Requirement: R2
Execute tasks in order from {SPEC_PATH}/tasks.md. This phase covers execution mechanics, state navigation, and session recovery.
Validation: Before executing, confirm {SPEC_PATH}/tasks.md exists, contains valid task entries (Scope + Specifics + Verification fields), and all tasks have valid status markers ([ ] / [~] / [✓] / [⏭]). If the file is missing, malformed, or has tasks with missing/invalid status markers, stop and fix the format before proceeding.
First time with a confirmed tasks.md:
0. Validate tasks.md format — ensure every task has a valid status marker [ ]/[~]/[✓]/[⏭]. Fix any missing/invalid markers before proceeding.
1. Read {SPEC_PATH}/tasks.md → if any [~] task exists, continue it; otherwise find first [ ] task
2. Mark it [~] → execute per Specifics description
3. When done: mark [✓], fill Verification, stage changes
4. Show diff → wait for user review and explicit commit approval (**skipped in [Continuous Operation Mode](#continuous-operation-mode)**)
5. If user approves: commit → backfill Commit field with actual message + short hash → next task. If user rejects: revert status to [~], address feedback, repeat from step 2
6. User says "next" → repeat from step 1
Session compressed? Jump to Compression Recovery. Continuous batch authorized by the user (e.g. "you may continue implementing" / "complete the rest without asking"), or running under driver/monitor automation? Jump to Continuous Operation Mode.
Received user instruction
│
├─ Is the scope clear and small? ──→ YES → Do NOT use this skill, execute directly
│ NO
├─ Does it need design/architecture? → YES → Plan first → Write tasks.md → Execute
│ NO (unclear)
└─ Investigate → Reclassify
| Current State | What To Do Next | Key Output |
|---|---|---|
| Just received instruction | Classify task (simple / complex / fix / routine) → see Entry Points for entry decisions | Decision: plan or execute directly |
| Planning in progress (Phase 1-3) | Continue current phase → wait for user confirmation before next phase | Confirmed spec doc |
| Ready to implement | Read {SPEC_PATH}/tasks.md, mark first pending task as [~] | Task in progress |
| Just finished a task | Update tasks.md to [✓] → verify → commit → next task | Updated tracker |
| Hit an error | Stop → diagnose → fix → re-verify → wait for user confirmation → judge next step based on user's direction | Documented fix |
| Session interrupted / compressed | Jump to Compression Recovery | Recovered context |
| User asks unrelated question | Handle query → return to previous state, do NOT modify tracker | Continuity preserved |
| User starts a new feature mid-task | Pause current (mark [~]) → create new tracker → see Context Switching | New {SPEC_PATH} |
| User changes direction mid-task | Stop → document in Notes → wait for confirmation | Updated tracker |
| User corrects design assumption | Update tasks.md Notes and design.md → wait for confirmation | Synced docs |
| All tasks done | Generate final summary → wait for user confirmation → complete | See Task Completion |
When all tasks in tasks.md are [✓] or [⏭]:
requirements.md, design.md, tasks.md) are retained as project documentationThe State Navigation table is the primary reference. The flow diagram below illustrates the core state machine; all scenarios in the table are authoritative.
[Classified] --(simple/routine)--> [Direct Execution] --> [Done]
│
└─(complex/fix)--> [Planning] --(confirmed)--> [Executing] --(task done)--> [Update tracker] --(more tasks)--> [Executing]
│ └─(all done)--> [Complete]
└─(rejected)--> [Revise plan]
[Executing] --(error)--> [Diagnosing] --(fixed)--> [Update tracker] --> [Executing]
└─(stuck)--> [Ask user] --(user responds)--> [Judge next step based on user's direction]
[Complete] --(user confirms)--> [Done]
[Any state] --(unrelated user query)--> [Handle query] --> [Return to prior state]
[Any state] --(user changes direction)--> [Stop + document] --> [Wait for confirmation]
[Any state] --(user corrects design assumption)--> [Update tasks.md + design.md] --> [Wait for confirmation]
[Any state] --(session compressed/interrupted)--> [Recovery] --(tracker reconciled)--> [Resume prior state]
Scope note: The diagram above covers only tasks that enter the Spec workflow (Complex / Fix). Simple and Routine tasks are executed directly without entering this state machine.
Critical rule: You cannot transition from [Executing] to the next task without updating the tracker. Updating tasks.md is the definition of task completion.
Skips per-task show diff → wait approval. Auto-advances to next [ ] task. All other tracker disciplines remain mandatory.
you may continue implementing / complete the rest without asking)Ambiguous confirmations (OK / continue / okay) do NOT activate. Authorization does not survive session compression.
| Discipline | Status |
|---|---|
Mark [~] / [✓], fill Verification + Commit | ✅ Kept |
| Run verification (compile / test / grep) | ✅ Kept |
| Per-task independent commit | ✅ Kept |
| Increment User corrections on rejection | ✅ Kept |
| Show diff → wait approval | ❌ Skipped |
Wait for next between tasks | ❌ Auto-advance |
Reverts to Default Mode immediately on:
| Trigger | Action |
|---|---|
| Compilation / verification fails | Rollback to [~], record in Notes |
| User corrections ≥ 2 | Escalate per project config |
| Scope expansion | Record drift, wait for confirmation |
| Risky ops (force push, reset --hard, schema migration, etc.) | Stop and ask |
| User interrupts | Stop after current task's commit |
| All tasks complete | Switch to Task Completion |
| Session compression recovery | Revert to Default, re-confirm |
tasks.md){SPEC_PATH}/tasks.md is the primary state reference. If memory, conversation, and tracker disagree, pause and reconcile with the user — never silently override user intent.
Key reminders for execution:
[ ] Not started / [~] In progress (set before editing code) / [✓] Done (set before committing) / [⏭] Skipped (user decision only){SPEC_PATH}/tasks.md must be updated in real time — never retroactively:
| Event | Action | Why |
|---|---|---|
| Start a task | [ ] → [~] before editing code | Prevents duplicate work |
| Finish a task (before commit) | [~] → [✓], fill Verification immediately | Defines completion |
| Finish a task (after commit) | Backfill Commit field with actual message + short hash | Traceability |
| User changes scope | Record in Notes immediately, increment User corrections | Prevents drift |
| Session compresses | [~] → [ ] if uncertain about state | Prevents false progress |
Precedence: This takes precedence over compilation, testing, and starting the next task. A task whose tracker entry is not updated is considered NOT done.
Prohibited:
{SPEC_PATH}/tasks.md is the operational basis for recovery.
Trigger: System message "This session is being continued from a previous conversation" or when memory is fuzzy.
| Quick Step | Full Step Mapping |
|---|---|
| Read and confirm progress | Step 1 |
| Verify code state | Step 2-3 |
| Determine next step | Step 4-6 |
Step 1: Read Spec files, confirm {SPEC_PATH}/tasks.md progress
{SPEC_PATH}/requirements.md, {SPEC_PATH}/design.md, {SPEC_PATH}/tasks.mdtasks.md is the only trustworthy state source — summary progress descriptions are NOT reliablegit status and git diff, determine progress from working tree state, continue directlytasks.md is missing: Rebuild tasks.md from design.md, note in remarks "table rebuilt after compression recovery"Step 2: Verify actual code state
git status and git diff to confirm working tree state[✓] rows in tasks.md (no tasks completed yet): first [ ] or [~] row is the next task, skip the rest of this step and all of Step 3 → go to Step 4[✓] rows exist: Only verify the last [✓] row (state boundary), re-execute verification per "Scope + Specifics + Verification" fields[✓]; if fails → change that task status to [ ], consider backtrackingtasks.md doesn't match actual state, fix tasks.md first, then continueStep 3: Do not trust summary "completed" conclusions
[ ], consider backtrackingStep 4: Re-confirm next task
Step 5: Use programmatic verification, not manual reading
Step 6: Update tasks.md before executing
{SPEC_PATH}/tasks.md firsttasks.md is consistent with actual state| Scenario | Rule |
|---|---|
| User starts a new feature | Pause current task (mark [~]), create new tracker for new work |
| User raises multiple parallel requests | Confirm priority and order with user; create separate Spec directories (different {SPEC_NAME}) for each; execute sequentially, never mix tasks.md |
Key principle: One tasks.md per requirement. Different requirements must have different {SPEC_PATH}.
Do not abandon unfinished tasks. Unless user explicitly says "cancel" or "skip", mark unfinished tasks as [~] and record progress.
When returning to a previous task, re-verify state. Verify the last [✓] row per Step 2 of Compression Recovery.
{SPEC_PATH}/tasks.md is the definition of task completion; it takes precedence over all other operations