4 Writing Lean code
This chapter covers
- Clarifying intent before implementation
- Constraining solutions to prevent overproduction
- Evaluating code based on removability, not cleverness
- Recognizing hidden costs before they compound
- Practicing judgment through deliberate reduction
You've probably been here: you spend three days building a feature, only to realize on day four that you misunderstood the requirement. Or you ask an AI to "add user authentication" and get back 800 lines of code with JWT refresh tokens, role-based permissions, and password complexity validators you never asked for. Or you inherit a module so tangled with dependencies that fixing a small bug means risking three other systems.
This chapter is about preventing that waste before you write the code. Writing Lean code is about writing code that's easy to understand, change, or delete when you don't need it anymore. In a world where AI can generate thousands of lines in seconds, knowing what not to build matters more than ever. The focus here is not on tools, frameworks, or clever techniques. It’s on developing judgment. You’ll practice making intent explicit before implementation begins, constraining solutions so they cannot quietly grow beyond their purpose, and evaluating code based on whether it earns its place in the system. The emphasis is on decisions you can apply immediately: how you frame work, accept or reject generated code, and recognize cost long before it shows up as a defect.