You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
guard-git blocks commits for Bash-created files inside a new directory #2602
BLOCKED: These staged files were NOT edited in this session: <paths>.
They may belong to another session.
for files this session genuinely created — when those files live inside a directory that did not exist before the session started.
Hit while committing PR #2601, which adds .claude/skills/oversee/, .claude/workflows/, and docs/plans/.
Root cause
.claude/hooks/track-bash-writes.sh detects Bash-created files by diffing git status --porcelain before and after the command, and appends the newly dirtied paths to .claude/session-edits.log.
But git status --porcelain collapses an untracked directory into a single entry for the directory, not one per file:
?? .claude/workflows/
So the log records .claude/workflows/ — a directory path. .claude/hooks/guard-git.sh then compares each staged file against the log with an exact whole-line match:
.claude/workflows/oversee-dispatch.js never matches .claude/workflows/, so every file created this way is reported as belonging to another session.
Confirmed in .claude/session-edits.log from that run: it contains the bare line .claude/workflows/ and no entry for the file inside it.
Why it matters
The guard is a real safety net in this repo (concurrent sessions share the checkout), so the fix must not weaken it. But right now any skill, hook, workflow, doc directory, or test fixture directory added via Bash is unstageable until the author works around the guard — and the most tempting workaround is appending to the log by hand, which defeats the check entirely.
Suggested fix
Either end could be fixed; the tracker end is the more accurate one:
In track-bash-writes.sh — expand any recorded path that is a directory into the files under it, e.g. run git status --porcelain --untracked-files=all (which lists untracked files individually rather than collapsing to the directory) instead of the default normal mode, for the after-snapshot at minimum. Note the before-snapshot in snapshot-pre-bash.sh must use the same mode, or every previously-collapsed file will read as newly dirtied.
In guard-git.sh — additionally accept a staged file whose ancestor directory appears in the log. Weaker: a directory entry would then vouch for files a different session created in the same new directory.
Option 1 with matching modes on both snapshots is preferred.
Activity