Compose a Weft Workflow
Read the conversation context, scan available skills, identify gaps, and propose a v2 workflow template with loops and skill blocks.
Arguments
$ARGUMENTS
Modes
| Usage |
Behavior |
/wf-compose "review, fix, iterate until clean" |
One-shot: propose from description |
/wf-compose (no args) |
Interactive: ask "What are you trying to accomplish?" |
/wf-compose --from feature-workflow |
Start from existing template, modify based on context |
Step 1: Gather Context
Understand what the user is trying to do:
- Review the recent conversation for intent (what task, what repo, what outcome).
- Check git state:
git branch --show-current 2>/dev/null
git diff --stat 2>/dev/null | tail -5
- Check if a weft workflow is already active:
python3 "${CLAUDE_PLUGIN_ROOT}/core/cli.py" status 2>/dev/null
- If
--from <template> was provided, load it as the starting point:python3 "${CLAUDE_PLUGIN_ROOT}/core/cli.py" preview <template>
Step 2: Scan Skill Registry
Build a map of what skills are available:
- Read the local skills registry, if any (path varies by setup):
cat "${CLAUDE_SKILLS_REGISTRY:-$HOME/.claude/skills-registry.json}" 2>/dev/null
- List weft templates:
python3 "${CLAUDE_PLUGIN_ROOT}/core/cli.py" start
- Categorize skills by function (examples — substitute what you have available):
- Review: staff-review, arch-review, code-review, differential-review
- Fix/Polish: fix-polish, refactor, simplify
- Test: infra-test, webapp-testing
- Plan: aot-plan, spec-first
- Research: perplexity, context7, research-loop
- Deploy: deploy-service, pr-ready
Step 3: Gap Analysis
Compare what the user described against available skills:
- Extract skill references from the user's description (explicit names like "/staff-review" or implicit like "review code", "test it", "deploy").
- For each referenced skill, check if it exists in the registry.
- For missing skills, present options:
Missing skill: /devils-advocate
Options:
1. Create a stub skill (I'll generate a skeleton)
2. Use /staff-review instead (similar purpose)
3. Skip this step
- Wait for user choice on each gap before proceeding.
Step 4: Generate Template
Build a v2 template JSON:
Map each step in the user's described workflow to a template step.
For each step, set:
name: kebab-case identifier
skill: the matching skill name (e.g., "/staff-review"), or null if manual
on_fail: "retry" for review/test steps, "block" for critical gates, "continue" for optional steps
guards: add logical guards (e.g., no git push before review)
description: one-line summary of what the step does
For iterative segments (user said "until", "repeat", "loop", "iterate"):
- Identify the loop boundary (which steps repeat)
- Set
loop_back_to on the last step of the loop, pointing to the first
- Set
max_iterations (default 3, or what the user specified)
- Set
exit_condition from the user's description (natural language)
Add schema_version: 2 to the template root.
Step 5: Present to User
Show the proposed workflow in two formats:
ASCII Diagram
Draw the workflow as a flow diagram showing loops:
┌────────────┐ ┌───────────────┐ ┌─────────────┐
│ review │────>│ fix-issues │────>│ run-tests │
│ /staff-rev │ │ /fix-polish │ │ │
└────────────┘ └───────────────┘ └──────┬──────┘
^ │
│ ↻ until clean (max 3) │
└─────────────────────────────────────────┘
│ done
v
┌─────────────┐
│ ship │
│ /pr-ready │
└─────────────┘
For linear segments, use a simple arrow chain:
setup ──> plan ──> implement ──> verify
JSON Preview
Show the full template JSON, formatted for readability.
Prompt
Ask the user:
Approve this workflow? (approve / edit / cancel)
- approve: Save template and optionally start it
- edit: Describe what to change
- cancel: Discard
Step 6: Save and Start
On approve:
- Save the template:
echo '<json>' | python3 "${CLAUDE_PLUGIN_ROOT}/core/cli.py" save-template
- Ask: "Start this workflow now? (y/n)"
- If yes: invoke
/wf-start <template-name>
On edit:
- Ask what to change
- Modify the template
- Go back to Step 5 (re-present)
On cancel:
- Discard and confirm
Design Rules
- Every step with a matching skill gets a
skill field. This is metadata — Claude reads it from context.md and knows which skill to invoke.
- Loops are defined by
loop_back_to on the last step of the repeating segment. The state machine handles the rest.
exit_condition is evaluated by Claude (natural language), not by scripts. Keep conditions specific and observable: "no MEDIUM+ issues" not "code is good enough".
max_iterations defaults to 3. If the user says "until done" without a cap, set it to 5 and note the cap.
- Guards should prevent premature actions: no
git push before review, no deploy before tests.
- Template names are kebab-case. If the user doesn't name it, derive from the description.
1---2name: wf-compose3description: Propose a weft workflow from conversation context. Scans skills, identifies gaps, builds template with loops.4---56# Compose a Weft Workflow78Read the conversation context, scan available skills, identify gaps, and propose a v2 workflow template with loops and skill blocks.910## Arguments11$ARGUMENTS1213## Modes1415| Usage | Behavior |16|-------|----------|17| `/wf-compose "review, fix, iterate until clean"` | One-shot: propose from description |18| `/wf-compose` (no args) | Interactive: ask "What are you trying to accomplish?" |19| `/wf-compose --from feature-workflow` | Start from existing template, modify based on context |2021## Step 1: Gather Context2223Understand what the user is trying to do:24251. Review the recent conversation for intent (what task, what repo, what outcome).262. Check git state:27 ```bash28 git branch --show-current 2>/dev/null29 git diff --stat 2>/dev/null | tail -530 ```313. Check if a weft workflow is already active:32 ```bash33 python3 "${CLAUDE_PLUGIN_ROOT}/core/cli.py" status 2>/dev/null34 ```354. If `--from <template>` was provided, load it as the starting point:36 ```bash37 python3 "${CLAUDE_PLUGIN_ROOT}/core/cli.py" preview <template>38 ```3940## Step 2: Scan Skill Registry4142Build a map of what skills are available:43441. Read the local skills registry, if any (path varies by setup):45 ```bash46 cat "${CLAUDE_SKILLS_REGISTRY:-$HOME/.claude/skills-registry.json}" 2>/dev/null47 ```482. List weft templates:49 ```bash50 python3 "${CLAUDE_PLUGIN_ROOT}/core/cli.py" start51 ```523. Categorize skills by function (examples — substitute what you have available):53 - **Review**: staff-review, arch-review, code-review, differential-review54 - **Fix/Polish**: fix-polish, refactor, simplify55 - **Test**: infra-test, webapp-testing56 - **Plan**: aot-plan, spec-first57 - **Research**: perplexity, context7, research-loop58 - **Deploy**: deploy-service, pr-ready5960## Step 3: Gap Analysis6162Compare what the user described against available skills:63641. Extract skill references from the user's description (explicit names like "/staff-review" or implicit like "review code", "test it", "deploy").652. For each referenced skill, check if it exists in the registry.663. For missing skills, present options:67 ```68 Missing skill: /devils-advocate69 Options:70 1. Create a stub skill (I'll generate a skeleton)71 2. Use /staff-review instead (similar purpose)72 3. Skip this step73 ```744. Wait for user choice on each gap before proceeding.7576## Step 4: Generate Template7778Build a v2 template JSON:79801. Map each step in the user's described workflow to a template step.812. For each step, set:82 - `name`: kebab-case identifier83 - `skill`: the matching skill name (e.g., "/staff-review"), or null if manual84 - `on_fail`: "retry" for review/test steps, "block" for critical gates, "continue" for optional steps85 - `guards`: add logical guards (e.g., no `git push` before review)86 - `description`: one-line summary of what the step does87883. For iterative segments (user said "until", "repeat", "loop", "iterate"):89 - Identify the loop boundary (which steps repeat)90 - Set `loop_back_to` on the last step of the loop, pointing to the first91 - Set `max_iterations` (default 3, or what the user specified)92 - Set `exit_condition` from the user's description (natural language)93944. Add `schema_version: 2` to the template root.9596## Step 5: Present to User9798Show the proposed workflow in two formats:99100### ASCII Diagram101102Draw the workflow as a flow diagram showing loops:103104```105 ┌────────────┐ ┌───────────────┐ ┌─────────────┐106 │ review │────>│ fix-issues │────>│ run-tests │107 │ /staff-rev │ │ /fix-polish │ │ │108 └────────────┘ └───────────────┘ └──────┬──────┘109 ^ │110 │ ↻ until clean (max 3) │111 └─────────────────────────────────────────┘112 │ done113 v114 ┌─────────────┐115 │ ship │116 │ /pr-ready │117 └─────────────┘118```119120For linear segments, use a simple arrow chain:121```122 setup ──> plan ──> implement ──> verify123```124125### JSON Preview126127Show the full template JSON, formatted for readability.128129### Prompt130131Ask the user:132```133Approve this workflow? (approve / edit / cancel)134- approve: Save template and optionally start it135- edit: Describe what to change136- cancel: Discard137```138139## Step 6: Save and Start140141On **approve**:1421. Save the template:143 ```bash144 echo '<json>' | python3 "${CLAUDE_PLUGIN_ROOT}/core/cli.py" save-template145 ```1462. Ask: "Start this workflow now? (y/n)"1473. If yes: invoke `/wf-start <template-name>`148149On **edit**:1501. Ask what to change1512. Modify the template1523. Go back to Step 5 (re-present)153154On **cancel**:1551. Discard and confirm156157## Design Rules158159- Every step with a matching skill gets a `skill` field. This is metadata — Claude reads it from context.md and knows which skill to invoke.160- Loops are defined by `loop_back_to` on the last step of the repeating segment. The state machine handles the rest.161- `exit_condition` is evaluated by Claude (natural language), not by scripts. Keep conditions specific and observable: "no MEDIUM+ issues" not "code is good enough".162- `max_iterations` defaults to 3. If the user says "until done" without a cap, set it to 5 and note the cap.163- Guards should prevent premature actions: no `git push` before review, no deploy before tests.164- Template names are kebab-case. If the user doesn't name it, derive from the description.