360 Secure SkillHub
360 安全技能中心

principle-minimize-reader-load

该 Skill 提供一条代码可维护性原则:用追踪答案所需的间接层数和读者需记住的隐藏或可变状态衡量读者负担,建议内联单调用包装、缩小状态作用域,并在边界命名不变量,以审查或调整难追踪的代码。

分类:开发
poteto
热度 0.00
最近更新 2026-11-25 17:46:35

安装

发给 Agent
帮我安装这个技能:npx secure-skills-cli add poteto/plugins/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

Maintainability is the work a reader must do to understand code. Track two axes:

  1. Layers to trace. How many indirections sit between the question and the answer.
  2. State to hold. How much hidden or mutable context the reader must keep in their head.

Why: Code is read far more than it is written. 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.

The pattern:

  • Collapse layers that do not earn their keep: wrappers with one caller, adapters with no second implementation, indirection introduced for a future that never came. Inline them.
  • 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 this reduce reader load somewhere else 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.