| name | clean-code-js |
| description | Clean Code principles for JavaScript and TypeScript.
Covers naming, functions, classes, SOLID, testing, concurrency, error handling, formatting, and comments.
Use when writing, refactoring, or reviewing JavaScript/TypeScript code.
|
| allowed-tools | ["Read","Glob","Grep"] |
Clean Code (JavaScript / TypeScript)
Software engineering principles from Robert C. Martin's Clean Code, adapted for JavaScript by Ryan McDermott
(source).
These are guidelines, not rules. Not every principle must be followed strictly, and few are universally
agreed upon. They are distilled from many years of collective experience — apply judgment.
When to use
- Writing new JavaScript/TypeScript code
- Refactoring existing JS/TS code
- Reviewing JS/TS code (pair with the
code-review skill)
How to use
- Identify which category your concern falls into (variables, functions, classes, etc.).
- Read the matching reference file for the principles and examples.
- Apply judgment — follow the Why behind each rule, not just the rule.
References
| # | Category | File | Focus |
|---|
| 1 | Variables | 01-variables.md | Meaningful names, searchability, default parameters |
| 2 | Functions | 02-functions.md | Argument count, single responsibility, side effects, abstraction levels |
| 3 | Objects and Data Structures | 03-objects-and-data.md | Getters/setters, private members |
| 4 | Classes | 04-classes.md | ES6 classes, method chaining, composition over inheritance |
| 5 | SOLID | 05-solid.md | SRP, OCP, LSP, ISP, DIP |
| 6 | Testing | 06-testing.md | Single concept per test |
| 7 | Concurrency | 07-concurrency.md | Promises, async/await over callbacks |
| 8 | Error Handling | 08-error-handling.md | Don't swallow errors or rejected promises |
| 9 | Formatting | 09-formatting.md | Consistent capitalization, caller/callee proximity |
| 10 | Comments | 10-comments.md | Comment only non-obvious "why", not "what" |
Core principles (cross-cutting)
- Names reveal intent. A reader should not need to ask what a variable, function, or class is for.
- Functions do one thing. Small, single-purpose, single abstraction level.
- Avoid side effects. Pure functions are easier to test and reason about.
- Prefer composition over inheritance. Inheritance couples more tightly than most realize.
- Code is read more than written. Optimize for the next reader, not the current writer.