earn-every-line
Nothing enters a file without a present need. Code earns its place by a caller that exists, a comment by saying what the code cannot, flexibility by a stated requirement. Triggers on over-engineered, over-commented, YAGNI, speculative, gold-plating, "just in case", "future-proofing", "flexibility", and on "simplify" / "keep it simple" (both over-correction ditches are fenced); more generally when writing or refactoring code. Does not fire on recognising AI-written code (unslop-code owns the audit), failure-message wording (honest-failure-surfacing), or client-supplied data rules (server-side-authority).
randommonicle · 已有静态检查记录
安装与使用
运行命令前先阅读来源与依赖说明。复制命令不会自动安装或执行。
npx skills add randommonicle/claude-skills --skill earn-every-line技能说明
name: earn-every-line description: Nothing enters a file without a present need. Code earns its place by a caller that exists, a comment by saying what the code cannot, flexibility by a stated requirement. Triggers on over-engineered, over-commented, YAGNI, speculative, gold-plating, "just in case", "future-proofing", "flexibility", and on "simplify" / "keep it simple" (both over-correction ditches are fenced); more generally when writing or refactoring code. Does not fire on recognising AI-written code (unslop-code owns the audit), failure-message wording (honest-failure-surfacing), or client-supplied data rules (server-side-authority).
Earn every line
The model's default is to add: the helper the function did not need, the option nobody passes, the try/except around code that cannot fail, a comment per line saying what the line says. Anthropic's own docs admit the tendency of its models (the "Overeagerness" section, written for Opus 4.5/4.6: they "overengineer by creating extra files, adding unnecessary abstractions, or building in flexibility that wasn't requested"), and this library's unslop-code catalog corroborates it from complaint data (over-engineering verified at 7.8% of tell-naming complaints, narrating comments 8.5%). This skill is the write-time gate those numbers point at. Layer: leaf. Admitted by commission plus external evidence rather than the misses log — see Provenance — so candidate-tier until fires accumulate.
The rule
Every line serves someone who exists. Code serves a caller that exists; a comment serves a reader who learns something the code cannot tell them; flexibility serves a requirement someone actually stated. Name the caller, the reader, or the requirement — by name, not by category ("a future maintainer" is a category; "the retry loop in sync.ts" is a name). Cannot name one → it does not go in. The test is positional, so it travels: the check that is rigour at a system edge is noise three calls deep, a public API owes the docstring a module-private helper does not, and a report section or plan phase answers the same question — who needs this now?
Deletion gets the mirror test, and it outranks every licence below: name what is lost if this line goes — the caller, the reader, or the requirement it serves. Can name one → it stays. Concretely banned as "fixes": stripping validation at a trust boundary, deleting a comment that carries a why, golfing for line count, and citing YAGNI to skip tests or refactoring — Fowler's own exclusion: yagni "does not apply to effort to make the software easier to modify" and "is not a justification for neglecting the health of your code base."
At diff level, the same rule: make the change that was asked or is clearly necessary to it. Reformatting neighbours, renaming things you passed, upgrading patterns you dislike — unrequested improvements are speculation in the change dimension, and they turn a 50-line reviewable diff into a 500-line unreviewable one.
The structure half
The phrase YAGNI came out of a Beck–Hendrickson exchange on the C3 project (Fowler's account); the canonical sentence is Jeffries', 1998: "Always implement things when you actually need them, never when you just foresee that you need them." The tests:
- The named-caller test, at write time. A helper, wrapper, interface, base class, or parameter you are about to add for one caller: inline it. For no caller: do not write it. Removing code that already exists is a different act with a different bar: run blast-radius-grep first (a plain grep misses dynamic dispatch, registries, reflection, test-only callers, open branches, and published surface — an export never counts as zero-callers from inside one repo), and where zero users cannot be established, it stays.
- Abstract on the third occurrence, not the first. Refactoring (1999) records Don Roberts' guideline: the first time, just do it; the second time, wince and duplicate anyway; the third time, refactor. Until then, "duplication is far cheaper than the wrong abstraction" (Metz, 2016) — and the wrong abstraction does not sit still: "existing code exerts a powerful influence. Its very presence argues that it is both correct and necessary." The retrospective is always the same shape: "My code traded the ability to change requirements for reduced duplication, and it was not a good trade" (Abramov, Goodbye, Clean Code, 2020).
- Flexibility is a cost until a stated requirement redeems it. An option with one call site passing one value, a config nobody sets, a plugin point with no second plugin. Fowler prices the presumptive feature four ways — build, delay, carry, repair — and carry compounds: every later reader parses the flexibility to learn that nothing uses it.
- Defence belongs at trust boundaries, and the boundary list is never exhaustive. The vendor's counter-prompt: "Trust internal code and framework guarantees. Only validate at system boundaries (user input, external APIs)" — and read those two examples as a floor, not the list. Anything that crossed a process, network, storage, tenant, or privilege line, or came out of a model, is external no matter which repo wrote it (server-side-authority and ai-surface-discipline own those surfaces). Inside the boundary, "cannot occur" must be named: point at the constraint, type, or invariant that makes the state unreachable, or the check stays. And a fallback that manufactures a value when code you control fails does not handle the failure, it hides it (no-silent-data-drop owns that rule).
- Edit in place. No
_v2/_new/enhanced_forks; git owns history. No backwards-compatibility shim when every caller is in the same diff — and a caller outside this repo means it is not the same diff.
The comment half
One test per comment: does the reader learn something here that the code below cannot tell them? No → do not write it. Yes → it is almost always a why: t
阅读完整来源 ↗