My agent guard blocked its own health check A developer building Mac YOLO Safeguards, a credential guard for AI coding agents like Claude Code, Codex and Cursor, fixed a self-protection rule that was blocking the guard's own read-only health check and settings greps. The original guard-config check flagged any command containing both an interpreter and the guard's name, so `node .../mac-yolo-credential-guard.js doctor` was denied as an attack on the guard. Commit 86f295d replaces it with a `guardConfigWrite` check that splits commands into parts and judges each, backed by test lists of 17 read-only commands that must pass and 15 write commands that must be denied. I build ThumbGate, a check that runs before every Claude Code, Codex or Cursor tool call and blocks the risky ones. Free install: npx thumbgate init . Pro is $19/month: https://thumbgate.ai/pricing?utm source=devto&utm medium=article&utm campaign=daily-2026-11-19 https://thumbgate.ai/pricing?utm source=devto&utm medium=article&utm campaign=daily-2026-11-19 I build Mac YOLO Safeguards, a set of guards for AI coding agents that run with approvals turned off. One of them is a credential guard: a hook that Claude Code, Codex and Cursor run before every tool call, and that refuses things like keychain reads and copies of browser login stores. Both it and ThumbGate, my other project, are mine, and this post is about a bug that showed up as soon as the hook was switched on. The first version of the guard shipped in commit 1319269 on 2026-11-19. It includes a rule called guard-config , whose job is self-protection. An agent must not be able to switch off the thing that is watching it, so the guard refuses install, uninstall and edits to its own settings and to the hook files of each agent. With the hook live, the guard's own health check, node tools/mac-yolo-credential-guard.js doctor run after a cd , was denied as a guard-config change. So was a grep of ~/.claude/settings.json to see whether the hook was registered. Same rule both times. A read-only look at the guard was being treated as an attack on the guard. The fix is in commit 86f295d , and its message describes both failures. The original check combined two questions about the whole command string. Did the command contain a write-capable operation or an interpreter anywhere? Did it name the guard anywhere? If both answers were yes, deny. That sounds careful, and it is, in the way a smoke alarm that goes off when you make toast is careful. node counts as an interpreter, because an interpreter can write any file it names. The path to the guard file contains the guard's name. So node .../mac-yolo-credential-guard.js doctor matched both questions without writing a single byte. The grep of the settings file hit the same pair from the other side. The deeper problem is the unit of judgment. A command line is not one action. cd /repo && node tool.js doctor 2 &1 | head -20 is three parts, and what matters is what each part does to which file. The new check, guardConfigWrite in tools/mac-yolo-credential-guard.js , splits the command into parts and judges each one. The rules from the commit message: install , uninstall , fix and work-folders add or remove are denied. doctor , check , work-folders list and --help pass. rm , mv , ln , chmod , sed -i , jq -i , tee or cp . cd earlier in the same command, so cd ~/.cursor && echo {} hooks.json is still caught. One excerpt shows the shape of it: js // Redirect targets: file , file , 2 file not 2 &1 . for const m of seg.text.matchAll / ?:^| ^< &\d \d? ?\s ^\s & \S /g { const t = resolve m 1 ; if t && isGuarded t, false return true; } if DESTRUCTIVE HEADS.has seg.head && paths.some p = isGuarded p, true return true; Interpreters keep a conservative rule. An interpreter can write any file it names, so if one appears in the command and a guarded path is also named, the guard still denies. That is why python3 -c "json.dump {}, open '