designing-workflows
Skill11 starsChanged 3 months agoMITView on GitHub
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'. Also invoked by develop when workflow patterns are detected.
We split this skill into the rules it gives an agent
8 rules. About 0 are common, 7 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈7
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 21
Transitions Are Events: Every arrow needs a named trigger
- Distinctive: line 23
Error States Are First-Class: Every state needs an error path
- Distinctive: line 26
Visualization Validates Design: If you cannot draw it, you do not understand it
- Distinctive: line 52
Guards: Must be mutually exclusive when sharing triggers.
- Distinctive: line 58
Guard Design: Ensure mutual exclusivity, explicit exhaustiveness
- Very specific: line 59
Error Handling: Every state needs failure path with retry/escalate/terminate
- Distinctive: line 100
Validation: All states reachable, no dead ends, guards exclusive
- Distinctive: line 126
If ANY unchecked: revise before completing.
≈ “Common” is an estimate: at least 1 in 5 of the 308,232 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Workflow Design
<ROLE>
Workflow Architect with formal methods background. Your reputation depends on state machines that are complete (no dead ends), deterministic (unambiguous transitions), and recoverable (graceful error handling). A workflow that hangs or silently fails is a professional failure.
</ROLE><analysis>Before designing: What are the business states? What events trigger transitions? What invariants? What can fail?</analysis>
<reflection>After designing: Is every state reachable? Can every state exit? Are guards mutually exclusive? Are error states recoverable?</reflection>
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 1Token-Based Enforcement: Tokens validate allowed transitions, prevent stage skipping.
Checkpoint/Resume: Load checkpoint, restore state, re-enter at saved stage.
Example
<example>
Design: Order approval workflow- 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
</example>
<FORBIDDEN>
- States named after implementation ("step1")
- Transitions without named triggers
- Overlapping guards (ambiguous transitions)
- Missing error handling (only happy path)
- Side effects without compensating actions
- Dead-end states not marked terminal
- Implicit guards ("else" without condition)
- Skipping completeness validation
</FORBIDDEN>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>
In this repository65 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- documentation-updatesSkill
- spellbook-auditingSkill
- advanced-code-reviewSkill
- adversarial-reviewSkill
- agent2agentSkill
- analyzing-domainsSkill
- analyzing-skill-usageSkill
- assembling-contextSkill
- async-await-patternsSkill
- auditing-green-mirageSkill
- autonomous-modeSkill
- branch-contextSkill
- code-reviewSkill
- creating-issues-and-pull-requestsSkill
- debuggingSkill
- dedupeSkill
- deep-researchSkill
- dehallucinationSkill
- design-explorationSkill
- developSkill
- devils-advocateSkill
- dispatching-parallel-agentsSkill
- distilling-prsSkill
- documenting-projectsSkill
- documenting-toolsSkill
- emotional-stakesSkill
- enforcing-code-qualitySkill
- estimating-ticketsSkill
- executing-plansSkill
- fact-checkingSkill
- finding-dead-codeSkill
- finishing-a-development-branchSkill
- fixing-testsSkill
- fractal-thinkingSkill
- gathering-requirementsSkill
- generating-diagramsSkill
- instruction-engineeringSkill
- isolated-testingSkill
- managing-artifactsSkill
- merging-worktreesSkill
- opportunity-awarenessSkill
- optimizing-instructionsSkill
- polish-repoSkill
- reflexionSkill
- requesting-code-reviewSkill
- resolving-merge-conflictsSkill
- reviewing-design-docsSkill
- reviewing-impl-plansSkill
- reviewing-prsSkill
- rounding-up-worktree-sessionsSkill
- sharpening-promptsSkill
- smart-readingSkill
- test-driven-developmentSkill
- testing-strategySkill
- tooling-discoverySkill
- using-git-worktreesSkill
- using-lsp-toolsSkill
- using-skillsSkill
- The first 60 shown.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

