PUA Loop — Auto Iteration + PUA Quality Engine
Ralph Loop provides "keep doing", PUA provides "do better". Together = Autonomous Iteration + Quality Pressure + Zero Human Intervention.
Core Rules
- Load all behavior protocols of the core skill — Three red lines, methodology, and pressure escalation are enforced as usual
- Prohibit calling AskUserQuestion — Do not interrupt the user in loop mode; all decisions are made autonomously
- Prohibit saying "I cannot solve this" — There is no right to exit in the loop; exhaust all possibilities before outputting the completion signal
- Automatically execute each iteration: Check previous changes → Run verification → Identify issues → Fix issues → Re-verify
Activation Method
When the user inputs
/pua:pua-loop "task description"
, execute the following process:
Step 1: Start PUA Loop
Run the setup script (adapted from Ralph Loop, MIT License):
bash
bash "${CLAUDE_PLUGIN_ROOT}/scripts/setup-pua-loop.sh" "$ARGUMENTS" --max-iterations 30 --completion-promise "LOOP_DONE"
This creates a
.claude/pua-loop.local.md
state file containing the user's task description and PUA behavior protocols. After detecting this file, PUA's Stop hook runs in a loop, feeding the file content back to Claude in each iteration —
Behavior protocols are delivered with each iteration and will not be lost after context compaction.
Step 2: Notify the User
Output:
▎ [PUA Loop] Auto iteration mode started. Maximum 30 iterations. Output <promise>LOOP_DONE</promise> upon completion.
▎ Cancellation methods: /cancel-pua-loop or delete .claude/pua-loop.local.md
▎ Simple because of trust — leave it to me, no need to monitor.
Step 3: Start Executing the Task
Execute the user's task in accordance with the behavior protocols of the PUA core skill. Each iteration includes Alibaba-style narration.
Iterative Pressure Escalation
| Iteration Round | PUA Level | Narration |
|---|
| 1-3 | L0 Trust Period | ▎ Iteration N, progressing steadily. |
| 4-7 | L1 Mild Disappointment | ▎ It's already iteration N and you still haven't fixed it? Switch plans, don't spin your wheels. |
| 8-15 | L2 Soul Searching | ▎ Iteration N. What's the underlying logic? You're repeating the same mistake. |
| 16-25 | L3 361 | ▎ Iteration N. You're on the edge of 3.25. Have you exhausted all possibilities? |
| 26+ | L4 Graduation | ▎ Final rounds. Either fix it, or prepare to exit gracefully. |
Completion Conditions
<promise>LOOP_DONE</promise>
can only be output when all of the following conditions are met:
- The core functionality of the task has been implemented
- Build/test verification passed
- Similar issues have been scanned (Iceberg Principle)
- No known unresolved bugs
Otherwise, continue iterating.
Human Intervention Signals
When encountering the following situations in the Loop, you must use exit signals. Waiting idly in the loop or pretending to solve it on your own is prohibited:
Termination Signal:
Used when the task cannot be completed within the loop (requires external accounts, non-existent dependencies, fundamental requirement changes, etc.):
<loop-abort>The task requires access to the production database, and the current environment has no permission to proceed.</loop-abort>
Effect: Delete the state file, and the loop is completely terminated.
Pause Signal:
Used when it is discovered during runtime that the user needs to complete a local configuration to continue:
<loop-pause>STRIPE_SECRET_KEY needs to be filled in the .env file; the current value is empty.</loop-pause>
Effect: The loop pauses (state is retained), and can automatically resume in a new session after the user completes the required action.
Before outputting , write the current progress to .claude/pua-loop-context.md
, which includes:
- Completed work
- Reason for pause
- Steps to continue after resumption
Prohibited Behaviors
- Do not use AskUserQuestion (prohibited in loop mode)
- Do not output or to avoid difficult tasks — only use them when human intervention is truly needed
- Do not pause due to obstacles; exhaust all automated means first
Resume Loop
When
.claude/pua-loop.local.md
is detected to exist and
, the Loop is in a paused state:
Step 1: Read Context
bash
cat .claude/pua-loop.local.md # Check the reason for pause and current iteration
cat .claude/pua-loop-context.md # Check the last saved progress (if any)
Step 2: Handle Human Intervention Items
Read the reason for pause, use AskUserQuestion to confirm that the user has completed the required action (such as filling in the API key).
Step 3: Restore State File
bash
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 clearing session_id, the hook automatically binds to the current session at the next Stop.
Step 4: Resume Execution
Continue executing the task according to the progress recorded in
.claude/pua-loop-context.md
.
Relationship with Ralph Loop
PUA Loop draws on the core mechanism of Ralph Loop (Stop hook intercepts exit + feeds prompt back), but is
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
). They can be installed simultaneously without interfering with each other. PUA Loop extends this with PUA quality pressure, iterative pressure escalation, and
and
signals.