Skip to main content
Redhat Developers  Logo
  • Products

    Platforms

    • Red Hat Enterprise Linux
      Red Hat Enterprise Linux Icon
    • Red Hat AI
      Red Hat AI
    • Red Hat OpenShift
      Openshift icon
    • Red Hat Ansible Automation Platform
      Ansible icon
    • See all Red Hat products

    Featured

    • Red Hat build of OpenJDK
    • Red Hat Developer Hub
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat OpenShift Local
    • Red Hat Developer Sandbox

      Try Red Hat products and technologies without setup or configuration fees for 30 days with this shared Red Hat OpenShift and Kubernetes cluster.
    • Try at no cost
  • Technologies

    Featured

    • AI/ML
      AI/ML Icon
    • Linux
      Linux Icon
    • Kubernetes
      Cloud icon
    • Automation
      Automation Icon showing arrows moving in a circle around a gear
    • See all technologies
    • Programming languages & frameworks

      • Java
      • Python
      • JavaScript
    • System design & architecture

      • Red Hat architecture and design patterns
      • Microservices
      • Event-Driven Architecture
      • Databases
    • Developer experience

      • Productivity
      • Tools
      • GitOps
    • Automated data processing

      • AI/ML
      • Data science
      • Apache Kafka on Kubernetes
    • Platform engineering

      • DevOps
      • DevSecOps
      • Red Hat Ansible Automation Platform for applications and services
    • Secure development & architectures

      • Security
      • Secure coding
  • Learn

    Featured

    • Kubernetes & cloud native
      Openshift icon
    • Linux
      Rhel icon
    • Automation
      Ansible cloud icon
    • AI/ML
      AI/ML Icon
    • See all learning resources

    E-books

    • GitOps cookbook
    • Podman in action
    • Kubernetes operators
    • The path to GitOps
    • See all e-books

    Cheat sheets

    • Linux commands
    • Bash commands
    • Git
    • systemd commands
    • See all cheat sheets

    Documentation

    • Product documentation
    • API catalog
    • Legacy documentation
  • Developer Sandbox

    Developer Sandbox

    • Access Red Hat’s products and technologies without setup or configuration, and start developing quicker than ever before with our new, no-cost sandbox environments.
    • Explore the Developer Sandbox

    Featured Developer Sandbox activities

    • Get started with your Developer Sandbox
    • OpenShift virtualization and application modernization using the Developer Sandbox
    • Explore all Developer Sandbox activities

    Ready to start developing apps?

    • Try at no cost
  • Blog
  • Events
  • Videos

AI-powered documentation updates: From code diff to docs PR in one comment

Automate documentation updates with Code-to-Docs

