pipeshape-tune
Pick the branch the request names. When a failed run is in the session,
start with Diagnose. Every branch that edits a script ends with
Apply and verify.
Diagnose a run
- Locate the run's transcript directory from the Workflow tool result and
read
journal.jsonl there. It holds each agent's actual return value; a
cached result may be empty.
- Open
/workflows, select the failed agent, and read its prompt, tool
calls, and result.
- Name the cause as exactly one of these and say which evidence decided it:
- prompt defect, when the agent did the wrong task or returned prose where
a schema was required
- schema contradiction, when the run failed before the agent started
- permission denial, when a tool call was blocked
- cap reached, when
parallel() or pipeline() rejected the item list or
the 1,000-agent limit ended the run
- upstream null, when a stage received
null from a stopped or errored
agent
- Fix the cause in the script, then relaunch with
resumeFromRunId so
unchanged agents return their cached results.
Improve after a run
Use when a run finished but the user wants better results next time.
- Read the returned object:
status, verdicts, rounds, dropped counts.
- Classify what went wrong, one label per observation:
- the same acceptance item failed every round: verdict criteria too vague,
or the rework prompt lacks the failing evidence
- reviewers disagreed with QA: add a lens or narrow one
- a finding was refuted that the user considers real: refuter prompt too
eager; raise the vote threshold or add a reproduce step
- the run was escalated at
maxRounds: raise the ceiling or move the gate
earlier
- the user rejected the spec at the gate: analysis prompt is missing a
question axis
- Propose at most three changes, each pointing at the exact prompt or option
to edit, and apply the ones the user picks.
Change the harness
Map the request to the edit, then apply it.
- Add a stage: one more
agent() call with a label and a phase option;
add its phase() title to meta.phases; give it a schema when a later
stage branches on it.
- Remove a stage: delete the call and every reference to its result; remove
its title from
meta.phases.
- Add or move a gate: split the script at that point per
pipeshape-gate;
the segment before it ends with a schema summary and a file under
.pipeline/<slug>/.
- Change pass or fail criteria: edit the verdict prompt text and the
severity enum or the check on findings.
- Parallelize two stages: wrap them in
parallel() and move any shared
interface into the upstream prompt.
- Change model or role: set
model or agentType on that agent() call.
- Change commands: edit the
<!-- pipeshape start --> block in CLAUDE.md,
not the script.
- Add a review lens: append to the
lenses default or pass it in args.
- Two agents overwrite each other's files (implement and test in the same
parallel()): add isolation: 'worktree' to both agent() calls. It costs
setup time and disk per agent, so add it only after a collision, not by
default.
Migrate a v1 pipeline
- Read
.claude/skills/<name>/pipeline.yml, its prompts/*.md, and the
agents it names under .claude/agents/.
- Map each construct with
pipeshape-topologies:
- a listed node becomes one
agent() call; its prompt file becomes the
prompt string with {{vars.*}} replaced by args.*
parallel: [...] becomes parallel()
if: FAILED, goto, max, exhausted becomes the producer and reviewer loop
branch: becomes expert routing
type: command becomes an agent instructed to run the command and
return the exit code in a schema
gate: true splits the script into segments per pipeshape-gate
context: disappears; pass the referenced result into the prompt string
GRAPH_STATUS and GRAPH_OUTPUT become a schema on the agent
- Fold the agent definition's role text into the prompt string, or keep the
agent and pass its name as
agentType.
- Write
.claude/workflows/<name>.js and show the user the shape as a short
phase list.
- Propose deleting
.claude/skills/<name>/ and the old CLAUDE.md marker
block. Do not delete them yourself.
Apply and verify
- Load the
workflow-authoring bundled skill before editing any script.
- Keep
export const meta as the first statement and a pure literal. Keep
every phase() title listed in meta.phases.
- Run
node --check on the file. When node is absent, skip this step;
/reload-skills reports syntax errors instead.
- Append one line to
.claude/workflows/CHANGELOG.md: date, request, files
changed. Create the file when missing.
- When a write under
.claude/ is denied (headless -p runs deny it), write
the files to a scratch directory instead and print the exact cp command
that moves them into .claude/workflows/. Do not silently drop them.
- Tell the user to run
/reload-skills, then /<name> again.
1---2name: pipeshape-tune3description: Improves and changes an installed pipeline harness. Diagnoses a failed workflow run, applies improvements after a run, changes stages, gates, criteria, or agents in a saved workflow, and migrates a v1 pipeline.yml.4---56# pipeshape-tune78Pick the branch the request names. When a failed run is in the session,9start with **Diagnose**. Every branch that edits a script ends with10**Apply and verify**.1112## Diagnose a run13141. Locate the run's transcript directory from the Workflow tool result and15 read `journal.jsonl` there. It holds each agent's actual return value; a16 cached result may be empty.172. Open `/workflows`, select the failed agent, and read its prompt, tool18 calls, and result.193. Name the cause as exactly one of these and say which evidence decided it:20 - prompt defect, when the agent did the wrong task or returned prose where21 a schema was required22 - schema contradiction, when the run failed before the agent started23 - permission denial, when a tool call was blocked24 - cap reached, when `parallel()` or `pipeline()` rejected the item list or25 the 1,000-agent limit ended the run26 - upstream null, when a stage received `null` from a stopped or errored27 agent284. Fix the cause in the script, then relaunch with `resumeFromRunId` so29 unchanged agents return their cached results.3031## Improve after a run3233Use when a run finished but the user wants better results next time.34351. Read the returned object: `status`, `verdicts`, `rounds`, dropped counts.362. Classify what went wrong, one label per observation:37 - the same acceptance item failed every round: verdict criteria too vague,38 or the rework prompt lacks the failing evidence39 - reviewers disagreed with QA: add a lens or narrow one40 - a finding was refuted that the user considers real: refuter prompt too41 eager; raise the vote threshold or add a reproduce step42 - the run was escalated at `maxRounds`: raise the ceiling or move the gate43 earlier44 - the user rejected the spec at the gate: analysis prompt is missing a45 question axis463. Propose at most three changes, each pointing at the exact prompt or option47 to edit, and apply the ones the user picks.4849## Change the harness5051Map the request to the edit, then apply it.5253- Add a stage: one more `agent()` call with a `label` and a `phase` option;54 add its `phase()` title to `meta.phases`; give it a `schema` when a later55 stage branches on it.56- Remove a stage: delete the call and every reference to its result; remove57 its title from `meta.phases`.58- Add or move a gate: split the script at that point per `pipeshape-gate`;59 the segment before it ends with a `schema` summary and a file under60 `.pipeline/<slug>/`.61- Change pass or fail criteria: edit the verdict prompt text and the62 `severity` enum or the check on `findings`.63- Parallelize two stages: wrap them in `parallel()` and move any shared64 interface into the upstream prompt.65- Change model or role: set `model` or `agentType` on that `agent()` call.66- Change commands: edit the `<!-- pipeshape start -->` block in `CLAUDE.md`,67 not the script.68- Add a review lens: append to the `lenses` default or pass it in `args`.69- Two agents overwrite each other's files (implement and test in the same70 `parallel()`): add `isolation: 'worktree'` to both `agent()` calls. It costs71 setup time and disk per agent, so add it only after a collision, not by72 default.7374## Migrate a v1 pipeline75761. Read `.claude/skills/<name>/pipeline.yml`, its `prompts/*.md`, and the77 agents it names under `.claude/agents/`.782. Map each construct with `pipeshape-topologies`:79 - a listed node becomes one `agent()` call; its prompt file becomes the80 prompt string with `{{vars.*}}` replaced by `args.*`81 - `parallel: [...]` becomes `parallel()`82 - `if: FAILED, goto, max, exhausted` becomes the producer and reviewer loop83 - `branch:` becomes expert routing84 - `type: command` becomes an agent instructed to run the command and85 return the exit code in a schema86 - `gate: true` splits the script into segments per `pipeshape-gate`87 - `context:` disappears; pass the referenced result into the prompt string88 - `GRAPH_STATUS` and `GRAPH_OUTPUT` become a `schema` on the agent893. Fold the agent definition's role text into the prompt string, or keep the90 agent and pass its name as `agentType`.914. Write `.claude/workflows/<name>.js` and show the user the shape as a short92 phase list.935. Propose deleting `.claude/skills/<name>/` and the old `CLAUDE.md` marker94 block. Do not delete them yourself.9596## Apply and verify97981. Load the `workflow-authoring` bundled skill before editing any script.992. Keep `export const meta` as the first statement and a pure literal. Keep100 every `phase()` title listed in `meta.phases`.1013. Run `node --check` on the file. When `node` is absent, skip this step;102 `/reload-skills` reports syntax errors instead.1034. Append one line to `.claude/workflows/CHANGELOG.md`: date, request, files104 changed. Create the file when missing.1055. When a write under `.claude/` is denied (headless `-p` runs deny it), write106 the files to a scratch directory instead and print the exact `cp` command107 that moves them into `.claude/workflows/`. Do not silently drop them.1086. Tell the user to run `/reload-skills`, then `/<name>` again.