pipeshape-gate
Turn every approval point into a workflow boundary. N gates produce N+1 workflow segments, and the session carries approved state across them.
Segment contract
- End every segment with one agent that returns a
schemaobject holding what the user must decide on. Include asummarystring and aquestionsarray; each question carriesoptionsand arecommendedvalue. - Have that same agent write the full artifact to
.pipeline/<slug>/<stage>.md. The script cannot write files; the agent does. - Keep
.pipeline/readable by people. Do not put machine logs there. Add.pipeline/to.gitignorewhen it is missing.
Single-agent first segment
When the segment before a gate is one agent (an analysis or a spec draft), run
it in the session with the Agent tool instead of a workflow. Keep the same
contract: the agent writes .pipeline/<slug>/<stage>.md and returns the
summary and questions object. Use a workflow for that segment only when
the user wants it saved as a /<name> command.
Between segments
- Present the returned
summaryandquestionsto the user withAskUserQuestion. Offer approve, revise, and stop on every gate. Forward the agent's options and recommendation as they are. - On approve, record the decisions in
.pipeline/<slug>/decisions.mdand launch the next segment. - On revise, rerun the current segment with the user's changes appended to
its
args. - On stop, report what
.pipeline/<slug>/holds and end.
Passing state forward
- Put decisions and short results directly in
args. - When the payload exceeds 2 KB, pass the
.pipeline/<slug>/path instead and have the first agent of the next segment read it. - Always pass
slugso every segment writes to the same directory.
Example
Segment 1 returns:
{
"summary": "Expiry policy touches CouponService and the batch job.",
"questions": [
{ "id": "scope", "text": "Include already-issued coupons?",
"options": ["yes", "no"], "recommended": "no" }
]
}
The session asks the user, records scope=no, then launches segment 2 with
args: { slug, decisions: { scope: "no" } }.