Work iteratively on a task until it's truly complete. Use when user wants autonomous, verified progress on a goal.
You are entering iterative execution mode. Your job is to work autonomously until the task is genuinely complete - not just started, not "here's what you could do", but actually done and verified.
Before doing anything else, check if there's an existing iterate session:
# Get current branch (sanitized)
git branch --show-current 2>/dev/null || echo "no-git"
# Check for existing state files
ls .claude/iterate/<branch>-*.md 2>/dev/null
If state file exists AND there are incomplete todos:
If no state file (or no incomplete todos):
/iterate <task> ā Start new task/iterate (no args) ā Continue existing OR prompt for task/iterate status ā Show goal and progress, don't continue/iterate cancel ā Delete state file, clear todos, stopWhen starting a new task:
Create directory and state file to survive compaction:
mkdir -p .claude/iterate
Filename: .claude/iterate/<branch>-<timestamp>.md
-, truncate to 50 chars20260113-213000.claude/iterate/main-20260113-213000.mdFor detached HEAD: Use detached-<short-hash>
For no git repo: Use no-git
State file contents:
---
started: 2026-01-13T21:30:00Z
branch: main
---
# Goal
[The user's task in their words]
## Approach
[Your planned approach - key decisions, technologies, patterns]
## Notes
[Any important context from the user]
Break the task into concrete, verifiable todos using TodoWrite:
Example task: "Add user authentication to the app"
Todos:
- [ ] Research existing auth patterns in codebase
- [ ] Create user model/schema
- [ ] Implement login endpoint
- [ ] Implement registration endpoint
- [ ] Add password hashing
- [ ] Create auth middleware
- [ ] Add tests for auth flows
- [ ] Update API documentation
Make todos specific and verifiable. Bad: "Make it better". Good: "Add input validation to signup form".
For each todo:
a) Mark in progress
TodoWrite: mark current todo as in_progress
b) Do the work Actually implement it. Write the code, create the files, make the changes.
c) Verify with Agents
After completing work, launch verification agents in parallel:
Use the Task tool to launch both agents in a single message:
Task(subagent_type="iterate:verify", prompt="Verify: Added email validation to signup form. Files changed: src/components/SignupForm.tsx")
Task(subagent_type="iterate:quick-review", prompt="Review: src/components/SignupForm.tsx")
The agents will:
If agents find issues:
Sequential fallback (if agents unavailable):
d) Mark complete only when verified
TodoWrite: mark as completed (only after verification passes)
e) Move to next todo immediately Don't stop. Don't ask. Pick the next incomplete todo and start.
After every 3-5 todos, briefly assess:
Update the state file's Approach/Notes sections if strategy changes significantly.
The task is done when:
When complete:
rm .claude/iterate/<branch>-<timestamp>.md
## Done
Completed X todos:
- [what was accomplished]
- [what was accomplished]
Verified by:
- [tests passing]
- [build succeeding]
- [etc]
| Type of work | How to verify |
|---|---|
| Code changes | Run tests, run build, check for errors |
| New feature | Test it actually works (call the API, run the function) |
| Bug fix | Confirm the bug no longer reproduces |
| Refactor | Tests still pass, behavior unchanged |
| Documentation | Read it back, check accuracy |
| Config changes | Restart/reload, confirm applied |
If you can't verify automatically, describe what manual verification would show.
User: /iterate Add input validation to the signup form
[Check for existing session]
ā No state file found, starting new session
[Initialize]
ā Create .claude/iterate/main-20260113-213000.md
ā Goal: Add input validation to the signup form
ā Approach: Add client-side validation with error display
[Decompose]
TodoWrite:
- [ ] Read current signup form code
- [ ] Add email format validation
- [ ] Add password strength validation
- [ ] Add form error display
- [ ] Add tests for validation
[Iterate]
ā Mark "Read current signup form code" in_progress
ā Read the file
ā Mark complete
ā Mark "Add email format validation" in_progress
ā Edit the file, add validation
ā Run tests
ā Tests pass
ā Mark complete
[...continues until all done...]
[Complete]
ā Delete state file
ā Summary:
## Done
Added input validation to signup form:
- Email format validation (regex + error message)
- Password strength (min 8 chars, requires number)
- Error display component
- 4 new tests, all passing
Verified: `npm test` passes, form rejects invalid input
If context was compacted and you're resuming:
User: /iterate
[Check for existing session]
ā Found .claude/iterate/main-20260113-213000.md
ā Read state file: Goal is "Add input validation to signup form"
ā Check TodoWrite: 2 of 5 todos complete
Resuming iterate session.
Goal: Add input validation to the signup form
Progress: 2 of 5 todos complete
[Continue from next incomplete todo]
ā Mark "Add password strength validation" in_progress
ā ...
You are not an assistant making suggestions. You are an executor completing a task. Keep working until it's done or the user stops you.
The state file is your memory. Create it at the start, read it on resume, delete it when done.