Skip to content

Add hook allowlist for host-safe commands and auto-inject SKILL.md on session start#21

Merged
aniongithub merged 2 commits into
mainfrom
fix/hooks-allowlist
May 14, 2026
Merged

Add hook allowlist for host-safe commands and auto-inject SKILL.md on session start#21
aniongithub merged 2 commits into
mainfrom
fix/hooks-allowlist

Conversation

@aniongithub
Copy link
Copy Markdown
Owner

Summary

Two improvements to the hook infrastructure:

1. Allowlist for host-safe commands

The devcontainer guard hook was blanket-blocking all bash/shell commands when a devcontainer was detected — including git operations that are inherently host-level (fetch, rebase, commit, push, etc.).

Fix: Add an allowlist of host-safe commands (git, gh) that pass through the guard. Every command in a chain (&&, ||, ;, |) must be on the allowlist — so git fetch && cargo build is correctly blocked.

Commands like curl/wget are intentionally excluded since they can pipe to sh.

2. Auto-inject SKILL.md on session start (closes #19)

New sessionStart hook (devcontainer-skill-loader.sh) that detects .devcontainer/devcontainer.json and injects SKILL.md content via additionalContext. This makes agents automatically aware of devcontainer-mcp tools without requiring manual skill installation.

Other

  • Moved hooks from hooks/ to .github/hooks/ so the project self-protects even without the MCP server installed
  • Updated install scripts (sh + ps1) with new hook download, SKILL.md data copy, and sessionStart configuration for both Claude Code and Copilot CLI

The hook was blanket-blocking all bash/shell commands when a devcontainer
was detected, including git operations that are inherently host-level.

Add an allowlist of host-safe commands (git, gh) that are permitted even
when a devcontainer exists. All commands in a chain (&&, ||, ;, |) must
be on the allowlist — so 'git fetch && cargo build' is correctly blocked.

Move hooks from hooks/ to .github/hooks/ so the project self-protects
even without the MCP server installed.

Commands like curl/wget are intentionally excluded since they can pipe
to sh. The bypass (USER_CONFIRMED_HOST_OPERATION=1) still works for
anything not on the allowlist.
When a session starts in a directory with .devcontainer/devcontainer.json,
the new devcontainer-skill-loader hook injects the SKILL.md content as
additionalContext, making agents automatically aware of devcontainer-mcp
tools without manual skill installation.

- Add .github/hooks/devcontainer-skill-loader.sh and JSON config
- Install SKILL.md to ~/.local/share/devcontainer-mcp/ for the loader
- Configure sessionStart hooks for both Claude Code and Copilot CLI
- Update install.sh and install.ps1 with the new hook

Closes #19
@aniongithub aniongithub merged commit 77ef453 into main May 14, 2026
1 check passed
@aniongithub aniongithub deleted the fix/hooks-allowlist branch May 14, 2026 20:21
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.

Auto-inject SKILL.md on session start when devcontainer is detected

1 participant