description:MANDATORY — always active. Apply Robert C. Martin's (Uncle Bob's) Clean Code, Clean Architecture, and Clean Craftsmanship principles when writing, reviewing, or refactoring code. Use this skill whenever the user asks to write new code of non-trivial size, refactor existing code, review code for quality, design a module or system boundary, write tests, or the user mentions clean-code concepts in any language. Also engage proactively from code quality signals — poor naming, long functions (>20 lines), deep nesting, unclear abstractions, duplicated logic, switch/if-else chains that should be polymorphic, missing tests, leaky boundaries, or frameworks bleeding into business logic — even if the user did not explicitly ask for a cleanup. Works regardless of spoken language.
- **Law of Demeter** — don't talk to strangers. No train wrecks (`a.getB().getC().doSomething()`).
- **Tell, don't ask** — tell the object to do the work instead of asking for state and deciding.
## 6. Error Handling
- Use exceptions/Result types, not return codes.
- Write try-catch-finally first when an operation can fail.
- Wrap third-party exceptions in your own types.
- **Don't return null.** Return empty collections or use Option/Result.
- **Don't pass null.** Fail fast at boundaries.
## 7. Tests
- **Three Laws of TDD:** 1) no production code without a failing test, 2) no more test than sufficient to fail, 3) no more production code than sufficient to pass.