YAGNI — short for “You Aren’t Gonna Need It” — is a software design principle that says you should not build a feature, abstraction or generalisation until you actually need it. It comes from Extreme Programming and has become one of the most quoted ideas in agile engineering.
The idea sounds obvious until you watch it being violated. Engineers and product managers routinely add things “in case we need them later”:
- A configuration option for a behaviour nobody has ever asked to change.
- A plugin system for plugins that don’t exist yet.
- A database column for a feature in next quarter’s roadmap that may not survive.
- An abstraction layer that makes today’s code worse to support a generalisation that may never come.
YAGNI says: don’t. Build what is needed now. The cost of adding the thing later is almost always lower than the cost of carrying it through every change between now and then.
Why YAGNI is more than laziness
The principle isn’t “do less work.” It’s that speculative work has hidden compounding costs:
- Carrying cost — every untested feature, every config flag, every abstraction has to be read, understood and maintained by everyone who touches the code afterwards.
- Opportunity cost — time spent building for hypothetical needs is time not spent on real ones.
- Wrong-shape risk — when the imagined need finally arrives, it almost never matches what you predicted, and the speculative scaffolding usually has to be torn out anyway.
YAGNI is not “don’t think ahead”
Good engineers still notice when a design choice will paint them into a corner, and they avoid those choices. YAGNI is about not building solutions for problems you don’t have, not about ignoring obvious future shape.
A useful test: if the imagined need does arrive next month, will you be glad the speculative code is there, or will you wish you’d just built the simpler version and modified it then? Most of the time, the second answer wins.
Related ideas
- MVP — ship the smallest thing that could be useful. The MVP is YAGNI applied at the product level.
- Tech debt — over-built speculative code is a particular flavour of debt: you’re paying interest on a loan you didn’t need to take.
- Scope creep — YAGNI is the engineer’s defence against a project gradually expanding into things nobody asked for.