Prevent the 23.5% incident spike from AI-generated code.
MetricImpactIncident rate+23.5% per PR with AI codeCode churn3.1% → 5.7% (nearly doubled)Developer speed-19% slower with AI tools (experienced devs)Trust in AI output33% (down from higher)
Root cause: Teams ship code faster than they understand it.
Definition: Cognitive debt = the gap between what your codebase does and what your team comprehends about it.
Unlike technical debt (code you know is bad), cognitive debt is code you don't even know is bad — because you never understood it.
Living architecture context for humans and AI agents.
markdown
# MEMORY.md Template
## Architecture Decisions
- [Decision 1]: Why we chose X over Y
- [Decision 2]: Trade-offs we accepted
## AI-Free Zones (human must own completely)
- Authentication & authorization
- Payment processing
- Data deletion
- Database migrations
- Security-critical paths
## Conventions
- Naming: [rules]
- Error handling: [pattern]
- Testing: [requirements]
## Known Constraints
- [Performance requirement]
- [Compliance requirement]
- [Integration dependency]
Rule: MEMORY.md is open in editor at all times when working with AI.
3 questions before accepting AI-generated code:
text
Before you click "Accept" on AI output:
1. Can I explain what this code does in plain language?
[ ] Yes → Continue
[ ] No → STOP. Read until you can.
2. Can I trace the data flow from input to output?
[ ] Yes → Continue
[ ] No → STOP. Add comments or simplify.
3. If this breaks in production, would I know where to look?
[ ] Yes → Accept
[ ] No → STOP. Add logging or documentation.
Rule: All 3 must be YES before merge.
Active Use ✅Passive Use ❌Prompt → Read → Understand → Modify → ShipPrompt → Accept → Ship → ForgetYou steer, AI fillsAI decides, you acceptComprehension maintainedCognitive debt accumulates
Rule: Never accept >50 lines of AI code without reading and understanding every line.
AI-assisted PR limits:
ConstraintLimitMax lines per AI PR200Concerns per PR1Test coverage on AI paths100%Files touched≤5
Why: Smaller PRs = easier to comprehend = less cognitive debt.
90-minute sprint ceremony:
text
## Cognitive Debt Audit Agenda
1. Review top 5 AI-heaviest PRs from last quarter
2. For each PR, ask:
- Can we still explain what it does?
- Have we had incidents related to it?
- Is documentation up to date?
3. Identify cognitive debt hotspots
4. Plan debt reduction for next sprint
5. Update MEMORY.md with new learnings
When reviewing AI-generated code:
text
Layer 1: Comprehension
- Can I understand this without running it?
- Is naming clear?
- Is complexity justified?
Layer 2: Correctness
- Does it do what it claims?
- Edge cases covered?
- Error handling present?
Layer 3: Integration
- Fits existing patterns?
- No duplicate functionality?
- Dependencies appropriate?
Layer 4: Security
- No exposed secrets?
- Input validation?
- AI-free zone respected?
Layer 5: Maintainability
- Tests included?
- Documentation added?
- Will I understand this in 6 months?
This skill activates when:
text
Before Accepting AI Code:
1. Read it (all of it)
2. Explain it (out loud if needed)
3. Trace data flow
4. Check AI-free zone
5. Limit: 200 lines, 1 concern
MIT