Skip to content

fix: keep ~/.claude/hooks scripts executable after skeleton copy - #1

Merged
awcjack merged 1 commit into
masterfrom
fix/claude-hooks-executable
Jun 30, 2026
Merged

fix: keep ~/.claude/hooks scripts executable after skeleton copy#1
awcjack merged 1 commit into
masterfrom
fix/claude-hooks-executable

Conversation

@awcjack

@awcjack awcjack commented Jun 30, 2026

Copy link
Copy Markdown
Owner

Problem

Claude Code's Stop hook (and a PreToolUse hook) fail in-container with:

/home/agent/.claude/hooks/stop-test-runner.sh: Permission denied

The skeleton hook scripts (stop-test-runner.sh, test-runner.sh, gitleaks-precommit.sh) are built executable (executable = true + chmod +x in skelDir), but the entrypoint seeds the home with:

cp -rT --no-preserve=mode "$SKEL_DIR" "$HOME_DIR"

--no-preserve=mode (kept so home files stay agent-writable) strips the +x bit, so the scripts land at 0644. managed-settings.json execs them directly so Claude Code hits 'Permission denied' on Stop / PreToolUse. The ~/.hooks/*.sh set is unaffected because it is bind-mounted and chmod'd separately.

Fix

Re-assert +x on ~/.claude/hooks/*.sh in entrypoint-user:

  • before the fast-path exit, so homes initialized prior to this fix (persisted ~/.agentbox/home on darwin hosts) are repaired;
  • after the skeleton copy, so a fresh home works on its first session.

Cheap, idempotent globs guarded by [ -d ... ].

🤖 Generated with Claude Code

The container entrypoint seeds the home from /etc/skel.agent with
cp -rT --no-preserve=mode to keep home files agent-writable, but that
strips the +x bit baked into the skeleton hook scripts. Claude Code execs
~/.claude/hooks/*.sh directly (stop-test-runner, test-runner,
gitleaks-precommit referenced from managed-settings.json), so they failed
with 'Permission denied' on the Stop and PreToolUse events.

Re-assert +x on ~/.claude/hooks/*.sh in the entrypoint: once before the
fast-path exit so already-initialized homes are repaired, and once after
the skeleton copy so the first session on a fresh home works too.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@awcjack
awcjack merged commit 09e44b4 into master Jun 30, 2026
1 check passed
@awcjack
awcjack deleted the fix/claude-hooks-executable branch June 30, 2026 03:17
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