State Management Skill
This skill provides techniques for managing workflow state through simplified, consolidated markdown files. The refactored structure uses just two file patterns: a single FLOW.md at project level and one ITEM-XXX.md per work item.
Core Principles
-
Minimal Footprint: Only two file patterns instead of 9+
-
Single Source of Truth: FLOW.md contains backlog + project context, ITEM-XXX.md contains everything about one item
-
Human Readable: All state in plain markdown, easy to edit
-
Checkpoint Recovery: State enables resumption from any interruption
-
Context Budget Awareness: Track and report context usage
Directory Structure
.flow/ ├── FLOW.md # Project state + backlog (single file) └── items/ ├── ITEM-001.md # All state for work item 001 ├── ITEM-002.md # All state for work item 002 └── ...
State Files Overview
File Purpose Contains
FLOW.md
Project-level state Vision, backlog, active item, capabilities cache
ITEM-XXX.md
Per-item state Phase, decisions, requirements, tasks, checkpoint
FLOW.md Structure
The single project file contains:
Sections
-
Vision: High-level project vision
-
Backlog: Table of all work items with status
-
Active Item: Currently active item pointer
-
Capabilities Cache: Discovered plugin mappings with timestamp
Template
See templates.md for the full FLOW.md template.
ITEM-XXX.md Structure
Each work item has a single consolidated file containing:
Sections
-
Header: Item ID, title, timestamps
-
Phase: Current phase and progress (DISCUSS/PLAN/EXECUTE/VERIFY)
-
Decisions: Numbered decisions with rationale
-
Requirements: Extracted functional/non-functional requirements
-
Tasks: XML-structured atomic tasks (when in EXECUTE)
-
Checkpoint: Current state snapshot for resume
Template
See templates.md for the full ITEM-XXX.md template.
Work Item States
Items progress through these phases:
Phase Description Next Phase
BACKLOG
Defined but not started DISCUSS
DISCUSS
Gathering requirements PLAN
PLAN
Creating task plan EXECUTE
EXECUTE
Implementing tasks VERIFY
VERIFY
Validating implementation DONE
DONE
Completed (terminal)
ON_HOLD
Paused intentionally Previous
BLOCKED
Waiting on dependency Previous
State Operations
Initialize Project
- Create .flow/ directory if not exists
- Create .flow/items/ directory
- Scan for installed plugins
- Detect project type from file patterns
- Create FLOW.md with empty backlog + capabilities
Create Work Item (/flow-workflow:start )
- Read FLOW.md to get next item number
- Generate ITEM-XXX ID
- Create .flow/items/ITEM-XXX.md with DISCUSS phase
- Update FLOW.md backlog table
- Set as active item in FLOW.md
Switch Active Item
- Update checkpoint in current item's file
- Update FLOW.md active item pointer
- Load new item's context
Phase Transition
- Verify completion criteria for current phase
- Update phase in ITEM-XXX.md
- Create checkpoint snapshot
- Initialize next phase section
Create Checkpoint
- Record current phase and task progress
- Capture context budget percentage
- List next recommended action
- Add timestamp
Resume from Checkpoint
- Read FLOW.md to get active item
- Read ITEM-XXX.md checkpoint section
- Restore context from checkpoint
- Identify next action
- Continue workflow
Context Budget Tracking
Track context usage in FLOW.md and report:
Context Monitor
- Current session: [X]% (limit: 50% before fresh agent)
- Last auto-spawn: [TIMESTAMP]
- Fresh agents this session: [N]
State Validation
Before any phase transition, validate:
-
Completeness: Required sections filled
-
Consistency: No contradictory decisions
-
Recoverability: Checkpoint exists for current progress
Best Practices
Writing State Updates
-
Use timestamps in ISO format
-
Include brief rationale for decisions
-
Mark status clearly (DONE, BLOCKED, etc.)
-
Keep checkpoint current
Reading State for Context
-
Load FLOW.md first for active item
-
Load ITEM-XXX.md for current phase details
-
Check checkpoint before proceeding
Handling Phase Transitions
-
Always create checkpoint before transition
-
Update both FLOW.md backlog and ITEM-XXX.md
-
Announce transition to user
Migration from Old Format
If legacy .flow/ structure detected (BACKLOG.md, ACTIVE.md, PROJECT.md, etc.):
-
Read existing state files
-
Consolidate into FLOW.md
-
Consolidate per-item files into ITEM-XXX.md
-
Backup old files to .flow/legacy/
-
Report migration complete
Integration Points
State management integrates with:
-
Capability Discovery: Cache plugin mappings in FLOW.md
-
Workflow Orchestration: Phase transitions and checkpoints
-
Smart Continuation: Resume from checkpoint via /flow-workflow:go
See templates.md for full file templates.