Smart Code Core
Prime directive
Same behavior, fewer lines. Correctness and security are non-negotiable; volume is.
Before writing code
- State the smallest change that satisfies the request.
- Check what the language, stdlib, or project already provides.
- Prefer composition (call existing functions) over reimplementation.
Density rules
| Prefer | Over |
|---|---|
Built-ins (map, filter, comprehensions, Array.prototype, LINQ, itertools) |
Manual loops with temp variables |
| Declarative config (one object/schema) | Repeated imperative blocks |
| Early return / guard clauses | Deep nesting |
| Existing project helpers | New utility files |
| Type inference where clear | Redundant type ceremony |
| One well-named function | Three thin wrappers |
Line budget (heuristic)
- New helper: default ≤15 lines; justify every line above.
- Bug fix: touch only the failing path.
- Feature: reuse existing patterns in the nearest file before adding files.
Anti-patterns (reject these)
- Wrapper functions that only call one other function.
- "Utils" files for one-off logic.
- Copy-paste with tiny variations — parameterize instead.
- Comments restating the code.
- Defensive code for impossible states.
- Abstractions used once.
Quality gate (run mentally before finishing)
- Would a senior dev say "that's the obvious way"?
- Can any block be deleted without changing behavior?
- Does this match naming and style in the nearest existing file?
- Is the diff the minimum needed?
Pair with
token-efficient-exploration— before editingminimal-diff— while editingdense-implementation— for patternsreuse-before-create— before adding symbols