Phases

Contents
  1. The Phase Graph
  2. Check Types
  3. Verdict Lines
  4. Quality Gates After the Check
  5. Adding and Removing Phases
  6. Instruction Files
  7. run/last-failure.md
  8. See Also

Documentation › Phases

The single-mode workflow is a graph of phases in the phases key of the configuration; the shipped graph is plan → implement → review (see How it works). Feature mode has its own graphs in feature.planPhases and feature.stepPhases, with the same keys.

The Phase Graph

Each phase has next (a phase name or done), an optional allowEdits list of path prefixes (omit it to allow all edits), an optional instructions file, an optional delegate flag and an optional subagent name (see Delegating a phase and Choosing the subagent), an optional agent object with model and effort for a delegated phase (see Model and effort per phase) and an optional check.

Check Types

check.type Fields Passes when
file path the file exists and is non-empty
command command the command exits 0 (run with shell, default bash, from the project root)
verdict path, approve, reject (optional), onReject the last verdict line of the file is approve. If it is reject, the flow jumps to onReject.
steps path, requireAllPending steps.json parses and matches the schema (feature mode planning; see Feature mode). With requireAllPending every step must be pending.

A check’s path may use {attempt_dir}; see Review attempts. A phase with no check passes immediately.

Verdict Lines

A verdict check reads only whole lines. A verdict line is a line that equals approve or reject once surrounding whitespace, Markdown emphasis, a -, + or * bullet, a heading marker and one trailing period are removed. So - `VERDICT: APPROVE`. counts, while Final: VERDICT: APPROVE does not. When several verdict lines are present, the last one wins.

A marker never counts inside a fenced code block, an indented code block (four or more columns of indentation) or a blockquote, so a review can quote an example verdict safely. Fences follow Markdown rules: a block closes only on a bare run of the same character, at least as long and quoted as deeply as the opener, and a fence inside a blockquote ends with the blockquote. If a fence is still open at the end of the file, no verdict line counts and the check fails with a message saying so; put a snippet that contains ``` inside a ```` fence.

reject is optional: null drops the default, and the check then fails until the file approves. The markers get the same normalization as lines; markers that become empty or identical are compared as written. The file is read as UTF-8, with or without a byte order mark.

Quality Gates After the Check

When the check passes, the quality gates that name the phase in their phases list run, in declared order. The phase passes only if every block gate passes; otherwise the stop is blocked as for a failed check, with every failed gate in one message. A failed check ends the stop before any gate runs, and planning phases never run gates.

Adding and Removing Phases

To remove a phase, set it to null and re-point the previous phase’s next. For example, to skip review:

{ "phases": { "implement": { "next": "done" }, "review": null } }

To add a phase, for example docs after implement, define it in config.json, point implement.next at it, and put the instructions in overrides/docs.md.

Instruction Files

Shipped instructions are in phases/ and are replaced on update; a file of the same name in overrides/ takes precedence. The shipped files are plan.md, implement.md and review.md (single mode), feature-plan.md, feature-replan.md, step-implement.md and step-review.md (feature mode, see Feature mode) and delegate.md (the orchestration preamble, see Delegating a phase).

In instruction files, {spec} becomes the spec path, {run_dir} becomes .claude/specloop/run, {attempt_dir} becomes the current attempt’s directory, and {review_file} becomes the path the current phase’s verdict check reads, which is {attempt_dir}/review.md in a phase without one. {quality_gates} becomes a Markdown list of the quality gates that run in the current phase and step, with the protected paths and forbidden patterns, and nothing when no gate applies; the shipped implement.md and step-implement.md use it, and an override without it keeps working. In delegate.md only, {subagent} becomes the subagent_type of the current phase (see Choosing the subagent), {agent_settings} becomes one sentence naming the model and effort the Agent tool needs (see Model and effort per phase) and nothing when the phase has none, and {brief} becomes the phase brief; an override without {subagent} or {agent_settings} keeps working. Feature-mode step placeholders are listed under Step cycle.

run/last-failure.md

Whenever a check or a quality gate fails or a review requests changes, the full details (the complete check output, every failed gate’s output or the review text, not truncated) are written to .claude/specloop/run/last-failure.md. The file is removed when a phase passes and on /sl-advance.

See Also

View this page on GitHub