settings: hard-deny edits to coily/ from sessions outside coily/ cwd via PreToolUse hook #65
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally filed by @coilysiren on 2026-04-27T02:25:33Z - https://github.com/coilysiren/coily/issues/20
AGENTS.md in this repo says edits to coily from sessions whose primary cwd is not coily/ are forbidden, but today that's enforced only by the agent reading the rule. A session that ignores it (or one where Claude pattern-matches past it under load) can still edit coily files freely. Already happened once in the session that produced
f9087cb: primary cwd was the workspace root, edits landed in coily/ anyway. Worked out fine because the work was Kai-directed, but the rule should not depend on Claude noticing.Wire a
PreToolUsehook in~/.claude/settings.jsonthat hard-denies edits to coily/ from sessions whose primary cwd is anywhere else. Hook is workspace-level, not coily-level - the whole point is to block edits before the agent gets a chance to plead intent.Shape sketch:
Hook logic:
Read tool-call JSON from stdin.
Resolve the target path(s):
Edit/Write/MultiEdit/NotebookEdit:tool_input.file_path(andedits[*].file_pathfor MultiEdit).Bash: parse the command for redirects (>,>>,tee),git apply,cp/mvdestinations, anything that writes. Conservative match - if the command mentions a path under coily/ in a write-y context, treat as a target.If any target path is under
~/projects/coilysiren/coily/AND$CLAUDE_PROJECT_DIRis not exactly that path, exit 2 with stderr like:Otherwise exit 0.
Edge cases worth nailing:
coily/.claude/worktrees/...- resolve viarealpathor accept paths under that subtree as still-coily for hook purposes. A session started in a coily worktree should be able to edit coily files.cat,grep,git log). Hook should be write-detection-only on the Bash path; readonly Bash never triggers.Out of scope: any same-rule lockdown for sibling-repo edits (coily-vault, infrastructure, etc.). If those want similar isolation, separate issues. Coily is the only one with the lockdown-wrapper-integrity story that makes the gate worth the friction.