Repository navigation
Description
Problem
Today the adopt flow commits the agent-guard PreToolUse hook wiring into the
tracked .claude/settings.json, while the script it invokes
(.claude/hooks/agent-guard.py) stays gitignored and is only synced in by
/magpie-setup. That split has caused a chain of follow-up fixes:
- fix(agent-guard): make the PreToolUse hook a no-op until agent-guard.py is present #786 — a fresh clone has the committed wiring but not yet the script, so
the hook command had to be guarded ([ -f … ] && python3 … || true) to
no-op when the script is absent. - fix(agent-guard): make the fresh-clone hook guard cross-platform (Windows) #823 — that guard is a POSIX-shell conditional, which breaks on Windows
(PowerShell, no Git Bash), so it had to be rewritten as an inline
python3 -cexistence check.
Both are workarounds for the same root cause: we commit machine-specific hook
wiring for a script we deliberately don't commit. It also enlarges the
always-committed footprint for an opt-in feature.
Proposal
Have /magpie-setup write the hook entry into the gitignored, per-machine
.claude/settings.local.json at the same moment it deposits
agent-guard.py — and stop committing it in .claude/settings.json.
Because the wiring then only ever exists once the script is present:
- No fresh-clone guard needed (fix(agent-guard): make the PreToolUse hook a no-op until agent-guard.py is present #786 becomes moot) — the command can be a
plainpython3 "$CLAUDE_PROJECT_DIR/.claude/hooks/agent-guard.py". - No cross-platform shell gymnastics needed (fix(agent-guard): make the fresh-clone hook guard cross-platform (Windows) #823 becomes moot) — plain
python3 "…"runs on POSIX and Windows alike. - Zero committed footprint for the hook — nothing tracked in the adopter
repo, matching the fact that both the script and its trigger are
per-machine framework artefacts, not project config.
.claude/settings.local.json is Claude Code's documented per-user override
file and is already the natural home for machine-local settings; adopters
gitignore it (as this repo's .gitignore already does for settings.local).
Scope of the framework change
skills/setup/adopt.md— Step 12 (and the verify step): write/merge the
hook block into.claude/settings.local.jsoninstead of surfacing a
settings.jsonsnippet for the maintainer to commit; drop the-f/guard..gitignoretemplate — ensure/.claude/settings.local.jsonis ignored.tools/agent-guard/README.md— document thesettings.local.jsonwiring
and the plain command.- unadopt/verify flows — read/clean
settings.local.json. - Idempotent merge: don't clobber an adopter's existing
settings.local.jsonkeys.
Context
Raised from Apache JMeter's adoption review. The JMeter PMC reviewer (@vlsi)
independently asked "Can magpie add the hook entry to
.claude/settings.local.json on setup?" — this issue is that request,
generalised. JMeter has already dropped the committed .claude/settings.json
from its adoption PR in anticipation.
If accepted, this supersedes #823 (and retro-justifies removing the #786
guard).
Activity
onlyarnav commentedon Jul 12, 2026
Is this issue still relevant and need work?
I can't seem to understand if this requires contribution?
Please lmk, Thanks!
fix(setup): wire the agent-guard hook into settings.local.json, not s…
fix(setup): wire the agent-guard hook into settings.local.json, not s…