This skill should be used when the user asks to "implement", "build", "create", "add feature", "develop", "design", "architect", "plan", "structure", "refactor", "improve", "optimize", "review", "fix", "solve", "handle", "debug", or discusses implementation strategies. Apply cognitive load principles to ALL development work as a cornerstone principle.
This skill inherits all available tools. When active, it can use any tool Claude has access to.
references/anti-patterns.mdreferences/code-review-checklist.mdreferences/examples.mdPeople can hold ~4 chunks in working memory at once. Beyond this, mental burden increases exponentially. The goal is to minimize extraneous cognitive load - the load created by how information is presented, not the inherent task difficulty.
There are two types of cognitive load:
Great code is boring code. If newcomers take >40 minutes to understand a piece of code, it needs improvement.
Multiple conditions in a single statement force simultaneous mental tracking.
// High load - track all conditions at once
if val > someConstant && (condition2 || condition3) && (condition4 && !condition5) { }
// Low load - named, sequential concepts
isValid := val > someConstant
isAllowed := condition2 || condition3
isSecure := condition4 && !condition5
if isValid && isAllowed && isSecure { }
Rule: If a condition has more than 2-3 parts, extract to named variables.
Nested conditionals require tracking multiple preconditions simultaneously.
// High load - nested context tracking
if isValid {
if isSecure {
if hasPermission {
doStuff()
}
}
}
// Low load - linear thinking, guard clauses
if !isValid { return }
if !isSecure { return }
if !hasPermission { return }
doStuff()
Rule: Flatten nested conditionals with early returns. Focus on the happy path.
Deep inheritance requires jumping between multiple files to understand behavior.
AdminController → UserController → GuestController → BaseController = exponential cognitive load.
Rule: Compose behaviors from small, focused components instead of inheriting from base classes.
Unix I/O has 5 basic calls hiding hundreds of thousands of lines. That's a deep module.
Anti-pattern: 80 tiny classes with single methods each = impossible to understand. The cognitive load is in remembering ALL modules AND their interactions.
Rule: Don't fragment code into many small pieces. Interfaces more complex than implementations are a smell.
Wrong: "One method per responsibility" = shallow module explosion.
Correct: A module should be responsible to one stakeholder. If changes cause two different stakeholders to complain, the principle is violated.
Rule: SRP is about who might request changes, not counting methods.
5 developers × 17 microservices = distributed monolith disaster.
Rule: Start with a modular monolith. Only extract services when team scaling demands it. Apply deep/shallow thinking at architecture scale.
Every language feature creates a decision point. Readers must recreate why you chose this approach.
C++ developers must understand historical baggage, multiple initialization syntaxes, and competing paradigms.
Rule: Use orthogonal, minimal feature sets. Prefer boring, obvious patterns.
Numeric codes require mental mapping: 401 = expired JWT, 403 = insufficient access, 418 = banned user.
// Instead of numeric codes in headers
{ "code": "jwt_has_expired" }
Rule: Return self-describing codes. Prefer "login" over "authentication", "permissions" over "authorization".
Over-eliminating repetition creates tight coupling between unrelated components.
"A little copying is better than a little dependency." — Rob Pike
Rule: Don't extract common functionality based on perceived similarity. Dependencies mean debugging 10+ stack trace levels.
"Magic" in frameworks forces learning framework internals before contributing business logic.
Anti-pattern: Business logic residing inside framework decorators/annotations.
Rule: Position frameworks outside core logic. New contributors should add value on day one without framework expertise.
Layered architecture (hexagonal, onion) adds indirection without reducing cognitive load.
Real consequences:
Rule: Add layers only when justified by practical extension needs, not architectural aesthetics.
"We write code in DDD" = subjective interpretations per team = battleground for debate.
DDD addresses ubiquitous language and domain boundaries. It's not about repositories, aggregates, or folder naming.
Rule: Focus on understanding the problem domain, not enforcing structural patterns.
Code can feel familiar (internalized mental models) without being simple.
Original authors add complexity incrementally (unnoticed). Newcomers encounter the entire mess at once.
Detection: If new developers experience sustained confusion (>40 minutes), the code needs improvement.
Rule: Measure code quality by newcomer onboarding time, not expert familiarity.
Before writing or reviewing code, ask:
For detailed patterns and examples, consult:
references/anti-patterns.md - Comprehensive anti-pattern catalog with explanationsreferences/code-review-checklist.md - Quick checklist for code reviewsreferences/examples.md - Before/after code transformations"Debugging is twice as hard as writing code. If you write code as cleverly as possible, you're not smart enough to debug it." — Brian Kernighan