clean-code
Write readable, maintainable code through disciplined naming, focused functions, and clean error handling.
Skill by jd-solanki
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/jd-solanki-clean-code
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: testing, writing
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md and code. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/clean-code
What's inside
- Skill name
clean-code- Description
- Write readable, maintainable code through disciplined naming, focused functions, and clean error handling. Use when the user mentions "code review", "naming conventions", "function too long", "code smells", "readable code", "boy scout rule", "single responsibility", or "unit test quality". Also trigger when reviewing pull requests for readability, refactoring messy functions, debating comment styles, or improving error handling patterns. Covers SRP, comment discipline, formatting, and unit testing. For refactoring techniques, see refactoring-patterns. For architecture, see clean-architecture.
- License
- MIT
- Instructions
- 224 lines in SKILL.md · view on GitHub
Files (7)
- SKILL.md
- code-smells.md · references/
- comments-formatting.md · references/
- error-handling.md · references/
- functions-and-methods.md · references/
- naming-conventions.md · references/
- testing-principles.md · references/
SKILL.md (first lines)
# Clean Code Framework A disciplined approach to writing code that communicates intent, minimizes surprises, and welcomes change. Apply these principles when writing new code, reviewing pull requests, refactoring legacy systems, or advising on code quality. ## Core Principle **Code is read far more often than it is written — optimize for the reader.** The read-to-write ratio is well over 10:1, so every naming choice, function boundary, and formatting decision either adds clarity or adds cost. Clean code reads like well-written prose: names reveal intent, functions tell a story one step at a time, and the Boy Scout Rule applies — always leave the code cleaner than you found it. ## Scoring **Goal: 10/10.** Rate any code 0-10 against the principles below. Report the current score and the specific improvements needed to reach 10/10. - **9-10:** Names reveal intent, each function does one thing, error handling is consistent, tests are clean and comprehensive - **7-8:** Mostly clean with minor naming ambiguities or a few multi-purpose functions; tests may lack edge cases - **5-6:** Mixed — good patterns alongside unclear names, duplicated logic, or inconsistent error handling - **3-4:** Long multi-purpose functions, misleading names, poor or missing tests - **1-2:** Nearly unreadable — magic numbers, cryptic abbreviations, no structure, no tests ## The Clean Code Framework Six disciplines for writing code that communicates clearly and adapts to change: ### 1. Meaningful Names **Core concept:** Names should reveal intent, avoid disinformation, and make the code read like prose. If a name requires a comment to explain it, the name is wrong. **Why it works:** Names are the most pervasive form of documentation — a well-chosen name eliminates the need to read the implementation; a poor one forces every reader to reverse-engineer intent. **Key insights:** - A name should answer why it exists, what it does, and how it is used - No encodings, prefixes, or type information (no Hungarian notation); single letters only for tiny-scope loop counters - Classes are nouns; methods are verbs - One word per concept: don't mix `fetch`, `retrieve`, and `get` - Longer scope demands a longer, more descriptive name - Rename freely — IDEs make it trivial **Code applications:** | Context | Pattern | Example | |---------|---------|---------| | **Variables** | Intention-revealing | `elapsedTimeInDays` not `d` | | **Booleans** | Predicate phrasing | `isActive`, `hasPermission`, `canEdit` | | **Functions** | Verb + noun | `calculateMonthlyRevenue()` not `calc()` | | **Classes** | Noun naming the responsibility | `InvoiceGenerator` not `InvoiceManager` | See: [references/naming-conventions.md](references/naming-conventions.md) ### 2. Functions **Core concept:** A function does one thing at one level of abstraction, with zero to two arguments. Split it when it does two things, not when it passes a line count: a long function with one job behind a small signature is a deep module (see `/code-organisation`). **Why it works:** Single-purpose functions are easy to name, understand, test, and reuse; multi-purpose functions hide bugs, resist testing, and accumulate responsibilities. Length is a reason to look for a second job, not proof of one. **Key insights:** - Step-Down Rule: code reads top-down, each function calling the next level of abstraction - Argument count: zero best, one fine, two acceptable, three+ requires justification - Flag arguments are a smell — the function does two things; split it - Command-Query Separation: change state or return a value, never both - Extract a block when it has its own name and its own job; an extraction that only renames a few lines adds a hop, not a concept - No hidden side effects — the name must tell the whole truth **Code applications:** | Context | Pattern | Example | |---------|---------|---------| | **Multi-purpose function** | Extract each job as a named step | `validateInput(); transformData(); saveRecord();` | | **Flag argument** | Split into two functions | `renderForPrint()` / `renderForScreen()` not `render(isPrint)` | | **Error cases** | Guard clauses at top | Early return for errors, single happy path | | **Many arguments** | Introduce parameter object | `new DateRange(start, end)` not `report(start, end, format, locale)` | | **Side effects** | Make effects explicit | `checkPassword()` that starts a session → rename or separate | See: [references/functions-and-methods.md](references/functions-and-methods.md) ### 3. Comments and Formatting **Core concept:** A comment is a failure to express yourself in code. When comments are necessary, they explain *why*, never *what*. Formatting creates the visual structure that makes code scannable. **Why it works:** Comments rot — code changes but comments often don't, creating documentation worse than none. Clean formatting lets developers scan code like a newspaper: headlines first, details on demand. **Key insights:** - The best comment is a well-named extracted function - Acceptable: legal headers, TODOs, public API docs, genuine "why" explanations - Commented-out code and journal comments: delete — version control remembers - Vertical openness between concepts; vertical density within them; declare variables near usage - Newspaper metaphor: high-level functions at the top of the file, details below **Code applications:** | Context | Pattern | Example | |---------|---------|---------| | **Explaining "what"** | Replace with better name | `// check if eligible` → `isEligible()` | | **Explaining "why"** | Keep as comment | `// RFC 7231 requires this header for proxies` | | **Commented-out code** | Delete it | Trust version control | | **Team formatting** | Decide once, automate | Prettier, Black, gofmt | See: [references/comments-formatting.md](references/comments-formatting.md) ### 4. Error Handling **Core concept:** Error handling is a separate concern from business logic. Use exceptions rather than return codes, provide context with every exception, and never return or pass null. **Why it works:** Return codes clutter the happy path with checks; exceptions separate the two cleanly. Returning null forces null checks on every caller, and one missing check crashes far from the source. **Key insights:** - Write the try-catch first — it defines a transaction boundary - Prefer unchecked exceptions — checked ones violate the Open/Closed Principle - Define exception classes by the caller's needs, not the failure type - Don't return null (use empty collections, Optional, or throw); don't pass null either - Special Case / Null Object pattern: return an object with default behavior instead of null **Code applications:** | Context | Pattern | Example | |---------|---------|---------| | **Null returns** | Empty collection or Optional | `return Collections.emptyList()` not `return null` | | **Error codes** | Replace with exceptions | `throw new InsufficientFundsException(balance, amount)` | | **Third-party APIs** | Wrap with adapter | `PortfolioService` wraps the vendor API, translates its exceptions | | **Special cases** | Null Object pattern | `GuestUser` with default behavior instead of null checks | | **Context in errors** | Include operation + state | `"Failed to save invoice #1234 for customer 'Acme'"` |
From jd-solanki/ai, MIT.
More from jd-solanki/ai
- 0.629score
nostics
jd-solanki
Structured diagnostic code library for JavaScript/TypeScript.
SkillAFreshness: A★ 7Claude Code +9 - 0.624score
context7-cli
jd-solanki
Use the ctx7 CLI to fetch library documentation, manage AI coding skills, and configure Context7 MCP.
SkillAFreshness: A★ 7Claude Code +9 - 0.624score
ponytail
jd-solanki
Lazy senior dev mode: the smallest change that fully solves the task, and a reply a busy human understands in one read.
SkillAFreshness: A★ 7Claude Code +9 - 0.619score
ponytail-audit
jd-solanki
Quality audit of a whole repo: bugs, security holes, what breaks under real load, risky code without tests, slow paths, and what to delete, merge or split.
SkillAFreshness: A★ 7Claude Code +9 - 0.619score
ponytail-review
jd-solanki
Quality review of a change: is the logic right, is it safe, does it hold under real load, is risky code tested, is it fast enough, and is every line needed.
SkillAFreshness: A★ 7Claude Code +9 - 0.619score
automate-commit-based-gh-release-changelog
jd-solanki
Automate GitHub release creation and changelog generation from Conventional Commits using changelogithub — includes GitHub release mechanics, tag-based…
SkillAFreshness: A★ 7Claude Code +9 - 0.619score
automate-npm-release
jd-solanki
Automate npm package publishing via GitHub Actions for single-package repos and independent monorepo packages, including bumpp version tags, GitHub release…
SkillAFreshness: A★ 7Claude Code +9 - 0.618score
add-diagnostic
jd-solanki
Add a new diagnostic code following the defineDiagnostics() conventions from nostics
SkillAFreshness: A★ 7Claude Code +9 - 0.594score
codebase-design
jd-solanki
Shared vocabulary for designing deep modules.
SkillAFreshness: A★ 7Claude Code +9 - 0.583score
implement
jd-solanki
Implement a piece of work based on a spec or set of tickets.
SkillAFreshness: A★ 7Claude Code +9 - 0.576score
bruno
jd-solanki
Create and manage Bruno API collections in the Bru Lang (.bru) format - adding a request, creating an environment, writing pre/post scripts, or scaffolding a…
SkillBFreshness: B★ 7Claude Code +9 - 0.574score
aws-architecture
jd-solanki
AWS architecture patterns for webhooks, event routing, SQS/Lambda pipelines, microservices, environment target guards, and long-running server deployment with…
SkillBFreshness: B★ 7Claude Code +9
Signals
- Stars
- 7
- Forks
- 2
- Open issues
- 9
- Last commit (this folder)
- Oct 13, 2026 (15 days ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/jd-solanki/ai
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from jd-solanki
- 0.629score
nostics
jd-solanki
Structured diagnostic code library for JavaScript/TypeScript.
SkillAFreshness: A★ 7Claude Code +9 - 0.624score
ponytail
jd-solanki
Lazy senior dev mode: the smallest change that fully solves the task, and a reply a busy human understands in one read.
SkillAFreshness: A★ 7Claude Code +9 - 0.624score
context7-cli
jd-solanki
Use the ctx7 CLI to fetch library documentation, manage AI coding skills, and configure Context7 MCP.
SkillAFreshness: A★ 7Claude Code +9 - 0.619score
automate-commit-based-gh-release-changelog
jd-solanki
Automate GitHub release creation and changelog generation from Conventional Commits using changelogithub — includes GitHub release mechanics, tag-based…
SkillAFreshness: A★ 7Claude Code +9 - 0.619score
ponytail-review
jd-solanki
Quality review of a change: is the logic right, is it safe, does it hold under real load, is risky code tested, is it fast enough, and is every line needed.
SkillAFreshness: A★ 7Claude Code +9 - 0.619score
automate-npm-release
jd-solanki
Automate npm package publishing via GitHub Actions for single-package repos and independent monorepo packages, including bumpp version tags, GitHub release…
SkillAFreshness: A★ 7Claude Code +9
Cite this page
clean-code skill. Agent Mart. https://agentmart.dev/skills/jd-solanki-clean-code (last updated 2026-10-24)