← Prompt libraryClean Code Standards
Rule · Standards · #standards #clean-code
Clean Code Standards
Functions & structure
- Functions do one thing; if you need "and" to describe it, split it.
- Keep nesting shallow — return early instead of wrapping in
else.
- No magic numbers or strings; name constants where they're defined.
Names
- Names reveal intent — no abbreviations, no
data2, no temp.
- Booleans read as questions:
isValid, hasAccess, canRetry.
- Rename the moment a name stops being true.
Errors
- Handle errors explicitly; never swallow an exception silently.
- Fail loud and early, with a message that says what to do next.
- Validate at the boundary; trust checked data inside.
Tests & changes
- Write the failing test first when fixing a bug — it proves the fix.
- Leave the file cleaner than you found it, but keep refactors out of feature diffs.
- Small commits, one logical change each.
This is one of dozens of free prompts in the AIStorageDepot library. Sign up free to save them, version them, and pull them straight into Claude, Cursor, or VS Code over MCP.