Can AI generate documentation for a large codebase that has none?
Yes, for what the code does: modules, call paths, build steps and APIs. Tools like DeepWiki and Claude Code's /init will draft that in an afternoon. No, for why it was built that way, because the reasons live in pull requests, tickets and Slack, not in the code. Generate a thin map, check it, and let AI answer the why questions from those sources on demand.
Yes, partly. AI documentation for a large codebase is good at one half of the job: a map of what the code does. That covers the modules, how they call each other, how to build and test it, and what each public function takes and returns. Generated documentation is text a model writes by reading the source code alone. It cannot say why the code is the way it is, because that reasoning was never in the code. It sits in merged pull requests, closed tickets, design threads in Slack and old incident channels. So the honest plan has two parts. Generate a short map from the code and have someone check it. Then answer the "why" questions from the sources that hold them, at the moment someone asks, instead of trying to write them all down first.
What AI tools can generate from code alone#
Several tools will draft documentation from a repository with no human input. Claude Code's /init command reads the codebase and "creates a file with build commands, test instructions, and project conventions it discovers" (Claude Code docs). Cognition's DeepWiki goes further and builds a whole wiki with "architecture diagrams, links to sources, and summaries of your codebase" (DeepWiki docs).
These are good at the parts a careful reader could work out from the code with enough time. For example, they trace imports, name the main services, list entry points and describe data flow. On a codebase nobody has written up, that alone can spare a new engineer a lot of reading.
Both vendors are also clear about the edges. The Claude Code docs tell you to add "instructions Claude wouldn't discover on its own" by hand. Longer files, they warn, "consume more context and reduce adherence," so keep each CLAUDE.md under 200 lines. DeepWiki's docs note that large repositories "may hit built-in limits" and cap a configured wiki at 30 pages, or 80 on enterprise plans. A map of a million-line system in 30 pages is a summary, not a manual.
How good is generated documentation today?#
Better than nothing, and not yet good enough to trust unread. An April 2026 benchmark, SWD-Bench, tested generated documentation by asking a model to find, locate and complete real features using only the docs (Wang et al., 2026). It compared DeepWiki, RepoAgent, DocAgent, AutoDoc and human-written docs. The best method reached "an average MCC of only 29.35" on feature detection. MCC runs from -1 to 1 and the paper reports it multiplied by 100, so 100 would be perfect and 0 is no better than chance. The authors found "notable limitations, particularly in providing intent-oriented details." That means the purpose and motivation behind the code.
Two other results from the same paper matter for planning. Pairing the docs with the source code improved feature detection by about 10 and 40 percent on its two measures, so docs work best when they are read alongside the code. And good docs still helped agents: the best method lifted a coding agent's issue-solving rate by 20 percent. Generated docs are worth having. They just should not be the only thing an agent or a new hire reads.
The part that was never in the code#
Design rationale is the reason behind a choice in the code, along with the options that were turned down. It is often what people are looking for when they open the docs. They ask why we retry three times here, why this service is split in two, or why we stopped using the old queue. Claude Code's own docs make the same split. They describe a type of memory for "decisions that Claude can't derive from the code or git history."
That reasoning does exist. It is spread across other systems:
| Question | Can AI write it from code? | Where the answer lives |
|---|---|---|
| What does this service do? | Yes | The code |
| How do I build and test it? | Yes | Build files, CI config |
| Why do we retry three times? | No | The PR that added the retry |
| Why is this service split in two? | No | The ticket and design thread |
| Why did we drop the old queue? | No | The incident channel |
Developers already look in those places. The 2026 Stack Overflow survey found that when developers need a specific answer, they turn to "the people you work with (72%), the code (63%), and documentation (60%)" (Stack Overflow). Colleagues make that list because they remember the history. When an agent cannot ask them, it repeats approaches the team already rejected. We cover how to trace one decision back through Jira, Confluence and Slack in asking why code was written this way.
Why writing everything down first does not scale#
Even if a tool could write every "why" into a document, two problems remain.
The first is size. Claude's largest models hold up to 1M tokens, and Anthropic warns that "as token count grows, accuracy and recall degrade, a phenomenon known as context rot" (Claude docs). A large codebase plus its full write-up will not fit, and loading more of it makes answers worse.
The second is drift. Documentation drift is the gap that opens between a page and the code as merges land after the page was written. Generated docs describe the code on the day they were made. Each merge after that moves the code a little further from the page, and agents read the stale page with full confidence. Our guide to tools that stop agents acting on stale documentation covers the ways teams catch this.
What to do instead#
A plan for a team that has no docs:
- Run
/initor DeepWiki once to get a map. Have the engineer who knows each area read its section and fix it. Keep it short. - Check in only the parts that change slowly: build steps, service boundaries, naming rules. Skip the per-function detail the code already shows.
- For the "why" questions, connect the systems that hold the reasons, and let people and agents ask them directly.
That last step is what Unblocked does. It is a context engine that reads code, PRs, issues, docs, Slack or Teams threads and incidents, and answers in Claude Code, Cursor, VS Code, JetBrains, Slack or the web with each source cited. Each user sees only what their access in the source systems allows. "It's like having an extra senior engineer who knows everything and responds instantly," says Luca Sale, Director of Engineering at TravelPerk.
If you want written docs on top of that, our roundup of AI documentation tools for engineering teams compares the products that help you write and maintain them.


