This repository is a GitHub Action and a tool that can scans your codebase and add/update documentation to your code.
This action is designed to be run regularly over your codebase, using a workflow triggered by each sync with the main branch.
The action uses GenAIScript and AST-GREP.
Note
This action uses GitHub Models for LLM inference.
- TypeScript:
.ts
,.tsx
,.mts
,.cts
- Python:
.py
- C#:
.cs
- Java:
.java
- C:
.h
,.c
- C++:
.hpp
,.cpp
,.cc
,.cxx
- Go:
.go
- Rust:
.rs
Note
Do you need another language? File an issue or ask copilot to add it.
github_token
: GitHub token withmodels: read
permission at least. (required)model
: The model to use for generating documentation. (default:github:openai/gpt-4.1-mini
)files
: The files to process, in glob format. (default:**/src/**/*.{,py}
)kinds
: Comma-separated list of kinds of entities to process: module,type,function,property,variable. (default: all but variable)exports_only
: If true, only process exported entities. (default:false
)update_existing
: Update existing docs (increases cost). (default:false
)instructions
: Additional prompting instructions for the LLM.max_context
: Maximum number of tokens to build content of requests. (default:6000
)max_edits
: Maximum number of new or updated comments total. (default:50
)judge
: If true, the script will judge the quality of generated comments. (default:false
)dry_run
: If true, the script will not modify files. (default:false
)mock
: If true, the script will insert a mock comment instead of actual documentation. (default:false
)debug
: Enable debug logging.
Add the following to your step in your workflow file:
uses: pelikhan/action-continuous-comments@v0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
files: "**/src/*"
name: Improve Code Comments
on:
push:
branches:
- main
workflow_dispatch:
permissions:
contents: write
pull-requests: write
models: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
improve-comments:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# This is the cache used by "improve comments"
- uses: actions/cache@v4
with:
path: .genaiscript/cache/**
key: genaiscript-${{ github.run_id }}
restore-keys: genaiscript-
# Improve the comments in the codebase
- name: improve comments
uses: pelikhan/action-continuous-comments@v0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
max_edits: 20
# Create a pull request with the changes
- name: create pull request
uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.GITHUB_TOKEN }}
title: "genai-commentor: Suggested comment improvements"
body: "Hi! 👋 I'm a Code Commentor 🤖.\n\nThis pull request was automatically generated by the genai-commentor action to write and update code comments.\n\n> ⚠️ AI can make mistakes — please review carefully before merging. ✅"
branch: genai-commentor/updates
commit-message: "Code Commentor: Suggested comment improvements"
Note
You must set "Allow GitHub Actions to create and approve pull requests" in your repository settings to allow the action to create pull requests with documentation updates.
This action was automatically generated by GenAIScript from the script metadata. We recommend updating the script metadata instead of editing the action files directly.
- the action inputs are inferred from the script parameters
- the action outputs are inferred from the script output schema
- the action description is the script title
- the readme description is the script description
- the action branding is the script branding
To regenerate the action files (action.yml
), run:
npm run configure
To lint script files, run:
npm run lint
To typecheck the scripts, run:
npm run typecheck
The GenAIScript version is pinned in the package.json
file. To upgrade it, run:
npm run upgrade
To release a new version of this action, run the release script on a clean working directory.
npm run release