clean-code
/clean-code
This skill should be used when writing, reviewing, or refactoring code. Contains SRP, DRY, YAGNI, naming, error handling, dependency direction, and Kent Beck's four rules of simple design.
- Author
- incubyte ↗
- Repository
- ai-plugins ↗
- Licence
- MIT
- Last repository change
- 18.09.2026
Assessment and security
- Files in this package
- 2
- Scripts
- 0
- HTML comments
- 0
- URLs in SKILL.md
- 0
No signals detected. Repository changed on 18.09.2026, without references to retired models or APIs.
MIT, open: use and modify while retaining author attribution.
What it does and when to use it
This skill should be used when writing, reviewing, or refactoring code. Contains SRP, DRY, YAGNI, naming, error handling, dependency direction, and Kent Beck's four rules of simple design.
Original author description
This skill should be used when writing, reviewing, or refactoring code. Contains SRP, DRY, YAGNI, naming, error handling, dependency direction, and Kent Beck's four rules of simple design.
How it works
- YAGNI — You Aren't Gonna Need It
- DRY — Don't Repeat Yourself
- SRP — Single Responsibility Principle
- Small Functions
- One Level of Abstraction
- Tidy First
- Meaningful Names
- Error Handling
- Dependency Direction
- Composition Over Inheritance
SKILL.md preview
---
name: clean-code
description: "This skill should be used when writing, reviewing, or refactoring code. Contains SRP, DRY, YAGNI, naming, error handling, dependency direction, and Kent Beck's four rules of simple design."
---
# Clean Code Principles
These principles apply to ALL code Bee produces, evaluates, or cleans up — regardless of architecture pattern, language, or framework. They are non-negotiable defaults. The target project's CLAUDE.md may add project-specific conventions on top of these.
## YAGNI — You Aren't Gonna Need It
**Don't build what nothing asks for.**
Before writing any code, abstraction, or interface, ask: does a test or acceptance criterion require this RIGHT NOW?
- **One implementation? Skip the interface.** Extract the interface when a second implementation actually arrives.
- **No test demands it? Don't build it.** "Might need it someday" is not a reason.
- **Unused parameters, empty extension points, commented-out feature flags** — all YAGNI violations. Remove them.
## DRY — Don't Repeat Yourself
**Every piece of knowledge should have a single, authoritative representation.**
- **Extract on the third occurrence, not the second.** Two similar blocks might be coincidence. Three means there's a pattern.
- **DRY applies to knowledge, not syntax.** Two functions with similar-looking code that handle different domain concepts are NOT duplication.
- **Constants over magic values.** If the same number/string appears in multiple places and means the same thing, extract it.
## SRP — Single Responsibility Principle
**Each unit of code should have one reason to change.**
- **Functions do one thing.** If a function name has "and" in it, it does two things. Split it.
- **Classes/modules have one owner.** Ask "who would request a change to this?"
- **Files stay focused.** A 500-line file doing validation, HTTP handling, database queries, and email sending has at least four responsibilities.
## Small Functions
**Functions should be short enough to understand at a glance.**
- **5-20 lines is the sweet spot.** Over 30 lines, look for extraction opportunities. Over 50 is almost always too much.
- **If you need a comment to explain a block of code, that block should be a function.** The function name replaces the comment.
## One Level of Abstraction
**Every statement in a function should be at the same level of abstraction.**
Don't mix high-level orchestration with low-level details.
## Tidy First
**Clean up before building, not after.**
- Before adding a feature, tidy the area you're about to change. Separate commit.
- Small structural improvements make the feature change simpler and the diff reviewable.
- Don't tidy unrelated areas — scope tidying to the code you're about to touch.
## Meaningful Names
**Names should reveal intent. A reader should understand the code without needing comments.**
- **Variables:** say what they hold. `remainingAttempts` not `num`.
- **Functions:** say what they do with a verb. `calculateDiscount()` not `discount()`.
- **Booleans:** start with `is`, `has`, `can`, `should`.
- **Avoid meaningless names:** `data`, `info`, `temp`, `result` — unless scope is 1-2 lines.
## Error Handling
**Errors are not exceptional — they're expected. Handle them explicitly.**
- **Don't swallow errors.** `catch (e) {}` is almost never correct.
- **Fail fast and loud.** Reject invalid input immediately with a clear error message.
- **Use domain-specific errors.** `OrderNotFoundError` not `Error('not found')`.
- **Errors at boundaries.** Validate at the entry point. Inner layers can assume valid data.
- **Don't use exceptions for control flow.**
## Dependency Direction
**Dependencies always point inward — from less stable to more stable.**
- HTTP handlers depend on services, never the reverse.
- Services depend on domain logic, never the reverse.
- Domain logic depends on nothing external.
- If an inner module imports from an outer module, the dependency is inverted.
## Composition Over Inheritance
Prefer composing behavior from small, focused pieces over deep inheritance hierarchies. One level of inheritance is usually fine. Three levels — refactor.
## Principle of Least Surprise
**Code should do what its name says. Nothing more, nothing less.**
A function called `getUser()` should not modify the user or trigger side effects.
## Comments Are a Last Resort
**A comment is a failure to express intent in code.**
- Justified comments: legal headers, explanation of _why_, warnings, TODOs with ticket numbers.
- Noise comments: restating the code, mandated Javadoc, commented-out code.
## Kent Beck's Four Rules of Simple Design
**In priority order — the first rule wins when they conflict:**
1. **Passes the tests.** Working code is non-negotiable.
2. **Reveals intention.** Every name, structure, and grouping should make purpose obvious.
3. **No duplication.** Every piece of knowledge has a single representation.
4. **Fewest elements.** Remove anything that doesn't serve the first three rules.
## Applying These Principles
**When producing code** (TDD planners, quick-fix, programmer):
- The refactor step in RED-GREEN-REFACTOR is specifically for applying these principles.
**When evaluating code** (verifier, reviewer):
- SRP and dependency direction are the highest-priority checks.
**When cleaning code** (tidy):
- These principles define what "tidy" means. Focus on the change area.
**When the target project has its own CLAUDE.md:**
- Project conventions take precedence for project-specific rules.
- These Bee principles still apply for universal code quality.
## Additional Resources
### Reference Files
For detailed code examples illustrating each principle, consult:
- **`references/code-examples.md`** — Concrete code examples for YAGNI, DRY, SRP, abstraction levels, naming, error handling, and anti-patterns like feature envy, Law of Demeter violations, and null returns.
Files in this package (2)
- SKILL.md 6 KB
- references/code-examples.md 5 KB
Versions
| Repository | Score | Licence |
|---|---|---|
| This page · incubyte/ai-plugins | 100 | MIT |
| hanspeterdietiker/open-agent-skills | 100 | MIT |
| FrancoStino/opencode-skills-collection | 100 | MIT |
| rootcastleco/rei-skills | 100 | MIT |
| iWiiCK/iwiick-ai-agent-plugin | 100 | MIT |
| sickn33/agentic-awesome-skills | 100 | MIT |
| sagargupta16/claude-skills | 100 | MIT |
| claude-dev-suite/claude-dev-suite | 100 | MIT |
| jonax1337/clean-code-skill | 100 | MIT |
Database snapshot: 13.11.2026 · package version ae973068fafd (SHA-256 digest of the entire package)
Downloads in the last 30 days: 0 · ranking
Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.
Similar skills
- 100kent-beck-review
Code review from the Kent Beck Simple Design 4 Rules perspective. God Object splitting, SRP, duplication removal, naming, cyclomatic complexity. Triggered by "kent beck", "simple design", "simplify", "refactoring" ("리팩토링"), "refactor", "god object", "SRP" keywords. - 95kent-beck-style
Review code following Kent Beck's refactoring philosophy and simple design principles. Detects code smells, guides refactoring techniques, and promotes incremental improvement (YAGNI, KISS). Use when reviewing code quality, refactoring, or improving code readability. - 95kent-beck-style
Review code following Kent Beck's refactoring philosophy and simple design principles. Detects code smells, guides refactoring techniques, and promotes incremental improvement (YAGNI, KISS). Use when reviewing code quality, refactoring, or improving code readability. - 80Code Standards
This skill should be used when the user asks about "code quality", "file size limits", "function length", "KISS", "DRY", "YAGNI", "SRP", "best practices", "clean code", "cyclomatic complexity", "code review checklist", "refactoring rules", or mentions specific thresholds for… - 100053-design-simple-rules
Use when Java design, refactoring, or implementation tradeoffs should be evaluated with Kent Beck's simple design rules, including passes the tests, reveals intention, has no duplication, and has the fewest elements. This should trigger for requests such as Apply simple design… - 100test-desiderata
Analyze and improve test code quality using Kent Beck's Test Desiderata framework. Use when analyzing test files, reviewing test code, identifying test quality issues, suggesting test improvements, or when asked to evaluate tests against best practices. Applies to unit tests,…