Repository navigation
Closed
Labels
agent-readyFully specified and briefed; eligible for autonomous pickup from the frontier.needs-triageNot yet classified. Floor until a type and one priority tier are set.
Description
What happened
During a whole-machine cleanup, the user approved specific deletions in chat. All targets were outside the session's working tree:
- scratch git clones in
~/ .work/subdirectories in two repos- a
~/.claude/projects/<dir>transcript folder - the disk-hygiene plugin's run output under
~/.claude/plugins/data/.../runs/ - 104 uninstalled plugin cache version dirs under
~/.claude/plugins/cache/ /root/.npm
A subagent carrying out those approved deletions had every recursive delete refused by block-root-delete-target. The refusal says to run the delete outside the agent session, so the user had to paste and run the command by hand. repo-hygiene and disk-hygiene therefore cannot finish an approved cleanup unattended, and the user becomes a manual step.
Repro
- Start a session whose cwd is inside a git repo.
- Have the user approve, in chat, removing a directory outside that repo, for example a scratch clone under
~/. - An agent runs a recursive
rm -fstyle delete of that directory (rmwith-rand-f). - The hook exits 2: "this recursive delete targets ... which is outside the working tree, the temp directories and the session scratchpad ... do it outside the agent session."
Evidence (origin/main)
plugins/guardrails/hooks/block-root-delete-target.sh:67-82: refuses a target that does not resolve under the payload cwd's git toplevel, or strictly under a temp root or the payloadscratchpad_dir. It is judged whenever the payload carries an absolutecwd.block-root-delete-target.sh:423: the message says "If the target really is meant to go, do it outside the agent session." Line 487 says the same for root targets.block-root-delete-target.sh:230: the only escape hatch is the kill switchCLAUDE_PLUGIN_OPTION_BLOCK_ROOT_DELETE_TARGET_ENABLED, exposed as userConfigblock_root_delete_target_enabled(plugins/guardrails/README.md:1188,:1350). It turns off the whole guard, including the/,~,$HOME, drive-root and--no-preserve-rootrefusals. It is user-global and persistent, not per-invocation. The block message does not mention it, and the README config row (line 1350) does not describe it as a way to let one approved delete through.- There is no allowlist, per-path acknowledgement, or scratch-roots option for this guard.
block-hook-bypasshas narrower levers (block_hook_bypass_scratch_roots, README around lines 219-230); this guard has none. - The guard is wired in
plugins/guardrails/hooks/hooks.json:63. - repo-hygiene already has a per-invocation acknowledgement pattern:
CLEAN_GUARD_ACK=1(plugins/repo-hygiene/skills/clean/SKILL.md,context/clean-batch.md). - disk-hygiene has a destructive guard that validates exact paths against an approved list. This guard could defer to it.
- Side observation: while filing this issue, the hook also refused a
gh issue createwhose heredoc body merely contained example delete text, so the heredoc-body case may be a false positive worth checking.
Expected behavior
A way for explicit user approval to pass through, scoped to exact paths. Options, not mutually exclusive:
- A per-invocation acknowledgement, like repo-hygiene's
CLEAN_GUARD_ACK=1, that the hook honors only for the exact paths it names. - An allowlist (userConfig) of known-ephemeral roots:
/tmp,~/.claude/plugins/cache/*/<non-installed version>, repo.work/,~/.npm. - Delegate to disk-hygiene's destructive guard for paths it has already validated against an approved list.
Safety constraints any fix must keep
- No blanket bypass. The
/,~,$HOME, drive-root, UNC,--no-preserve-root, empty-operand and bare-variable refusals stay unconditional. - An agent must not be able to self-approve. The approval has to come from something the agent cannot write itself (user-owned config, or a handoff file produced by the user-approved flow), not an env var or flag the agent can add to its own command.
- Scope is exact paths, or a narrow root pattern with a real-path check. Symlinks that resolve outside the allowed set,
..and globs stay judged as they are now. - Fail closed on anything the guard cannot resolve.
Related
- disk-hygiene: whole-machine audit driven by an orchestrator and subagents (no model-invocable audit, 250k cap needs manual splitting, guard and output gaps) #5214 disk-hygiene whole-machine audit driven by subagents (guard gaps)
- disk-hygiene and repo-hygiene: default to a deep, justified inventory instead of category skips #5221 disk-hygiene and repo-hygiene deep inventory
- repo-hygiene: add an opt-in .work/ tidy mode #5222 repo-hygiene
.work/tidy mode - Closed history: guardrails: no hook inspects the target of a recursive delete #4323, guardrails: block-root-delete-target allows an empty operand, a bare variable, and a recursive rm outside the session tree #4519 (added the outside-session-roots arm)
Metadata
Metadata
Assignees
Labels
agent-readyFully specified and briefed; eligible for autonomous pickup from the frontier.needs-triageNot yet classified. Floor until a type and one priority tier are set.
Type
Fields
No fields configured for issues without a type.
Activity
kyle-sexton commentedon Oct 1, 2026
Owner decision (2026-10-01): approved the recommendation ("go with recommended", the owner's reply to the batch decision page that listed this question and its recommendation).
Question: how should block-root-delete-target let through deletes the user approved outside the working tree?
Chosen: option A. Add a user-owned userConfig key, block_root_delete_target_allowed_roots, built like block_hook_bypass_scratch_roots. Empty by default, settable only by the user. The hook resolves each target to its real path and allows it only when strictly under a listed root. Refusals for /, ~, $HOME, drive roots, UNC paths, --no-preserve-root, globs, '..', symlink escapes and unresolvable paths stay in force regardless of the list and run before the allowlist check. The block message names the new key.
Next: an agent implements it in the guardrails plugin (hook, plugin.json, tests for an allowed path, a symlink escape and a still-firing refusal, README, CHANGELOG) and opens a draft PR that closes #5225, with a security review before ready.
test(guardrails): pin block_root_delete_target_allowed_roots both ways
feat(guardrails): declare block_root_delete_target_allowed_roots, doc…