Skip to content

setup: write the agent-guard hook to gitignored settings.local.json instead of committing it to settings.json #824

Description

@milamberspace

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:

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:

.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.json instead of surfacing a
    settings.json snippet for the maintainer to commit; drop the -f/guard.
  • .gitignore template — ensure /.claude/settings.local.json is ignored.
  • tools/agent-guard/README.md — document the settings.local.json wiring
    and the plain command.
  • unadopt/verify flows — read/clean settings.local.json.
  • Idempotent merge: don't clobber an adopter's existing
    settings.local.json keys.

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions