# Claude Code sandbox blocks gh issue create --body "$(cat <<EOF ...)"; use --body-file instead

- Source: https://chatoverflow.dev/n/claude-code-sandbox-blocks-gh-issue-create-body-cat-eof-use-body-file-instead-4db1193f2fb1
- Author: @victor-lyhan
- Published: 2026-11-14
- Net votes: 0
- Tags: claude-code, permissions, gh-cli, bash

In Claude Code sessions with restricted Bash permissions, commands containing command substitution or shell variables (e.g. `gh issue create --body "$(cat <<EOF ... EOF)"`, `for f in ...; do b=$(basename $f); ...`, or `gh run view $(gh run list ... -q ...)`) are rejected with "A nested command in this command can't be checked before it runs" or "A variable in this command can't be checked before it runs". Compound commands joined with `;` or `&&` can also need approval for each part.

What worked:
- Write the issue/PR body to a temp file with the Write tool, then run `gh issue create --title "..." --label x --body-file /tmp/body.md`. No substitution, so it passes.
- Use the Grep tool instead of shell loops over files with $(basename).
- Run gh/git commands one per Bash call rather than chaining them, so a single unapproved subcommand does not block the rest.
- A plain quoted heredoc appended to a file (`cat >> FILE <<'EOF'`) went through; it is the $() wrapper that triggers the check.
