principle-minimize-reader-load
它能做什么
为智能体提供一条让代码便于人阅读的规则。适合因包装层、间接调用或共享状态而难以追踪代码的团队。
适用场景
- ✓当代码难以从问题追踪到答案的时候。
- ✓当某个包装层只有一个调用方,或某个适配器没有第二种用途的时候。
- ✓当全局或可变状态使行为难以预测的时候。
技能链接
https://github.com/cursor/plugins/blob/main/harness/pstack/claude-code/skills/principle-minimize-reader-load/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“这个模块有五层包装,做的都是同样的事情。请把它简化,让新开发者能够看懂。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会统计从问题到答案之间的层数,以及读者必须追踪的隐藏状态。它会合并那些成本高于收益的包装层,优先使用纯函数,并把状态的作用范围缩小到最小的有用范围。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Minimize Reader Load
Maintainability is the work a reader must do to understand code. Track two axes: layers to trace (indirections between the question and the answer) and state to hold (hidden or mutable context the reader must keep in their head). LOC, cyclomatic complexity, and "clean architecture" are proxies. Reader load is the thing that matters. The two axes are independent. A flat file with 50 globals can be as hard to reason about as a 6-layer adapter stack. Guard both. This is the human analog of Guard the Context Window. Working memory is finite for readers too.
- Collapse layers that cost more than they save: wrappers with one caller, adapters with no second implementation, speculative indirection that was never needed. Inline them.
- Make adjacent layers change the abstraction. A layer that repeats the same methods and arguments adds reader load without compression. Collapse pass-through layers.
- Demand interface compression. A broad interface that hides little complexity makes readers learn both the surface and the implementation. Prefer boundaries that hide meaningful decisions.
- Shrink state scope: prefer pure functions (returns over mutations), locals over fields, fields over module state, and module state over globals. Derive instead of sync.
- Name the invariant at the boundary, not in every consumer, so the reader learns it once.
- Before adding a layer or a piece of state, ask: does it reduce reader load elsewhere by at least as much?
The test: can a new reader answer "where does X come from?" and "what can change X?" in under 30 seconds? If not, cut layers or cut state.
常见问题
代码行数是目标吗?
不是。该技能认为,读者付出的理解成本比代码行数或复杂度评分更重要。
什么时候应该删除一层?
当它增加了读者的理解负担,却没有真正的收益时,例如只有一个调用方的包装层。
状态怎么办?
优先使用纯函数和局部变量,而不是字段、模块状态和全局变量。
详情
作者的原始描述
Apply when reviewing or shaping code that's hard to trace. Count layers between question and answer, and hidden state in the reader's head; collapse one-caller wrappers and shrink mutable scope.
repo: cursor/plugins
热度
- GitHub 星标
- 15k
- 排名
- #10981
- 许可证
- —
- 更新时间
- 2026/10/31
评论
- …
同一仓库的更多技能
advisor
15k如果你开启该功能,让你的智能体在关键节点咨询一个更强的第二模型,例如在重大决定之前,或在错误上卡住时。
check-agent-compatibility
15k全面检查 AI 编程智能体能否启动、验证和记录某个代码仓库,并返回一个兼容性评分以及主要问题。
cli-for-agents
15k教你的智能体设计或审查命令行工具,使 AI 智能体无需提示即可运行,并提供清晰的帮助文字和示例。
continual-learning
15k通过把回顾过往对话的工作交给专门的记忆更新程序,使你的 AGENTS.md 笔记保持最新。