clean-code-and-oop
Authoritative engineering standards for writing Clean Code, Object-Oriented Programming (OOP) architectures, SOLID design principles, and safe refactoring.
Skill by werlang
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/werlang-clean-code-and-oop
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: design, 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. 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-and-oop
What's inside
- Skill name
clean-code-and-oop- Description
- Authoritative engineering standards for writing Clean Code, Object-Oriented Programming (OOP) architectures, SOLID design principles, and safe refactoring. Trigger automatically whenever creating new features, writing classes/modules, designing domain entities, refactoring existing code, restructuring functions, reviewing code quality, or simplifying complex logic.
- License
- MIT
- Instructions
- 105 lines in SKILL.md · view on GitHub
Files (4)
- SKILL.md
- clean-code-checklist.md · references/
- oop-patterns-and-anti-patterns.md · references/
- refactoring-catalog.md · references/
SKILL.md (first lines)
# Clean Code, OOP, and Refactoring Guidelines
This skill defines the engineering standards for writing clean, object-oriented, and maintainable software. Apply these principles by default across all code generation, refactoring, and code review tasks.
---
## 1. Core Engineering Principles
```text
┌─────────────────────────────────────────────────────────────────────────────┐
│ The Pragmatic Foundation │
├─────────────────────────────────────────────────────────────────────────────┤
│ KISS: Choose the most direct, readable solution over cleverness. │
│ YAGNI: Code strictly for current requirements, never future guesses. │
│ DRY & Rule of Three: Copy twice, abstract on the 3rd occurrence. │
│ SOLID: Maintain single-responsibility classes and stable interfaces. │
└─────────────────────────────────────────────────────────────────────────────┘
```
---
## 2. Clean Code Standards
1. **Intention-Revealing Naming**:
- Class and entity names must be explicit domain nouns (`UserRegistration`, `CatalogModel`). Avoid generic suffixes like `Data`, `Info`, `Manager`, `Processor`.
- Method names must begin with active verbs (`calculateTotal`, `verifyEmail`, `publishRelease`).
- Boolean variables and predicates must use clear prefixes (`isActive`, `hasPermission`, `canDownload`).
- Never use type-based prefixes (`strName`, `arrItems`) or cryptic abbreviations.
2. **Function & Method Hygiene**:
- **Single Responsibility (SRP)**: Each function must do one thing at a single level of abstraction.
- **Small & Focused**: Keep functions short and easy to understand in a single pass.
- **Bounded Parameters**: Functions should take 0–2 positional parameters. If 3 or more parameters are needed, group them into a structured options object (`{ key, bucket, fileName }`).
- **Command-Query Separation (CQS)**: Methods that mutate state must not return complex query objects with hidden side-effects. Methods that query data must be pure and free of side-effects.
3. **Guard Clauses & Control Flow**:
- Flatten control flow with **early returns** / guard clauses at the top of functions to handle edge cases, invalid inputs, and error conditions.
- Never write deeply nested `if/else` ladders (arrow anti-pattern).
- **Fail Fast & Loud**: Throw typed custom errors (`CustomError`) with stable machine-readable error codes instead of returning silent `null` or empty objects.
4. **Zero Dead Code & Noise**:
- Completely delete commented-out code, orphaned variables, and temporary debug statements (`console.log`) before completing a task.
---
## 3. OOP & Domain Architecture
1. **True Encapsulation & Rich Domain Entities**:
- Protect internal class state; expose intention-driven domain methods rather than public property mutations.
- Avoid **Anemic Domain Models** (where models are dumb data bags and business validation is scattered across controllers/routes). Business invariants, state transitions, and validation belong inside the entity class.
- Return copies or immutable views of internal collections to prevent external callers from mutating private class arrays/sets.
2. **Composition over Inheritance**:
- Use class inheritance strictly for genuine polymorphic *is-a* relationships (e.g. `Modal extends BaseComponent`, `User extends Model`).
- Use composition (`has-a` / `uses-a`) to combine cohesive collaborators, strategies, and helpers.
3. **SOLID Principles in Practice**:
- **Single Responsibility Principle (SRP)**: A class should have only one reason to change.
- **Open/Closed Principle (OCP)**: Open for extension (via strategies, polymorphism, or event handlers), closed for direct modification.
- **Liskov Substitution Principle (LSP)**: Derived classes must remain completely substitutable for their base class without violating contracts.
- **Interface Segregation Principle (ISP)**: Expose small, cohesive, client-specific method interfaces rather than bloated god-classes.
- **Dependency Inversion Principle (DIP)**: High-level routes and services depend on abstractions and domain models, never raw low-level database drivers or infrastructure details.
4. **Polymorphism & Strategy over Type-Branching**:
- Replace sprawling `switch(type)` / `if (role === 'admin')` dispatch trees with polymorphic handlers or strategy lookup maps.
---
## 4. Refactoring Guidelines
1. **Test-Guarded (Red-Green-Refactor)**:
- Always run unit tests before and after refactoring to ensure behavioral equivalence. Never perform refactoring on untested paths without adding regression coverage first.
2. **Core Refactoring Moves**:
- **Extract Method**: Break down long methods into cohesive, intention-revealing private/helper functions.
- **Extract Class / Component**: Split classes that accumulate multiple responsibilities.
- **Decompose Conditional**: Replace complex boolean expressions with descriptive variables or guard methods.
- **Parameter Object**: Replace parameter-heavy function signatures with structured options objects.
3. **Boy Scout Rule**:
- Leave every touched file cleaner, simpler, and better documented than you found it.
4. **Production Baseline vs. In-Flight Work**:
- `main` is the canonical source of production code.
- **In-flight / Pre-release work (not in `main`)**: Perform **hard replacements**. Completely delete obsolete code, parameters, and methods in a single pass. Never introduce backwards-compatibility fallbacks, dual-variable shims, or legacy aliases.
- **Production contracts (already in `main`)**: Apply safe evolution, non-breaking schema migrations, and backward-compatible transitions only when modifying live production contracts or persistent production data.
---
## 5. References & Deep Dive Guides
Consult the bundled reference guides for concrete before/after examples and detailed checklists:
- [Clean Code Diagnostic Checklist](references/clean-code-checklist.md) - Quick pre-flight inspection checklist.
- [OOP Patterns and Anti-Patterns](references/oop-patterns-and-anti-patterns.md) - Rich vs. anemic models, strategy pattern, composition vs. inheritance.
- [Refactoring Catalog & Recipes](references/refactoring-catalog.md) - Step-by-step refactoring recipes and smells.
---
## 6. Related Skills
- [`code-review`](../code-review/SKILL.md) - Code quality and standards evaluation.
- [`api-building`](../api-building/SKILL.md) - Clean API architecture and entity models.
- [`web-frontend`](../web-frontend/SKILL.md) - Component OOP hierarchy and model-view separation.
- [`document-touched-code`](../document-touched-code/SKILL.md) - JSDoc contracts and interface documentation.From werlang/user-skills, MIT.
More from werlang/user-skills
- 0.570score
git-change-workflow
werlang
Choose and apply a Git branching, worktree, and commit workflow for implementation, refactor, bug-fix, documentation, and configuration work.
SkillAFreshness: AClaude Code +9 - 0.570score
code-review
werlang
Review changes since a fixed point (commit, branch, tag, or merge-base) along a risk-calibrated gradient (Trunk vs Leaf code) across Standards, Spec, and…
SkillAFreshness: AClaude Code +9 - 0.570score
css-standards
werlang
Enforce reusable, brand-aware CSS architecture for public web apps by owning shared tokens in a common stylesheet, importing page entrypoints first, keeping…
SkillAFreshness: AClaude Code +9 - 0.570score
api-building
werlang
Build or refactor reusable Node.js APIs using Express, express.Router, ESM imports, named exports, entity classes in model/, helpers for non-endpoint logic…
SkillAFreshness: AClaude Code +9 - 0.570score
entity-models
werlang
Model API entities as classes inside model/, including base model inheritance, relation helpers, model-to-model composition, and route-to-model instance flows.
SkillAFreshness: AClaude Code +9 - 0.544score
frontend-design
werlang
Guidance for distinctive, intentional visual design when building new UI or reshaping an existing one.
SkillAFreshness: AClaude Code +9 - 0.529score
document-touched-code
werlang
Document touched code with JSDoc, method comments, and focused section comments as the default behavior whenever implementing a new feature, refactoring…
SkillBFreshness: BClaude Code +9 - 0.479score
audit-project-context
werlang
Audit, verify, update, or clean docs, prompts, skills, agents, instructions, README files, and other markdown/MD files against the current project codebase.
SkillCFreshness: CClaude Code +9 - 0.474score
documentation-maintenance
werlang
Keep project documentation, agent guidance, comments, and validation instructions synchronized with the real implementation.
SkillCFreshness: CClaude Code +9
Signals
- Stars
- 0
- Forks
- 0
- Open issues
- 0
- Last commit (this folder)
- Oct 9, 2026 (19 days ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/werlang/user-skills
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from werlang
- 0.570score
git-change-workflow
werlang
Choose and apply a Git branching, worktree, and commit workflow for implementation, refactor, bug-fix, documentation, and configuration work.
SkillAFreshness: AClaude Code +9 - 0.570score
code-review
werlang
Review changes since a fixed point (commit, branch, tag, or merge-base) along a risk-calibrated gradient (Trunk vs Leaf code) across Standards, Spec, and…
SkillAFreshness: AClaude Code +9 - 0.570score
css-standards
werlang
Enforce reusable, brand-aware CSS architecture for public web apps by owning shared tokens in a common stylesheet, importing page entrypoints first, keeping…
SkillAFreshness: AClaude Code +9 - 0.570score
api-building
werlang
Build or refactor reusable Node.js APIs using Express, express.Router, ESM imports, named exports, entity classes in model/, helpers for non-endpoint logic…
SkillAFreshness: AClaude Code +9 - 0.570score
entity-models
werlang
Model API entities as classes inside model/, including base model inheritance, relation helpers, model-to-model composition, and route-to-model instance flows.
SkillAFreshness: AClaude Code +9 - 0.544score
frontend-design
werlang
Guidance for distinctive, intentional visual design when building new UI or reshaping an existing one.
SkillAFreshness: AClaude Code +9
Cite this page
clean-code-and-oop skill. Agent Mart. https://agentmart.dev/skills/werlang-clean-code-and-oop (last updated 2026-10-24)