fix(hooks): skip read-guard advisory on Claude Code runtime (#2001)
* fix(hooks): skip read-guard advisory on Claude Code runtime (#1984) Claude Code natively enforces read-before-edit at the runtime level, so the gsd-read-guard.js advisory is redundant — it wastes ~80 tokens per Write/Edit call and clutters tool flow with system-reminder noise. Add early exit when CLAUDE_SESSION_ID is set (standard Claude Code session env var). Non-Claude runtimes (OpenCode, Gemini, etc.) that lack native read-before-edit enforcement continue to receive the advisory as before. Closes #1984 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix(hooks): sanitize runHook env to prevent test failures in Claude Code The runHook() test helper now blanks CLAUDE_SESSION_ID so positive-path tests pass even when the test suite runs inside a Claude Code session. The new skip test passes the env var explicitly via envOverrides. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -36,6 +36,11 @@ process.stdin.on('end', () => {
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
// Claude Code natively enforces read-before-edit — skip the advisory (#1984)
|
||||
if (process.env.CLAUDE_SESSION_ID) {
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
const filePath = data.tool_input?.file_path || '';
|
||||
if (!filePath) {
|
||||
process.exit(0);
|
||||
|
||||
Reference in New Issue
Block a user