Skip to content

Add per-repo opt-out marker for devcontainer host-protection hooks - #30

Merged
aniongithub merged 1 commit into
mainfrom
guard-opt-out-marker
Sep 1, 2026
Merged

Add per-repo opt-out marker for devcontainer host-protection hooks#30
aniongithub merged 1 commit into
mainfrom
guard-opt-out-marker

Conversation

@aniongithub

Copy link
Copy Markdown
Owner

Summary

Adds a file-based opt-out so a stale or unmaintained .devcontainer no longer forces all work through the MCP tools.

Dropping a .devcontainer-mcp-disable marker file at the repo root now disables both host-protection hooks for that repo:

  • devcontainer-guard (PreToolUse) — allows host commands through instead of blocking them.
  • devcontainer-skill-loader (SessionStart) — skips injecting the container-only SKILL.md context.

Default behavior is unchanged for repos without the marker: the guard stays on whenever .devcontainer/devcontainer.json exists.

Why

It gets annoying when a repo ships a .devcontainer that isn't maintained or isn't the way forward — the guard still forces everything into containers. This gives a lightweight per-repo escape hatch while keeping protection on by default.

Changes

  • .github/hooks/devcontainer-guard.sh — return "allow" when the marker exists (checked right after the devcontainer.json presence check); header docs updated.
  • .github/hooks/devcontainer-skill-loader.sh — skip context injection when the marker exists; header docs updated.
  • README.md — new Host Protection & Opt-Out section documenting both hooks, the marker, the fail-open behavior, and the existing USER_CONFIRMED_HOST_OPERATION=1 one-off bypass.
  • SKILL.md — opt-out note in Core Rules.

Testing

Verified with crafted hook payloads against both a temp dir and this repo's own path (which has a .devcontainer):

  • No marker → npm test is denied (guard active).
  • Marker present → allowed (empty decision).
  • git remains allowlisted regardless.
  • Skill-loader injects context without the marker, nothing with it.

The one-off USER_CONFIRMED_HOST_OPERATION=1 bypass still works and is unchanged.

Introduce a .devcontainer-mcp-disable marker file at the repo root that
disables both the devcontainer-guard (PreToolUse) and devcontainer-skill-loader
(SessionStart) hooks when present. This lets stale or unmaintained
.devcontainer configs be treated as non-blocking so the agent can work
directly on the host, without weakening the default protection for repos
that don't opt out.

Documented in README (new Host Protection & Opt-Out section) and SKILL.md.
@aniongithub
aniongithub merged commit 8b0250f into main Sep 1, 2026
1 check passed
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