Documentation Is Not a Nice-to-Have
Most developers treat documentation as a chore, something to do after the real work is done. In practice, it rarely gets done at all. The README was written when the project started and never updated. Environment variables are documented in someone's memory. The API has no contract beyond "read the code."
This matters more than most teams realise. Documentation is not just about making life easier for new joiners. It is a signal of how well a team understands and maintains its codebase. A project with clear, accurate documentation is almost always better structured, better tested, and more reliable than one without.
The README Is Your Front Door
The README is the first thing anyone sees when they encounter a repository. For open-source projects, it determines whether someone will use your library. For internal projects, it determines how quickly a new team member becomes productive.
A useful README answers five questions:
- What does this project do? A one-paragraph summary. Not the mission statement, not the product vision. What does the code actually do?
- How do I run it locally? Step-by-step instructions that work on a clean machine. Include prerequisites, environment setup, and the commands to start the application.
- How do I run the tests? The command to run the test suite, any required setup (test databases, fixtures), and expected output.
- How is the project structured? A brief overview of the directory layout and where to find key files.
- How do I deploy it? Or at least, a pointer to where deployment documentation lives.
What Bad READMEs Look Like
A README that only contains the project name and a one-line description generated by the scaffolding tool is effectively no README at all. Equally unhelpful is a README that was accurate two years ago but has not been updated since.
Common problems include:
- Outdated setup instructions. The README says to run
npm installbut the project switched to pnpm eighteen months ago. - Missing prerequisites. The project requires Node 20, Redis, and a local PostgreSQL instance, but the README does not mention any of them.
- No environment variable documentation. The application crashes on startup because
DATABASE_URLis not set, and nowhere does the README explain what variables are needed.
Each of these problems costs time. Not once, but every time a new developer joins the team, every time someone returns to the project after a few months away, and every time an incident response requires someone unfamiliar with the service to investigate.
Environment Variable Documentation
Environment variables are one of the most commonly undocumented aspects of a codebase. The application needs a dozen variables to run, but the only way to discover them is to start the application and watch it fail, then search the codebase for process.env references.
The .env.example Pattern
The simplest solution is a .env.example file committed to the repository. It contains every required environment variable with a placeholder or description instead of a real value.
# Database
DATABASE_URL=postgresql://localhost:5432/myapp
DATABASE_POOL_SIZE=10
# Authentication
AUTH_SECRET=generate-a-random-string-here
GITHUB_CLIENT_ID=your-github-oauth-app-id
GITHUB_CLIENT_SECRET=your-github-oauth-app-secret
# External services
STRIPE_SECRET_KEY=sk_test_...
RESEND_API_KEY=re_...
This file serves multiple purposes. It documents what variables exist. It shows the expected format. It provides sensible defaults for local development. And it is always in sync with the code because it lives in the same repository.
When .env.example Drifts
The .env.example file is only useful if it stays current. When a developer adds a new environment variable to the code but not to .env.example, the documentation is immediately out of date.
Some teams solve this with a CI check that compares the variables referenced in code against those listed in .env.example. If a variable is used in code but missing from the example file, the build fails. This is a simple check with outsized impact.
API Documentation
For any project that exposes an API, whether external or internal, the API documentation is the contract. Without it, consumers must read the source code to understand request formats, response shapes, authentication requirements, and error handling.
What Good API Docs Cover
At minimum, API documentation should include:
- Endpoints. URL, HTTP method, and a brief description of what each endpoint does.
- Request format. Required and optional parameters, their types, and validation rules.
- Response format. The shape of successful responses and error responses.
- Authentication. What credentials are needed and how to provide them (header, query parameter, cookie).
- Error codes. What errors can be returned and what they mean.
The Documentation Drift Problem
API documentation that is maintained separately from the code will drift. The endpoint gets a new required parameter, but the documentation is not updated. A response field is renamed, but the docs still reference the old name.
The most reliable approach is to generate documentation from the code itself. OpenAPI specifications, TypeScript types, and JSDoc comments can all serve as documentation sources that stay in sync because they are part of the code.
When generated documentation is not practical, treat documentation updates as part of the definition of done for any API change. A PR that modifies an endpoint without updating the documentation is incomplete.
How Out-of-Date Docs Create Real Risk
Documentation that is wrong is worse than no documentation at all. At least with no documentation, people know they need to read the code. Wrong documentation creates false confidence.
Onboarding Friction
A new developer following an outdated setup guide will waste hours. They will install the wrong version of Node, configure environment variables that no longer exist, and run commands that fail silently. By the time they get the application running, they have already lost trust in the documentation and will default to asking colleagues instead. This does not scale.
Operational Risk
During an incident, accurate documentation can be the difference between a five-minute fix and a two-hour investigation. If the runbook says the service uses port 3000 but it was changed to 8080 six months ago, the on-call engineer is debugging a ghost.
Environment variable documentation is particularly critical here. If a service is crashing because a new required variable was not set in production, and there is no documentation listing what variables are needed, the resolution depends entirely on finding someone who knows the code.
Architectural Misunderstanding
When documentation does not reflect the actual architecture, developers make decisions based on incorrect assumptions. They add code to the wrong module, create dependencies that violate the intended structure, and build features on foundations that were deprecated months ago.
Documentation as a Quality Signal
There is a strong correlation between documentation quality and overall codebase health. This is not coincidental. The same discipline that produces good documentation also produces good code.
Teams that document their setup process tend to have a setup process that actually works. The act of writing it down forces you to verify each step.
Teams that document environment variables tend to have cleaner configuration management. Documenting a variable makes you think about whether it is really needed.
Teams that maintain API docs tend to have more consistent APIs. Writing the documentation often reveals inconsistencies in naming, error handling, or response formats that would otherwise go unnoticed.
Teams that document their architecture tend to have clearer architectural boundaries. The act of describing the structure forces you to confront the gap between the intended architecture and the actual one.
Frequently Asked Questions
How often should documentation be updated?
Documentation should be updated whenever the code it describes changes. The most effective approach is to treat documentation updates as part of the definition of done for any pull request. If a PR changes setup steps, API behaviour, or environment variables, the corresponding documentation should be updated in the same PR.
What is the minimum documentation a project needs?
At minimum, every project needs a README that explains what the project does, how to run it locally, and what environment variables are required. For projects with APIs, endpoint documentation is also essential. Everything beyond that is valuable but these three items are the baseline.
How do you prevent documentation from going stale?
Automate where possible. Use CI checks to compare .env.example against actual code usage. Generate API documentation from types or schemas. Include documentation review as an explicit step in your pull request checklist. The less documentation depends on manual effort, the more likely it is to stay current.
Practical Steps to Improve Documentation
Improving documentation does not require a dedicated "documentation sprint." It requires small, consistent habits.
Audit your README. Can a new developer go from zero to running the application using only the README? If not, fix the gaps.
Create or update .env.example. List every environment variable the application needs. Add a CI check to keep it in sync.
Document your API. Start with the most commonly used endpoints. Add one endpoint per PR until coverage is complete.
Add a documentation check to your review process. If a PR adds a new feature, environment variable, or API endpoint, ask whether the documentation has been updated.
Treat documentation bugs like code bugs. When someone finds incorrect documentation, fix it immediately. Do not let it sit in a backlog.
Good documentation is not about writing prose. It is about making the implicit knowledge in your team explicit, verifiable, and accessible to anyone who needs it. That is not a nice-to-have. It is a quality signal.