Cc Read Limit Hook
Description
A hook that limit and guide how claude code read files.
Installation
This entry records only its repository, not the path inside it, so there is no
exact command to give. Open the source below and copy the folder into
~/.claude/skills/, or the file into ~/.claude/agents/.
README
cc-read-limit-hook
A Claude Code PreToolUse hook that enforces file read limits to optimize context usage.
一个 Claude Code PreToolUse 钩子,用于限制文件读取范围以优化上下文使用。
Features / 功能
- Block large file reads - Files >1000 lines or >50KB require
offset+limitparameters - Limit single reads - Max 500 lines / 20KB per read operation
- Auto-add limit - Automatically adds limit when only offset is specified
- Statistics logging - Logs read attempts for analysis
- 阻止大文件读取 - 超过 1000 行或 50KB 的文件必须指定
offset+limit参数 - 限制单次读取 - 每次最多读取 500 行 / 20KB
- 自动添加 limit - 仅指定 offset 时自动补充 limit
- 统计日志 - 记录读取操作用于分析
Installation / 安装
Copy `read-guard.py` to your hooks directory:
cp read-guard.py "$USERPROFILE/.claude/hooks/"Add to `~/.claude/settings.json`:
{ "hooks": { "PreToolUse": [ { "matcher": "Read", "hooks": [ { "type": "command", "command": "python \"$USERPROFILE/.claude/hooks/read-guard.py\"" } ] } ] } }
Configuration / 配置
Edit the constants in `read-guard.py`:
MAX_FILE_LINES = 1000 # Line threshold / 行数阈值
MAX_FILE_BYTES = 50 * 1024 # Byte threshold / 字节阈值
MAX_SINGLE_READ_LINES = 500 # Max lines per read / 单次最大行数
MAX_SINGLE_READ_BYTES = 20 * 1024 # Max bytes per read / 单次最大字节
License / 许可
MIT
Related Skills
Awesome Go
A curated list of awesome Go frameworks, libraries and software
Development next.js
| The React Framework | 138360 | 1503 | 1 |
Development sharing-skills
skill for guidance.
Development root-cause-tracing
Use when errors occur deep in execution and you need to trace back to find the original trigger.
Development Template Skill
Minimal skeleton for a new skill project structure.
Development Third-party Notices
THE FOLLOWING SETS FORTH ATTRIBUTION NOTICES FOR THIRD PARTY SOFTWARE THAT MAY BE CONTAINED IN PORTIONS OF THI
Development