Rebuilds what the standard library or framework has: counters, flag loops, CSV, date math, argument parsing
Code that already exists: one of the ways AI coding agents bloat software, from lessloc's pattern catalog. lessloc gives every session a rule against it and catches it as simpler and reinvented.
What makes rebuilding what the standard library or framework has a bad practice?
The standard that calls it a bad practice: Bloch, Effective Java Item 59: Know and use the libraries.
What does lessloc do about rebuilding what the standard library or framework has?
lessloc gives every session a rule against it and catches it as simpler and reinvented. The working standard puts the standard library and the platform before new code. simpler catches hand-built counters, flag loops and range(len()). reinvented catches deep clone, UUID, debounce, slugify, CSV and flag parsing written by hand, and retry loops where the project already retries.
simpler(tier 2): Brute-force code with a shorter idiom:== True, an if/else that returns the condition, an index loop that only readsxs[i],.filter(...).length > 0, a catch that only rethrows, a flag loop that isany(), a hand-built counter, an__init__that@dataclasswrites, a React Effect that only sets state. ruff and clippy add more.reinvented(tier 2): A hand-written version of what the standard library or an installed package does (deep clone, UUID, debounce, slugify, CSV, flag parsing), or a retry loop where the project already retries.
Examples
Caught as reinvented:
export function deepClone(o) {
return JSON.parse(JSON.stringify(o));
}Written well:
export function snapshot(o) {
return structuredClone(o);
}Caught as reinvented:
def deep_copy(obj):
return {k: v for k, v in obj.items()}Written well:
import copy
def snapshot(obj):
return copy.deepcopy(obj)Related patterns
The other patterns in Code that already exists:
- Reimplementing a helper the project already has: lessloc gives every session the rule: take what is already in the codebase before new code.
- Copying a rule another function owns: lessloc catches it as
repeated-literal. - Keeping old and new versions side by side: lessloc gives every session the rule: one implementation per rule.
- Copy-pasted test cases instead of one parametrized test: lessloc catches it as
copied-tests. - A second library for a job an installed one already does:
new-dependencynames the library that is already installed. - The same data shape in several layers (DTO, model, entity):
copycatches identical type bodies. - The same CSS declarations under another selector: lessloc catches it as
style-copy.

