This GitHub Action analyzes pull request diffs using an LLM (Large Language Model) and automatically adds relevant comments to the PR. It helps improve code quality by providing automated code review feedback.
- Analyzes PR diffs using an LLM
- Considers PR context (title, description, and comments) to better understand intent
- Posts line-specific comments on code that could be improved
- Provides a summary comment of the overall PR
- Configurable rules for comment generation
- Works with any GitHub repository
Add this action to your workflow file:
name: PR Analysis
on:
pull_request:
types: [opened, synchronize]
jobs:
analyze:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Analyze PR
uses: your-org/pr-comment-analysis@v1
with:
github-token: ${{ secrets.MUSASHI }}
# repo-name defaults to the current repository
pr-number: ${{ github.event.pull_request.number }}
llm-api-key: ${{ secrets.LLM_API_KEY }}
# Comment rules will be read from .cursor/rules dir if exists
log-level: "info""Focus on security issues and performance improvements"
| Input | Description | Required | Default |
|---|---|---|---|
github-token |
GitHub token for API access | Yes | N/A |
repo-name |
Target repository name (owner/repo) | No | ${{ github.repository }} |
pr-number |
Pull request number to analyze | Yes | N/A |
llm-api-key |
API key for the LLM service | Yes | N/A |
comment-rules |
JSON configuration for comment rules (if .cursor/rules don't exist) | No | {} |
log-level |
Logging level (debug, info, warn, error) | No | info |
llm-provider |
LLM provider to use (openai or anthropic) | No | openai |
llm-model |
Specific model to use | No | provider default |
You can configure the action by adding a .cursor/rules/*.mdc files to the root of your repository. These files take precedence over the comment-rules input parameter.
If the .cursor/rules file is not found or cannot be parsed, the action will fall back to using the comment-rules input parameter.
| Output | Description |
|---|---|
comment-count |
Number of comments posted |
analysis-summary |
Summary of the analysis |
- bun
- TypeScript knowledge
- Clone the repository
- Install dependencies:
bun install - Build the action:
bun build
This project is built with TypeScript for improved type safety and developer experience. The TypeScript configuration is in tsconfig.json.
To check types without building:
bun typecheck
To build the TypeScript code:
bun build
Run tests with: bun test
For manual testing, you can use:
bun test:manual
MIT