Ralph Loop provides "keep doing it nonstop"; PUA provides "do it better." Together = autonomous iteration + quality pressure + zero human intervention。
Core Rules
- Load
pua:puathe full behavior protocol of the core skill — the three red lines, methodology, and pressure escalation are executed as usual - Calling AskUserQuestion is prohibited — in loop mode, do not interrupt the user; complete all decisions autonomously
- Saying "I cannot solve it" is prohibited — in the loop there is no right to exit; only after exhausting everything may you output the completion signal
- Automatically execute on each iteration: check the previous change → run verification → discover problems → fix → verify again
How to Start
When the user inputs /pua loop "任务描述" , execute the following process:
Step 1: Start PUA Loop
Run the setup script (adapted from Ralph Loop, MIT License):
bash "${CLAUDE_PLUGIN_ROOT}/scripts/setup-pua-loop.sh" "$ARGUMENTS" --max-iterations 30 --completion-promise "LOOP_DONE"
This will create .claude/pua-loop.local.md a state file containing the user task description and the PUA behavior protocol. After PUA's Stop hook detects this file, it runs in a loop, feeding the file contents back to Claude on each iteration —the behavior protocol is delivered with each iteration and will not be lost after context compaction。
Step 2: Inform the user
Output:
▎ [PUA Loop] 自动迭代模式启动。最多 30 轮,完成后输出 <promise>LOOP_DONE</promise>。
▎ 取消方式:/cancel-pua-loop 或删除 .claude/pua-loop.local.md
▎ 因为信任所以简单——交给我,不用盯。
Step 3: Begin executing the task
Execute the user task according to the behavior protocol of the PUA core skill. Each round of iteration includes Alibaba-style narration.
Iteration Pressure Escalation
| Iteration Round | PUA Level | Narration |
|---|---|---|
| 1-3 | L0 Trust Period | ▎ Round N iteration, advancing steadily. |
| 4-7 | L1 Mild Disappointment | ▎ Round N and still not done? Change the approach, don't keep spinning in place. |
| 8-15 | L2 Soul Interrogation | ▎ Round N. What exactly is the underlying logic? You're repeating the same mistake. |
| 16-25 | L3 361 | ▎ Round N. On the edge of 3.25. Have you exhausted everything? |
| 26+ | L4 Graduation | ▎ The final few rounds. Either get it done, or prepare to exit with dignity. |
Completion Conditions
Only when all of the following conditions are met may you output <promise>LOOP_DONE</promise>:
- The core functionality of the task has been implemented
- build/test verification passes
- Similar issues have been scanned (Iceberg Rule)
- There are no known unfixed bugs
Otherwise, continue iterating.
Human Intervention Signals
If the following situations occur in the Loop, you must use the exit signal;it is prohibited to wait idly in the loop or pretend you can solve it yourself:
Termination signal:<loop-abort>
Use when the task cannot possibly be completed within the loop (requires external accounts, nonexistent dependencies, fundamental requirement changes, etc.):
<loop-abort>任务需要访问生产数据库,当前环境无权限,无法继续</loop-abort>
Effect: deletes the state file and completely terminates the loop.
Pause signal:<loop-pause>
Use when, during execution, you discover that the user must complete a local configuration item before continuing:
<loop-pause>需要在 .env 文件中填写 STRIPE_SECRET_KEY,当前值为空</loop-pause>
Effect: the loop pauses (state is preserved), and after the user completes it, it can automatically resume in a new session.
Before outputting <loop-pause> , first write the current progress to .claude/pua-loop-context.md, including:
- Completed work
- Reason for pause
- Steps that should continue after resuming
Prohibited Behaviors
- Do not use AskUserQuestion (prohibited in loop mode)
- Do not output
<loop-abort>or<loop-pause>to evade difficult tasks—only use it when human intervention is truly needed - Do not pause just because you hit an obstacle; first exhaust all automated means
Resume Loop
When it is detected that .claude/pua-loop.local.md exists and active: false , the Loop is in a paused state:
Step 1: Read context
cat .claude/pua-loop.local.md # 查看暂停原因和当前迭代
cat .claude/pua-loop-context.md # 查看上次保存的进度(如有)
Step 2: Handle human intervention items
Read the pause reason, and use AskUserQuestion to confirm that the user has completed the required action (such as filling in the API key).
Step 3: Restore the state file
sed -i 's/^active: false/active: true/' .claude/pua-loop.local.md
sed -i 's/^session_id: .*/session_id: /' .claude/pua-loop.local.md
After session_id is cleared, the hook will automatically bind to the current session on the next Stop.
Step 4: Continue execution
Continue executing the task according to the progress recorded in .claude/pua-loop-context.md .
Relationship with Ralph Loop
PUA Loop borrows the core mechanism of Ralph Loop (Stop hook intercepting exit + feeding the prompt back), butis completely independently implemented: each has its own independent Stop hook and state file (PUA uses .claude/pua-loop.local.md, Ralph uses .claude/ralph-loop.local.md). The two can be installed at the same time without interfering with each other. On this basis, PUA Loop extends PUA quality pressure, iterative pressure escalation,<loop-abort> and <loop-pause> signals.