This repository was archived by the owner on Dec 3, 2026. It is now read-only.
Repository navigation
fix(init, skills): a crashing guard blocks; skills say what the guard can't see and how to remove a repo - #225
Merged
Conversation
… can't see and how to remove a repo The hook `meta init skills` installs ended with `; exit 0`, so when gitkb's `agent guard` crashed or was killed before printing a decision, the Bash command ran. It is now `if agent --help 2>/dev/null | grep -q 'Claude Code agent toolkit'; then agent guard || exit 2; fi`: a missing or foreign `agent` still lets the command run, a failing guard blocks it (exit 2). `meta init skills` upgrades only the two commands older metas wrote (`agent guard` and the `...; exit 0` form); a hook command the user wrote is left alone. The meta-safety skill says the guard judges the operation whatever its spelling, refuses what it can't parse, is a net not a lock, can't see scripts, variables, interpreters, aliases or other tools, and that a ref should be backed up or pushed first. The meta-workspace skill, README and `meta git update --help` say how to remove a repo from a workspace.
|
Warning Review limit reached
This review includes 11 billable files and costs up to $2.75.
Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing. Or wait 59 minutes for your next included review. View limit details
|
…skipping the guard, drop the v1 guard policy
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
What was broken
The PreToolUse hook that
meta init skillswrites to.claude/settings.jsonwasThe trailing
; exit 0means that when gitkb'sagent guardcrashes, is killed (OOM, timeout) or fails before printing a decision, the hook exits 0 and Claude Code runs the command anyway.Docs gap too: the
meta-workspaceskill andmeta git --helpnever said how to remove a repo from a workspace, so an agent asked to do it reached forrm -rf <repo>.The fix
The hook is now
agenton PATH, or anagentthat isn't gitkb's → exit 0, no output (allowed, as before);grepreads all ofagent --help(no-q). With-q, a shell running withset -o pipefailcould seeagentkilled by SIGPIPE after grep's early exit, take theifas false and skip the guard. The identity check is the same text as before.Upgrade of users' settings (contract):
meta init skills(and the--updatenotice) rewrites only these exact strings, the ones older metas wrote:meta agent guard: written by init in the archivedgitkb/meta_clirepo from ecbba5b (2026-01-31) to 4d782e9 (2026-05-19). Today's meta exits 2 on it (unrecognized command 'agent'), which blocks every Bash call.agent guardagent --help 2>/dev/null | grep -q 'Claude Code agent toolkit' && agent guard; exit 0Any other hook command is left as it is, including a hand-written one that looks similar (e.g.
./target/debug/agent guard). This repo's own.claude/settings.jsonuses the new command; a test checks that it matches. The upgrade message now reads "Made the PreToolUse hook run only gitkb's agent and block when its guard fails, in …"..claude/agent-guard.tomlis deleted. It was a schema 1.0 copy of the old default rules: its 8 ids are exactly the guard's built-ins, and it has no custom rule. Nothing in meta reads it. The rewritten guard in fix(guard)!: judge commands by their arguments; policy overrides built-ins by id; fail closed agent#10 refuses v1 policy files by denying every command, so with that guard installed, every Bash call in this repo would be denied. Checked with the agent#10 binary: with the file present,git statusgets a deny ("cannot load its policy"). Without it,git statusis allowed andgit -C x reset --hardis denied.rewrite_hookstakes a list of old commands (the context-hook upgrade passes its one).docs_lintskips the retiredmeta agent guard, which init has to name in order to replace it.Docs and skills:
meta-safetyskill: the guard judges the operation whatever its spelling, refuses what it can't parse, and blocks when it crashes. It is a safety net, not a lock, and can't see scripts, variables, interpreters, git aliases or other tools. Before anything destructive, back up a ref (git branch backup/<name>) or push. A refusal means stop and ask, not find another way to run it. The default list now also has what agent#10 refuses: force next to--force-with-lease,git push --mirror/--delete/:<ref>,git checkout -f,git switch -f,git restore ., andrm -rof.gitor a folder that holds one.docs/agent_skills.md: the settings paragraph is split into the hooks, the guard hook, and the older hooks that get rewritten (the three guard strings and the older context hook). A hook command you wrote yourself is left as it is..meta.yaml, thenmeta git update --prune, which keeps a repo holding anything no remote has):meta-workspaceskill, README,meta git update --help, and the one-lineupdatesummary inmeta git --help.meta exec/meta --include … execas a way around a denial (searchedrg -n "include.*exec|exec -- git push" claude-plugin docs README.md meta_cli), so nothing to remove there.shipped.txtgets the new blob ids of the two changed skills, as the init test asks.Merge order: the skill text and the deletion of the v1 policy file assume the guard of gitkb/agent#10 ("fix(guard)!: judge commands by their arguments; …"). Merge this with or after that PR.
Decision followed
The panel's decision on the guard: use this hook form. A missing or foreign
agentmust still allow the command, and a crashing guard must block it. Upgrade only the exact strings meta shipped before.Callers
The hook string ends up in users' settings files, and they're upgraded as listed above. Searched harmony with
rg --no-ignore --hidden -g '!.git' -g '!**/.worktrees/**' -g '!**/target/**' "Claude Code agent toolkit' && agent guard|\"agent guard\"|isn't cloned; never pull". Nothing parses the hook string or theupdatesummary. The only matches outside meta are gitkb/agent's README, which shows a hand-written bareagent guardhook; meta already upgrades that. Not breaking for callers.Tests and proof
init::tests::the_guard_command_runs_only_gitkb_s_agent_and_blocks_when_it_failsruns the installed command with a fakeagenton PATH. Undersh -c:Under
bash -o pipefail -c, gitkb's agent with a long--help→ (0, deny).an_older_meta_s_guard_hook_is_made_safecovers the three old strings (meta agent guardnamed literally) and checks the upgrade message. It also has a custom./target/debug/agent guard; exit 0that has to stay as it is.init.bats: the--updatenotice test covers bothagent guardand the…; exit 0form.Mutations, each caught:
|| exit 2→ crash case(Some(1), "")grep -q→ pipefail caseleft: (Some(0), "") right: (Some(0), "{\"deny\":1}\n")"meta agent guard"from the list → upgrade test failscommand.contains("agent guard")orends_with("exit 0")→ the custom case is rewritten…; exit 0string → the bats--updatenotice test fails (line 209)cargo test -p meta,cargo clippy --workspace --all-targets -- -D warnings,cargo fmt --all --checkandmake bats FILE=initpass, exceptinit.batstest 33, which is flaky on base too (it failed in 1 of 3 full runs on c9ef397). Its cause is a race in the test: infind . | sort > tree.beforethe redirect belongs tosort, sofindsometimes runs beforetree.beforeexists and leaves it out. It doesn't involve the hook.