Clean code

From kumaran-is/claude-code-onboarding · View interactive version

Clean code is an AI agent skill from the GitHub repository kumaran-is/claude-code-onboarding. Applies principles from Robert C. Martin's 'Clean Code'. Use when writing, reviewing, or refactoring code to ensure high quality, readability, and maintainability. Covers naming, functions, comments, formatting, error handling, unit tests, classes, and code smells. Language-agnostic — applies to Jav

How to use this skill

Skill file

Clean Code Skill

Iron Law: Before applying any principle, READ the relevant source file first.

Do not refactor or flag issues based on memory — verify the actual code (file:line) before making any claim.

This skill embodies the principles of "Clean Code" by Robert C. Martin (Uncle Bob). Use it to transform "code that works" into "code that is clean."

Core Philosophy

"Code is clean if it can be read, and enhanced by a developer other than its original author." — Grady Booch

When to Use

1. Meaningful Names

2. Functions

3. Comments

```python

# BAD: comment explains intent that code should express

if employee.flags & HOURLY and employee.age > 65:

# GOOD: code expresses intent directly

if employee.isEligibleForFullBenefits():

```

4. Formatting

5. Objects and Data Structures

```java

// BAD — violates Law of Demeter

String city = order.getCustomer().getAddress().getCity();

// GOOD — delegate to the object

String city = order.getCustomerCity();

```

6. Error Handling

This section reinforces code-standards.md error handling rules ("No Silent Failures"). These are consistent — not conflicting.

7. Unit Tests

1. Don't write production code until you have a failing unit test.

2. Don't write more of a unit test than is sufficient to fail.

3. Don't write more production code than is sufficient to pass the failing test.

8. Classes

9. Smells and Heuristics

Anti-Patterns to Avoid

Don't do these — they are the most common clean code violations in this codebase.

Verify Step

After applying any clean code refactor, run the following to confirm nothing regressed:

# Run all tests — refactors must not change behavior
# Java
mvn test

# NestJS / Angular
npm test

# Python
uv run pytest

# Flutter / Dart
flutter test

Also check:

Implementation Checklist

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.