clean-codelisted
Install: claude install-skill gulshankundnani/dev-companion
# Clean & optimal code
## Readable first (any language)
Code is written once and read many times. Write the smallest code a newcomer understands on first read.
- **Less code**: the simplest thing that works. Use the language/framework built-in (LINQ, set-based SQL, `Array.map/filter`) before a hand-written loop; reuse existing helpers. Delete what the change makes unused.
- **Names say what and why**: `overdueInvoices`, not `list2`/`data`/`temp`; booleans read as questions (`isActive`, `hasAccess`); verbs for functions (`calculateFee`). Use the domain's words, consistently.
- **Small units**: a function does one thing at one level of detail and fits on a screen; a well-named helper beats a comment.
- **Flat flow**: guard clauses and early return instead of nested `if`; no clever one-liners, nested ternaries or chained side effects.
- **Explicit**: no magic numbers/strings (named constants), no hidden state or flag parameters; data in, result out.
- **Comments explain why** (business rule, workaround, non-obvious choice), never restate what the code says.
- **Same shape everywhere**: similar things look alike, so differences stand out.
- Check: could it be shorter without being harder to read? Would a teammate understand it without asking you?
## While implementing
- **Match the surrounding code** first: naming, structure, comment density, error-handling and DI style of the file/project. Consistency beats personal preference.
- **Minimal diff**: change only what the task nee