Focus Loops
Focus loops enable Claude to work on a task repeatedly until completion, preventing premature exit. When active, Claude's stop hook intercepts exit attempts and re-injects the task prompt. ## Architecture ``` Claude Code Session | v Plugin Stop Hook (claudezilla/plugin/) | (Unix socket query) v Claudezilla Host (loop state) | v Firefox Extension (visual control) ``` The plugin hook runs every time Claude tries to end its turn. If a loop is active, it blocks the exit and feeds the prompt back in. ## Setup Link the Claudezilla plugin into your Claude plugins directory: ```bash ln -s /path/to/claudezilla/plugin ~/.claude/plugins/claudezilla-loop ``` The plugin contains: - `.claude-plugin/` — plugin metadata - `hooks/` — stop hook that queries loop state via Unix socket ## Starting a Loop ```js firefox_start_loop({ prompt: "Build a REST API with CRUD endpoints for a todo list", maxIterations: 20 }) ``` | Parameter | Required | Description | |-----------|----------|-------------| | `prompt` | Yes | The task description re-injected each iteration | | `maxIterations` | No | Maximum iterations before auto-stop (default: 10) | | `completionPromise` | No | End loop when `<promise>VALUE</promise>` is detected | ## Completion Detection There are three ways a loop ends: ### 1. Max Iterations The loop stops automatically after `maxIterations` is reached. ### 2. Manual Stop ```js firefox_stop_loop() ``` ### 3. Completion Promise Set a completion marker that Claude emits when the task is done: ```js firefox_start_loop({ prompt: "Fix all TypeScript errors in src/", maxIterations: 30, completionPromise: "ALL_ERRORS_FIXED" }) // When Claude determines all errors are fixed, it outputs: // <promise>ALL_ERRORS_FIXED</promise> // The hook detects this and stops the loop. ``` ## Checking Status ```js firefox_loop_status() // { // active: true, // iteration: 5, // maxIterations: 20, // prompt: "Build a REST API...", // startedAt: "2026-03-06T10:00:00Z" // } ``` ## Browser UI When a loop is active, the Claudezilla popup shows: - Current iteration count - Task prompt preview - A stop button for manual cancellation ## Tips - Keep prompts specific and actionable. Vague prompts lead to repetitive iterations. - Set `maxIterations` as a safety net — most tasks complete well under the limit. - Use `completionPromise` for tasks with a clear "done" condition (all tests pass, no errors remain). - Monitor progress with `firefox_loop_status()` to see which iteration you're on.Focus loops enable Claude to work on a task repeatedly until completion, preventing premature exit. When active, Claude’s stop hook intercepts exit attempts and re-injects the task prompt.
Architecture
Section titled “Architecture”Claude Code Session | vPlugin Stop Hook (claudezilla/plugin/) | (Unix socket query) vClaudezilla Host (loop state) | vFirefox Extension (visual control)The plugin hook runs every time Claude tries to end its turn. If a loop is active, it blocks the exit and feeds the prompt back in.
Link the Claudezilla plugin into your Claude plugins directory:
ln -s /path/to/claudezilla/plugin ~/.claude/plugins/claudezilla-loopThe plugin contains:
.claude-plugin/— plugin metadatahooks/— stop hook that queries loop state via Unix socket
Starting a Loop
Section titled “Starting a Loop”firefox_start_loop({ prompt: "Build a REST API with CRUD endpoints for a todo list", maxIterations: 20})| Parameter | Required | Description |
|---|---|---|
prompt | Yes | The task description re-injected each iteration |
maxIterations | No | Maximum iterations before auto-stop (default: 10) |
completionPromise | No | End loop when <promise>VALUE</promise> is detected |
Completion Detection
Section titled “Completion Detection”There are three ways a loop ends:
1. Max Iterations
Section titled “1. Max Iterations”The loop stops automatically after maxIterations is reached.
2. Manual Stop
Section titled “2. Manual Stop”firefox_stop_loop()3. Completion Promise
Section titled “3. Completion Promise”Set a completion marker that Claude emits when the task is done:
firefox_start_loop({ prompt: "Fix all TypeScript errors in src/", maxIterations: 30, completionPromise: "ALL_ERRORS_FIXED"})
// When Claude determines all errors are fixed, it outputs:// <promise>ALL_ERRORS_FIXED</promise>// The hook detects this and stops the loop.Checking Status
Section titled “Checking Status”firefox_loop_status()// {// active: true,// iteration: 5,// maxIterations: 20,// prompt: "Build a REST API...",// startedAt: "2026-03-06T10:00:00Z"// }Browser UI
Section titled “Browser UI”When a loop is active, the Claudezilla popup shows:
- Current iteration count
- Task prompt preview
- A stop button for manual cancellation
- Keep prompts specific and actionable. Vague prompts lead to repetitive iterations.
- Set
maxIterationsas a safety net — most tasks complete well under the limit. - Use
completionPromisefor tasks with a clear “done” condition (all tests pass, no errors remain). - Monitor progress with
firefox_loop_status()to see which iteration you’re on.