April 21, 2026
Carmel Soceanu
Related topics:
Artificial intelligenceDeveloper productivity
Related products:
Developer Tools

    TL;DR: Want to automatically update your documentation following code changes? See it in action with this interactive demo.

    Every developer knows the feeling: You merge a pull request changing how a configuration option works, or refactors an API endpoint, and somewhere in a separate repository, the documentation still describes the old behavior. Weeks later, a user or fellow contributor follows those outdated instructions and hits a wall.

    The problem isn't that developers don't care about documentation. It's that keeping docs in sync with code is a separate task, often in a separate repository, that's easy to forget when you're focused on shipping features and fixing bugs. For large open source projects with mountains of documentation pages, even knowing which files need updating after a code change can be a challenge.

    Code-to-Docs is an open source GitHub Action that addresses this gap. It uses AI to analyze your code changes, identify which documentation files are affected, and generate updated content — all triggered by a simple comment on your pull request.

    How Code-to-Docs works

    Code-to-Docs integrates into your pull request workflow through two commands, typed as PR comments:

    • [review-docs]: AI examines your code diff, finds relevant documentation files, and posts a review comment with checkboxes listing each file it thinks needs an update, along with a short explanation of why.
    • [update-docs]: Takes the files you approved in the review (or runs the full pipeline if you skipped the review step) and creates a pull request in your docs repository with the generated updates.

    Recommended workflow for Code-to-Docs

    The two-step approach keeps humans in control while letting AI handle the discovery and drafting: AI suggests (as in Figure 1), and you decide. Nothing gets merged without human approval.

    The GitHub Action analyzes the code diff and posts a review listing which documentation files need updates, with checkboxes for the reviewer to accept or reject each suggestion. This image is from the interactive demo.
    Figure 1: The GitHub Action analyzes the code diff and posts a review listing which documentation files need updates, with checkboxes for the reviewer to accept or reject each suggestion. This image is from the interactive demo.

    Here's an example scenario:

    1. A developer opens a pull request (PR) that changes a configuration option.
    2. A reviewer (or the developer) adds the [review-docs] comment to the PR.
    3. The GitHub Action analyzes the diff and responds with a list of probable changes: "These 3 doc files reference the config you changed. Here's what I'd update in each one…"
    4. The reviewer disables the one file that doesn't actually need changes.
    5. The reviewer adds the [update-docs] comment to the PR, and a new docs PR appears in the documentation repository with the accepted updates ready for review (see Figure 2).
    AI-generated documentation updates shown side-by-side. In this example, the GitHub Action has added rate limiting details to the API docs, matching the project's existing style. This image is from the interactive demo.
    Figure 2: AI-generated documentation updates shown side-by-side. In this example, the GitHub Action has added rate limiting details to the API docs, matching the project's existing style. This image is from the interactive demo.

    Guiding the AI with instructions

    Sometimes you want more control over what AI generates. With Code-to-Docs, you can add instructions directly in your [update-docs] comment: Global instructions on the first line, and instructions for specific files on the lines that follow (see Figure 3).

    A reviewer guides the AI with global instructions on the first line and file-specific instructions on the lines that follow. This image is from the interactive demo.
    Figure 3: A reviewer guides the AI with global instructions on the first line and file-specific instructions on the lines that follow. This image is from the interactive demo.

    This is useful when you know exactly what part of a doc needs attention, or when you want to constrain the AI to small, focused edits rather than broad rewrites.

    Setting up Code-to-Docs

    Getting started takes two steps: Add a GitHub Actions workflow file, and configure a few repository secrets.

    Step 1: Add the workflow file

    Create .github/workflows/docs-assistant.yml in your repository, following these setup steps.

    The workflow listens for issue_comment events, and triggers when a comment contains [review-docs] or [update-docs]. It checks out the PR's code, extracts the diff, and runs the Code-to-Docs action.

    Step 2: Configure repository secrets

    In your repository's Settings > Secrets and variables > Actions panel, add the required secrets, following these configuration details.

    That's it. The next time someone comments [review-docs] on a pull request, the GitHub Action kicks in.

    How AI identifies and updates documentation files

    Code-to-Docs uses any OpenAI-compatible LLM to analyze code changes and generate documentation updates. It works, with no customization necessary, with models deployed on Red Hat OpenShift AI with vLLM, Google Gemini, OpenAI, Ollama, and any other inference server that exposes the OpenAI API format. Here's a closer look at the key components that make this work.

    Smart file discovery with semantic indexing

    One of the biggest challenges is figuring out which documentation files are affected by a code change. In a project with hundreds of doc files, scanning every one with AI on each run would be slow and expensive. Code-to-Docs solves this with a two-stage semantic indexing system:

    1. Folder indexes: On the first run, the GitHub Action generates AI-powered summaries of each documentation folder, describing what topics each folder covers. These summaries are cached in a .doc-index directory and committed to your main branch.
    2. File summaries: For long documentation files, the GitHub Action generates and caches concise summaries so it doesn't need to send the full file content to the AI on every run.

    When a new PR triggers the GitHub Action, it first checks the folder-level indexes to narrow down which areas of the documentation are relevant (a single API call instead of scanning hundreds of files). Then it examines only the files in those relevant folders. This cuts runtime from around 20 minutes to about 4 minutes on large documentation sets. Performance improves over time as more summaries are built up, and when a documentation file is updated, its cached summary is regenerated automatically.

    The AI is prompted to be conservative in its file selection. It only picks files that directly document code being changed, preferring to return few results over noisy false positives. It works with AsciiDoc, Markdown, and reStructuredText, and supports both separate documentation repositories and docs that live alongside your code in the same repo.

    Get started

    Code contributors are often domain experts in the code they're changing, but they may not know the documentation structure well enough to find every affected file. Code-to-Docs lowers that barrier by handling doc discovery and drafting automatically. Maintainers get a clear signal when documentation needs attention, and the review-then-update workflow means nothing happens without human approval. The AI is a tool, not a gatekeeper.

    Code-to-Docs is open source. Here are the resources to help you get started:

    • Source code and documentation
    • Interactive demo
    • Report issues

    Recent Posts

    • Combining KServe and llm-d for optimized generative AI inference

    • AI-powered documentation updates: From code diff to docs PR in one comment

    • 3 lessons for building reliable ServiceNow AI integrations

    • Deploy hosted control planes with OpenShift Virtualization

    • Camel integration quarterly digest: Q1 2026

    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Platforms

    • Red Hat AI
    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Build

    • Developer Sandbox
    • Developer tools
    • Interactive tutorials
    • API catalog

    Quicklinks

    • Learning resources
    • E-books
    • Cheat sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site status dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit
    © 2026 Red Hat

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Report a website issue