skills/code-quality-best-practices/SKILL.md
Distinguished Engineer-level code quality standards for writing, reviewing, and refactoring code. Use this skill when writing new code, reviewing pull requests, refactoring existing code, designing module boundaries, choosing design patterns, fixing bugs, addressing code smells, or optimizing performance across any programming language.
npx skillsauth add kylejryan/better-code code-quality-best-practicesInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Every line of code must satisfy three invariants simultaneously: correctness, clarity, and changeability. They are not in tension — at the DE level, they reinforce each other.
Apply these standards when:
Every piece of code must satisfy all three:
| Priority | Category | Impact | Prefix |
|----------|----------|--------|--------|
| 1 | Core Philosophy | CRITICAL | philosophy- |
| 2 | Architecture | CRITICAL | arch- |
| 3 | Code Quality Standards | CRITICAL | quality- |
| 4 | Anti-Patterns | HIGH | anti- |
| 5 | Design Patterns | HIGH | pattern- |
| 6 | Performance | HIGH | perf- |
| 7 | Code Smells | MEDIUM-HIGH | smell- |
| 8 | Refactoring | MEDIUM | refactor- |
KISS: Prefer the boring solution that works over the clever solution that impresses. Every abstraction must pay for itself — if it doesn't simplify at least three call sites or eliminate a class of bugs, remove it.
DRY (knowledge, not text): Two identical-looking code blocks that change for different reasons are NOT duplication — they are coincidence. Tolerate duplication until you see it three times.
Parse, don't validate: Push validation to the boundary and produce typed, validated domain objects. Internal code operates on objects that are correct by construction.
Fail fast: Validate preconditions at the top. Return early for error cases. The happy path should be the least-indented path.
Read individual reference files for detailed explanations and code examples:
references/philosophy-kiss.md
references/quality-naming.md
references/arch-dependency-inversion.md
references/pattern-selection-heuristic.md
references/_sections.md
Each reference file contains:
After writing code, verify:
development
Use this skill when performing the actual vulnerability analysis AFTER a threat model has been established (see threat-model skill). Triggers when the user asks to find vulnerabilities, audit code for security, hunt for bugs, or perform security review of source code AND a threat model already exists or the codebase context is clear. This skill enforces depth-first, exploitability-proven analysis — it actively prevents the breadth-first pattern-matching that produces lists of theoretical vulnerabilities. Do NOT use without a threat model; use threat-model skill first. Do NOT use for general code quality review.
development
Staff+ engineering patterns for maximum leverage per line of code. Use this skill when designing abstractions, building reusable primitives, creating shared libraries, reducing code through architecture, reviewing code for leverage and reuse potential, choosing between building vs configuring, or establishing conventions and patterns across a codebase.
development
Use this skill when designing test strategies, writing tests beyond basic unit tests, verifying software for production readiness, or improving test coverage and reliability. Triggers when the user asks about testing strategy, integration tests, end-to-end tests, contract tests, property-based tests, load tests, chaos testing, test architecture, flaky tests, test confidence, 'how do I test this,' 'how do I know this is safe to deploy,' 'my tests are flaky,' 'what should I test,' 'test coverage,' CI/CD test pipelines, or any question about software verification and validation. Also triggers when the user is shipping a change and wants confidence it won't break production. Primarily targets TypeScript and Go but principles apply universally. Do NOT use for writing basic unit tests for simple functions — this skill is for the harder testing questions.
development
Use this skill when debugging software issues, performing root cause analysis, triaging errors from logs or alerts, or investigating why code isn't working as expected. Triggers when the user shares an error message, stack trace, log output, failing test, unexpected behavior, crash report, performance degradation, or says things like 'this isn't working,' 'I'm getting an error,' 'help me debug,' 'why is this failing,' 'something broke,' or 'I can't figure out what's wrong.' Also use when the user has been going back and forth trying fixes that aren't working — this is the signal to stop guessing and start systematically diagnosing. Do NOT use for writing new code from scratch, general code review, or feature development unless a bug is involved.