Agent skill
designing-workflows
Use when designing systems with explicit states, transitions, or multi-step flows. Triggers: "design a workflow", "state machine", "approval flow", "pipeline stages", "what states does X have", "how does X transition", or when implementing-features Phase 2.1 detects workflow patterns.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/designing-workflows
SKILL.md
Workflow Design
Reasoning Schema
Before designing: What are the business states? What events trigger transitions? What invariants? What can fail?
After designing: Is every state reachable? Can every state exit? Are guards mutually exclusive? Are error states recoverable?
Invariant Principles
- States Are Business Concepts: "ProcessingPayment" not "step3".
- Transitions Are Events: Every arrow needs a named trigger.
- Guards Prevent Ambiguity: Mutually exclusive and exhaustive.
- Error States Are First-Class: Every state needs an error path.
- Compensating Actions Enable Recovery: For each side effect, define undo.
- Invariants Are Explicit: Violations are bugs, not edge cases.
- Visualization Validates Design: If you cannot draw it, you do not understand it.
Inputs / Outputs
| Input | Required | Description |
|---|---|---|
process_description |
Yes | Natural language description of the workflow |
domain_context |
No | Business rules, constraints, existing systems |
| Output | Type | Description |
|---|---|---|
state_machine_spec |
File | At ~/.local/spellbook/docs/<project>/plans/ |
mermaid_diagram |
Inline | State diagram for validation |
transition_table |
Inline | Tabular representation |
State Machine Components
| State Type | Purpose | Example |
|---|---|---|
| Initial | Entry point (exactly one) | Draft, New |
| Intermediate | Processing stages | UnderReview |
| Terminal | Happy/failure completion | Approved, Rejected |
| Error | Recoverable, can retry | Failed, Suspended |
Transitions: Source --trigger[guard]/action--> Target
Guards: Must be mutually exclusive when sharing triggers. No implicit else.
Design Process
- State Identification: List status nouns, classify types, name with domain vocabulary
- Transition Mapping: For each state, what events cause exit?
- Guard Design: Ensure mutual exclusivity, explicit exhaustiveness
- Error Handling: Every state needs failure path with retry/escalate/terminate
- Validation: Reachable, no dead ends, deterministic
Visualization
stateDiagram-v2
[*] --> Draft
Draft --> UnderReview: submit [isValid]
Draft --> Draft: submit [!isValid]
UnderReview --> Approved: approve
UnderReview --> Rejected: reject
Approved --> [*]
Rejected --> [*]
Workflow Patterns
Saga Pattern: Side effects + compensating actions in reverse order on failure.
Step 1: reserveInventory() | Compensate: releaseInventory()
Step 2: chargePayment() | Compensate: refundPayment()
On failure at N: Execute compensations N-1 through 1
Token-Based Enforcement: Tokens validate allowed transitions, prevent stage skipping.
Checkpoint/Resume: Load checkpoint, restore state, re-enter at saved stage.
Example
- States: Draft (initial), UnderReview (intermediate), Approved/Rejected (terminal), ReviewFailed (error)
- Transitions:
- Draft --submit[valid]--> UnderReview
- UnderReview --approve[hasAuthority]--> Approved
- UnderReview --reject--> Rejected
- UnderReview --error[retryable]--> ReviewFailed
- ReviewFailed --retry[count<3]--> UnderReview
- Validation: All states reachable, no dead ends, guards exclusive
- Output: Mermaid diagram + transition table
Self-Check
- States use business domain vocabulary
- Every transition has named trigger
- Guards mutually exclusive and exhaustive
- Every non-terminal state has exit
- Error states with retry/escalate paths
- Side effects have compensating actions
- Mermaid diagram renders correctly
- Completeness validated
If ANY unchecked: revise before completing.
<FINAL_EMPHASIS> Workflows are contracts. Every state is a promise. Every transition is a fulfillment. Every guard is a condition. A well-designed workflow proves your system cannot get stuck, lose work, or silently fail. The mermaid diagram IS the design. </FINAL_EMPHASIS>
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?