Goal Loop
Operator-invoked objective loop. Turn a bounded goal into success criteria, execute small passes, verify, and loop only on remaining gaps. Stop cleanly when the goal is complete, blocked, or the loop budget is exhausted.
Invocation Boundary
- Run only when the operator explicitly asks for or equivalent loop/until-done behavior.
- Use for non-ticket objectives, refactors, cleanup, docs rewrites, or follow-up work after a ticket.
- Do not replace for ticket lifecycle planning, and do not replace for review-only cleanup of an existing diff.
- Never stage, commit, push, continue a git operation, or invoke .
Arguments
Parse these optional flags before reading files:
| Flag | Meaning |
|---|
| Use an existing plan as the goal source. |
| Limit reads and edits to a path or package. |
| Verification command to run after each round. |
| Loop budget. Default ; hard cap unless the operator explicitly confirms after round 5. |
| After all criteria pass, run one single-pass quality gate on the loop's diff against the shared review rubric. |
Everything else is the goal text.
Goal Contract
Before editing, write a compact contract:
markdown
Goal: <one sentence>
Scope: <files/packages allowed, or "current diff" / "ask required">
Success criteria:
- [ ] <criterion 1>
- [ ] <criterion 2>
Verification:
- <command or manual/static check>
Loop budget: <N> rounds
Stop conditions: complete | blocked | budget exhausted | human decision needed
If the goal, scope, success criteria, or verification cannot be stated concretely, stop and ask one clarifying question. Never start broad cleanup from a vague goal such as "clean the repo" without an explicit scope.
Loop
For each round, up to the loop budget:
- Inspect. Read the goal source, current , relevant project rules (
.turkit.yaml -> rules.docs
, else / / when present), and only the files needed for the current round.
- Plan the round. Pick the smallest set of edits that can satisfy the next unmet criteria. If a change would expand scope, stop and ask.
- Edit. Apply changes in place. Keep edits focused on the contract. Do not batch unrelated cleanup.
- Verify. Run when provided. Otherwise resolve the project / / command per
references/build-tool-detection.md
and run the narrowest relevant gate. If no command is available, do a static self-check and mark verification as .
- Score. Mark each success criterion as , , or . Continue only for concrete gaps that can be safely fixed inside the scope.
Stop early when all criteria are
and verification passes. If the same verification failure survives two rounds, stop as
and report it instead of looping blindly.
Quality gate ( only). When all criteria are
and verification passes, review the diff the loop produced against
references/review-rubric.md
: apply its Auto-fix bucket, then treat remaining P0/P1 findings as gaps for
at most one extra round. Never loop the gate; findings that survive that round go under
in the report.
Orchestration & Platform
Use parallel subagents only for read-only investigation, such as surveying candidate files or checking whether a criterion is satisfied. The main agent applies all edits. If subagents or Workflow tools are unavailable, run the same inspection sequentially. Correctness must not depend on Claude-only orchestration.
Output Format
Keep the final report short:
markdown
## Goal Loop Result
Status: complete | partial | blocked | budget-exhausted
Rounds: <used>/<max>
Goal: <one sentence>
Criteria:
- [done|gap|blocked] <criterion>
Changes:
- <file> - <one-line change>
Verification:
- Ran: <commands or "static check only">
- Result: pass | fail | unverified
- Quality gate (--review): not requested | clean | residual findings under Remaining
Remaining:
- <none or concrete follow-up>
Guardrails
- Never continue a vague or whole-repo goal without explicit scope.
- Never broaden the goal mid-loop without asking.
- Never hide skipped verification or coverage caps.
- Never keep looping after a repeated failure with no new evidence.
- Never stage, commit, push, amend, rebase, reset, or rewrite history.
- Apply
references/output-preferences.md
for operator-facing language/style.