agentleFS
kayamankayaman/skills/yagni-principle/SKILL.md

yagni-principle

Skill3 starsChanged 8 months agoCC0-1.0View on GitHub

Enforces the YAGNI (You Aren't Gonna Need It) principle to prevent speculative complexity while maintaining code quality. Use when evaluating whether to build a feature preemptively, deciding between extensibility and simplicity, reviewing code for over-engineering, resolving the YAGNI-SOLID tension, or assessing whether supporting practices (tests, CI, refactoring) are in place to apply YAGNI safely.

The file

We split this skill into the rules it gives an agent

6 rules. About 0 are common, 6 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈6

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    If refactoring later is cheap → don't build it now

    line 86
  2. Distinctive:

    If refactoring later is genuinely expensive (e.g., database schema migration affecting millions of rows) → consider building it now

    line 87
  3. Distinctive:

    When tempted to build something preemptively:

    line 94
  4. Distinctive:

    Is there a confirmed, current need?: If yes, build it. YAGNI doesn't apply to known requirements.

    line 96
  5. Distinctive:

    Are you building a framework from a single use case?: If so, stop. You need at least three concrete use cases to know the right abstraction.

    line 104
  6. Distinctive:

    When reviewing code or proposals for YAGNI compliance, verify:

    line 134

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

YAGNI Principle

Reference: Extreme Programming Explained (Beck), Tidy First? (Beck), Software Engineering at Google (Winters et al.)

When to Apply

  • Evaluating whether to build functionality that is not yet needed
  • Reviewing code for speculative abstractions, unused extension points, or premature generalization
  • Deciding between building flexibility now vs adding it when needed
  • Resolving tension between YAGNI simplicity and SOLID extensibility
  • Assessing whether the codebase has the supporting practices to apply YAGNI safely

Core Principle

"Always implement things when you actually need them, never when you just foresee that you need them." — Ron Jeffries

YAGNI originated from Extreme Programming in the late 1990s. Kent Beck and Chet Hendrickson, working on the Chrysler C3 project, found that every proposed future capability turned out to be unnecessary — hence, "You Aren't Gonna Need It."

Critical caveat: YAGNI requires supporting practices — continuous refactoring, automated testing, and CI. Without these, YAGNI leads to disorganized code. YAGNI means "don't build it yet," not "don't build it well."


The Four Costs of Unnecessary Complexity

Martin Fowler's analysis of what you pay when you build speculatively:

CostDescriptionImpact
Cost of BuildTime and effort spent on features that turn out unnecessaryWasted development time
Cost of DelayNeeded features are delayed while building speculative onesOften the largest cost — opportunity cost of not shipping real value
Cost of CarryAdded complexity makes ALL other features harder to build, test, and understandCompounds over time; slows the entire team
Cost of RepairEven if eventually needed, understanding evolves; code from months ago may need reworkingThe speculative code rarely matches the actual need

Studies show only about one-third of features actually improve the metrics they target (Kohavi et al., Microsoft analysis of thousands of A/B tests).


What YAGNI Applies To

YAGNI Violations (Do NOT Build)

  • Features no user has requested based on "what if they want..."
  • Abstract factories, plugin systems, or strategy patterns with only one implementation
  • Configuration options for hypothetical future flexibility
  • Database columns for anticipated but unconfirmed requirements
  • API endpoints for features that don't exist yet
  • Generic frameworks extracted from a single use case

NOT YAGNI Violations (These Are Good Practice)

  • Clean code structure (SRP, meaningful names, small functions)
  • Automated tests for existing functionality
  • Proper error handling for current operations
  • Security measures for current features
  • Documentation of current behavior
  • Refactoring existing code for clarity

Fowler's key distinction: "YAGNI only applies to capabilities built into the software to support a presumptive feature. It does not apply to effort to make the software easier to modify."


The YAGNI-SOLID Tension

The apparent conflict: YAGNI says don't build what you don't need; SOLID/OCP says make things extensible.

Fowler's Resolution

ConceptWhat It MeansYAGNI?
"Open for extension"Good structure that MAKES future changes easy (clean interfaces, SRP, DIP)NOT a violation — this is good design
"Already extended"Speculative extension points, abstract factories with one impl, unused plugin systemsYAGNI violation — premature complexity

Being easy to extend is a property of well-structured code. Being already extended is speculative engineering.

Fowler's Practical Test

"Imagine the refactoring you'd have to do later to add this feature. Is it significantly more expensive to add later than now?"

  • If refactoring later is cheap → don't build it now
  • If refactoring later is genuinely expensive (e.g., database schema migration affecting millions of rows) → consider building it now
  • In most cases, the refactoring is cheaper than you think

Decision Framework

When tempted to build something preemptively:

  1. Is there a confirmed, current need? If yes, build it. YAGNI doesn't apply to known requirements.
  2. Is it structural quality or speculative capability? Clean code, tests, and good naming are NOT YAGNI violations. Only speculative features and extension points are.
  3. Apply the refactoring thought experiment. How expensive would it be to add this later when you actually need it? If the answer is "not much more expensive," wait.
  4. Check for supporting practices. YAGNI is safe only with automated tests, CI, and a culture of continuous refactoring. Without these, you need more upfront design.
  5. Are you building a framework from a single use case? If so, stop. You need at least three concrete use cases to know the right abstraction.

Common Pitfalls

PitfallSignalRemedy
Speculative generalityAbstract classes with one subclass; interfaces with one implementation; unused parametersRemove the abstraction; add it when the second use case arrives
Gold platingFeature has more options, configurations, or edge case handling than any user needsShip the minimal version; add complexity when users request it
Resume-driven developmentUsing complex patterns to learn or showcase skills, not to solve the problemAsk: "Would the simplest team member understand this?"
YAGNI as excuse for poor qualitySkipping tests, error handling, or security "because YAGNI"YAGNI applies to features, not to quality; quality is always needed
Ignoring confirmed requirementsDismissing known requirements as "not needed yet"YAGNI applies to speculative features, not to confirmed ones
Confusing "don't build" with "don't think"Making no design decisions at allThink ahead, but build only what's needed now

YAGNI at Scale

At Google scale (Software Engineering at Google), YAGNI manifests as:

  • Simple designs that evolve — start with the simplest architecture; evolve as traffic and complexity grow
  • Incremental infrastructure — build infrastructure for current scale, not predicted future scale
  • Feature flags over speculative features — ship code behind flags; enable when ready
  • Monorepo simplicity — avoid premature decomposition into microservices; a monolith is fine until proven otherwise

Checklist

When reviewing code or proposals for YAGNI compliance, verify:

  • Every feature addresses a confirmed, current need — not a speculative "might need"
  • Abstractions (interfaces, factories, plugin systems) have at least two concrete implementations
  • No configuration options exist for hypothetical flexibility
  • Structural quality (clean code, tests, good names) is maintained — YAGNI doesn't excuse poor design
  • The refactoring thought experiment shows it's not significantly more expensive to add later
  • Supporting practices are in place: automated tests, CI, continuous refactoring
  • The simplest solution that meets current requirements has been chosen

Key References

BookAuthor(s)PublisherYear
Extreme Programming Explained (2nd ed.)Kent BeckAddison-Wesley2004
Tidy First?Kent BeckO'Reilly2023
Software Engineering at GoogleWinters, Manshreck, WrightO'Reilly2020
The Pragmatic Programmer (2nd ed.)Hunt & ThomasAddison-Wesley2020
Refactoring (2nd ed.)Martin FowlerAddison-Wesley2018

Online References

  • Martin Fowler, "Yagni" (bliki, 2015)
  • Ron Jeffries, "YAGNI, yes. Skimping, no. Technical Debt? Not even."

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.