Awesome-omni-skill code-quality-foundations

Code quality pillars, goals, abstraction layers, and tradeoff thinking. Use when evaluating code quality, setting quality goals, choosing abstraction levels, making design tradeoffs, or auditing code against quality pillars. Covers readability, modularity, testability, reusability, and the principle of least astonishment.

install
source · Clone the upstream repo
git clone https://github.com/diegosouzapw/awesome-omni-skill
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/diegosouzapw/awesome-omni-skill "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/testing-security/code-quality-foundations" ~/.claude/skills/diegosouzapw-awesome-omni-skill-code-quality-foundations && rm -rf "$T"
manifest: skills/testing-security/code-quality-foundations/SKILL.md
source content

Code Quality Foundations

The Four Goals of High-Quality Code

GoalQuestion to AskFailure Mode
It worksDoes it solve the problem correctly?Bugs, unhandled edge cases, unmet requirements
It keeps workingWill it survive changes around it?Brittle dependencies, no tests, hidden assumptions
It's adaptableCan requirements change without a rewrite?Rigid coupling, over-engineering, hardcoded assumptions
It doesn't reinvent the wheelAre we reusing proven solutions?Custom code for solved problems, duplicated effort

The Six Pillars of Code Quality

PillarWhat It MeansKey Technique
ReadableOther engineers can understand it quicklyDescriptive names, clean layers, consistent style
No surprisesBehavior matches expectations (POLA)Explicit contracts, no magic values, no hidden side effects
Hard to misuseDifficult to use incorrectlyType safety, immutability, validated construction
ModularComponents can be swapped independentlyInterfaces, DI, separation of concerns, cohesion
Reusable & generalizableSolves problems broadly, not just one caseFocused parameters, generics, avoiding assumptions
TestableCan be verified in isolationModularity enables testability; design for it from the start

POLA = Principle of Least Astonishment. If a function does something a reasonable caller wouldn't expect, it's a bug in the design, even if it "works."

Modern Additions (2024-2026 Industry Consensus)

ConcernWhy It's Now ExplicitOriginal Coverage
SecureShift-left security; threat model at design timeImplicit in "works"
EfficientResource optimization is a design choice, not afterthoughtSubsumed under "works"
ReliableExplicit error recovery and graceful degradationSubsumed under "keeps working"

Decision Tables

"Should I Abstract This?"

SignalAction
Same logic appears in 2+ placesExtract to shared function/class
Function can't be described in one sentenceSplit into smaller functions
Class has method groups that use different fieldsConsider splitting into separate classes
Changing one feature requires touching many filesImprove modularity and layer boundaries
Only one use case existsWait — don't abstract prematurely

"Where Should I Invest Quality Effort?"

SituationFocus OnRationale
Greenfield projectModularity, clean interfacesFoundation decisions compound; structure early
Legacy codebaseTesting, readabilityUnderstand before changing safely
High-traffic serviceReliability, efficiency, testingProduction failures are expensive
Prototype / spikeWorking code, speedValidate the idea; plan to rewrite
Shared library / APIHard to misuse, no surprisesYou can't predict how consumers will use it
Security-sensitive codeSecurity, testabilityBreaches are catastrophic and trust-destroying

Checklists

Before Writing Code

  • Problem clearly understood (requirements, constraints, edge cases)
  • Existing solutions checked (libraries, shared code, prior art)
  • Testing strategy considered (how will this be verified?)
  • Key tradeoffs identified (what are we choosing, and what are we giving up?)

Code Quality Self-Review

  • Functions translate to single sentences
  • No surprises: behavior matches names and types
  • Hard to misuse: invalid states are unrepresentable where possible
  • Modular: changes are localized, not scattered
  • Testable: can be unit tested without complex setup
  • Clean abstractions: API doesn't leak implementation details