the-loop
"the-loop" is an opinionated product-development-lifecycle (PDLC) harness, shipped as a
plugin for Claude Code and Cursor. Once a work item's spec chain (requirements → design
→ testing plan → tasks) is approved, the harness executes it end-to-end with MINIMAL or
NO human intervention, escalating only when a decision/opinion is genuinely required.
Read the relevant reference file before acting — they carry the full detail so the
essence is not lost:
reference/workflow.md — the loop, phases, TDD, reviews, autonomy, DAG, resumability.
reference/context.md — context-window management: clearing vs compaction, the checkpoint-then-reset protocol, per-harness mechanics.
reference/onboarding.md — the guided, schema-driven config onboarding /init runs (groups, ask levels, sensible-defaults precedence).
reference/instructions.md — user-provided custom instruction docs (customInstructions): when to read them, precedence, what they can and cannot override.
reference/design-artifacts.md — UI/UX design artifacts (Figma / HTML prototypes) in the design phase and the designer iteration loop.
reference/reviewing.md — the self/critic review procedure the review counts drive.
reference/security.md — the security lens on every phase gate: threat-model-lite, security design, the security-review gate, human sign-off tiers.
reference/tooling.md — repo management, per-language tooling matrix, hooks, CI parity.
reference/testing.md — the testing plan and the verification node (test-type matrix, verification environment, evidence and redaction), Gherkin scenario docstrings on integration tests, the queryable scenario view, OpenAPI/GraphQL contract conventions.
reference/minimalism.md — generation-time decision ladder to counter code bloat.
reference/token-economy.md — token/cost levers (model routing, verbosity, disclosure, sub-agents, telemetry); advisory, never at the expense of rigor.
reference/collaboration.md — collaborators/roles, paper trail, the self-comment loop-prevention marker (every reply MUST carry it), conflict log, notifications, MCP.
reference/observability.md — dev==runtime logging, levels, browser logging.
reference/automation.md — distribution, the CLI, webhooks, predictability, learnings lifecycle.
One rule lives in a sibling skill rather than a reference file, because it applies
outside a work item too: the-loop:writing (skills/writing/) — how every artifact
a human reads is written.
The artifact chain (optional brainstorm → spec → testing plan, Kiro-style)
Every work item is a chain of artifacts, each derived from and iterated after the one
before it. An artifact with a human gate is refined with feedback at that gate until
the gate locks it (status: approved) — and the gate is the only locker
(issue-281): when it classifies an authorized approval it writes the status and the
approver into the front matter itself. The session never sets status: approved and
never requests an approval of its own — one gate, one human reply. An artifact without
a gate (brainstorm.md, tasks.md) advances on shape alone, with no human stop. Specs
live in docs/specs/<id>/:
brainstorm.md (optional, the root artifact) — a free-form scratchpad to explore
a fuzzy idea before committing to requirements: problem, options, open questions,
working hypothesis. Created by /the-loop:brainstorm; converted to requirements once
its author says it has converged — it has no approval gate, so it is never
status: approved (issue-281). Phase: brainstorming. Skip it when the work is
already clear.
requirements.md (or bugfix.md for bugs) — user stories + EARS acceptance
criteria (WHEN <event> THEN the system SHALL <response>). Phase: requirements-definition.
Both names clear the same gate, and exactly one of them may be present — two would
leave the gate with no defined source of truth, so it blocks (decision-045). Whichever
name it carries, the artifact needs the same ## Requirements and
## Security considerations sections; both bundled templates provide them.
design.md — architecture, components/interfaces, data models, error handling,
testing strategy. Phase: design. For a user-facing work item the design phase also
tracks UI/UX design artifacts (Figma links / self-contained HTML prototypes under
docs/specs/<id>/design/), iterated-until-locked with the designer
(reference/design-artifacts.md).
testing-plan.md — how this work item will be proved: a matrix of testing
types (each either in scope, or n/a with a reason), the verification environment,
the evidence to capture, and the activities checklist. Phase: test-planning.
Derived from design.md and reviewed together with it — one human gate
(design-approval) approves and locks the pair, so the plan gets human review
without a stop of its own. It is authored here and completed at the
verification node — one artifact, written once as a plan and once as a record.
See reference/testing.md.
tasks.md — a DAG of small, verifiable tasks referencing requirements; each
task's _Test:_ names a row of the testing plan. Phase: tasks-breakdown. Derived
mechanically from the two artifacts the human just approved, so it has no approval
gate and needs no human sign-off (issue-281) — it advances on shape alone.
The work item's phase is tracked on the ticket via a label
(<workflow.phaseLabelPrefix><phase>) and mirrored in the execution log (brainstorming
is optional):
not-started → brainstorming → requirements-definition → design → test-planning
→ tasks-breakdown → implementation → verification → needs-review → complete
This sequence is defined by the shipped process graph
(cli/the_loop/graph/pdlc-work-item-loop.yaml — the outer loop, walked in the
repository the ticket was created in; each PR delivering a work item walks its own
pdlc-pr-loop in its own session — one per contributing repository — and the
outer implementation node waits for those inner loops to finish); the prose
here renders it, never redefines it (issue-148). A third shipped graph,
pdlc-contribution-loop (issue-185), is walked instead of the outer loop when
the-loop is invited into an existing, in-progress work item as a
contributor (the-loop contribute): it cannot start without an authorized
human's goal and success criteria, plans in one contribution.md instead
of the four-file spec chain, and completes only when every stated criterion is
met — see reference/workflow.md § The contribution loop. A fourth,
pdlc-adhoc-loop (issue-225), is the smallest of them: a tactical task that
runs no PDLC process at all (the-loop do) — work → review → complete, no
spec chain, no phase selection, no artifact gates, no review chain, finished
when the requester says so. See reference/workflow.md § The ad-hoc loop. A
fifth, pdlc-review-loop (issue-279), makes the-loop the reviewer of a pull
request rather than its author (the-loop review, binding to the PR itself):
no brief, no review — an authorized reviewer's questions/angles/validations are
frozen first — then review rounds and follow-ups on the thread until the
reviewer says done, with no code changed. See reference/workflow.md
§ The review loop.
When a node's work is done, tell the graph so —
the-loop graph complete <id> — rather than only narrating the transition.
See reference/workflow.md for what each phase contains, the review gates, the
self/critic-review counts, evidence, resumability and DAG orchestration.
Operating principles (rules)
- Every work item has a ticket. Nothing the harness works on lacks a GH issue (or
Jira) ticket.
- Spec before execution. Create the spec chain and get each phase
reviewed/approved by the required collaborators before writing code.
- Approvals are owned by approval nodes (issue-281). The graph's human gates
(
requirements-approval, design-approval, and human-approval on the PR) are where
feedback is classified and where locking happens: an authorized approval at the gate
writes status: approved and the approver into the artifact via lock-artifacts.
Never set status: approved yourself, and never post an approval request of your
own — the gate's request-review is the one ask, and a session-invented stop just
costs the human a second approval the gate will discard. An artifact whose gate lies
ahead is complete when its sections are; iterate it with the feedback the gate
records into it.
- Gate-less artifacts advance on shape alone.
brainstorm.md and tasks.md have no
approval node — do not hold them for a human "approved". tasks.md is derived from
the pair the human just approved at design-approval; the brainstorm converges when
its author says so on the thread. Never write a downstream artifact against an
upstream one whose gate has not yet approved it.
- Human review per phase (
workflow.requireHumanReviewPerPhase, default true) —
delivered by the graph's approval nodes, never re-implemented in a session.
- Skips are declared by humans, never taken by the harness (issue-177,
decision-067). Every work item starts at
phase-selection: the-loop posts a
checklist of the selectable phases on the ticket and waits for an authorized user
to reply with the ones to keep plus the-loop execute. Every phase of the outer loop
is selectable (issue-179, decision-068) — the spec chain, the testing plan, the
reviews, the security review and the approval gate alike — with exactly one exception:
phase-selection itself, which is required: true so the loop can never walk past the
act of choosing. That invariant is the floor now: not a list of phases that always run,
but a named human answering, up front, which ones do. The same gate also offers what
is not on by default (issue-188, decision-071): a node marked optIn is rendered
unticked and runs only if somebody ticks it — the loop ships one,
design-critic-review, a different model reading the locked design.md before the
testing plan and task DAG are derived from it. An operator can make the same
declaration with the-loop graph skip <id> --node <token> --reason <why>
(audited, like force). A declared skip is reported by the-loop check as
skipped by declaration with provenance — never as a pass. Never answer the
selection gate or run the skip verb from a working session: if phases seem
unnecessary, say so on the ticket and let a human declare it. The same reply also
answers the two questions that are not phases — where the outer loop is iterated
(issue-183) and how many sessions this item's pull requests get (issue-260,
pr-sessions-*, defaulting to the operator's routing.tmux.sessionPerPr) — and the
agent never ticks those rows either. See reference/workflow.md § Declared skips.
- Reference, don't duplicate (single source of truth). Once
requirements/design/testing-plan/tasks exist, update the ticket with a link to each
checked-in artifact. Subsequent
changes are edits to those files, not new comments.
- Capability docs are the organized view of specs. Raw specs under
docs/specs/<id>/ are the per-work-item record (deltas); living capability docs
under workflow.capabilitiesDir (default docs/capabilities/, indexed by
capabilities.md) are the single source of truth for a capability's current
behaviour (state), each behaviour traced by a history row to the specs/decisions
that produced it. Update the affected capability docs in the same PR as the work
item — a ready-to-ship gate item. Mint docs emergently (product-feature and
architecture shaped both valid) and evolve the taxonomy through PR-review feedback.
See reference/workflow.md.
- The user-facing docs ship with the change too. Capability docs serve a reader who
already uses the project;
README.md, the documentation site and this skill with its
reference/ docs are what a reader meets first, and they rot the same way. Update
whichever of them the change makes wrong in the same PR — also a ready-to-ship gate
item — and record what changed in the execution log's ## Documentation section,
which the capability-docs node gates alongside ## Capability docs (issue-174,
decision-066). A work item that changed no user-facing doc says so with the reason;
a blank is not an answer. The rule exists because the process itself changed shape —
two loops, a fourth spec artifact — while the front page went on describing the old one.
- Keep
tasks.md checkmarks current as tasks complete (- [ ] → - [x]).
- Identify collaborators up-front. Each work item names the personas it needs; not
every task needs every persona (a bug fix needs the engineer; a content fix may not).
More can be added later. See
reference/collaboration.md.
- Paper trail. Every human decision/opinion is captured on the ticket or PR.
Planning questions → ticket comments. PR & all reviews → PR/ticket comments.
Notify via configured messaging channels when a human action is pending.
- One work item, one origin repository; one contributing repository, one PR. The
outer loop runs in the repository the ticket was created in — the origin repository
— and the work item's one spec chain lives there. A work item that needs code in n
repositories raises n pull requests, one per repository, each walking its own
pdlc-pr-loop; the origin repository gets one only if it too receives code. Each inner
loop's state sits under the origin repo's spec directory, qualified by repository
(pr-loops/<owner>__<repo>/pr-<n>/), and a work item may declare those repositories
in execution-log.md's front matter (repos:) so await-inner-loops holds
implementation until every one of them has finished. See reference/workflow.md
§ Several repositories, one work item.
- Ask on the declared channel; iterate artifacts on a durable surface. A session the CLI daemon
drives is told where its answers come from (
routing.interaction.mode, rendered into
the prompt): work-item (the default) means every question is a comment on the ticket
or PR and the session then waits for the reply to arrive as an event — never block on
an interactive prompt, never read silence as consent; cli means a human is attached to
this terminal, so ask here and record the outcome on the ticket. Independently of
the mode: once an artifact exists (brainstorm.md, requirements.md/bugfix.md,
design.md, testing-plan.md, tasks.md), iterate on it only on a durable,
reviewable surface — never interactively, where the reasoning dies with the scrollback.
Which durable surface the outer loop uses is this work item's own choice,
made by its author at phase-selection and frozen there: the work item itself
(the default — comments on the ticket, Jira-style, so an item whose code lands
elsewhere opens no discussion-only PR) or a pull request in the origin repository
(the outer-loop-on-pull-request box). It is deliberately not a config key in any
file: one project has both a one-repo bugfix and a three-repo migration. Commit and
push the artifact either way and link it; never re-paste it into a comment. The
inner loop has no such choice — a PR's loop is iterated on that PR — and neither
does a contribution, which owns no outer loop and is never offered the box. See
reference/collaboration.md § Where questions go.
- RULE: mark every comment/reply as your own (loop prevention). You post as the
operator's own credentials, so an unmarked reply is indistinguishable from a human
one and can resume your own session forever. Before posting any comment, PR
review, or reply — not just review findings — append
<!-- the-loop:agent-comment -->
(exact string, invisible) plus a short visible attribution line. This applies at
every point above that posts a comment (paper trail, reviews, escalations, the PR
briefing). See reference/collaboration.md § loop prevention.
- Self-check continuously. Maintain
docs/specs/<id>/execution-log.md; keep the
phase label in sync; run tests at logical checkpoints; log progress for visibility.
- Manage the context window deliberately (checkpoint, then reset). Never reset
context without first checkpointing (checkmarks, execution-log entry with a concrete
next step, phase label, WIP committed/noted). Then: clear at phase boundaries
(locked spec → fresh window for implementation, plan-mode style), compact after
each completed task and mid-task (never clear mid-task), and isolate high-volume
exploration in subagents. The checked-in artifacts are the memory that makes resets
affordable (
contextManagement). See reference/context.md.
- Review before escalating. Run
reviews.selfReviewCount self-reviews then
reviews.criticReviewCount critic reviews (a different harness/model), default 3
each, BEFORE reaching out to a human. All reviews are comments. Follow the defined
procedure in reference/reviewing.md (attribution prefix, reply-first-then-fix,
stop on zero new findings, escalate on a repeated finding).
- Security is gated, not bolted on (
config.security). Every phase gate also asks
the security question: requirements carry a Security considerations
threat-model-lite (untrusted actors, trust boundaries, abuse cases, fail-closed);
design carries a Security design section enforcing those boundaries; the
ready-to-ship gate includes a security review (built-in security-review skill or
the-loop's checklist), with a named human sign-off at risk tier ≥
security.review.humanSignOffMinTier. "No new attack surface" is written and
justified, never implied. See reference/security.md.
- Test-first.
tdd.mode (default standard): no production code without a failing
test that motivates it; record the red→green transition as evidence.
- Plan the proof, then execute the plan. How a work item will be verified is an
artifact (
testing-plan.md), not an afterthought: the test-planning node decides
which kinds of testing apply — unit, integration, contract, e2e, UI/visual, snapshot,
performance, security/abuse-case, accessibility, migration, manual — and records
n/a with a reason for the ones that do not. The verification node then runs it,
ticks each activity only once it has actually run, and records per-activity command,
outcome and evidence. An activity that cannot run is not ticked: say why, replan or
escalate. See reference/testing.md.
- Evidence is captured, committed, and redacted. Test output, screenshots and
recordings live under
<specDir>/<id>/evidence/ and are committed with the work item —
a link to a CI run that expires is not evidence. Textual evidence is markdown
(.md), never .txt — titled, sectioned per command, with the raw output in fenced
blocks; binary captures keep their own formats and are referenced from it. UI
verification presents screenshots
of the verified states, and an animated capture (GIF) when the behaviour is a flow.
Because the directory is as public as the repository, redact tokens, cookies, personal
data and internal hostnames before committing; a capture that cannot be redacted is not
committed.
- the-loop facilitates verification; it does not own it. For anything beyond a single
repository — several checkouts, a staging environment, a bespoke harness — the plan's
Verification environment section declares what is needed (repos, services,
fixtures, credentials by reference only) and names the project's own commands. the-loop
brings no runner or environment manager of its own, and reads the operator's
customInstructions docs rather than restating them.
- Scenario-documented integration tests. Every integration test carries a
Gherkin-syntax docstring (
Feature:/Scenario:/Given-When-Then) naming the scenario
under test, with a Requirement: link when tied to a requirements.md
(config.testing). The harness can query all covered scenarios as a table via
the-loop scenarios (--format table|markdown|json). See reference/testing.md.
- Contract-first APIs. RESTful API specs are authored in
specs/openapi/ in the
OpenAPI format; GraphQL schemas are SDL-first under specs/graphql/; documentation is
generated from those contracts, never hand-written (config.apiSpecs). See
reference/testing.md.
- UI/UX design is a first-class artifact. For user-facing work,
design.md (markdown +
mermaid) is not enough — the visual design is tracked as artifacts under
docs/specs/<id>/design/ (design.uiArtifacts): Figma links and/or self-contained
HTML+CSS+JS prototypes (Claude-artifact style). They are iterated-until-locked with the
designer on the rendered output, referenced from the ticket, and become the visual
contract implementation matches. Backend/CLI/infra work produces none. See
reference/design-artifacts.md.
- Minimalism. Apply the
reference/minimalism.md decision ladder (YAGNI → stdlib →
native → existing dep → inline → new abstraction); justify every new dependency in
design.md. Never trade away validation/error-handling/security/accessibility.
- Write the artifacts for the human who has to approve them. Every document a person
reads —
requirements.md, design.md, testing-plan.md, the PR briefing, decision and
capability docs, ticket and review comments — follows the bundled the-loop:writing
skill (userInteraction.writingStyle): a four-part spine (what was broken → what we did
→ what it costs → what to check), conclusion-first sections, and draw it rather than
describe it where three or more named parts are involved
(writingStyle.diagramFirst). There is no length limit — scope is not knowable in
advance, so the test is density (can a sentence come out without losing information?),
and that is a review judgement, never a gate. Two things concision never buys: a gated
section is never deleted to shorten a document (say it is empty, and why), and the
formal registers stay formal — EARS criteria, abuse cases, RFC-2119 keywords, API
contracts and schema descriptions (writingStyle.formalRegisters) are contracts, not
prose. Distinct from
tokenEconomy.outputVerbosity, which compresses chat narration and preserves specs; this
governs the specs themselves. Rules and the tells catalogue live in the skill — do not
restate them here.
- Token economy. Apply the
reference/token-economy.md levers (config.tokenEconomy):
progressive/phase-scoped disclosure, dense prompts, model routing + thinking-effort by
stage/risk tier, narration-only output compression (with its preservation list),
sub-agent delegation for verbose work, compaction/filesystem-memory, and per-work-item
token telemetry. Advisory, never a gate — cheaper never means sloppier; the rigor
floor (validation/security/tests/paper-trail/review depth) is untouchable.
- Risk-tiered autonomy. Gate completion by the work item's risk tier
(
config.autonomy): low tiers may complete after the review loop; high tiers wait for
a human. Only complete autonomously once the ready-to-ship gate holds (green
checks, all threads resolved, evidence recorded).
- Keep moving; log conflicts. Resolvable ambiguity → assume a reasonable default and
continue; genuine block → log to
docs/decisions/conflicts.md, escalate once, move on.
- Learnings lifecycle. Capture → write-gate (rule-of-three) → consolidate (size cap)
→ inject a capped index (
config.selfImprovement), in the tree
workflow.learningsDir names (default docs/learnings). See reference/automation.md.
- Evidence at the end. Present validated evidence that acceptance criteria are met.
- Communicate for the reviewer (required gate). Before requesting human review,
post/update the reviewer briefing in the PR — produced from the-loop's internal
${CLAUDE_PLUGIN_ROOT}/skills/the-loop/templates/pr-briefing.md: a condensed,
prioritized summary (where to
focus first), the spec→implementation insights and low-level decisions, and mermaid
diagrams. This is a required item of the ready-to-ship gate
(userInteraction.prSummary.required), so mandatory user-education is triggered, not
optional — you cannot request review without it. See reference/collaboration.md.
- Honor the user's custom instructions. Read every doc registered in
customInstructions.docs (in order) when starting work on an item, and follow it —
these are the operator's conventions (developing/testing/coding styles, house rules)
that the structured config does not model. The structured config wins where both
speak, and no instruction doc can weaken the loop's gates (security, paper trail,
reviews); a missing doc is handled per customInstructions.onMissing. Run
the-loop instructions at the same time, so a registration that silently fails to
resolve is a signal rather than guidance you never received. See
reference/instructions.md.
- Use the configured tooling. Package managers, test runners, linters, type checkers
and release tooling come from
.the-loop/harness-config.yaml; run scripts from the project
root; lint ALL files including markdown. See reference/tooling.md.
- Same tooling everywhere. Pre-commit/pre-push hooks and CI run the SAME commands —
no last-minute build surprises.
- Conventional Commits. All commits follow Conventional Commits v1.0.0
(
<type>[scope][!]: <desc>), enforced by a commit-msg hook running commitizen
(cz check, not custom code) — hooks.commitConvention. See reference/tooling.md.
- Identical observability. Logging is the same at dev-time and runtime; the only dev
advantage is breakpoints. See
reference/observability.md.
Configuration
Behaviour is driven by .the-loop/harness-config.yaml (this repo's harness/plugin
config, formerly config.yaml — issue-82, decision-035), validated against
harness-config.schema.json. Sections: ticketing, repository,
workflow, tooling, customInstructions, testing, apiSpecs, design,
localOrchestration, hooks, observability, reviews, autonomy, security, tdd,
minimalism, tokenEconomy, selfImprovement, contextManagement, userInteraction,
notifications, externalTools. People (collaborators and the roles they hold — no
delivery config of their own, issue-304) live in .the-loop/collaborators.yaml
(validated against collaborators.schema.json) — the single source of truth;
notifications
references roles only. A subset of keys can be overridden per work
item via the YAML front-matter overrides of the work-item / spec markdown. Managed
files are listed in .the-loop/manifest.yaml.
The schemas are the plugin's, not the project's (issue-220). All three —
harness-config, collaborators, cli-config — ship under
${CLAUDE_PLUGIN_ROOT}/.the-loop/ (manifest.schemasDir, the same shape
manifest.templatesDir has for templates) and are read from there whenever a config is
validated or the onboarding walkthrough is driven. Never copy one into a project, and
never fetch one over the network. A scaffolded config carries the schema's published URL
in a # yaml-language-server: $schema=… first line so an operator's editor validates
it; that comment is for the editor alone and is never what the loop validates against.
A repository that has never run /the-loop:init is worked under the built-in default
— the same baseline --defaults writes, shipped inside the CLI — and the-loop writes it
into .the-loop/harness-config.yaml the first time it works there, so the config is a
file you can read and edit rather than an assumption (issue-193, decision-073). It never
overwrites an existing config, and a contribution adopts nothing: see
reference/automation.md.
The CLI daemon (gh-webhook/poll/sessions/events) reads a separate, independent
CLI config instead (webhooks, polling, eventLog) — it is not tied to this
repo. See docs/config/ (the configuration reference) and
docs/decisions/decision-032.md.
Commands
/the-loop:init — scaffold the-loop into a repo (config, docs, templates, phase labels).
/the-loop:work-on <ticket> — run the whole loop on a work item (resumable per phase).
Superset of the granular commands below.
/the-loop:upgrade-the-loop — reconcile project files with the installed plugin version.
Granular commands (one step at a time; same flow work-on runs end-to-end):
/the-loop:brainstorm <title> — (optional Phase 0) draft a free-form brainstorm.md
scratchpad (the root artifact) in docs/specs/draft-<slug>/ for a fuzzy idea; iterate,
then convert to requirements.
/the-loop:new-requirement <title> — draft requirements.md in a temporary
docs/specs/draft-<slug>/ folder before a ticket exists (converts a sibling
brainstorm.md if one is present).
/the-loop:create-ticket <path> — create the ticket from a requirements.md and
promote draft-<slug>/ → docs/specs/<id>/.
/the-loop:create-design <id> — requirements.md → design.md (Phase 2).
/the-loop:create-testing-plan <id> — requirements + design → testing-plan.md.
/the-loop:create-tasks-plan <id> — requirements + design + testing plan → tasks.md DAG.
/the-loop:execute-tasks <id> — implement the DAG, self-check, self/critic-review.
/the-loop:verify-work <id> — execute the testing plan; record results and evidence.
/the-loop:finish-tasks <id> — cleanup after all tasks (close the ticket; extensible).
/the-loop:work-status <id> — read-only status from the specs, tasks checkmarks and log.
/the-loop:contribute-to <id> — join an existing, in-progress work item as a
contributor: walk pdlc-contribution-loop toward the human-stated goal and success
criteria (issue-185).
/the-loop:do-task <id> — do an ad-hoc, tactical task with no PDLC process: walk
pdlc-adhoc-loop, author no spec chain, ask follow-ups on the thread, and continue
until the requester declares it done (issue-225).
/the-loop:review-pr <id> — review a pull request against an authorized
reviewer's brief: walk pdlc-review-loop, answer every question, examine every
angle, run every validation, converse until the reviewer says done — and change no
code (issue-279).
Knowledge the loop maintains
docs/specs/<id>/brainstorm.md — (optional) the root scratchpad a work item was
explored in before requirements.
docs/specs/<id>/testing-plan.md + docs/specs/<id>/evidence/ — how the work item is
proved, and the committed proof.
docs/architecture/architecture.md — architecture index → sub-component docs.
docs/capabilities/capabilities.md + <capability>.md — living capability docs:
the organized view of specs; current behaviour per capability with history links.
docs/decisions/decisions.md + decision-<nnn>.md — decision log (every durable
decision is recorded).
docs/specs/<id>/ — the per-work-item 3-phase spec + execution log.
<learningsDir>/learnings.md + learning-<nnn>.md — learnings from user & system
feedback, checked in for review. workflow.learningsDir (default docs/learnings), so
the tree sits wherever this project keeps the documents the loop maintains. See
reference/automation.md.
Interacting with other tools
the-loop may freely use the MCP servers, CLIs, skills and plugins registered in
config.externalTools (the externalTools.tools list + notes in
.the-loop/harness-config.yaml). Check that registry before assuming a capability is available.
Custom instructions the loop honors
Supplementary to the external-tools registry, config.customInstructions registers
guidance rather than tools: user-provided readme/markdown docs (per installation,
configurable paths) the harness reads at the start of working an item and follows —
conventions and styles the structured config does not model. Precedence and limits:
reference/instructions.md.
1---2name: the-loop3description: The operating model for delivering product work items end-to-end with an agent harness. Use whenever working a ticket/issue under the-loop — to write the spec chain (requirements/design/testing-plan/tasks), execute the task DAG, verify against the testing plan, self/critic-review, escalate, present evidence, and record decisions and learnings under the project's PDLC rules and tooling.4---56# the-loop78"the-loop" is an opinionated product-development-lifecycle (PDLC) harness, shipped as a9plugin for Claude Code and Cursor. Once a work item's spec chain (requirements → design10→ testing plan → tasks) is approved, the harness executes it end-to-end with MINIMAL or11NO human intervention, escalating only when a decision/opinion is genuinely required.1213> **Read the relevant reference file before acting** — they carry the full detail so the14> essence is not lost:15> - `reference/workflow.md` — the loop, phases, TDD, reviews, autonomy, DAG, resumability.16> - `reference/context.md` — context-window management: clearing vs compaction, the checkpoint-then-reset protocol, per-harness mechanics.17> - `reference/onboarding.md` — the guided, schema-driven config onboarding `/init` runs (groups, ask levels, sensible-defaults precedence).18> - `reference/instructions.md` — user-provided custom instruction docs (`customInstructions`): when to read them, precedence, what they can and cannot override.19> - `reference/design-artifacts.md` — UI/UX design artifacts (Figma / HTML prototypes) in the design phase and the designer iteration loop.20> - `reference/reviewing.md` — the self/critic review procedure the review counts drive.21> - `reference/security.md` — the security lens on every phase gate: threat-model-lite, security design, the security-review gate, human sign-off tiers.22> - `reference/tooling.md` — repo management, per-language tooling matrix, hooks, CI parity.23> - `reference/testing.md` — the testing plan and the verification node (test-type matrix, verification environment, evidence and redaction), Gherkin scenario docstrings on integration tests, the queryable scenario view, OpenAPI/GraphQL contract conventions.24> - `reference/minimalism.md` — generation-time decision ladder to counter code bloat.25> - `reference/token-economy.md` — token/cost levers (model routing, verbosity, disclosure, sub-agents, telemetry); advisory, never at the expense of rigor.26> - `reference/collaboration.md` — collaborators/roles, paper trail, **the self-comment loop-prevention marker (every reply MUST carry it)**, conflict log, notifications, MCP.27> - `reference/observability.md` — dev==runtime logging, levels, browser logging.28> - `reference/automation.md` — distribution, the CLI, webhooks, predictability, learnings lifecycle.29>30> One rule lives in a **sibling skill** rather than a reference file, because it applies31> outside a work item too: **`the-loop:writing`** (`skills/writing/`) — how every artifact32> a human reads is written.3334## The artifact chain (optional brainstorm → spec → testing plan, Kiro-style)3536Every work item is a chain of artifacts, each **derived from and iterated after** the one37before it. An artifact with a human gate is refined with feedback **at that gate** until38the gate **locks** it (`status: approved`) — and the gate is the *only* locker39(issue-281): when it classifies an authorized approval it writes the status and the40approver into the front matter itself. The session never sets `status: approved` and41never requests an approval of its own — one gate, one human reply. An artifact **without**42a gate (`brainstorm.md`, `tasks.md`) advances on shape alone, with no human stop. Specs43live in `docs/specs/<id>/`:44450. **`brainstorm.md`** *(optional, the root artifact)* — a free-form scratchpad to explore46 a fuzzy idea before committing to requirements: problem, options, open questions,47 working hypothesis. Created by `/the-loop:brainstorm`; converted to requirements once48 its author says it has converged — it has no approval gate, so it is never49 `status: approved` (issue-281). Phase: `brainstorming`. Skip it when the work is50 already clear.511. **`requirements.md`** (or **`bugfix.md`** for bugs) — user stories + EARS acceptance52 criteria (`WHEN <event> THEN the system SHALL <response>`). Phase: `requirements-definition`.53 Both names clear the same gate, and **exactly one of them may be present** — two would54 leave the gate with no defined source of truth, so it blocks (decision-045). Whichever55 name it carries, the artifact needs the same `## Requirements` and56 `## Security considerations` sections; both bundled templates provide them.572. **`design.md`** — architecture, components/interfaces, data models, error handling,58 testing strategy. Phase: `design`. For a **user-facing** work item the design phase also59 tracks **UI/UX design artifacts** (Figma links / self-contained HTML prototypes under60 `docs/specs/<id>/design/`), iterated-until-locked with the designer61 (`reference/design-artifacts.md`).623. **`testing-plan.md`** — how this work item will be **proved**: a matrix of testing63 types (each either in scope, or `n/a` *with a reason*), the verification environment,64 the evidence to capture, and the activities checklist. Phase: `test-planning`.65 Derived from `design.md` and **reviewed together with it** — one human gate66 (`design-approval`) approves **and locks** the pair, so the plan gets human review67 without a stop of its own. It is authored here and **completed at the68 `verification` node** — one artifact, written once as a plan and once as a record.69 See `reference/testing.md`.704. **`tasks.md`** — a **DAG** of small, verifiable tasks referencing requirements; each71 task's `_Test:_` names a row of the testing plan. Phase: `tasks-breakdown`. Derived72 mechanically from the two artifacts the human just approved, so it has **no approval73 gate and needs no human sign-off** (issue-281) — it advances on shape alone.7475The work item's **phase** is tracked on the ticket via a label76(`<workflow.phaseLabelPrefix><phase>`) and mirrored in the execution log (`brainstorming`77is optional):7879```80not-started → brainstorming → requirements-definition → design → test-planning81 → tasks-breakdown → implementation → verification → needs-review → complete82```8384This sequence is **defined by the shipped process graph**85(`cli/the_loop/graph/pdlc-work-item-loop.yaml` — the **outer loop**, walked in the86repository the ticket was created in; each PR delivering a work item walks its own87`pdlc-pr-loop` in its own session — one per contributing repository — and the88outer `implementation` node waits for those inner loops to finish); the prose89here renders it, never redefines it (issue-148). A third shipped graph,90`pdlc-contribution-loop` (issue-185), is walked instead of the outer loop when91the-loop is **invited into an existing, in-progress work item as a92contributor** (`the-loop contribute`): it cannot start without an authorized93human's **goal and success criteria**, plans in one `contribution.md` instead94of the four-file spec chain, and completes only when every stated criterion is95met — see `reference/workflow.md` § The contribution loop. A fourth,96`pdlc-adhoc-loop` (issue-225), is the smallest of them: a **tactical task that97runs no PDLC process at all** (`the-loop do`) — `work → review → complete`, no98spec chain, no phase selection, no artifact gates, no review chain, finished99when the requester says so. See `reference/workflow.md` § The ad-hoc loop. A100fifth, `pdlc-review-loop` (issue-279), makes the-loop the **reviewer of a pull101request rather than its author** (`the-loop review`, binding to the PR itself):102no brief, no review — an authorized reviewer's questions/angles/validations are103frozen first — then review rounds and follow-ups on the thread until the104reviewer says done, with **no code changed**. See `reference/workflow.md`105§ The review loop.106When a node's work is done, tell the graph so —107`the-loop graph complete <id>` — rather than only narrating the transition.108109See `reference/workflow.md` for what each phase contains, the review gates, the110self/critic-review counts, evidence, resumability and DAG orchestration.111112## Operating principles (rules)113114- **Every work item has a ticket.** Nothing the harness works on lacks a GH issue (or115 Jira) ticket.116- **Spec before execution.** Create the spec chain and get each phase117 reviewed/approved by the required collaborators before writing code.118- **Approvals are owned by approval nodes** (issue-281). The graph's human gates119 (`requirements-approval`, `design-approval`, and `human-approval` on the PR) are where120 feedback is classified and where locking happens: an authorized approval at the gate121 writes `status: approved` and the approver into the artifact via `lock-artifacts`.122 **Never set `status: approved` yourself, and never post an approval request of your123 own** — the gate's `request-review` is the one ask, and a session-invented stop just124 costs the human a second approval the gate will discard. An artifact whose gate lies125 ahead is complete when its sections are; iterate it with the feedback the gate126 records into it.127- **Gate-less artifacts advance on shape alone.** `brainstorm.md` and `tasks.md` have no128 approval node — do not hold them for a human "approved". `tasks.md` is derived from129 the pair the human just approved at `design-approval`; the brainstorm converges when130 its author says so on the thread. Never write a downstream artifact against an131 upstream one whose gate has not yet approved it.132- **Human review per phase** (`workflow.requireHumanReviewPerPhase`, default true) —133 delivered by the graph's approval nodes, never re-implemented in a session.134- **Skips are declared by humans, never taken by the harness** (issue-177,135 decision-067). Every work item starts at **`phase-selection`**: the-loop posts a136 checklist of the selectable phases on the ticket and waits for an **authorized user**137 to reply with the ones to keep plus `the-loop execute`. **Every phase of the outer loop138 is selectable** (issue-179, decision-068) — the spec chain, the testing plan, the139 reviews, the security review and the approval gate alike — with exactly one exception:140 `phase-selection` itself, which is `required: true` so the loop can never walk past the141 act of choosing. That invariant is the floor now: not a list of phases that always run,142 but a named human answering, up front, which ones do. **The same gate also offers what143 is *not* on by default** (issue-188, decision-071): a node marked `optIn` is rendered144 unticked and runs only if somebody ticks it — the loop ships one,145 `design-critic-review`, a different model reading the locked `design.md` before the146 testing plan and task DAG are derived from it. An operator can make the same147 declaration with `the-loop graph skip <id> --node <token> --reason <why>`148 (audited, like `force`). A declared skip is reported by `the-loop check` as149 *skipped by declaration* with provenance — never as a pass. **Never answer the150 selection gate or run the skip verb from a working session**: if phases seem151 unnecessary, say so on the ticket and let a human declare it. The same reply also152 answers the two questions that are **not** phases — where the outer loop is iterated153 (issue-183) and how many sessions this item's pull requests get (issue-260,154 `pr-sessions-*`, defaulting to the operator's `routing.tmux.sessionPerPr`) — and the155 agent never ticks those rows either. See `reference/workflow.md` § Declared skips.156- **Reference, don't duplicate (single source of truth).** Once157 requirements/design/testing-plan/tasks exist, update the ticket with a **link** to each158 checked-in artifact. Subsequent159 changes are **edits to those files, not new comments**.160- **Capability docs are the organized view of specs.** Raw specs under161 `docs/specs/<id>/` are the per-work-item record (*deltas*); living capability docs162 under `workflow.capabilitiesDir` (default `docs/capabilities/`, indexed by163 `capabilities.md`) are the **single source of truth for a capability's *current*164 behaviour** (*state*), each behaviour traced by a history row to the specs/decisions165 that produced it. Update the affected capability docs **in the same PR** as the work166 item — a ready-to-ship gate item. Mint docs emergently (product-feature and167 architecture shaped both valid) and evolve the taxonomy through PR-review feedback.168 See `reference/workflow.md`.169- **The user-facing docs ship with the change too.** Capability docs serve a reader who170 already uses the project; `README.md`, the documentation site and this skill with its171 `reference/` docs are what a reader meets *first*, and they rot the same way. Update172 whichever of them the change makes wrong **in the same PR** — also a ready-to-ship gate173 item — and record what changed in the execution log's **`## Documentation`** section,174 which the `capability-docs` node gates alongside `## Capability docs` (issue-174,175 decision-066). A work item that changed no user-facing doc says so **with the reason**;176 a blank is not an answer. The rule exists because the process itself changed shape —177 two loops, a fourth spec artifact — while the front page went on describing the old one.178- **Keep `tasks.md` checkmarks current** as tasks complete (`- [ ]` → `- [x]`).179- **Identify collaborators up-front.** Each work item names the personas it needs; not180 every task needs every persona (a bug fix needs the engineer; a content fix may not).181 More can be added later. See `reference/collaboration.md`.182- **Paper trail.** Every human decision/opinion is captured on the ticket or PR.183 Planning questions → ticket comments. PR & all reviews → PR/ticket comments.184 Notify via configured messaging channels when a human action is pending.185- **One work item, one origin repository; one contributing repository, one PR.** The186 outer loop runs in the repository the ticket was created in — the **origin** repository187 — and the work item's one spec chain lives there. A work item that needs code in *n*188 repositories raises *n* pull requests, one per repository, each walking its own189 `pdlc-pr-loop`; the origin repository gets one only if it too receives code. Each inner190 loop's state sits under the origin repo's spec directory, qualified by repository191 (`pr-loops/<owner>__<repo>/pr-<n>/`), and a work item may **declare** those repositories192 in `execution-log.md`'s front matter (`repos:`) so `await-inner-loops` holds193 `implementation` until every one of them has finished. See `reference/workflow.md`194 § Several repositories, one work item.195- **Ask on the declared channel; iterate artifacts on a durable surface.** A session the CLI daemon196 drives is *told* where its answers come from (`routing.interaction.mode`, rendered into197 the prompt): `work-item` (the default) means every question is a **comment on the ticket198 or PR** and the session then waits for the reply to arrive as an event — never block on199 an interactive prompt, never read silence as consent; `cli` means a human is attached to200 this terminal, so ask here and record the *outcome* on the ticket. **Independently of201 the mode:** once an artifact exists (`brainstorm.md`, `requirements.md`/`bugfix.md`,202 `design.md`, `testing-plan.md`, `tasks.md`), iterate on it **only** on a durable,203 reviewable surface — never interactively, where the reasoning dies with the scrollback.204 Which durable surface the **outer** loop uses is **this work item's own choice**,205 made by its author at `phase-selection` and frozen there: the **work item** itself206 (the default — comments on the ticket, Jira-style, so an item whose code lands207 elsewhere opens no discussion-only PR) or a **pull request** in the origin repository208 (the `outer-loop-on-pull-request` box). It is deliberately not a config key in any209 file: one project has both a one-repo bugfix and a three-repo migration. Commit and210 push the artifact either way and link it; never re-paste it into a comment. The211 **inner** loop has no such choice — a PR's loop is iterated on that PR — and neither212 does a **contribution**, which owns no outer loop and is never offered the box. See213 `reference/collaboration.md` § Where questions go.214- **RULE: mark every comment/reply as your own (loop prevention).** You post as the215 operator's own credentials, so an unmarked reply is indistinguishable from a human216 one and can resume your own session forever. Before posting **any** comment, PR217 review, or reply — not just review findings — append `<!-- the-loop:agent-comment -->`218 (exact string, invisible) plus a short visible attribution line. This applies at219 every point above that posts a comment (paper trail, reviews, escalations, the PR220 briefing). See `reference/collaboration.md` § loop prevention.221- **Self-check continuously.** Maintain `docs/specs/<id>/execution-log.md`; keep the222 phase label in sync; run tests at logical checkpoints; log progress for visibility.223- **Manage the context window deliberately (checkpoint, then reset).** Never reset224 context without first checkpointing (checkmarks, execution-log entry with a concrete225 next step, phase label, WIP committed/noted). Then: **clear** at phase boundaries226 (locked spec → fresh window for implementation, plan-mode style), **compact** after227 each completed task and mid-task (never clear mid-task), and isolate high-volume228 exploration in subagents. The checked-in artifacts are the memory that makes resets229 affordable (`contextManagement`). See `reference/context.md`.230- **Review before escalating.** Run `reviews.selfReviewCount` self-reviews then231 `reviews.criticReviewCount` critic reviews (a different harness/model), default 3232 each, BEFORE reaching out to a human. All reviews are comments. **Follow the defined233 procedure** in `reference/reviewing.md` (attribution prefix, reply-first-then-fix,234 stop on zero new findings, escalate on a repeated finding).235- **Security is gated, not bolted on** (`config.security`). Every phase gate also asks236 the security question: requirements carry a **Security considerations**237 threat-model-lite (untrusted actors, trust boundaries, abuse cases, fail-closed);238 design carries a **Security design** section enforcing those boundaries; the239 ready-to-ship gate includes a **security review** (built-in security-review skill or240 the-loop's checklist), with a named human sign-off at risk tier ≥241 `security.review.humanSignOffMinTier`. "No new attack surface" is written and242 justified, never implied. See `reference/security.md`.243- **Test-first.** `tdd.mode` (default `standard`): no production code without a failing244 test that motivates it; record the red→green transition as evidence.245- **Plan the proof, then execute the plan.** How a work item will be verified is an246 artifact (`testing-plan.md`), not an afterthought: the `test-planning` node decides247 which kinds of testing apply — unit, integration, contract, e2e, UI/visual, snapshot,248 performance, security/abuse-case, accessibility, migration, manual — and records249 `n/a` **with a reason** for the ones that do not. The `verification` node then runs it,250 ticks each activity only once it has actually run, and records per-activity command,251 outcome and evidence. An activity that cannot run is **not** ticked: say why, replan or252 escalate. See `reference/testing.md`.253- **Evidence is captured, committed, and redacted.** Test output, screenshots and254 recordings live under `<specDir>/<id>/evidence/` and are committed with the work item —255 a link to a CI run that expires is not evidence. **Textual evidence is markdown256 (`.md`), never `.txt`** — titled, sectioned per command, with the raw output in fenced257 blocks; binary captures keep their own formats and are referenced from it. UI258 verification presents screenshots259 of the verified states, and an animated capture (GIF) when the behaviour is a *flow*.260 Because the directory is as public as the repository, redact tokens, cookies, personal261 data and internal hostnames before committing; a capture that cannot be redacted is not262 committed.263- **the-loop facilitates verification; it does not own it.** For anything beyond a single264 repository — several checkouts, a staging environment, a bespoke harness — the plan's265 **Verification environment** section *declares* what is needed (repos, services,266 fixtures, credentials **by reference only**) and names the project's own commands. the-loop267 brings no runner or environment manager of its own, and reads the operator's268 `customInstructions` docs rather than restating them.269- **Scenario-documented integration tests.** Every integration test carries a270 Gherkin-syntax docstring (`Feature:`/`Scenario:`/Given-When-Then) naming the scenario271 under test, with a `Requirement:` link when tied to a `requirements.md`272 (`config.testing`). The harness can query all covered scenarios as a table via273 `the-loop scenarios` (`--format table|markdown|json`). See `reference/testing.md`.274- **Contract-first APIs.** RESTful API specs are authored in `specs/openapi/` in the275 OpenAPI format; GraphQL schemas are SDL-first under `specs/graphql/`; documentation is276 generated from those contracts, never hand-written (`config.apiSpecs`). See277 `reference/testing.md`.278- **UI/UX design is a first-class artifact.** For user-facing work, `design.md` (markdown +279 mermaid) is not enough — the **visual** design is tracked as artifacts under280 `docs/specs/<id>/design/` (`design.uiArtifacts`): Figma links and/or self-contained281 HTML+CSS+JS prototypes (Claude-artifact style). They are iterated-until-locked with the282 **designer** on the *rendered* output, referenced from the ticket, and become the visual283 contract implementation matches. Backend/CLI/infra work produces none. See284 `reference/design-artifacts.md`.285- **Minimalism.** Apply the `reference/minimalism.md` decision ladder (YAGNI → stdlib →286 native → existing dep → inline → new abstraction); justify every new dependency in287 `design.md`. Never trade away validation/error-handling/security/accessibility.288- **Write the artifacts for the human who has to approve them.** Every document a person289 reads — `requirements.md`, `design.md`, `testing-plan.md`, the PR briefing, decision and290 capability docs, ticket and review comments — follows the bundled **`the-loop:writing`**291 skill (`userInteraction.writingStyle`): a four-part spine (what was broken → what we did292 → what it costs → what to check), conclusion-first sections, and **draw it rather than293 describe it** where three or more named parts are involved294 (`writingStyle.diagramFirst`). **There is no length limit** — scope is not knowable in295 advance, so the test is *density* (can a sentence come out without losing information?),296 and that is a review judgement, never a gate. Two things concision never buys: a **gated297 section is never deleted to shorten a document** (say it is empty, and why), and the298 **formal registers stay formal** — EARS criteria, abuse cases, RFC-2119 keywords, API299 contracts and schema descriptions (`writingStyle.formalRegisters`) are contracts, not300 prose. Distinct from301 `tokenEconomy.outputVerbosity`, which compresses chat narration and preserves specs; this302 governs the specs themselves. Rules and the tells catalogue live in the skill — do not303 restate them here.304- **Token economy.** Apply the `reference/token-economy.md` levers (`config.tokenEconomy`):305 progressive/phase-scoped disclosure, dense prompts, model routing + thinking-effort by306 stage/risk tier, narration-only output compression (with its preservation list),307 sub-agent delegation for verbose work, compaction/filesystem-memory, and per-work-item308 token telemetry. **Advisory, never a gate** — cheaper never means sloppier; the rigor309 floor (validation/security/tests/paper-trail/review depth) is untouchable.310- **Risk-tiered autonomy.** Gate completion by the work item's risk tier311 (`config.autonomy`): low tiers may complete after the review loop; high tiers wait for312 a human. Only complete autonomously once the **ready-to-ship gate** holds (green313 checks, all threads resolved, evidence recorded).314- **Keep moving; log conflicts.** Resolvable ambiguity → assume a reasonable default and315 continue; genuine block → log to `docs/decisions/conflicts.md`, escalate once, move on.316- **Learnings lifecycle.** Capture → write-gate (rule-of-three) → consolidate (size cap)317 → inject a capped index (`config.selfImprovement`), in the tree318 `workflow.learningsDir` names (default `docs/learnings`). See `reference/automation.md`.319- **Evidence at the end.** Present validated evidence that acceptance criteria are met.320- **Communicate for the reviewer (required gate).** Before requesting human review,321 post/update the **reviewer briefing** in the PR — produced from the-loop's internal322 `${CLAUDE_PLUGIN_ROOT}/skills/the-loop/templates/pr-briefing.md`: a **condensed,323 prioritized** summary (where to324 focus first), the spec→implementation insights and low-level decisions, and **mermaid**325 diagrams. This is a required item of the ready-to-ship gate326 (`userInteraction.prSummary.required`), so **mandatory user-education is triggered, not327 optional** — you cannot request review without it. See `reference/collaboration.md`.328- **Honor the user's custom instructions.** Read every doc registered in329 `customInstructions.docs` (in order) when starting work on an item, and follow it —330 these are the operator's conventions (developing/testing/coding styles, house rules)331 that the structured config does not model. The structured config wins where both332 speak, and no instruction doc can weaken the loop's gates (security, paper trail,333 reviews); a missing doc is handled per `customInstructions.onMissing`. Run334 `the-loop instructions` at the same time, so a registration that silently fails to335 resolve is a signal rather than guidance you never received. See336 `reference/instructions.md`.337- **Use the configured tooling.** Package managers, test runners, linters, type checkers338 and release tooling come from `.the-loop/harness-config.yaml`; run scripts from the project339 root; lint ALL files including markdown. See `reference/tooling.md`.340- **Same tooling everywhere.** Pre-commit/pre-push hooks and CI run the SAME commands —341 no last-minute build surprises.342- **Conventional Commits.** All commits follow Conventional Commits v1.0.0343 (`<type>[scope][!]: <desc>`), enforced by a commit-msg hook running **commitizen**344 (`cz check`, not custom code) — `hooks.commitConvention`. See `reference/tooling.md`.345- **Identical observability.** Logging is the same at dev-time and runtime; the only dev346 advantage is breakpoints. See `reference/observability.md`.347348## Configuration349350Behaviour is driven by `.the-loop/harness-config.yaml` (this repo's **harness/plugin351config**, formerly `config.yaml` — issue-82, decision-035), validated against352`harness-config.schema.json`. Sections: `ticketing`, `repository`,353`workflow`, `tooling`, `customInstructions`, `testing`, `apiSpecs`, `design`,354`localOrchestration`, `hooks`, `observability`, `reviews`, `autonomy`, `security`, `tdd`,355`minimalism`, `tokenEconomy`, `selfImprovement`, `contextManagement`, `userInteraction`,356`notifications`, `externalTools`. People (collaborators and the roles they hold — no357delivery config of their own, issue-304) live in `.the-loop/collaborators.yaml`358(validated against `collaborators.schema.json`) — the single source of truth;359`notifications`360references roles only. A subset of keys can be overridden per work361item via the YAML front-matter `overrides` of the work-item / spec markdown. Managed362files are listed in `.the-loop/manifest.yaml`.363364**The schemas are the plugin's, not the project's** (issue-220). All three —365`harness-config`, `collaborators`, `cli-config` — ship under366`${CLAUDE_PLUGIN_ROOT}/.the-loop/` (`manifest.schemasDir`, the same shape367`manifest.templatesDir` has for templates) and are read from there whenever a config is368validated or the onboarding walkthrough is driven. Never copy one into a project, and369never fetch one over the network. A scaffolded config carries the schema's published URL370in a `# yaml-language-server: $schema=…` **first line** so an operator's editor validates371it; that comment is for the editor alone and is never what the loop validates against.372373A repository that has never run `/the-loop:init` is worked under the **built-in default**374— the same baseline `--defaults` writes, shipped inside the CLI — and the-loop writes it375into `.the-loop/harness-config.yaml` the first time it works there, so the config is a376file you can read and edit rather than an assumption (issue-193, decision-073). It never377overwrites an existing config, and a **contribution** adopts nothing: see378`reference/automation.md`.379380The CLI daemon (`gh-webhook`/`poll`/`sessions`/`events`) reads a separate, independent381**CLI config** instead (`webhooks`, `polling`, `eventLog`) — it is not tied to this382repo. See `docs/config/` (the configuration reference) and383`docs/decisions/decision-032.md`.384385## Commands386387- `/the-loop:init` — scaffold the-loop into a repo (config, docs, templates, phase labels).388- `/the-loop:work-on <ticket>` — run the whole loop on a work item (resumable per phase).389 **Superset** of the granular commands below.390- `/the-loop:upgrade-the-loop` — reconcile project files with the installed plugin version.391392Granular commands (one step at a time; same flow `work-on` runs end-to-end):393394- `/the-loop:brainstorm <title>` — *(optional Phase 0)* draft a free-form `brainstorm.md`395 scratchpad (the root artifact) in `docs/specs/draft-<slug>/` for a fuzzy idea; iterate,396 then convert to requirements.397- `/the-loop:new-requirement <title>` — draft `requirements.md` in a temporary398 `docs/specs/draft-<slug>/` folder **before a ticket exists** (converts a sibling399 `brainstorm.md` if one is present).400- `/the-loop:create-ticket <path>` — create the ticket from a `requirements.md` and401 promote `draft-<slug>/` → `docs/specs/<id>/`.402- `/the-loop:create-design <id>` — `requirements.md` → `design.md` (Phase 2).403- `/the-loop:create-testing-plan <id>` — requirements + design → `testing-plan.md`.404- `/the-loop:create-tasks-plan <id>` — requirements + design + testing plan → `tasks.md` DAG.405- `/the-loop:execute-tasks <id>` — implement the DAG, self-check, self/critic-review.406- `/the-loop:verify-work <id>` — execute the testing plan; record results and evidence.407- `/the-loop:finish-tasks <id>` — cleanup after all tasks (close the ticket; extensible).408- `/the-loop:work-status <id>` — read-only status from the specs, tasks checkmarks and log.409- `/the-loop:contribute-to <id>` — join an **existing, in-progress** work item as a410 contributor: walk `pdlc-contribution-loop` toward the human-stated goal and success411 criteria (issue-185).412- `/the-loop:do-task <id>` — do an **ad-hoc, tactical** task with no PDLC process: walk413 `pdlc-adhoc-loop`, author no spec chain, ask follow-ups on the thread, and continue414 until the requester declares it done (issue-225).415- `/the-loop:review-pr <id>` — **review** a pull request against an authorized416 reviewer's brief: walk `pdlc-review-loop`, answer every question, examine every417 angle, run every validation, converse until the reviewer says done — and change no418 code (issue-279).419420## Knowledge the loop maintains421422- `docs/specs/<id>/brainstorm.md` — *(optional)* the root scratchpad a work item was423 explored in before requirements.424- `docs/specs/<id>/testing-plan.md` + `docs/specs/<id>/evidence/` — how the work item is425 proved, and the committed proof.426- `docs/architecture/architecture.md` — architecture index → sub-component docs.427- `docs/capabilities/capabilities.md` + `<capability>.md` — living capability docs:428 the organized view of specs; current behaviour per capability with history links.429- `docs/decisions/decisions.md` + `decision-<nnn>.md` — decision log (every durable430 decision is recorded).431- `docs/specs/<id>/` — the per-work-item 3-phase spec + execution log.432- `<learningsDir>/learnings.md` + `learning-<nnn>.md` — learnings from user & system433 feedback, checked in for review. `workflow.learningsDir` (default `docs/learnings`), so434 the tree sits wherever this project keeps the documents the loop maintains. See435 `reference/automation.md`.436437## Interacting with other tools438439the-loop may freely use the MCP servers, CLIs, skills and plugins registered in440`config.externalTools` (the `externalTools.tools` list + `notes` in441`.the-loop/harness-config.yaml`). Check that registry before assuming a capability is available.442443## Custom instructions the loop honors444445Supplementary to the external-tools registry, `config.customInstructions` registers446**guidance** rather than tools: user-provided readme/markdown docs (per installation,447configurable paths) the harness reads at the start of working an item and follows —448conventions and styles the structured config does not model. Precedence and limits:449`reference/instructions.md`.