Code Quality
Systematic code improvement through review, refactoring, and debugging with verification gates.
Module Selection
| Need |
Module |
Reference |
| Receive Feedback |
Review |
references/code-review-reception.md |
| Request Review |
Review |
references/requesting-code-review.md |
| Verify Before Claim |
Review |
references/verification-before-completion.md |
| Reduce Complexity |
Refactoring |
references/oop-refactoring-catalog.md |
| Functional Patterns |
Refactoring |
references/functional-refactoring-patterns.md |
| Find Code Smells |
Refactoring |
references/code-smells-reference.md |
| Test Strategies |
Refactoring |
references/testing-strategies.md |
| Investigate Bugs |
Debugging |
references/systematic-debugging.md |
| Trace Root Cause |
Debugging |
references/root-cause-tracing.md |
| Add Validation |
Debugging |
references/defense-in-depth.md |
| Verify Fix |
Debugging |
references/verification.md |
Core Principles
YAGNI, KISS, DRY - Always honor these.
Be honest, be brutal, straight to the point, and be concise.
Technical correctness over social comfort. Verify before implementing. Ask before assuming. Evidence before claims.
Code Review
Receiving Feedback
Pattern: READ → UNDERSTAND → VERIFY → EVALUATE → RESPOND → IMPLEMENT
Rules:
- ❌ No performative agreement ("You're right!", "Great point!")
- ❌ No implementation before verification
- ✅ Restate requirement, ask questions, push back with reasoning
- ✅ YAGNI check: grep for usage before implementing suggestions
Sources:
- Human partner → Implement after understanding
- External reviewer → Verify technically before implementing
Requesting Review
When: After major features, before merge, after complex fixes
Process:
- Get SHAs:
BASE_SHA=$(git rev-parse HEAD~1), HEAD_SHA=$(git rev-parse HEAD)
- Dispatch code-reviewer subagent with: WHAT, PLAN, SHAs, DESCRIPTION
- Fix Critical immediately, Important before proceeding, note Minor
Verification Gates
Iron Law: NO COMPLETION CLAIMS WITHOUT FRESH VERIFICATION EVIDENCE
Gate: IDENTIFY → RUN → READ → VERIFY → THEN claim
Skip any step = lying, not verifying.
Refactoring
Mindset
Simplify relentlessly. Preserve behavior religiously. Measure everything.
Every refactoring: small and safe, tested immediately, measurably better.
Protocol
- Assessment - Baseline metrics, identify smells, classify debt
- Safety Net - Verify test coverage, add characterization tests
- Red-Green-Refactor - Write failing test, minimal pass, improve design
- Pattern Application - SOLID, design patterns, functional transforms
- Validation - Measure improvements, verify behavior preserved
Code Smells (5 Categories)
- Bloaters: Long Method, Large Class, Long Parameter List
- OO Abusers: Switch Statements, Temporary Field
- Change Preventers: Divergent Change, Shotgun Surgery
- Dispensables: Duplicate Code, Dead Code, Lazy Class
- Couplers: Feature Envy, Inappropriate Intimacy
Quick Patterns
OOP: Extract Method, Inline, Replace Temp with Query, Guard Clauses
Functional: Map/Filter/Reduce, Pure Functions, Composition, Immutability
Debugging
Core Principle
NO FIXES WITHOUT ROOT CAUSE INVESTIGATION FIRST
Random fixes waste time and create new bugs.
The Four Techniques
1. Systematic Debugging (references/systematic-debugging.md)
- Phase 1: Root Cause Investigation
- Phase 2: Pattern Analysis
- Phase 3: Hypothesis Testing
- Phase 4: Implementation
2. Root Cause Tracing (references/root-cause-tracing.md)
Trace backward through call stack to find original trigger.
3. Defense-in-Depth (references/defense-in-depth.md)
Validate at every layer: Entry → Business logic → Environment → Debug
4. Verification (references/verification.md)
Run command. Read output. Then claim result.
Quick Reference
Bug → systematic-debugging.md (Phase 1-4)
Error deep in stack? → root-cause-tracing.md
Found root cause? → defense-in-depth.md
About to claim success? → verification.md
Red Flags
Stop if thinking:
- "Quick fix for now, investigate later"
- "Just try changing X and see"
- "It's probably X, let me fix that"
- "Should work now" / "Seems fixed"
References
Code Review
references/code-review-reception.md - Response protocols
references/requesting-code-review.md - Request process
references/verification-before-completion.md - Verification gates
Refactoring
references/oop-refactoring-catalog.md - Martin Fowler's patterns
references/functional-refactoring-patterns.md - FP transformations
references/code-smells-reference.md - 23 smells, 5 categories
references/testing-strategies.md - Characterization tests, TDD
Debugging
references/systematic-debugging.md - Four-phase framework
references/root-cause-tracing.md - Call stack analysis
references/defense-in-depth.md - Multi-layer validation
references/verification.md - Verification protocols
Bottom Line
- Review: Technical rigor over social performance
- Refactor: Small, safe, tested, measurable
- Debug: Root cause first, fix once
- Always: Evidence before claims
Verify. Question. Then implement. Evidence. Then claim.
1---
2name: code-quality
3description: "Code quality improvement: review, refactoring, debugging. Phases: review feedback, systematic refactoring, root cause debugging, verification. Capabilities: SOLID/DRY compliance, code smell detection, complexity reduction, bug investigation, verification gates. Actions: review, refactor, debug, verify, validate code. Keywords: code review, refactor, debug, SOLID, DRY, code smell, bug fix, root cause, verification, technical debt, extract method, test failure, completion claim. Use when: reviewing code changes, improving code quality, fixing bugs, reducing technical debt, validating before merge/commit."
4metadata:
5 source: https://skillmd.com/skills/aibot88/code-quality
6---
7
8# Code Quality
9
10Systematic code improvement through review, refactoring, and debugging with verification gates.
11
12## Module Selection
13
14| Need | Module | Reference |
15|------|--------|-----------|
16| **Receive Feedback** | Review | `references/code-review-reception.md` |
17| **Request Review** | Review | `references/requesting-code-review.md` |
18| **Verify Before Claim** | Review | `references/verification-before-completion.md` |
19| **Reduce Complexity** | Refactoring | `references/oop-refactoring-catalog.md` |
20| **Functional Patterns** | Refactoring | `references/functional-refactoring-patterns.md` |
21| **Find Code Smells** | Refactoring | `references/code-smells-reference.md` |
22| **Test Strategies** | Refactoring | `references/testing-strategies.md` |
23| **Investigate Bugs** | Debugging | `references/systematic-debugging.md` |
24| **Trace Root Cause** | Debugging | `references/root-cause-tracing.md` |
25| **Add Validation** | Debugging | `references/defense-in-depth.md` |
26| **Verify Fix** | Debugging | `references/verification.md` |
27
28---
29
30## Core Principles
31
32**YAGNI, KISS, DRY** - Always honor these.
33
34**Be honest, be brutal, straight to the point, and be concise.**
35
36**Technical correctness over social comfort.** Verify before implementing. Ask before assuming. Evidence before claims.
37
38---
39
40## Code Review
41
42### Receiving Feedback
43
44**Pattern:** READ → UNDERSTAND → VERIFY → EVALUATE → RESPOND → IMPLEMENT
45
46**Rules:**
47- ❌ No performative agreement ("You're right!", "Great point!")
48- ❌ No implementation before verification
49- ✅ Restate requirement, ask questions, push back with reasoning
50- ✅ YAGNI check: grep for usage before implementing suggestions
51
52**Sources:**
53- Human partner → Implement after understanding
54- External reviewer → Verify technically before implementing
55
56### Requesting Review
57
58**When:** After major features, before merge, after complex fixes
59
60**Process:**
611. Get SHAs: `BASE_SHA=$(git rev-parse HEAD~1)`, `HEAD_SHA=$(git rev-parse HEAD)`
622. Dispatch code-reviewer subagent with: WHAT, PLAN, SHAs, DESCRIPTION
633. Fix Critical immediately, Important before proceeding, note Minor
64
65### Verification Gates
66
67**Iron Law:** NO COMPLETION CLAIMS WITHOUT FRESH VERIFICATION EVIDENCE
68
69**Gate:** IDENTIFY → RUN → READ → VERIFY → THEN claim
70
71Skip any step = lying, not verifying.
72
73---
74
75## Refactoring
76
77### Mindset
78
79Simplify relentlessly. Preserve behavior religiously. Measure everything.
80
81Every refactoring: small and safe, tested immediately, measurably better.
82
83### Protocol
84
851. **Assessment** - Baseline metrics, identify smells, classify debt
862. **Safety Net** - Verify test coverage, add characterization tests
873. **Red-Green-Refactor** - Write failing test, minimal pass, improve design
884. **Pattern Application** - SOLID, design patterns, functional transforms
895. **Validation** - Measure improvements, verify behavior preserved
90
91### Code Smells (5 Categories)
92
931. **Bloaters:** Long Method, Large Class, Long Parameter List
942. **OO Abusers:** Switch Statements, Temporary Field
953. **Change Preventers:** Divergent Change, Shotgun Surgery
964. **Dispensables:** Duplicate Code, Dead Code, Lazy Class
975. **Couplers:** Feature Envy, Inappropriate Intimacy
98
99### Quick Patterns
100
101**OOP:** Extract Method, Inline, Replace Temp with Query, Guard Clauses
102**Functional:** Map/Filter/Reduce, Pure Functions, Composition, Immutability
103
104---
105
106## Debugging
107
108### Core Principle
109
110**NO FIXES WITHOUT ROOT CAUSE INVESTIGATION FIRST**
111
112Random fixes waste time and create new bugs.
113
114### The Four Techniques
115
116**1. Systematic Debugging** (`references/systematic-debugging.md`)
117- Phase 1: Root Cause Investigation
118- Phase 2: Pattern Analysis
119- Phase 3: Hypothesis Testing
120- Phase 4: Implementation
121
122**2. Root Cause Tracing** (`references/root-cause-tracing.md`)
123Trace backward through call stack to find original trigger.
124
125**3. Defense-in-Depth** (`references/defense-in-depth.md`)
126Validate at every layer: Entry → Business logic → Environment → Debug
127
128**4. Verification** (`references/verification.md`)
129Run command. Read output. Then claim result.
130
131### Quick Reference
132
133```
134Bug → systematic-debugging.md (Phase 1-4)
135 Error deep in stack? → root-cause-tracing.md
136 Found root cause? → defense-in-depth.md
137 About to claim success? → verification.md
138```
139
140### Red Flags
141
142Stop if thinking:
143- "Quick fix for now, investigate later"
144- "Just try changing X and see"
145- "It's probably X, let me fix that"
146- "Should work now" / "Seems fixed"
147
148---
149
150## References
151
152### Code Review
153- `references/code-review-reception.md` - Response protocols
154- `references/requesting-code-review.md` - Request process
155- `references/verification-before-completion.md` - Verification gates
156
157### Refactoring
158- `references/oop-refactoring-catalog.md` - Martin Fowler's patterns
159- `references/functional-refactoring-patterns.md` - FP transformations
160- `references/code-smells-reference.md` - 23 smells, 5 categories
161- `references/testing-strategies.md` - Characterization tests, TDD
162
163### Debugging
164- `references/systematic-debugging.md` - Four-phase framework
165- `references/root-cause-tracing.md` - Call stack analysis
166- `references/defense-in-depth.md` - Multi-layer validation
167- `references/verification.md` - Verification protocols
168
169---
170
171## Bottom Line
172
1731. **Review:** Technical rigor over social performance
1742. **Refactor:** Small, safe, tested, measurable
1753. **Debug:** Root cause first, fix once
1764. **Always:** Evidence before claims
177
178Verify. Question. Then implement. Evidence. Then claim.