一键导入
levels-of-abstraction
Use when discussing levels of abstraction, composed method, SLAP, stepdown rule, or mixed abstraction levels within a function.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Use when discussing levels of abstraction, composed method, SLAP, stepdown rule, or mixed abstraction levels within a function.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Use when refactoring code, identifying refactor candidates, or improving design after tests are green.
Use when refactoring into deep modules, choosing seams, classifying dependencies, deciding adapter strategy, or planning tests around a refactor.
Use when designing interfaces, comparing interface alternatives, applying Design It Twice, or exploring interfaces for a module.
Find deep-module opportunities in a codebase. Use when the user wants to improve architecture, refactor, consolidate tightly-coupled modules, or make a codebase more testable and AI-navigable.
Test-driven development with red-green-refactor loop. Use when user wants to build features or fix bugs using TDD, mentions "red-green-refactor", wants integration tests, or asks for test-first development.
Use when discussing modules, interfaces, implementation, depth, seams, adapters, leverage, locality, or code design terminology.
| name | levels-of-abstraction |
| description | Use when discussing levels of abstraction, composed method, SLAP, stepdown rule, or mixed abstraction levels within a function. |
Every function should operate at a single level of abstraction. When a function calls high-level helpers and does low-level work inline, the reader has to constantly shift mental gears. The fix is always the same: give the low-level block a name.
Composed Method (Kent Beck, Smalltalk Best Practice Patterns, 1997) A public method that reads as an outline of steps. Each step is a call to a private method with a clear name. The public method states what; the private methods handle how.
Single Level of Abstraction — SLA / SLAP (named by Neal Ford, The Productive Programmer, 2008; restated by Robert C. Martin, Clean Code, 2008) All statements in a function belong to the same level of abstraction. If one statement is at a lower level, extract it.
Stepdown Rule (Robert C. Martin, Clean Code) Functions in a file read top-down: each function is followed by the functions one level of abstraction below it, like a newspaper article narrowing from headline to detail.
Mental Grouping The cognitive work a reader does to assemble missing abstractions — scanning a block of code and figuring out "this chunk does X." A missing method forces the reader to do the extraction in their head.
See refactoring — Extract function and Extract class are the primary moves. Extract class applies when extract function would need too many parameters (a sign the parameters want to be fields of a cohesive object).