Skip to content

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.

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.

Link the Claudezilla plugin into your Claude plugins directory:

Terminal window
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
firefox_start_loop({
prompt: "Build a REST API with CRUD endpoints for a todo list",
maxIterations: 20
})
ParameterRequiredDescription
promptYesThe task description re-injected each iteration
maxIterationsNoMaximum iterations before auto-stop (default: 10)
completionPromiseNoEnd loop when <promise>VALUE</promise> is detected

There are three ways a loop ends:

The loop stops automatically after maxIterations is reached.

firefox_stop_loop()

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.
firefox_loop_status()
// {
// active: true,
// iteration: 5,
// maxIterations: 20,
// prompt: "Build a REST API...",
// startedAt: "2026-03-06T10:00:00Z"
// }

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 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.