Skip to content

Add --bare flag to algorithm.ts subprocess spawns#988

Open
catchingknives wants to merge 1 commit intodanielmiessler:mainfrom
catchingknives:fix/algorithm-bare-flag-for-subprocess
Open

Add --bare flag to algorithm.ts subprocess spawns#988
catchingknives wants to merge 1 commit intodanielmiessler:mainfrom
catchingknives:fix/algorithm-bare-flag-for-subprocess

Conversation

@catchingknives
Copy link
Copy Markdown

Summary

  • Add --bare flag to both claude -p subprocess calls in algorithm.ts (parallel workers at line 669, sequential iteration at line 1114)
  • Interactive mode spawn (line 1227) intentionally left unchanged

Problem

Algorithm loop mode spawns claude -p subprocesses that load the full Claude Code environment — all hooks, LSP, plugin sync, and skill directory walks. This causes:

  1. Unnecessary overhead that compounds with parallel agents (N agents × full boot cost)
  2. Unintended side-effects in headless context: voice notifications, session state writes, rating capture hooks all fire in automation subprocesses where they're meaningless
  3. Potential state corruption from hooks writing session data in concurrent subprocess contexts

Fix

--bare was added in Claude Code v2.1.81 specifically for scripted -p calls. It skips hooks, LSP initialization, plugin synchronization, and skill directory walks — giving clean headless execution.

-    const proc = Bun.spawn(["claude", "-p", prompt,
+    const proc = Bun.spawn(["claude", "-p", "--bare", prompt,

Impact

Every PAI user running Algorithm loop mode benefits. The fix is 2 lines with zero behavioral change to the actual agent work — only the subprocess boot path is streamlined.

🤖 Generated with Claude Code

Algorithm loop mode spawns `claude -p` subprocesses for both parallel
workers and sequential iterations. Without `--bare`, each subprocess
loads all hooks, LSP, plugins, and walks skill directories — overhead
that compounds with parallel agents and causes unintended side-effects
(voice notifications, session state writes, rating capture) in headless
automation context.

`--bare` (added in Claude Code v2.1.81) skips hooks, LSP init, plugin
sync, and skill directory walks for scripted `-p` calls. Interactive
mode (line 1227) is intentionally left unchanged.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant