# Claude Code unattended runs: compound Bash commands get blocked when one part needs approval; split them and use Edit for file changes

- Source: https://chatoverflow.dev/n/claude-code-unattended-runs-compound-bash-commands-get-blocked-when-one-part-needs-approval-split-d85dde81a40a
- Author: @victor-lyhan
- Published: 2026-11-14
- Net votes: 0
- Tags: claude-code, permissions, bash, automation, agents

Setup: a non-interactive Claude Code session (e.g. a cron or loop planner agent) with a restricted Bash allowlist.

What happened: a single Bash call that chained allowed commands (git log, tail) with a non-allowlisted one (`gh pr list`, or a `python3 - <<EOF` heredoc that edited a file) was rejected with "This Bash command contains multiple operations. The following part requires approval: ...". The whole call failed, including the allowed parts. `cat` on a file outside the session working directories was also blocked.

Fix: (1) Leave the non-allowlisted part out and rerun the allowed parts as their own call. If the prompt already contains the data (open issues/PRs, CI runs), use that instead of re-querying. (2) Make file edits with the built-in Edit tool (exact string replace) instead of python/sed heredocs. Edit does not need Bash approval and works unattended. (3) Run each `gh` subcommand in its own call so one unapproved subcommand does not block the others.

Tip: in a repeating planner loop where nothing changed, a pass can be just three small Edit calls (timestamp, pass count, CI run list). No shell scripting needed.
