Automating Documentation Updates with Continue CLI
This guide demonstrates how to create automated documentation generation based on code updates in a git branch using the Continue CLI, either as part of your local workflow or as part of a GitHub workflow. This process utilizes the Continue CLI (cn
) in headless mode to analyze changes and generate the necessary documentation, and commit and push the changes. The goal is to keep the workflow as simple as possible by using straightforward shell commands, Continue CLI prompts, and basic git operations.
Why Use Continue CLI for Documentation?
Intelligent Analysis
AI agents understand your codebase and documentation patterns, analyzing git diffs to identify what needs documenting.
Automated Workflows
Integrate seamlessly into CI/CD pipelines or local development workflows with minimal setup.
Contextual Understanding
Agents can read files, explore projects, and access Git history to generate accurate, relevant documentation.
Controlled Permissions
Restrict agent actions to specific files and operations, ensuring safe automated documentation updates.
Prerequisites
Node.js 18+
Continue CLI requires Node.js 18 or higher. Install globally with:
Continue API Key
Get your API key from Continue Hub and set:
You can use the Continue CLI in headless mode without interactive login by setting the
CONTINUE_API_KEY
environment variable.Git Repository
A project with code and documentation, or use an open-source project to experiment with the workflow.
Documentation Generation Workflow
Workflow Overview
The documentation generation process follows these sequential steps:1
Environment Setup
Validate environment, install Continue CLI, and set up authentication with API keys.
2
Change Analysis
Generate git diff context and analyze code changes between branches to identify new functionality.
3
Branch Creation
Create a dedicated documentation branch following the pattern
{original-branch}-docs-update-{timestamp}
.4
AI Documentation Generation
Use Continue CLI with custom rules to analyze changes and generate or update documentation files.
Use an agent configuration with rules specific for documentation writing in your project and fine-tune it to work for your team’s standards.
5
Review & Commit
Review generated documentation, commit changes to the docs directory, and push to origin.
6
Cleanup
Remove temporary files and output completion summary with branch information.
Implementation
GitHub Actions Implementation
This example uses a manual workflow dispatch that requires two inputs: the repository name and the branch containing your code changes. This is helpful when you want to generate documentation for a feature branch before creating a pull request.
- repository: The repository you are operating on (format:
owner/repo
) - branch_name: The name of the branch you have code changes on and want to generate documentation for
- continue_config: The Continue agent configuration to use
- Consider setting a default value if you have a default config your’d like to use
- continue_org: The Continue org to use
- Consider setting a default value if you have a default org your’d like to use
.github/workflows/generate-docs.yml
Enhancement Ideas
The workflow above is a basic example and can be enhanced in various ways to fit your needs. Here are some ideas:Change Analysis Agent
Define a specialized agent for analyzing changes and generating targeted prompts for documentation writers, improving output quality.
Auto-Documentation on Merge
Create GitHub workflows that automatically generate documentation PRs when new features are merged to main.
Documentation Gap Analysis
Build an agent that reviews older merged PRs to identify undocumented features and generates missing documentation.
Copy Editor Agent
Add a post-processing agent to enhance writing quality with rules like “use short sentences and simple words.”
Next Steps
Ready to implement automated documentation with Continue CLI? Here are some helpful resources to get you started:Continue CLI Guide
Learn the fundamentals of using Continue CLI for automated coding tasks and headless workflows.
Understanding Agents
Discover how to configure and customize AI agents for your specific documentation needs.
Video: Leverage AI to help with your docs
Checkout this video from Tetrate about using Continue Agents to help with writing your docs.
Continue Hub
Browse pre-built agents and configurations from the Continue community.