Documentation Index
Fetch the complete documentation index at: https://docs.claude-mem.ai/llms.txt
Use this file to discover all available pages before exploring further.
File Read Gate
What It Is
The File Read Gate is a PreToolUse hook that intercepts Claude’sRead tool calls. When Claude tries to read a file that has prior observations in the database, the gate blocks the read and instead shows a compact timeline of past work on that file. Claude then decides the cheapest path to get the context it needs.
This is a concrete implementation of progressive disclosure — show what exists first, let the agent decide what to fetch.
How It Works
The Decision Tree
Claude has four options after seeing the timeline, ordered from cheapest to most expensive:| Option | Token Cost | When to Use |
|---|---|---|
| Semantic priming | 0 extra | Timeline titles tell Claude enough to proceed |
| get_observations([IDs]) | ~300 each | Need specific details from past work |
| smart_outline / smart_unfold | ~1-2k | Need current code structure or a specific function |
| Full file read | 5k-50k | File has changed significantly since observations |
Current Date/Time for Temporal Reasoning
The timeline includes the current date and time as its first line:- Observations from today — likely still accurate, semantic priming is safe
- Observations from last week — probably accurate, get_observations for details
- Observations from months ago — file may have changed, consider smart_outline or full read
YYYY-MM-DD time timezone), so Claude sees consistent temporal markers throughout its session.
Token Economics
A typical source file costs 5,000-50,000 tokens to read in full. The File Read Gate replaces that with:| Component | Tokens |
|---|---|
| Timeline header + instructions | ~120 |
| 15 observation entries | ~250 |
| Total timeline | ~370 |
Real-World Example
Without the gate (readingworker-service.ts):
Specificity Ranking
Not all observations about a file are equally relevant. The gate scores each observation by how specifically it relates to the target file:| Signal | Score Bonus |
|---|---|
| File was modified (not just read) | +2 |
| Observation covers 3 or fewer total files | +2 |
| Observation covers 4-8 total files | +1 |
| Observation covers 9+ files (survey-like) | +0 |
Configuration
Small File Bypass
Files smaller than 1,500 bytes always pass through the gate without interception. At that size, the timeline (~370 tokens) would cost more than reading the file directly. This threshold is hardcoded insrc/cli/handlers/file-context.ts.
Project Exclusions
Projects matching patterns inCLAUDE_MEM_EXCLUDED_PROJECTS skip the gate entirely. Configure this in ~/.claude-mem/settings.json:
How to Disable the Gate
The File Read Gate is implemented as a PreToolUse hook on theRead tool matcher. To disable it, remove the Read matcher entry from the hooks configuration:
-
Open your Claude Code settings:
-
Find the claude-mem hooks section under
hooks.PreToolUseand remove the entry with theReadmatcher.
Disabling the gate means Claude will read full files every time, which increases token usage but ensures it always sees the latest code. This is a reasonable choice for small projects or when observations are sparse.
How It Fits Together
The File Read Gate is one piece of claude-mem’s layered context strategy:- Session Start: Inject timeline of recent observations (layer 1 — metadata)
- File Read Gate: Intercept reads with observation history (layer 1 — metadata)
- get_observations: Fetch specific observation details on demand (layer 2 — details)
- smart_outline / smart_unfold: Read current code structure efficiently (layer 3 — source)
- Full file read: Last resort when everything else is insufficient

