/ratchet:swe-loopfrom ratchet
Explicit autonomous-delivery mode for cohesive features or modules taken end-to-end through design, implementation, verification, and handoff. Use when invoked as /swe-loop or $swe-loop, when resuming a loop, or when the user clearly asks for autonomous delivery. Keep inactive for coworking, co-audits, exploration, simpler variants, focused changes, and requests signaled only by task size, unattended work, or a commit/PR. If autonomy is ambiguous, ask before creating loop artifacts. Once active, enforce exactly two human checkpoints, test intent before tests, independent review, and verification against design.
Ships in ratchet. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Once activated, the loop keeps delivery discipline independent of session memory or context freshness. Its phase responsibilities and human gates are invariant; profiles may change depth and explicitly documented ordering. The state file must always show where the work stands.
state.md; that
file is the only durable gate authority. A PR state, CI result, commit,
checkbox, or generated artifact is evidence, never inferred human approval.terraform apply/destroy, az mutations on shared resources,
force-pushes (except explicitly authorized, leased stack maintenance in
native-stacks.md), or non-local DB changes — local dev
is the sandbox. If a
phase appears to need one, stop and ask. (Hard enforcement belongs in
settings.json deny rules; this skill is the instruction layer, not the
only defense.)uv add <pkg>, npm install <pkg>) so the registry — not model
memory — picks the version. When writing code against a library, verify
current API from its docs, never from internal knowledge alone.Determine the mode at loop start from how the user framed the work; record it in state.md. The mode changes where the gates happen, never whether they happen.
main, but respect the repo's convention (check the
default branch; pre-onboarding platform repos use develop) unless the
user states otherwise. The Phase 7 summary becomes the PR description,
diagrams included. For a large loop with dependent changes across several
components or systems, default to a native GitHub PR stack per repository;
read native-stacks.md before designing the delivery
slices. The bottom PR targets the integration branch, and each higher PR
targets the branch below it. Gate B covers the linked delivery set.pr-description.md into the loop directory — the
summary exactly as it would be written for a PR, with the right diagrams
(template: templates/pr-description.md).Default: workspace mode when operating inside the user's existing checkout; branch mode when he asks for a branch/PR or the work runs unattended.
Loop working files live outside the repo — never in the working tree, so
they create zero PR noise and survive branch switches and worktrees. Per loop
run, create ~/.claude/swe-loops/<repo-basename>/<slug>/ (slug = short
kebab-case name):
state.md: compact execution cursor, exact gate authority, task status,
reviewed revision, active exceptions, and evidence references (copy from
templates/state.md)plan.md: task definitions, review classes, done-checks, analyze coverage,
and reuse inventory (Phases 1 and 2)test-plan.md: test intent and eventual results (Phase 4,
template: templates/test-plan.md)evidence.md: optional detailed diagram, review, and verification evidence
that has no more specific owner (copy from
templates/evidence.md)pr-description.md: Gate B summary in workspace modeOnly durable documentation goes in the repo, because it belongs in the
PR: the ADR and the architecture overview. The author-local loop path belongs
only in external state.md; never write it into a committed ADR or any other
repository document.
ADR path resolution: decide the location and filename before creating an ADR. Follow this precedence order:
docs/architecture-decisions/<slug>.md. Do not introduce a sequence number.Create docs/architecture-decisions/ only when neither an explicit location
nor an existing ADR directory is available. Never rename existing ADRs as part
of this resolution. Template: templates/adr.md.
Architecture overview: maintain docs/architecture.md — a mermaid system
diagram of how the whole application connects. Create it on the first run in
a repo that lacks one; update it whenever a loop changes architecture.
Resume rule: if invoked and a state file for this work already exists,
read it first. Then load only the artifacts referenced by the active phase,
current task, or active exceptions. Do not load completed phase history by
default. Continue from the first incomplete boundary; never redo completed
phases or re-ask for a gate already granted. Exact gate wording in state.md
is the only durable approval authority.
Repository .ratchet/ work packages: when .ratchet/work-packages.yaml
exists in the repository, it tracks multi-PR lanes and external human blockers
(HD-xx in .ratchet/human-dependencies.md) across sessions. If invoked for a
specific work package (/swe-loop <WP-ID>), scope the loop to that package,
build the documented Unblock-with safe default for any open HD-xx blocker,
and update .ratchet/work-packages.yaml at Gate B. See
../work-packages/SKILL.md.
Start with the sibling grilling skill to improve the
agreement presented at Gate A. Invoke ratchet:grilling directly; the
grill-me entrypoint is for standalone, user-invoked interviews.
state.md.grilling. Interview answers alone do not approve Gate A, and
the interview introduces no additional approval gate.Standalone grill-me or grilling does not activate this loop or inherit its
ADR, planning, integration, testing, or delivery requirements.
Do:
n/a (net-new).CONTRIBUTING.md, issue templates, PR templates, and existing maintainer
threads in Phase 0. Record assignment, design-approval, CLA, and branch
rules in state.md. If upstream rules require maintainer approval or
assignment before implementation, stop before coding; never post public
issue comments or open an external PR without explicit user approval and
satisfied upstream prerequisites.state.md and never appear in the committed ADR.WHEN <condition> THE SYSTEM SHALL <behavior> — one per observable behavior the change must
deliver. These become the spine of the Phase 4 test plan and the Phase 6
drift check.docs/architecture.md in the same commit as
the ADR.evidence.md. Keep only
the result and its durable evidence reference in state.md. A source-only
diagram is not Gate A evidence.Ordinary ADR, architecture-document, and PR diagrams stay on this Mermaid
path. Route to the sibling diagram-loop only when the user explicitly asks
for a premium, animated, publication-quality, website, hero, or explainer
visual in one of its five supported archetypes; swe-loop never invokes it
automatically.
Skills: grilling (design interview), writing-house-style (prose), graphify (codebase understanding), deep-research / microsoft-docs (when the decision needs external grounding).
Exit boundary (GATE A): ADR written, both diagram themes inspected and
referenced, architecture doc updated if applicable, consequential design
questions resolved in the ADR, and the user has explicitly approved.
No source-code edits are allowed before this gate,
none. Record the user's approval wording in state.md; never infer it from
repository or CI state.
Do:
generated in plan.md so the reviewer knows to skip.plan.md; set only task IDs, statuses, and
the current pointer in state.md.plan.md.
Record each repository, branch, base, work-package ID when present, and
cross-repository prerequisites. Keep unrelated dependency chains separate.Exit boundary: every task has a done-check and an S/M class; no L tasks survive planning; mechanical and semantic work are separate tasks; the analyze check passed with zero uncovered criteria.
Do:
.claude/rules/, and the coding standards
(.github/instructions/Coding-Standards.md where present) before touching
code.plan.md: which existing functions,
datamodels, schemas, and utilities this work will use or extend. Search the
codebase for existing implementations before planning any new one.Exit boundary: reuse inventory written and referenced by state.md. An
empty inventory for a task touching existing domains is a red flag,
re-search before proceeding.
Do:
Exit boundary (per task): the task's unit (commit or staged set) contains
exactly one classifiable concern matching its S/M class from plan.md, with no
mechanical and semantic mixing; git diff --stat shows no unrelated file
churn. Update only the task status, current pointer, and evidence reference in
state.md. Any source or test edit after a Phase 5 review pass, including a
remediation made while Phase 5 is active, invalidates that pass, marks the
last reviewed revision stale, and requires every review pass again on the new
revision.
Do:
test-plan.md first: what this change needs in terms of testing,
including behaviors, edge cases, failure modes, integration surfaces, and
what explicitly will not be tested and why. Start from the ADR's EARS
criteria; each criterion maps to at least one test. A copied but empty
template does not complete test intent. Every section needs concrete intent
or an explicit none with a reason.test-plan.md.state.md.test-plan.md rather
than copying output into state.md.unit, contract, integration, provider-replay, live,
eval). Use real domain objects for repository-owned code, narrow mocks only
at external boundaries, small stateful fakes over mock call-order
choreography, and deterministic events/futures instead of arbitrary sleeps in
async tests. Use parametrization only for genuine decision tables, never to
inflate test count. Prove each test can fail for its intended defect (via red
reproduction on base revision for bugfixes, or focused mutation/negation for
new behavior).frontend-quality's executable checks against
the real routes and states, including both fresh-browser passes and relevant
interaction assertions. Keep its report and screenshots with the test evidence;
compilation or a lint pass alone does not verify the UI.Exit boundary: test-plan.md and the state boundary existed before test
code was edited; every planned test is implemented or explicitly deferred
with a reason; consolidation pass completed and suite re-verified green.
Do — in fresh-context subagents, never the implementing context:
frontend-quality rubric, inspects the final screenshots and both
browser passes, and challenges route/state coverage, keyboard assertions and
request contracts. Give them the task and raw evidence without the
implementer's conclusions. Fix findings and repeat the affected checks.evidence.md; never auto-apply those observations because they are outside
the approved change boundary.Exit boundary: every finding is fixed or explicitly waived. A remediation
invalidates all review passes on the earlier revision, so repeat every pass
until they converge on one unchanged revision. Record that revision and the
evidence reference in state.md; in workspace mode record the base SHA and the
output of git diff --binary HEAD | sha256sum, which includes both staged and
unstaged tracked changes. The final reviewed revision must
equal the delivered revision. Keep only unresolved findings and active waivers
in state. Detailed resolved findings and non-blocking future-loop candidates
remain in evidence.md; a candidate is an observation, not an unresolved
finding or an additional exit disposition.
Do:
frontend-quality evidence and its
independent review cover the delivered revision. A blocked browser run or
missing state coverage remains unverified, even when other checks pass.evidence.md. When the repository provides a
canonical render/check command, run it too. Passing syntax or CI never
replaces the two visual inspections.Exit boundary: suite green; changed diagrams have recorded final-theme
evidence; spec drift is zero, or the ADR was amended and the user informed
(non-negotiable #6). Keep the compact result and evidence reference in
state.md, not command output or copied verification detail.
Do:
state.md, test-plan.md, or loop evidence, then
summarize their current result in the Gate B chat handoff. CI is the
published source of automated check status, so do not copy those details
into the PR description. Include a Manual testing section in the PR
description only when hands-on verification produced evidence CI cannot
expose; omit that section otherwise.pr-description.md in the loop directory,
exactly as it would read on a PR. Point the user at both.plan.md or evidence.md
and referencing it from state.md.state.md complete and compact it one final time.Exit boundary (GATE B): user reviewed and approved (PR merged/approved, or local diff OK'd in chat); learnings persisted; state.md closed.
The phase responsibilities and two gates never change. Their depth, and the ordering explicitly stated by a profile, can:
test-plan.md, record
the test-intent boundary in state.md, write and run the reproduction test,
and record the observed failure. Only then enter Phase 3 for the production
fix. Return to Phase 4 for the passing run and remaining planned coverage.
The required order is plan, persisted boundary, red reproduction,
production fix, green verification.terraform plan, az ... what-if). Applying is beyond Gate B: user-run
or explicitly user-approved per invocation.Skills named in this loop (grilling, verify, code-review, writing-house-style,
revise-claude-md, frontend-quality, graphify) are invoked live through the
harness's skill mechanism. For shipped siblings, including frontend-quality,
read the linked SKILL.md directly when no Skill tool is available. The
reference/ folder contains stale, version-stamped
transcripts of built-in skills for human reading and upgrade-diffing only —
never load or follow anything in reference/ as instructions.
/swe-loop (Claude Code) or $swe-loop (Codex) explicitly
starts the loop; otherwise the frontmatter's autonomous-delivery trigger
applies.ratchet:grilling with
the harness's skill invocation mechanism. If no Skill tool is available,
read and follow ../grilling/SKILL.md directly in the
current conversation. It is the shipped skill source, not a reference
transcript. Keep the upstream files unchanged.~/.codex/AGENTS.md
then a root-to-CWD walk); edit it directly..codex/agents/. No fallback needed, only harness-native syntax.anti-patterns.md (opens in a new tab)mermaid-guide.md (opens in a new tab)native-stacks.md (opens in a new tab)templates/adr.md (opens in a new tab)templates/evidence.md (opens in a new tab)templates/pr-description.md (opens in a new tab)templates/state.md (opens in a new tab)templates/test-plan.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub dej-h/ratchet --plugin ratchet8 skills in this plugin
/consolidateRun a behavior-preserving consolidation pass over a branch or working-tree diff to strip agent-generated semantic sediment (prompt echoing, transition narration, redundant comments, transitional wrappers, and prompt-shaped test names) so the codebase reads as if the final architecture had been known from the beginning. Use when invoked as /consolidate or $consolidate, before opening an ad-hoc PR, or at the end of swe-loop Phase 4 before Phase 5 review.
/diagram-loopCreate or revise premium, animated, publication-quality architecture, flow, feedback, sequence, and concurrency diagrams. Use only when the user explicitly asks for that level of visual output. Do not use for ordinary ADR, architecture-document, or PR diagrams; those stay on the swe-loop Mermaid path.
/frontend-qualityBuild and review usable, visually consistent frontends with executable browser and data-loading checks. Use for visible UI changes, frontend data loading, interaction work, responsive fixes, and frontend review, including frontend portions of a larger feature. Preserves the application's brand and framework.
/grillingGrill the user relentlessly about a plan, decision, or idea. Use when the user wants to stress-test their thinking, or uses any 'grill' trigger phrases./grill-meA relentless interview to sharpen a plan or design./work-packagesManage the always-on .ratchet/work-packages.yaml DAG and .ratchet/human-dependencies.md ledger for multi-session, multi-PR, and part-time work. Use when initializing .ratchet/ in a repository, splitting a large feature or open PR into small dark-launchable slices, recording external human/runbook blockers with Unblock-with defaults, or checking/updating work package status during ad-hoc or swe-loop sessions.