Add host-protection hooks for Claude Code and Copilot CLI#16
Merged
Conversation
PreToolUse hooks that block bash/shell tool calls when a .devcontainer/devcontainer.json exists, forcing agents to use devcontainer-mcp MCP tools instead of executing on the host. - hooks/devcontainer-guard.sh: shared hook script supporting both Claude Code and Copilot CLI payload formats - .github/hooks/devcontainer-guard.json: Copilot CLI hook config for this repo - install.sh/install.ps1: auto-install hooks and configure agent environments during installation - 10 integration tests validating block/allow/bypass behavior - SKILL.md footer updated to mention hook enforcement Bypass: USER_CONFIRMED_HOST_OPERATION=1 in the command allows through, designed as a semantic tripwire that LLMs cannot honestly generate.
This was referenced May 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PreToolUse hooks that block bash/shell tool calls when a
.devcontainer/devcontainer.jsonexists in the working directory, forcing agents to use devcontainer-mcp MCP tools instead of executing on the host.Changes
hooks/devcontainer-guard.sh— shared hook script supporting both Claude Code (tool_name/tool_input) and Copilot CLI (toolName/toolArgs) payload formats.github/hooks/devcontainer-guard.json— Copilot CLI hook config for this repoinstall.sh/install.ps1— auto-install hooks and configure agent environments (Claude Code~/.claude/settings.json, Copilot CLI~/.copilot/hooks/) during installationskills/footer.md/SKILL.md— mention hook enforcement in the "What NOT to do" sectioncrates/devcontainer-mcp-core/tests/hook_guard_test.rs) validating block/allow/bypass behavior across both agent formatsHow it works
USER_CONFIRMED_HOST_OPERATION=1is in the command → allows through (human bypass).devcontainer/devcontainer.jsonexists in cwd → denies with helpful messageThe bypass string is a semantic tripwire: even if an LLM discovers it by reading the hook script, generating
USER_CONFIRMED_HOST_OPERATION=1means falsely asserting that a user confirmed the operation — directly conflicting with honesty training.