Code documentation is a vital part of the software development process. But for many software developers, documenting code can be a time-consuming task that often takes away from their key purpose of writing code.
This is where artificial intelligence comes in. Generative AI-powered tools employ large language models (LLMs) to make creating and maintaining documentation more efficient. Code LLMs have been trained or fine-tuned on coding datasets, analyzing source code syntax, structure and semantics. Based on the patterns they glean, the AI models generate low-level documentation such as inline code comments that explain lines or blocks of code, and documentation strings, or docstrings, that describe a particular class, function, method or module.
Here’s how AI tools can benefit code documentation workflows, with some bonus tips to help software engineering teams get the most out of AI for documenting code.
Industry newsletter
Get curated insights on the most important—and intriguing—AI news. Subscribe to our weekly Think newsletter. See the IBM Privacy Statement.
Your subscription will be delivered in English. You will find an unsubscribe link in every newsletter. You can manage your subscriptions or unsubscribe here. Refer to our IBM Privacy Statement for more information.
The 2025 State of AI-assisted Software Development Report from Google Cloud’s DORA research program found that 64% of surveyed software development professionals use AI for writing documentation.1
Automation can save developers time and effort, allowing them to focus more on devising algorithms, formulating logic and problem-solving. In an internal IBM test, for instance, participating teams using IBM® watsonx Code Assistant™ reported reducing code documentation time by an average of 59%.
Additionally, coding assistants like GitHub Copilot can be linked directly to popular integrated development environments (IDEs) and workspaces such as Eclipse, JetBrains IDEs and Visual Studio Code. Programmers stay “in flow” as they code, with AI assistants recommending inline comments and docstrings in real time.
Top tip: AI-generated documentation still requires a human coder’s expertise to fill in missing details, particularly when it comes to advanced logic, complex algorithms or edge cases. A programmer’s eye is also essential to spot any unnecessary code explanations, redundant comments and overly general suggestions that clutter code.
Documenting code often falls by the wayside, especially when high-severity or high-priority issues become more pressing. This can lead to documentation that’s out of sync with the current state of the repository (also called a repo). Outdated information can hinder future code maintenance and performance optimization efforts, and slow down onboarding new team members.
AI assistants can help narrow the discrepancy, promptly reflecting code changes in the documentation. Platforms like Mintlify, for example, have an AI agent that updates the relevant docs based on a pull request link for merging feature changes.
Updating code documentation is a growing use case for software development teams. According to Stack Overflow’s 2025 Developer Survey, nearly a quarter (24.8%) of developers mostly use AI and more than a quarter (27.3%) partially use AI for creating or maintaining documentation.2
Top tip: Take updates a step further by incorporating AI code documentation into your continuous integration/continuous delivery (CI/CD) pipeline. Make sure to check for compatibility with your existing tech stack. For instance, the GitBook platform offers documentation synchronization with Git-based version control systems such as GitHub and GitLab.
Similar to coding conventions, code documentation must also follow consistent style and structure. Sticking to them can be a challenge, specifically for huge enterprise and open-source repos with multiple contributors.
Like AI code review tools that check for code quality, functionality and style, AI code documentation tools can assess the entire documentation and automatically implement the necessary style and structure changes. Many of these AI tools also follow documentation standards depending on the programming language, such as Javadoc for Java, JSDoc for JavaScript and markdown for Python and others.
Top tip: Create templates laying out style and structure guidelines for code documentation, then train or fine-tune your chosen AI tool on those templates. Consider training or fine-tuning your documentation generator not only on your codebase but also on other high-level documentation—including architecture diagrams, design flowcharts and product requirements documents—to add further context and enhance documentation quality.
Code documentation also encompasses external types, which are typically customer-facing and tailored toward developers and users outside of an enterprise. For example, application programming interface (API) documentation outlines the available classes, functions, methods and modules of a software project’s public APIs.
Documentation generators can produce API documentation in various formats, including HTML, PDF and XML. These AI-driven tools evaluate code files to generate endpoint descriptions, request parameter structures and response schemas, and also detailed information about authentication requirements and error codes.
Top tip: AI-generated API documentation will need to be reviewed by a human coder. Verify the output to make sure it’s accurate, complete and high quality.
Modernizing legacy code can be a challenge and thus requires a meticulous plan. The first step entails understanding the codebase by reviewing any available documentation. However, legacy systems usually lack sufficient documentation, so the task falls on the hands of developers to have enough of a grasp of the system.
AI coding assistants can aid the modernization process. They have been trained on different programming languages—even older ones—equipping them with the ability to parse a codebase, map out dependencies and generate clear code documentation. Developers can then use the AI-generated documentation for debugging legacy code and guiding their modernization approach, be it code refactoring, migration or rewriting code.
In the previously mentioned internal IBM test, one participating team inherited over 50 undocumented code repositories containing some 750 JavaScript files. This meant weeks of manual analysis and documentation to comprehend the code. The team decided to enlist the help of watsonx Code Assistant, prompting it to produce one-sentence summaries of an initial 9 files with more than 1,000 lines of code. The AI tool summarized each file in about 12 seconds (based on internal testing with optimal bandwidth and response time for watsonx Code Assistant), whereas the team estimated that it might take them at least 3 minutes on average to manually review and summarize every file.
Top tip: Start small to avoid overwhelm. Divide the codebase into smaller, more manageable modules and document one at a time. Choose a core or critical component, then work your way down the documentation chain to less crucial or minor areas.
Harness generative AI and advanced automation to create enterprise-ready code faster.
Optimize software development efforts with trusted AI-driven tools that minimize time spent on writing code, debugging, code refactoring or code completion and make more room for innovation.
Reinvent critical workflows and operations by adding AI to maximize experiences, real-time decision-making and business value.
1. How are developers using AI? Inside our 2025 DORA report, Google, 23 September 2025
2. Developer Survey, Stack Overflow, 2025