← All guides

15 /goal Examples You Can Copy-Paste (With Exit Conditions)

A goal loop has three parts: an outcome, a command that proves the outcome, and a cap on iterations. The exit condition does the real work. If the check is not a command with an exit code, the agent will argue it is done instead of being done. It is also the part authors skip most — across this directory, a stated exit condition is one of the rarest grading signals. /goal puts it in the template, so you write it or you notice it missing.

Every example below follows that template. Swap in your own commands and paste into your harness, or feed any of them to the builder to get a runnable script.

/goal <outcome>
exit: <command that returns 0 when true>
budget: <max iterations>, <max wall-clock>
scope: <paths the agent may touch>

The full goal-loop collection is at /type/goal.

15 GOALS, FIVE CATEGORIES5Testing & CI2Types & lint3Refactor2Security & deps3Performance & db
The fifteen copy-paste goals group into five families — testing and CI, types and lint, refactoring, security and dependencies, and performance and database work.

Testing & CI

### 1. Tests pass and lint is clean

The canonical first loop. Directory: work-through-todo-turn-tests-green.

/goal all tests pass and lint is clean
exit: npm test && npm run lint
budget: 15 iterations, 60m
scope: src/, tests/ — never delete or skip a test to make it pass

### 2. Kill the flaky tests

The exit demands ten consecutive passes, not one lucky run. Directory: kill-flaky-tests.

/goal the test suite passes 10 consecutive runs with zero flakes
exit: for i in $(seq 10); do npm test || exit 1; done
budget: 25 iterations, 3h
scope: tests/, src/ — fix root causes; quarantining a test requires a TODO comment with the reason

### 3. Get the build green

/goal CI is green on this branch
exit: gh run watch --exit-status
budget: 10 iterations, 90m
scope: anything except .github/workflows/ — fixing the code is allowed, gaming the pipeline is not

Directory: get-the-build-green.

### 4. Reach a coverage target

/goal line coverage is at or above 80%
exit: npm test -- --coverage && node scripts/check-coverage.mjs 80
budget: 20 iterations, 2h
scope: tests/ only — write tests for existing behavior, do not modify src/ to be "more testable"

Directory: reach-coverage-target.

### 5. Ship the PR until it's green

A goal loop wrapped around CI feedback. Directory: ship-pr-until-green.

/goal PR #482 passes all required checks
exit: gh pr checks 482 --required
budget: 12 iterations, 2h
scope: the PR branch only — respond to CI failures with fixes, push, re-check

Types, lint, and formatting

### 6. TypeScript strict mode, zero errors

/goal the repo compiles under "strict": true
exit: npx tsc --noEmit
budget: 30 iterations, 4h
scope: src/ — no `any`, no `@ts-ignore` without a comment justifying it

### 7. Format until clean

/goal formatter and import sort produce zero diffs
exit: npx prettier --check . && npx eslint --max-warnings 0 .
budget: 5 iterations, 20m
scope: whole repo except generated files listed in .prettierignore

Directory: format-until-clean.

Refactoring & cleanup

### 8. Delete all dead code

/goal knip reports zero unused exports, files, or dependencies
exit: npx knip
budget: 15 iterations, 90m
scope: src/, package.json — every deletion must keep `npm test` passing

Directory: dead-code-elimination.

### 9. Burn down the TODOs

/goal zero TODO/FIXME comments older than 90 days remain
exit: node scripts/stale-todos.mjs --max-age 90 --fail-on-found
budget: 20 iterations, 2h
scope: src/ — each TODO is either fixed or converted to a tracked issue with a link

Directory: todo-burn-down.

### 10. Migrate an API, callsite by callsite

/goal no callers of the deprecated v1 client remain
exit: ! grep -rn "from '@lib/api-v1'" src/ && npm test
budget: 25 iterations, 3h
scope: src/ — migrate one module per iteration, tests pass after each

Directory: migrate-an-api.

Security & dependencies

### 11. Secrets scan comes back clean

/goal gitleaks finds zero secrets in the working tree
exit: gitleaks detect --no-git --exit-code 1 && echo clean
budget: 8 iterations, 45m
scope: whole repo — move secrets to env vars, add patterns to .gitleaksignore only for confirmed false positives

Directory: secrets-scan-clean.

### 12. Upgrade dependencies, one at a time

/goal zero outdated minor/patch dependencies, tests green after each bump
exit: npm outdated --json | node scripts/only-majors-left.mjs
budget: 30 iterations, 4h
scope: package.json, lockfile — ONE package per iteration, commit per package, revert on test failure

Directory: dependency-upgrade-one-at-a-time.

Performance & database

### 13. Hunt the N+1 queries

/goal the request-path query count in the perf suite is under budget
exit: npm run perf:queries -- --budget 12
budget: 15 iterations, 2h
scope: src/db/, src/api/ — add eager loading or batching; schema changes need human review

Directory: n-plus-one-query-hunt.

### 14. Hold the bundle-size line

/goal the client bundle is under 250 kB gzipped
exit: npm run build && node scripts/check-bundle-size.mjs 250
budget: 12 iterations, 90m
scope: src/, next.config.mjs — code-split and prune; removing user-facing features is out of bounds

Directory: bundle-size-budget.

### 15. Apply migrations until the schema matches

/goal migrations apply cleanly to a fresh database and schema matches models
exit: dropdb --if-exists loop_test && createdb loop_test && node scripts/migrate.mjs && node scripts/schema-check.mjs
budget: 10 iterations, 60m
scope: db/migrations/ — additive migrations only; destructive changes stop the loop for human review

Directory: apply-db-migrations.

The pattern behind all 15

THE PATTERN BEHIND EVERY /goalState the goal+ explicit exitAgent iteratesedit · runEvaluator checksexit met?Donecondition truenot yet → iterate again
Every /goal follows the same shape — state the goal with an explicit exit condition, let the agent iterate, and stop only when an evaluator confirms the condition is actually true.

Three rules hold across every example:

RuleWhat it means in practice
The exit condition is a commandIf you cannot && it in a shell, it is not an exit condition.
The scope names what is forbiddenGoal loops game their own metric: delete the failing test, skip the check, drop the feature that bloats the bundle. Name those moves as off-limits — listing allowed paths is not enough.
The harness enforces the budgetThe model does not count its own iterations. Your script does.

A loop that finishes at 3am and tells nobody wasted the run. Give long-running loops a notification path — one ConnectMyEmail hook at the end of the harness covers it.

If your goal is not on this list, feed it to the loop builder. It pressure-tests the exit condition, attaches a budget, and hands back a harness you can run today.

Ready to run one? Browse the loop directory →
All TESTING loops

Draft a sprint plan from the backlog

Turn the open issue backlog into a proposed two-week sprint plan with estimates, a dependency ordering, and an explicit cut line, written as a document for the team to edit.

Open loop →

Receipt & statement archiver

Scan the inbox for receipts, invoices, and statements and file each under a Receipts label — read-only on everything else, deleting nothing.

Open loop →

Auto-unsubscribe agent

Find newsletters you never open and unsubscribe via the List-Unsubscribe header — bulk mailing lists only, never transactional or security senders.

Open loop →

Complete goal with skill stack

Read goal.md, follow your skill guides, meet all acceptance criteria, and stop after 20 turns or verification passes.

Open loop →