clean-code/SKILL.md
Enforces clean code principles including meaningful naming, small focused functions, command-query separation, error handling with exceptions, and Kent Beck's four rules of simple design. Use when writing new code, refactoring existing code, reviewing pull requests for readability and maintainability, applying the Boy Scout Rule, or evaluating functions for single responsibility and appropriate abstraction level.
npx skillsauth add kayaman/skills clean-codeInstall 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.
Reference: Clean Code (Martin), Tidy First? (Beck), A Philosophy of Software Design (Ousterhout), Refactoring (Fowler)
"If a name requires a comment, it does not reveal its intent."
Order, ShippingPolicy) and verbs for methods (calculateTotal, validateAddress)fetch, retrieve, get for the same operationstrName, m_count)| Bad | Good | Why |
|-----|------|-----|
| d | elapsedTimeInDays | Intention-revealing |
| genymdhms | generationTimestamp | Pronounceable |
| accountList | accounts | Don't encode the container type |
| Manager, Processor, Handler | Specific name for the actual responsibility | Avoid meaningless suffixes |
Functions MUST either do something (command — changes state, returns void) or answer something (query — returns a value, no side effects). Never both.
# BAD — command and query mixed
def set_and_get_previous(value):
previous = self.value
self.value = value
return previous
# GOOD — separated
def get_value(self): # query
return self.value
def set_value(self, value): # command
self.value = value
"Don't comment bad code — rewrite it." (Kernighan & Plaugher)
| Type | Example | Why |
|------|---------|-----|
| Legal headers | // Copyright 2024 Acme Corp | Required by policy |
| Explanation of intent | // Use binary search because list is always sorted by insertion order | The code shows WHAT; the comment explains WHY |
| Warning of consequences | // This test takes 30 minutes to run | Prevents accidental execution |
| TODO markers | // TODO(#1234): Replace with batch API when available | Tracks known improvement with issue reference |
| API documentation | Javadoc/JSDoc for public APIs | Contract documentation for consumers |
i++; // increment iObjects and data structures are diametrically opposed (Martin). Choose deliberately.
| | Objects | Data Structures | |--|---------|----------------| | Expose | Behavior (methods) | Data (fields) | | Hide | Data (private state) | Nothing | | Easy to add | New types (add new class) | New functions (add function operating on all types) | | Hard to add | New behavior (must change all types) | New types (must change all functions) |
a.getB().getC().doSomething()try-catch-finally first when the function involves operations that can failnull — use Null Object pattern, Optional/Maybe, or throw an exceptionnull as a function argument — there's no reasonable expectation for handling it# BAD — checking null return
user = repository.find_by_id(id)
if user is not None:
# do something
# GOOD — exception or Optional
user = repository.find_by_id(id) # raises NotFoundError
# or
user = repository.find_by_id(id) # returns Optional<User>
user.if_present(lambda u: process(u))
| Principle | Rule | |-----------|------| | Fast | Tests MUST run quickly — slow tests don't get run | | Independent | Tests MUST NOT depend on each other or on execution order | | Repeatable | Tests MUST produce the same result in any environment | | Self-Validating | Tests MUST have a boolean output (pass/fail) — no manual log inspection | | Timely | Tests SHOULD be written just before the production code (TDD) |
In priority order:
Rules 2–4 are applied during refactoring under the safety net of rule 1.
"To write clean code, you must first write dirty code and then clean it."
Naming principles, SRP for functions, CQS, F.I.R.S.T. test principles, error handling with exceptions, the Boy Scout Rule, objects vs data structures distinction.
Extreme function size ("2–4 lines") can produce unreadable names and excessive indirection — prioritize clarity over arbitrary limits
Performance in hot paths — Muratori demonstrated that Clean Code structural rules can produce 10–25x slower code in performance-critical scenarios; optimize hot paths pragmatically
Deep modules (Ousterhout) — sometimes a larger function with a simple interface is better than many tiny functions that fragment the logic
SHOULD apply clean code principles as guidelines balanced by context, not as rigid dogma
SHOULD NOT fragment a clear 20-line function into five 4-line functions if it reduces readability
When writing or reviewing code, verify:
| Book | Author(s) | Publisher | Year | |------|-----------|-----------|------| | Clean Code | Robert C. Martin | Pearson | 2008 | | Refactoring (2nd ed.) | Martin Fowler | Addison-Wesley | 2018 | | A Philosophy of Software Design (2nd ed.) | John Ousterhout | Stanford | 2021 | | Tidy First? | Kent Beck | O'Reilly | 2023 | | Code That Fits in Your Head | Mark Seemann | Addison-Wesley | 2021 | | Five Lines of Code | Christian Clausen | Manning | 2021 | | The Pragmatic Programmer (2nd ed.) | Hunt & Thomas | Addison-Wesley | 2020 | | Implementation Patterns | Kent Beck | Addison-Wesley | 2007 |
tools
Guidance for designing charts, graphs, plots, dashboards, and data visualizations that communicate clearly and persuade. Use when creating or reviewing a visualization, choosing a chart type, picking a color palette, decluttering a busy graphic, fixing misleading axes or proportions, building a dashboard, annotating a figure, or turning data into a presentation, report, or data-driven story. Grounded in the standard data-visualization literature (Knaflic, Tufte, Cleveland & McGill, Cairo, Wilke, Munzner, Few, Berinato). Covers chart selection, graphical perception and encoding, color and accessibility, decluttering, graphical integrity, dashboards, and narrative. Does NOT cover building data pipelines or ETL, statistical modeling or analysis methods, BI tool/vendor selection, or general UI/UX layout (see ux-design-principles). Tool-agnostic, with optional Python recipes.
development
Architect and implement production-grade microservices systems in TypeScript (NestJS) and Python (FastAPI), including resilience, observability, testing, deployment, and migration guidance.
development
--- name: databricks-genie-spaces-best-practices description: Design, configure, curate, govern, monitor, and integrate Databricks AI/BI Genie Spaces — the natural-language-to-SQL surface over Unity Catalog. Covers space scoping, general instructions, parameterized example SQL, SQL functions, trusted assets, JOIN configuration, knowledge store, certified queries, benchmarks, monitoring tab, feedback loops, the Genie Conversation API, governance via Unity Catalog (row filters, column masks, embed
tools
Implement OTP and passwordless authentication on AWS for TypeScript projects using Cognito CUSTOM_AUTH triggers (default) or a custom DynamoDB-backed flow, with SES (email) and SNS (SMS) delivery. Use when the user mentions OTP, one-time password, passwordless login, magic link, Cognito custom auth, DefineAuthChallenge, CreateAuthChallenge, VerifyAuthChallengeResponse, SES verification email, SNS SMS code, or MFA over email/SMS. Covers architecture decision (Cognito vs custom), Lambda trigger handlers, SES/SNS notifiers, DynamoDB schema with TTL, rate limiting, constant-time comparison, threat model (enumeration, replay, brute force), and aws-sdk-client-mock testing.