Uncle Bob Craft
Apply Robert C. Martin (Uncle Bob) criteria for code review and production: Clean Code, Clean Architecture, The Clean Coder, Clean Agile, and design-pattern discipline. This skill is complementary to the existing @clean-code skill (which focuses on the Clean Code book) and to your project's linter/formatter—it does not replace them.
Overview
This skill aggregates principles from Uncle Bob's body of work for reviewing and writing code: naming and functions (via @clean-code), architecture and boundaries (Clean Architecture), professionalism and estimation (The Clean Coder), agile values and practices (Clean Agile), and design-pattern use vs misuse. Use it to evaluate structure, dependencies, SOLID in context, code smells, and professional practices. It provides craft and design criteria only—not syntax or style enforcement, which remain the responsibility of your linter and formatter.
Reference files (load on demand)
| File |
When to load |
./reference.md |
Load first for the full aggregated summary of all sources, including heuristics C1–T9-style and component principles (REP/CCP/CRP, ADP/SDP/SAP). |
./references/clean-architecture.md |
Load when reviewing layer boundaries, dependency direction, or separation of concerns. |
./references/clean-coder.md |
Load when discussing estimation, saying no, sustainable pace, or professionalism. |
./references/clean-agile.md |
Load when discussing Iron Cross, TDD, refactoring, pair programming, or agile process. |
./references/design-patterns.md |
Load when assessing whether a design pattern is justified or detecting cargo-cult misuse. |
When to Use
- Code review: Apply Dependency Rule, boundaries, SOLID, and smell heuristics; suggest concrete refactors.
- Refactoring: Decide what to extract, where to draw boundaries, and whether a design pattern is justified.
- Architecture discussion: Check layer boundaries, dependency direction, and separation of concerns.
- Design patterns: Assess correct use vs cargo-cult or overuse before introducing a pattern.
- Estimation and professionalism: Apply Clean Coder ideas (saying no, sustainable pace, three-point estimates).
- Agile practices: Reference Clean Agile (Iron Cross, TDD, refactoring, pair programming) when discussing process.
- Do NOT use to replace or override the project's linter, formatter, or automated tests.
Prerequisites
@clean-code skill should be available for naming, functions, comments, formatting, and test heuristics. This skill references it rather than duplicating that material.
- Project linter and formatter must be configured and runnable independently. This skill does not enforce syntax or style.
- Test suite should exist or be in progress; this skill reminds you to keep tests green during refactoring but does not generate or run them.
- Windows host (PowerShell) is the primary environment. Path examples use Windows conventions where relevant.
Procedure
Step 1 — Determine context (review vs writing vs refactoring)
| Context |
Apply |
| Code review |
Dependency Rule and boundaries; SOLID in context; list smells; suggest one or two concrete refactors (e.g., extract function, invert dependency); check tests and professionalism. |
| Writing new code |
Prefer small functions and single responsibility; depend inward (Clean Architecture); write tests first when doing TDD; avoid patterns until duplication or variation justifies them. |
| Refactoring |
Identify one smell at a time; refactor in small steps with tests green; improve names and structure before adding behavior. |
Step 2 — Check boundaries and Dependency Rule
- Identify the layers in the changed code (entities, use cases, interface adapters, frameworks/drivers).
- Verify that dependencies point inward: use cases do not import from UI, web framework, or DB client packages.
- Flag any outward-pointing dependency with file path and import statement.
For detailed layer definitions and boundary patterns, load ./references/clean-architecture.md.
Step 3 — Evaluate SOLID in context
Check each principle where it applies to the touched code:
- SRP: Does the function/class have one reason to change? If it parses AND persists, split.
- OCP: Can you add new behavior without modifying existing code? If not, consider a strategy or interface.
- LSP: Do subclasses preserve the contract of their base? Flag any override that breaks expectations.
- ISP: Are consumers forced to depend on methods they don't use? Split the interface.
- DIP: Do high-level modules depend on abstractions, not concretions? Introduce an interface if a use case imports a concrete DB client.
Step 4 — Scan for smells
| Smell |
Meaning |
| Rigidity |
Small change forces many edits. |
| Fragility |
Changes break unrelated areas. |
| Immobility |
Hard to reuse in another context. |
| Viscosity |
Easy to hack, hard to do the right thing. |
| Needless complexity |
Speculative or unused abstraction. |
| Needless repetition |
DRY violated; same idea in multiple places. |
| Opacity |
Code is hard to understand. |
List each smell with the file/function/area where it appears. Full heuristic lists (C1–T9-style) are in ./reference.md—load it when you need the complete checklist.
Step 5 — Propose concrete refactors
For each review, suggest at least one concrete refactor:
- "Extract this into a function named
apply_discount."
- "Introduce an
OrderRepository interface so the use case does not depend on the concrete DB client."
- "Split
process into parse and persist to satisfy SRP."
Step 6 — Assess design patterns (if relevant)
- Use patterns when they solve a real design problem (variation in behavior, lifecycle, or cross-cutting concern).
- Avoid cargo cult: Do not add Factory/Strategy/Repository just because the codebase "should" have them.
- Rule of thumb: Introduce a pattern when you feel the third duplication or the second reason to change; name the pattern in code or docs so intent is clear.
- Signs of misuse: Pattern name in every class name, layers that only delegate without logic, patterns that make simple code harder to follow.
Load ./references/design-patterns.md for detailed use-vs-misuse criteria.
Step 7 — Check tests and professionalism
- Note if tests exist for the changed code.
- Flag obvious "we'll fix it later" comments that violate professionalism (Clean Coder).
- If discussing process, reference Clean Agile: Iron Cross (cost/quality/features/schedule), TDD, refactoring, pair programming.
Load ./references/clean-coder.md for estimation and professionalism detail.
Load ./references/clean-agile.md for agile values and practices.
Step 8 — Run linter and formatter separately
This skill does NOT replace lint or format. After applying craft criteria, run the project's own tooling:
# Example: run project linter (use your project's actual command)
npm run lint
# Example: run formatter
npm run format
Examples
Example 1: Code review prompt (copy-pasteable)
Please review this change using Uncle Bob craft criteria (@uncle-bob-craft):
1. Dependency Rule and boundaries — do dependencies point inward?
2. SOLID in context — any violations in the touched code?
3. Smells — list rigidity, fragility, immobility, viscosity, needless complexity/repetition, or opacity.
4. Suggest one or two concrete refactors (e.g., extract function, invert dependency).
Do not duplicate lint/format; focus on structure and design.
Example 2: Before/after (extract and name)
Before (opacity, does more than one thing):
def process(d):
if d.get("t") == 1:
d["x"] = d["a"] * 1.1
elif d.get("t") == 2:
d["x"] = d["a"] * 1.2
return d
After (clear intent, single level of abstraction):
def apply_discount(amount: float, discount_type: int) -> float:
if discount_type == 1:
return amount * 1.1
if discount_type == 2:
return amount * 1.2
return amount
def process(order: dict) -> dict:
order["x"] = apply_discount(order["a"], order.get("t", 0))
return order
Pitfalls
Treating every class as needing a Factory or Strategy.
Fix: Introduce patterns only when you have a real design need (third duplication, second axis of change). Load ./references/design-patterns.md for criteria.
Review only listing "violates SOLID" without saying where or how.
Fix: Point to the file/function and name the specific principle (e.g., "SRP: this function parses and persists; split into parse and persist").
Skipping the project linter because "we applied Uncle Bob."
Fix: This skill is about craft and design; always run the project's lint and format separately. This skill does NOT enforce syntax or style.
Adding design patterns without a clear duplication or variation reason.
Fix: Wait for the third duplication or second reason to change before introducing a pattern. Name the pattern in code or docs so intent is clear.
Overwriting @clean-code material.
Fix: Use @clean-code for naming, functions, comments, formatting, and test heuristics. Use this skill for architecture, boundaries, SOLID, smells, and process.
Generating tests instead of reminding to write them.
Fix: This skill does not replace automated tests. It can remind you to write tests (Clean Coder, Clean Agile) but does not run or generate them.
Verification
After applying this skill, verify the following:
Dependency direction check: Confirm no use-case or entity imports from UI, web framework, or DB client packages.
# Example: search for outward-pointing imports in use-case layer
Select-String -Path .\src\use_cases\*.py -Pattern "import.*framework|import.*db_client|import.*ui"
Expected: no matches (or only matches through interfaces/abstractions).
Smell list completeness: Confirm each identified smell includes file path and function/area.
Concrete refactor proposed: Confirm at least one specific refactor suggestion exists (not just "violates SOLID").
Linter and formatter run independently: Confirm the project's lint and format commands were executed separately from this skill's review.
npm run lint
npm run format
No syntax/style enforcement from this skill: Confirm this skill did not override or replace linter/formatter output.
Related Skills
@clean-code — Detailed Clean Code book material (names, functions, comments, formatting, tests, classes, smells). Use for day-to-day code quality; use uncle-bob-craft for architecture and cross-book criteria.
@architecture — General architecture decisions and trade-offs. Use when choosing high-level structure; use uncle-bob-craft for Dependency Rule and boundaries.
@code-review-excellence — Code review practices. Combine with uncle-bob-craft for principle-based review.
@refactor-clean-code — Refactoring toward clean code. Use with uncle-bob-craft when refactoring for boundaries and SOLID.
@test-driven-development — TDD workflow. Aligns with Clean Agile and Clean Coder (tests as requirement, sustainable pace).
Limitations
- Does not replace the project linter or formatter. Run lint and format separately; this skill gives design and craft criteria only.
- Does not replace automated tests. It can remind you to write tests but does not run or generate them.
- Complementary to tooling. Use it alongside existing CI, lint, and test suites.
- No syntax or style enforcement. Focuses on structure, dependencies, smells, and professional practice—not brace style or line length.
- Summaries, not the books. Full Clean Code heuristics, component principles (REP/CCP/CRP, ADP/SDP/SAP), and detailed stories are in the books; we reference the most used parts. See
./reference.md "Scope and attribution."
1---2name: uncle-bob-craft3description: Applies Robert C. Martin craft to review and production code: inward Dependency Rule, SOLID in context, rigidity/fragility smells, and pattern use versus cargo cult. Trigger on code review, refactoring, Clean Architecture, SOLID, or Uncle Bob. Not a linter or formatter substitute and never a Clean Code naming/functions duplicate.4---5
6# Uncle Bob Craft
7
8Apply Robert C. Martin (Uncle Bob) criteria for **code review and production**: Clean Code, Clean Architecture, The Clean Coder, Clean Agile, and design-pattern discipline. This skill is **complementary** to the existing `@clean-code` skill (which focuses on the Clean Code book) and to your project's linter/formatter—it does not replace them.
9
10## Overview
11
12This skill aggregates principles from Uncle Bob's body of work for **reviewing** and **writing** code: naming and functions (via `@clean-code`), architecture and boundaries (Clean Architecture), professionalism and estimation (The Clean Coder), agile values and practices (Clean Agile), and design-pattern use vs misuse. Use it to evaluate structure, dependencies, SOLID in context, code smells, and professional practices. It provides craft and design criteria only—not syntax or style enforcement, which remain the responsibility of your linter and formatter.
13
14### Reference files (load on demand)
15
16| File | When to load |
17|------|-------------|
18| `./reference.md` | Load first for the full aggregated summary of all sources, including heuristics C1–T9-style and component principles (REP/CCP/CRP, ADP/SDP/SAP). |
19| `./references/clean-architecture.md` | Load when reviewing layer boundaries, dependency direction, or separation of concerns. |
20| `./references/clean-coder.md` | Load when discussing estimation, saying no, sustainable pace, or professionalism. |
21| `./references/clean-agile.md` | Load when discussing Iron Cross, TDD, refactoring, pair programming, or agile process. |
22| `./references/design-patterns.md` | Load when assessing whether a design pattern is justified or detecting cargo-cult misuse. |
23
24## When to Use
25
26- **Code review**: Apply Dependency Rule, boundaries, SOLID, and smell heuristics; suggest concrete refactors.
27- **Refactoring**: Decide what to extract, where to draw boundaries, and whether a design pattern is justified.
28- **Architecture discussion**: Check layer boundaries, dependency direction, and separation of concerns.
29- **Design patterns**: Assess correct use vs cargo-cult or overuse before introducing a pattern.
30- **Estimation and professionalism**: Apply Clean Coder ideas (saying no, sustainable pace, three-point estimates).
31- **Agile practices**: Reference Clean Agile (Iron Cross, TDD, refactoring, pair programming) when discussing process.
32- **Do NOT use** to replace or override the project's linter, formatter, or automated tests.
33
34## Prerequisites
35
36- **`@clean-code` skill** should be available for naming, functions, comments, formatting, and test heuristics. This skill references it rather than duplicating that material.
37- **Project linter and formatter** must be configured and runnable independently. This skill does not enforce syntax or style.
38- **Test suite** should exist or be in progress; this skill reminds you to keep tests green during refactoring but does not generate or run them.
39- **Windows host (PowerShell)** is the primary environment. Path examples use Windows conventions where relevant.
40
41## Procedure
42
43### Step 1 — Determine context (review vs writing vs refactoring)
44
45| Context | Apply |
46|---------|-------|
47| **Code review** | Dependency Rule and boundaries; SOLID in context; list smells; suggest one or two concrete refactors (e.g., extract function, invert dependency); check tests and professionalism. |
48| **Writing new code** | Prefer small functions and single responsibility; depend inward (Clean Architecture); write tests first when doing TDD; avoid patterns until duplication or variation justifies them. |
49| **Refactoring** | Identify one smell at a time; refactor in small steps with tests green; improve names and structure before adding behavior. |
50
51### Step 2 — Check boundaries and Dependency Rule
52
531. Identify the layers in the changed code (entities, use cases, interface adapters, frameworks/drivers).
542. Verify that **dependencies point inward**: use cases do not import from UI, web framework, or DB client packages.
553. Flag any outward-pointing dependency with file path and import statement.
56
57> For detailed layer definitions and boundary patterns, load `./references/clean-architecture.md`.
58
59### Step 3 — Evaluate SOLID in context
60
61Check each principle where it applies to the touched code:
62
63- **SRP**: Does the function/class have one reason to change? If it parses AND persists, split.
64- **OCP**: Can you add new behavior without modifying existing code? If not, consider a strategy or interface.
65- **LSP**: Do subclasses preserve the contract of their base? Flag any override that breaks expectations.
66- **ISP**: Are consumers forced to depend on methods they don't use? Split the interface.
67- **DIP**: Do high-level modules depend on abstractions, not concretions? Introduce an interface if a use case imports a concrete DB client.
68
69### Step 4 — Scan for smells
70
71| Smell | Meaning |
72|-------|---------|
73| **Rigidity** | Small change forces many edits. |
74| **Fragility** | Changes break unrelated areas. |
75| **Immobility** | Hard to reuse in another context. |
76| **Viscosity** | Easy to hack, hard to do the right thing. |
77| **Needless complexity** | Speculative or unused abstraction. |
78| **Needless repetition** | DRY violated; same idea in multiple places. |
79| **Opacity** | Code is hard to understand. |
80
81List each smell with the file/function/area where it appears. Full heuristic lists (C1–T9-style) are in `./reference.md`—load it when you need the complete checklist.
82
83### Step 5 — Propose concrete refactors
84
85For each review, suggest **at least one** concrete refactor:
86
87- "Extract this into a function named `apply_discount`."
88- "Introduce an `OrderRepository` interface so the use case does not depend on the concrete DB client."
89- "Split `process` into `parse` and `persist` to satisfy SRP."
90
91### Step 6 — Assess design patterns (if relevant)
92
93- **Use patterns** when they solve a real design problem (variation in behavior, lifecycle, or cross-cutting concern).
94- **Avoid cargo cult**: Do not add Factory/Strategy/Repository just because the codebase "should" have them.
95- **Rule of thumb**: Introduce a pattern when you feel the third duplication or the second reason to change; name the pattern in code or docs so intent is clear.
96- **Signs of misuse**: Pattern name in every class name, layers that only delegate without logic, patterns that make simple code harder to follow.
97
98> Load `./references/design-patterns.md` for detailed use-vs-misuse criteria.
99
100### Step 7 — Check tests and professionalism
101
102- Note if tests exist for the changed code.
103- Flag obvious "we'll fix it later" comments that violate professionalism (Clean Coder).
104- If discussing process, reference Clean Agile: Iron Cross (cost/quality/features/schedule), TDD, refactoring, pair programming.
105
106> Load `./references/clean-coder.md` for estimation and professionalism detail.
107> Load `./references/clean-agile.md` for agile values and practices.
108
109### Step 8 — Run linter and formatter separately
110
111This skill does NOT replace lint or format. After applying craft criteria, run the project's own tooling:
112
113```powershell
114# Example: run project linter (use your project's actual command)
115npm run lint
116
117# Example: run formatter
118npm run format
119```
120
121## Examples
122
123### Example 1: Code review prompt (copy-pasteable)
124
125```markdown
126Please review this change using Uncle Bob craft criteria (@uncle-bob-craft):
1271. Dependency Rule and boundaries — do dependencies point inward?
1282. SOLID in context — any violations in the touched code?
1293. Smells — list rigidity, fragility, immobility, viscosity, needless complexity/repetition, or opacity.
1304. Suggest one or two concrete refactors (e.g., extract function, invert dependency).
131Do not duplicate lint/format; focus on structure and design.
132```
133
134### Example 2: Before/after (extract and name)
135
136**Before (opacity, does more than one thing):**
137
138```python
139def process(d):
140 if d.get("t") == 1:
141 d["x"] = d["a"] * 1.1
142 elif d.get("t") == 2:
143 d["x"] = d["a"] * 1.2
144 return d
145```
146
147**After (clear intent, single level of abstraction):**
148
149```python
150def apply_discount(amount: float, discount_type: int) -> float:
151 if discount_type == 1:
152 return amount * 1.1
153 if discount_type == 2:
154 return amount * 1.2
155 return amount
156
157def process(order: dict) -> dict:
158 order["x"] = apply_discount(order["a"], order.get("t", 0))
159 return order
160```
161
162## Pitfalls
163
164- **Treating every class as needing a Factory or Strategy.**
165 *Fix*: Introduce patterns only when you have a real design need (third duplication, second axis of change). Load `./references/design-patterns.md` for criteria.
166
167- **Review only listing "violates SOLID" without saying where or how.**
168 *Fix*: Point to the file/function and name the specific principle (e.g., "SRP: this function parses and persists; split into `parse` and `persist`").
169
170- **Skipping the project linter because "we applied Uncle Bob."**
171 *Fix*: This skill is about craft and design; always run the project's lint and format separately. This skill does NOT enforce syntax or style.
172
173- **Adding design patterns without a clear duplication or variation reason.**
174 *Fix*: Wait for the third duplication or second reason to change before introducing a pattern. Name the pattern in code or docs so intent is clear.
175
176- **Overwriting `@clean-code` material.**
177 *Fix*: Use `@clean-code` for naming, functions, comments, formatting, and test heuristics. Use this skill for architecture, boundaries, SOLID, smells, and process.
178
179- **Generating tests instead of reminding to write them.**
180 *Fix*: This skill does not replace automated tests. It can remind you to write tests (Clean Coder, Clean Agile) but does not run or generate them.
181
182## Verification
183
184After applying this skill, verify the following:
185
1861. **Dependency direction check**: Confirm no use-case or entity imports from UI, web framework, or DB client packages.
187 ```powershell
188 # Example: search for outward-pointing imports in use-case layer
189 Select-String -Path .\src\use_cases\*.py -Pattern "import.*framework|import.*db_client|import.*ui"
190 ```
191 Expected: no matches (or only matches through interfaces/abstractions).
192
1932. **Smell list completeness**: Confirm each identified smell includes file path and function/area.
194
1953. **Concrete refactor proposed**: Confirm at least one specific refactor suggestion exists (not just "violates SOLID").
196
1974. **Linter and formatter run independently**: Confirm the project's lint and format commands were executed separately from this skill's review.
198 ```powershell
199 npm run lint
200 npm run format
201 ```
202
2035. **No syntax/style enforcement from this skill**: Confirm this skill did not override or replace linter/formatter output.
204
205## Related Skills
206
207- **`@clean-code`** — Detailed Clean Code book material (names, functions, comments, formatting, tests, classes, smells). Use for day-to-day code quality; use `uncle-bob-craft` for architecture and cross-book criteria.
208- **`@architecture`** — General architecture decisions and trade-offs. Use when choosing high-level structure; use `uncle-bob-craft` for Dependency Rule and boundaries.
209- **`@code-review-excellence`** — Code review practices. Combine with `uncle-bob-craft` for principle-based review.
210- **`@refactor-clean-code`** — Refactoring toward clean code. Use with `uncle-bob-craft` when refactoring for boundaries and SOLID.
211- **`@test-driven-development`** — TDD workflow. Aligns with Clean Agile and Clean Coder (tests as requirement, sustainable pace).
212
213## Limitations
214
215- **Does not replace the project linter or formatter.** Run lint and format separately; this skill gives design and craft criteria only.
216- **Does not replace automated tests.** It can remind you to write tests but does not run or generate them.
217- **Complementary to tooling.** Use it alongside existing CI, lint, and test suites.
218- **No syntax or style enforcement.** Focuses on structure, dependencies, smells, and professional practice—not brace style or line length.
219- **Summaries, not the books.** Full Clean Code heuristics, component principles (REP/CCP/CRP, ADP/SDP/SAP), and detailed stories are in the books; we reference the most used parts. See `./reference.md` "Scope and attribution."