360 Secure SkillHub
360 安全技能中心

principle-minimize-reader-load

提供一套代码评审与重构原则:合并只有一个调用者的包装层、缩小可变状态作用域、在边界处声明不变量,并以读者能否快速回答来源与变更问题作为检验标准。

分类:开发
backnotprop
热度 69.42
最近更新 2026-11-24 05:23:54

安装

发给 Agent
帮我安装这个技能:npx secure-skills-cli add backnotprop/pstack/principle-minimize-reader-load
兼容性
通用兼容
联网要求
不联网
数据出网
数据不出本机
Metadata
name
principle-minimize-reader-load
description
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.
disable-model-invocation
true

Minimize Reader Load

Reader load is the work a reader must do to understand code. It has two independent axes: layers to trace between the question and the answer, and hidden or mutable state to hold in their head. Guard both.

  • Collapse layers that only forward: wrappers with one caller, adapters with no second implementation, pass-through methods. Inline them.
  • Shrink state scope: returns over mutations, locals over fields, fields over module state, module state over globals. Derive instead of sync.
  • Name an invariant once at the boundary, not in every consumer.

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.