Appearance
Anti-over-abstraction Rule
Spirit (the 5 non-negotiables)
- Start with the smallest direct solution: implement the current requirement with concrete code that is easy to trace.
- Require present evidence: an abstraction needs a real boundary, meaningful reuse, multiple implementations, or a measurable reduction in complexity now.
- Keep small, local duplication when justified: similar code may represent concepts with different reasons to change.
- Use existing foundations: prefer the framework, standard library, and established project APIs over parallel infrastructure.
- Minimize total cognitive load: judge definitions, bindings, call sites, tests, configuration, and navigation together—not one file in isolation.
Rules
1) Direct, concrete implementations are mandatory
Implement the narrowest direct solution that satisfies the current behavior and constraints. Keep a simple flow inline when its purpose is clear. MUST NOT add a layer merely to give a name to a few lines; code review MUST reject that abstraction.
2) Evidence is required before introducing an abstraction
An abstraction MUST NOT be introduced unless at least one of these is true:
- It represents a real, named domain concept or architectural boundary.
- Multiple current callers share the same behavior and the same reason to change.
- Multiple current implementations must be substituted behind one contract.
- It removes meaningful repeated complexity, not just a few repeated lines.
- It isolates an unstable external service, protocol, or vendor boundary.
- It materially improves testing where framework-native testing is insufficient.
Imagined future callers and hypothetical implementations are not evidence.
3) Keep small duplication local
Do not extract code simply because a method is long or two snippets look similar. Small duplication MUST remain local when the code has different reasons to change, or when extraction would add more concepts, indirection, or navigation than it removes. The rule of three is only a review heuristic; it MUST NOT be used as automatic justification for extraction.
4) Do not design for requirements that do not exist
MUST NOT introduce speculative configuration, extension points, plugin systems, callbacks, strategy registries, or generic type parameters for hypothetical future needs.
5) Framework and standard-library primitives are mandatory
MUST use the framework, standard library, and established project APIs directly when they already own the responsibility. MUST NOT add a wrapper unless it adds substantial policy, translates between genuine boundaries, centralizes unstable vendor behavior, or provides a project-wide contract with more than one meaningful consumer. Renaming methods or forwarding arguments is not enough.
6) Prohibited speculative layers
Do not create these for one straightforward use case unless the task or existing architecture clearly requires them:
- Generic helpers or utility classes.
- Wrappers around framework APIs.
- Service or manager classes that only forward calls.
- Repositories that merely mirror an ORM.
- Interfaces with one implementation and no real substitution boundary.
- Factories that only call one constructor.
- Base classes or traits used only to share a few lines.
- Pipelines, registries, strategies, adapters, DTOs, or command buses added for ceremony.
- Custom infrastructure already provided by the framework (validation, routing, events, queues, caching, storage, collections, dependency injection, ORM).
7) Local composition is mandatory; global indirection is prohibited without evidence
Use a small private method only when it clarifies one local flow. MUST NOT promote it into a global helper without multiple real consumers. Keep domain policy separate from infrastructure when that boundary is real. MUST NOT split simple conditionals into polymorphism unless the variants are numerous, independently evolving, or externally supplied.
8) Preserve contracts
MUST keep existing public behavior and project conventions unless the requirement explicitly changes them. MUST NOT add a test-only production abstraction; test the direct implementation at the closest useful level with framework-native testing facilities.
Required gates
Author and reviewer MUST complete every item before introducing or approving an abstraction. The work is incomplete if any item is unchecked.
- [ ] Inspect nearby code and project conventions first.
- [ ] Identify the current requirement, behavior, and constraints.
- [ ] Implement the narrowest framework-native solution first; name the direct inline alternative.
- [ ] Name which Rule 2 evidence applies before adding an abstraction; confirm callers and implementations are current.
- [ ] Compare the direct and abstracted versions by total cognitive load (files, concepts, bindings, call sites, mocks, tests, configuration).
- [ ] Confirm it does not wrap or rebuild a capability the framework, standard library, or an existing project abstraction already owns.
- [ ] Preserve public contracts; add only the closest useful tests (Rule 8).
- [ ] Remove unused pass-through layers and speculative options; delete any new helper, interface, service, factory, trait, or configuration option that can be removed while keeping the code clear.
When uncertain, keep the code inline and concrete.

