gsd-read-guard.js
PreToolUse hook that advises the model to Read a file before it writes or edits that existing file.
The source repository is archived by its owner, so it gets no more updates.
- Kind
- Hook
- Works with
- Claude Code, Gemini / Antigravity
- Languages
- TypeScript / JavaScript
- Source
- gsd-build/get-shit-done @ bdcaab2c752d
- Path
- hooks/gsd-read-guard.js
- Jobs
- Guardrails
Credit
- Made by
- gsd-build
- Original
- github.com/gsd-build/get-shit-done/blob/bdcaab2c752d9a33a1a1c…
- License
- MIT
Listed by Skill Manifest; not made by us.
InstallCopy it from the source repository, or sign in and let the assistant adapt it for your project.
Install factsScanned 3 Nov 2026
- Adds
- Entries under `hooks` in .claude/settings.json
- Runs scripts
- Yes
- gsd-read-guard.js
- the component is a script
- Uses the network
- None found
- Needs secrets
- None found
- Reads environment variables
- CLAUDE_CODE_ENTRYPOINT
- CLAUDE_CODE_SSE_PORT
- CLAUDE_SESSION_ID
- CLAUDECODE
- Reads outside the project
- /usr/bin/env (gsd-read-guard.js)
- Source revision
- bdcaab2c752d
- Licence
- MIT
- Last activity
- Archived by its owner
- Last push 31 May 2026
- Review
- Reviewed
Found by a static scan of the stored text; nothing is run. “None found” is not a guarantee, so read what you install before you run it.
#!/usr/bin/env node
// gsd-hook-version: {{GSD_VERSION}}
// GSD Read Guard — PreToolUse hook
// Injects advisory guidance when Write/Edit targets an existing file,
// reminding the model to Read the file first.
//
// Background: Non-Claude models (e.g. MiniMax M2.5 on OpenCode) don't
// natively follow the read-before-edit pattern. When they attempt to
// Write/Edit an existing file without reading it, the runtime rejects
// with "You must read file before overwriting it." The model retries
// without reading, creating an infinite loop that burns through usage.
//
// This hook prevents that loop by injecting clear guidance BEFORE the
// tool call reaches the runtime. The model sees the advisory and can
// issue a Read call on the next turn.
//
// Triggers on: Write and Edit tool calls
// Action: Advisory (does not block) — injects read-first guidance
// Only fires when the target file already exists on disk.
const fs = require('fs');
const path = require('path');
let input = '';
const stdinTimeout = setTimeout(() => process.exit(0), 3000);
process.stdin.setEncoding('utf8');
process.stdin.on('data', chunk => input += chunk);
process.stdin.on('end', () => {
…