
"read-once: A Claude Code Hook That Stops Redundant File Reads"
Claude Code re-reads files constantly. It reads a file, edits it, reads it again to verify. It re-reads config files across different subtasks. When subagents share a session, they re-read the same files the parent already loaded. Each re-read costs tokens. A 200-line file costs ~2,000 tokens every time Claude reads it. Read it 5 times in a session? That's 10,000 tokens for content that's already sitting in the context window. I built read-once to fix this. It's a Claude Code hook that tracks file reads within a session and blocks redundant ones. How it works read-once is a PreToolUse hook that intercepts every Read tool call: First read of a file: allows it, records the file path and modification time Re-read of an unchanged file: blocks it, tells Claude the content is already in context Re-read of a changed file: allows it (or shows just the diff) Cache entries expire after 20 minutes to handle context compaction When a re-read is blocked, Claude sees: read-once: schema.rb (~2,340 to
Continue reading on Dev.to
Opens in a new tab
