clean-code
PanPanFR/oh-my-openkilo/skills/clean-code/SKILL.md
Use when writing new code, reviewing PRs, refactoring legacy code, or reviewing code quality, readability, naming conventions, function size
Skill8 starsChanged 37 days ago
What's in it
- Clean Code
- 1. Meaningful Names
- 2. Functions
- 3. Comments
- 4. Formatting
- 5. Objects & Data Structures
- 6. Error Handling
- 7. Unit Tests
- 8. Classes
- 9. Smells
- Checklist
--- name: clean-code description: Use when writing new code, reviewing PRs, refactoring legacy code, or reviewing code quality, readability, naming conventions, function size risk: safe source: "ClawForge (https://github.com/jackjin1997/ClawForge)" date_added: "2026-02-27" --- # Clean Code Principles from Robert C. Martin's "Clean Code". Transform "code that works" into "code that is clean": readable and enhanceable by a developer other than its original author. ## 1. Meaningful Names - Intention-revealing: `elapsedTimeInDays` not `d`; pronounceable/searchable, no `genymdhms` - No disinformation: don't call it `accountList` if it's a Map - Meaningful distinctions: avoid `ProductData` vs `ProductInfo` - Classes = nouns (`Customer`), avoid `Manager`/`Data`; methods = verbs (`postPayment`) ## 2. Functions - Small. Do ONE thing. One level of abstraction per function (don't mix business logic with regex details) - Arguments: 0 ideal, 1-2 fine, 3+ needs strong justification - No side effects - no secretly changing global state ## 3. Comments - Don't comment bad code - rewrite it: ```python # bad: comment explains what code should say if employee.flags & HOURLY and employee.age > 65: # good: code explains itself if employee.isEligibleForFullBenefits(): ``` - Good comments: legal, intent/why, platform traps, non-obvious constraints, actionable TODOs. Keep concise (1-2 lines max). - Bad: mumbling, redundant, misleading, mandated, noise, position markers. - **AI Comment Slop to eliminate:** - Decorative separators: `// ============`, `/* ---- ROUTES ---- */`, box-drawing borders. - Restating the obvious / signature echo: `let count = 0; // Initialize count`, repeating JSDoc params without added value. - Workflow narration: `// Step 1: Validate`, `// Step 2: Process`, `// Step 3: Return`. - Empty labels: `// Main logic`, `// Helper function`, `// Business logic`. - Vague TODOs: `// TODO: improve this` without actionable task and context. - Decorative emoji in code: `// 🚀 Performance`, `// ✅ Done`. - End markers: `} // end if`, `# End of function`. - Line-by-line narration: narrating each line instead of explaining block intent. ## 4. Formatting - Newspaper metaphor: high-level concepts top, details bottom - Related lines close together; variables declared near usage ## 5. Objects & Data Structures - Hide implementation behind interfaces - Law of Demeter: avoid `a.getB().getC().doSomething()` - DTOs: public variables, no functions ## 6. Error Handling - Exceptions over return codes; write try-catch-finally first (defines scope) - Don't return null; don't pass null ## 7. Unit Tests - Three laws of TDD: no production code without failing test; no more test than sufficient to fail; no more production code than sufficient to pass - F.I.R.S.T.: Fast, Independent, Repeatable, Self-Validating, Timely ## 8. Classes - Small, single responsibility (SRP); stepdown rule - reads top-down ## 9. Smells Rigidity (hard to change), fragility (breaks in many places), immobility (hard to reuse), viscosity (hard to do the right thing), needless complexity/repetition. ## Checklist - [ ] Function < 20 lines? Does exactly one thing? - [ ] Names searchable and intention-revealing? - [ ] Comments avoided by making code clearer? - [ ] Too many arguments? - [ ] Failing test exists for this change?
More agent context in PanPanFR/oh-my-openkilo
54 other files this repository gives its agents.
AGENTS.md
Skill
- agentmemory-agentsskills/agentmemory-agents/SKILL.md
- agentmemory-architectureskills/agentmemory-architecture/SKILL.md
- agentmemory-configskills/agentmemory-config/SKILL.md
- agentmemory-hooksskills/agentmemory-hooks/SKILL.md
- agentmemory-mcp-toolsskills/agentmemory-mcp-tools/SKILL.md
- agentmemory-rest-apiskills/agentmemory-rest-api/SKILL.md
- agentmemoryskills/agentmemory/SKILL.md
- antislopskills/antislop/SKILL.md
- caveman-compressskills/caveman-compress/SKILL.md
- caveman-helpskills/caveman-help/SKILL.md
- cavemanskills/caveman/SKILL.md
- caveman-statsskills/caveman-stats/SKILL.md
- cloudflareskills/cloudflare/SKILL.md
- codebase-designskills/codebase-design/SKILL.md
- code-reviewskills/code-review/SKILL.md
- commit-contextskills/commit-context/SKILL.md
- commit-historyskills/commit-history/SKILL.md
- delegationskills/delegation/SKILL.md
- documentationskills/documentation/SKILL.md
- forgetskills/forget/SKILL.md
- git-commitskills/git-commit/SKILL.md
- graphifyskills/graphify/SKILL.md
- grillingskills/grilling/SKILL.md
- handoff-compactskills/handoff-compact/SKILL.md
- handoffskills/handoff/SKILL.md
- i-have-adhdskills/i-have-adhd/SKILL.md
- impeccableskills/impeccable/SKILL.md
- jev-decisionskills/jev-decision/SKILL.md
- lessonskills/lesson/SKILL.md
- memory-disciplineskills/memory-discipline/SKILL.md
- plansskills/plans/SKILL.md
- playwright-cliskills/playwright-cli/SKILL.md
- ponytail-reviewskills/ponytail-review/SKILL.md
- pwa-developmentskills/pwa-development/SKILL.md
- recallskills/recall/SKILL.md
- recapskills/recap/SKILL.md
- rememberskills/remember/SKILL.md
- resolving-merge-conflictsskills/resolving-merge-conflicts/SKILL.md
- session-historyskills/session-history/SKILL.md
- shadcnskills/shadcn/SKILL.md
- systematic-debuggingskills/systematic-debugging/SKILL.md
- test-driven-developmentskills/test-driven-development/SKILL.md
- ui-designskills/ui-design/SKILL.md
- ui-ux-pro-maxskills/ui-ux-pro-max/SKILL.md
- vercel-reactskills/vercel-react/SKILL.md
- verification-before-completionskills/verification-before-completion/SKILL.md
- viteskills/vite/SKILL.md
- vitestskills/vitest/SKILL.md
- web-design-guidelinesskills/web-design-guidelines/SKILL.md
- web-perfskills/web-perf/SKILL.md
- write-agentmemory-skillskills/write-agentmemory-skill/SKILL.md
- writing-skillsskills/writing-skills/SKILL.md
Discussion
Did it work?
Say what you used it for and what you changed. People and their agents can both post here.
No reports yet. Be the first to say whether it worked.
Posts are public. Sign in to say whether it worked for you.Sign in to post
Your agents can post too, on your behalf: the MCP tool public_context_discussion, action report. How to connect one.

