← ClaudeAtlas

grep-the-types-statics-firstlisted

Before writing any logic over a type the project owns — merging, defaulting, unwrapping, normalizing, converting — grep that type's own static/factory methods and search the codebase for the verb you need. A mature codebase has already solved it, with the edge cases handled and a name the reviewer reads fluently. A plausible hand-rolled helper is worse than a bug: it compiles, it passes, and it reads to a maintainer as unfamiliarity with the house. When you do find the helper, check its RETURN TYPE against your call site before swapping, and verify by running rather than reading. Use before writing any utility loop over a house type. Trigger terms: helper method, merge params, apply defaults, unwrap, convert, write a small utility, is there an existing, reinvent, "I'll just loop over".
serhiy-bzhezytskyy/contrib-receipts · ★ 1 · Code & Development · score 75
Install: claude install-skill serhiy-bzhezytskyy/contrib-receipts
# Grep the type's statics first ## Purpose Given "apply these defaults without clobbering what the caller set", the obvious move is a loop: iterate the names, check whether the target already has each one, set it if not. Eight lines, correct, passes. And in a codebase that has existed for fifteen years, that operation has a name, a one-line call, and edge-case handling you didn't write. The hand-rolled version costs three ways: it is longer, it duplicates semantics that can now drift apart, and — the expensive one — it signals to the reviewer that you didn't look. Reviewers read unfamiliarity with their own API as a proxy for care, and increasingly as a tooling signature. The check is one grep. It is cheaper than the code it replaces. ## When to use - Before writing any loop or helper that manipulates a type the project owns. - Especially for these verbs: merge, default, override, unwrap, flatten, normalize, convert, copy-with-change, wrap. - When a reviewer asks "why not use X?" — treat it as a class of miss, not one miss, and sweep the rest of the diff for siblings. ## When NOT to use Don't stall on it. Two greps and a look at the type's public surface is the whole budget; if nothing turns up, write the loop and say in the PR that you looked. ## The practice (checklist) - [ ] Read the type's own factory/utility surface: `grep -n "public static" path/to/TheType.java` - [ ] Search the codebase for the verb, in the house's vocabulary: `grep -rn "wrapD