AI-powered GitHub Action that analyzes code changes in pull requests to identify and consolidate business themes using Claude AI.
- π― Theme Detection: AI-powered analysis of business themes in code changes
- π§ Smart Consolidation: Merges similar themes using Claude AI semantic analysis
- π Hierarchical Organization: Creates parent/child theme relationships
- π Business Focus: Describes themes from user/business perspective
- β‘ Efficient Processing: Batch processing with smart caching
- π Confidence Scoring: Provides confidence levels for each theme
name: Theme Analysis
on:
pull_request:
branches: [ main ]
jobs:
analyze-themes:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: 6529-Collections/ai-code-review-action@main
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
anthropic-api-key: ${{ secrets.ANTHROPIC_API_KEY }}- uses: 6529-Collections/ai-code-review-action@main
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
anthropic-api-key: ${{ secrets.ANTHROPIC_API_KEY }}
id: theme-analysis
env:
LOG_LEVEL: 'INFO' # Optional: Set logging level
LOG_TIMESTAMPS: 'true' # Optional: Include timestamps in logs
- name: Use theme analysis output
run: |
echo "Themes found: ${{ steps.theme-analysis.outputs.themes }}"
echo "Summary: ${{ steps.theme-analysis.outputs.summary }}"| Input | Description | Required | Default |
|---|---|---|---|
github-token |
GitHub token for API access | No | ${{ github.token }} |
anthropic-api-key |
Anthropic API key for Claude access | Yes | - |
| Output | Description |
|---|---|
themes |
Detailed theme analysis with consolidation information |
summary |
Summary of the theme analysis |
- Installs Claude Code CLI for AI analysis capabilities
- Analyzes changed files in pull requests to extract business themes
- Consolidates similar themes using AI-powered semantic analysis
- Organizes themes hierarchically with parent/child relationships
- Provides business-focused insights from a user perspective
The action outputs detailed theme analysis:
Found 3 themes:
1. **Improve code review automation** (85% confidence)
- Files: src/theme-service.ts, src/ai-similarity.ts (+2 more)
- Enhances automated analysis capabilities for better developer experience
- π Merged from 2 similar themes
2. **Simplify configuration** (72% confidence)
- Files: action.yml, package.json
- Streamlines setup process for easier adoption
- π Contains 1 sub-themes:
1. **Update input validation** (68%)
- Files: src/validation.ts
- Improves input handling and error messages
- Smart Consolidation: Similar themes are automatically merged
- Confidence Scoring: Each theme includes a confidence percentage
- Hierarchical Organization: Parent themes contain related sub-themes
- Business Perspective: Themes described from user/business viewpoint
- AI-Driven Natural Depth: Claude AI determines optimal hierarchy depth
- Adapts from simple 2-level changes to complex multi-level decompositions
- Naturally detects atomic, unit-testable changes
- No artificial metrics - AI understands code context directly
The action is built with a sophisticated, modular architecture:
src/
βββ index.ts # Main entry point - orchestrates theme analysis
βββ validation.ts # Input validation
βββ utils.ts # Utility functions
βββ services/
β βββ theme-service.ts # Core theme analysis orchestration
β βββ git-service.ts # Git operations and file analysis
β βββ theme-similarity.ts # AI-powered theme consolidation
β βββ ai-similarity.ts # Claude AI integration
β βββ batch-processor.ts # Efficient batch processing
β βββ business-domain.ts # Business domain grouping
β βββ theme-naming.ts # AI-powered theme naming
β βββ similarity-cache.ts # Performance caching
βββ utils/
β βββ code-analyzer.ts # Algorithmic code analysis
β βββ similarity-calculator.ts # Mathematical similarity calculations
βββ types/
βββ similarity-types.ts # Advanced type definitions
-
Install dependencies
yarn install
-
Set up environment variables
cp .env.example .env # Edit .env and add your ANTHROPIC_API_KEY -
Available scripts
# Build the action yarn build # Run tests yarn test # Run linter yarn lint # Format code yarn format # Test locally with Node.js yarn test:local "Test message" # Test with act (GitHub Actions locally) yarn test:act
# Uses test-local.js and loads .env file
yarn test:local# Install act
brew install act
# Test the action locally (loads secrets from .env)
yarn test:actThe action supports different diff modes for local testing:
Default Mode (Uncommitted Changes)
# Analyze all uncommitted changes (staged + unstaged + untracked)
yarn test:act
# or explicitly set
DIFF_MODE=uncommitted yarn test:actBranch Mode (PR Context Required)
# Analyze changes between current branch and target branch
DIFF_MODE=branch yarn test:actBranch Mode Requirements:
- Must be on a feature branch (not main/master)
- Branch must have upstream tracking set up
- Target branch (main/master/develop) must exist in remote
- Hard error if not in PR context - no fallbacks
Setup for Branch Mode:
# Create and switch to feature branch
git checkout -b feature/my-feature
# Set up upstream tracking
git push -u origin feature/my-feature
# Now branch mode will work
DIFF_MODE=branch yarn test:actFor local development, create a .env file:
ANTHROPIC_API_KEY=your_anthropic_api_key_hereOptional configuration:
# Local testing diff mode configuration
DIFF_MODE=uncommitted # Default: analyze uncommitted changes (staged + unstaged + untracked)
# DIFF_MODE=branch # Analyze changes between current branch and target branch (requires PR context)
# Logging configuration
LOG_LEVEL=INFO # Set log level: ERROR, WARN, INFO, DEBUG, TRACE
LOG_TIMESTAMPS=true # Include timestamps in log outputThe .env file is already in .gitignore to keep your API keys secure.
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
MIT License - see LICENSE file for details.
If you encounter any issues, please create an issue on GitHub.