AI-powered GitHub PR analysis, risk prediction, and automated release notes generation
Project description
PRCodeSnip ๐
AI-powered GitHub PR analysis, risk prediction, and automated release notes generation. Make smarter merge decisions with intelligent pre-merge analysis.
โจ Features
- ๐ฏ Smart Risk Prediction: AI-powered analysis to predict PR risks before merge
- ๐ Automated Release Notes: Generate professional release notes from PR changes
- ๐ Code Quality Analysis: Comprehensive pre-merge code quality checks
- ๐ Multi-language Support: Interface available in 25+ languages
- ๐ค GitHub Integration: Post comments, create status checks, and workflow automation
- โก Lightning Fast: Async processing with parallel analysis
- ๐ก๏ธ Security First: Built-in security scanning and vulnerability detection
๐ Quick Start
Installation
# Install from PyPI
pip install prcodesnip
# Or install in development mode
pip install -e .
First-time Setup (Interactive)
prcodesnip setup
This will guide you through:
- Setting up GitHub token
- Configuring OpenAI API key (optional)
- Setting default repository
- Choosing language preferences
Basic Usage
# Quick risk analysis
prcodesnip predict-risk --pr 123 --repo owner/repo
# Generate release notes
prcodesnip draft-release --pr 123 --repo owner/repo
# Complete pre-merge analysis
prcodesnip premerge-analyze --pr 123 --post-comment
๐ Complete Command Reference
๐ง Setup and Configuration
prcodesnip setup
Interactive setup wizard for first-time users.
prcodesnip setup
What it does:
- Guides you through GitHub token setup
- Configures OpenAI API key for AI features
- Sets default repository and preferences
- Creates configuration file
prcodesnip config
Manage configuration settings.
# Show current configuration
prcodesnip config --show
# Test your configuration
prcodesnip config --test
# Create sample config file
prcodesnip config --create
# Reset configuration (run setup again)
prcodesnip config --reset
Options:
--show: Display current configuration with masked tokens--test: Test GitHub and OpenAI API connections--create: Create a sample configuration file--reset: Reset configuration and run interactive setup
๐ฏ Risk Analysis Commands
prcodesnip predict-risk
Analyze and predict risks for a PR before merging.
prcodesnip predict-risk --pr 123 --repo owner/repo [OPTIONS]
Required Options:
--pr INTEGER: Pull Request number to analyze--repo TEXT: GitHub repository in formatowner/repo
Optional Options:
--token TEXT: GitHub token (or setGITHUB_TOKENenv var)--detailed: Show detailed risk breakdown by category--debug: Enable debug logging
Example Output:
โ
Risk Prediction Results
========================================
Overall Risk: โ ๏ธ Moderate (0.65/1.0)
Confidence: 0.85
๐ Detailed Risk Breakdown:
๐ Bug Probability: 0.30
๐ Security Risk: 0.15
โก Performance Risk: 0.80
๐งฉ Complexity Risk: 0.45
๐ก Recommendations:
1. Review performance impact of database changes
2. Add unit tests for new authentication logic
3. Consider breaking change into smaller PRs
๐ Release Notes Commands
prcodesnip draft-release
Generate draft release notes from PR changes.
prcodesnip draft-release --pr 123 --repo owner/repo [OPTIONS]
Required Options:
--pr INTEGER: Pull Request number (or will prompt interactively)
Optional Options:
--repo TEXT: GitHub repository (uses default from config if not provided)--token TEXT: GitHub token (or setGITHUB_TOKENenv var)--format [markdown|json|text]: Output format (default: markdown)--output TEXT: Output file path (default: stdout)
Format Examples:
Markdown (default):
## Draft Release Notes
*Generated from PR #123: Add user authentication system*
### โจ New Features
- Add JWT-based user authentication
- Implement password reset functionality
### ๐ Bug Fixes
- Fixed login form validation errors
### ๐ฆ Dependencies
- Updated security packages to latest versions
JSON:
{
"version": "minor",
"pr_number": 123,
"title": "Add user authentication system",
"generated_at": "2025-08-09T12:00:00.000000",
"changes": {
"features": ["Add JWT-based user authentication"],
"bug_fixes": ["Fixed login form validation errors"]
},
"confidence_score": 0.85
}
Text:
Version: minor
Confidence: 0.85
## Draft Release Notes
*Generated from PR #123: Add user authentication system*
### New Features
- Add JWT-based user authentication
- Implement password reset functionality
๐ Complete Analysis Commands
prcodesnip premerge-analyze
Complete pre-merge analysis with risk prediction and release notes.
prcodesnip premerge-analyze --pr 123 [OPTIONS]
Optional Options:
--pr INTEGER: Pull Request number (will prompt if not provided)--repo TEXT: GitHub repository (uses default from config)--token TEXT: GitHub token (or setGITHUB_TOKENenv var)--commit-sha TEXT: Commit SHA for GitHub status checks--post-comment: Post analysis results as PR comment--create-status: Create GitHub status check--output TEXT: Output file for analysis results (default: premerge-analysis.json)
Example Usage:
# Basic analysis
prcodesnip premerge-analyze --pr 123
# With GitHub integration
prcodesnip premerge-analyze --pr 123 --post-comment --create-status --commit-sha abc123def
# Save to custom file
prcodesnip premerge-analyze --pr 123 --output my-analysis.json
Output Structure:
{
"timestamp": "2025-08-09T12:00:00.000000",
"pr_data": {
"number": 123,
"title": "Add new feature",
"repository": "owner/repo"
},
"risk_analysis": {
"risk_assessment": {
"overall_score": 0.25,
"risk_level": "low",
"confidence": 0.90
},
"detailed_risks": {
"bug_probability": 0.10,
"security_risk": 0.05,
"performance_risk": 0.30,
"complexity_risk": 0.15
},
"recommendations": [
"Add unit tests for new functionality",
"Review performance impact"
]
},
"draft_release_notes": {
"version": "minor",
"release_notes": "## Draft Release Notes...",
"confidence_score": 0.85
}
}
prprcodesnip analyze-fast
Fast async analysis with parallel processing.
prprcodesnip analyze-fast --pr 123 --repo owner/repo [OPTIONS]
Options: Same as analyze command but optimized for speed.
Features:
- Parallel processing of analysis tasks
- Reduced memory usage
- Faster API calls
- Suitable for CI/CD pipelines
๐ค GitHub Integration Commands
prprcodesnip setup-workflow
Setup CI/CD workflow integration.
prprcodesnip setup-workflow [OPTIONS]
Options:
--provider [github-actions|gitlab-ci|jenkins]: CI/CD provider (default: github-actions)--output-dir TEXT: Directory for workflow files (default: .github/workflows)
Generated GitHub Actions Workflow:
- Triggers on PR open/update
- Runs complete pre-merge analysis
- Posts results as PR comments
- Creates GitHub status checks
- Uploads analysis artifacts
Setup Instructions After Generation:
- Add
OPENAI_API_KEYto repository secrets - Ensure
GITHUB_TOKENhas write permissions - Commit and push the workflow file
- Create a test PR to see it in action
๐ Multi-language Commands
prcodesnip language
Multi-language support commands for programming language detection and interface languages.
# Detect programming languages in repository
prcodesnip language detect-languages --repo owner/repo
# Setup development environment for programming language
prcodesnip language setup-environment python
# Set CLI interface language
prcodesnip language set-language es
# List available interface languages
prcodesnip language list-languages
# Show current locale information
prcodesnip language show-locale-info
๐ฅ๏ธ CLI Interface Languages (25+ supported):
- European: English, Spanish, French, German, Italian, Dutch, Portuguese, Russian, Polish, Czech
- Asian: Japanese, Korean, Chinese, Hindi, Thai, Vietnamese, Indonesian, Malay
- Middle Eastern: Arabic, Hebrew, Turkish
- Nordic: Swedish, Norwegian, Danish, Finnish
- Other: Romanian, Hungarian, Filipino
๐ป Programming Languages Supported (60+ languages):
Mainstream Languages:
- Python, JavaScript, TypeScript, Go, Java, C#, Rust, C++, C
- PHP, Ruby, Swift, Kotlin, Scala
Functional Languages:
- Haskell, OCaml, Erlang, Elixir, F#, Clojure
JVM Languages:
- Java, Kotlin, Scala, Groovy, Clojure
Systems Programming:
- Rust, C, C++, Assembly, Zig
Web Technologies:
- HTML, CSS, JavaScript, TypeScript
Mobile Development:
- Swift (iOS), Kotlin (Android), Dart (Flutter), Objective-C
Scientific Computing:
- Python, R, MATLAB, Julia
Scripting Languages:
- Python, JavaScript, Bash, PowerShell, Perl, Lua, Fish
Emerging Languages:
- Crystal, Nim, V, Zig
Blockchain:
- Solidity, Vyper
Game Development:
- GDScript (Godot), ActionScript
Hardware Description:
- Verilog, VHDL, SystemVerilog
Configuration & Markup:
- YAML, TOML, JSON, XML, Markdown
Infrastructure:
- Dockerfile, Terraform, Makefile
And many more! See the complete list in the language detector.
๐ Data and Analysis Commands
prcodesnip analyze
Legacy full analysis command (use premerge-analyze for new projects).
prcodesnip analyze --pr 123 --repo owner/repo [OPTIONS]
Options:
--pr INTEGER: Pull Request number (required)--repo TEXT: GitHub repository--token TEXT: GitHub token--openai-key TEXT: OpenAI API key--output TEXT: Output file (default: release-notes.md)
prcodesnip fetch
Fetch raw PR data from GitHub (useful for debugging).
prcodesnip fetch --pr 123 --repo owner/repo [OPTIONS]
Options:
--pr INTEGER: Pull Request number (required)--repo TEXT: GitHub repository--token TEXT: GitHub token
Output: Raw JSON data with PR title, body, diff, and metadata.
๐ Help and Information Commands
prcodesnip quickstart
Show quick start guide for new users.
prcodesnip quickstart
Displays:
- First-time setup instructions
- Basic usage examples
- Configuration tips
- GitHub integration guide
๐ง Configuration Options
Environment Variables
# Required for GitHub integration
export GITHUB_TOKEN="ghp_your_token_here"
# Optional for AI-powered release notes
export OPENAI_API_KEY="sk-your_key_here"
# Optional language setting
export PRCODESNIP_LANGUAGE="es"
Configuration File
PRCodeSnip looks for configuration in these locations (in order):
./.prcodesnip.json(current directory)~/.prcodesnip/config.json(user home)- Environment variables
Sample Configuration:
{
"github": {
"token": "env:GITHUB_TOKEN",
"default_repo": "owner/repo"
},
"openai": {
"api_key": "env:OPENAI_API_KEY",
"model": "gpt-4o-mini"
},
"quality": {
"tools": ["pytest", "pylint", "bandit", "coverage"],
"timeout": 300
},
"output": {
"default_format": "markdown",
"default_file": "release-notes.md"
},
"language": "en"
}
๐ Usage Examples
๐ฏ Risk Analysis Examples
# Basic risk analysis
prcodesnip predict-risk --pr 42 --repo microsoft/vscode
# Detailed risk breakdown
prcodesnip predict-risk --pr 42 --repo owner/repo --detailed
# With debug information
prcodesnip predict-risk --pr 42 --repo owner/repo --detailed --debug
๐ Release Notes Examples
# Generate markdown release notes
prcodesnip draft-release --pr 42 --repo owner/repo
# Generate JSON format
prcodesnip draft-release --pr 42 --repo owner/repo --format json
# Save to file
prcodesnip draft-release --pr 42 --repo owner/repo --output changelog.md
# Interactive mode (prompts for PR and repo)
prcodesnip draft-release
๐ Complete Analysis Examples
# Basic analysis
prcodesnip premerge-analyze --pr 42
# With GitHub integration
prcodesnip premerge-analyze --pr 42 --post-comment --create-status
# Production workflow
prcodesnip premerge-analyze \
--pr 42 \
--repo owner/repo \
--commit-sha abc123def \
--post-comment \
--create-status \
--output production-analysis.json
๐ Multi-language Examples
# === PROGRAMMING LANGUAGE DETECTION ===
# Detect programming languages used in repository
prcodesnip language detect-languages --repo microsoft/vscode
# Setup development environment for specific programming language
prcodesnip language setup-environment python --project-path ./my-python-project
# === CLI INTERFACE LANGUAGES ===
# Set Spanish interface for CLI
prcodesnip language set-language es
# Analyze with Spanish interface
prcodesnip predict-risk --pr 42 --repo owner/repo --language es
# Show current locale and number formatting
prcodesnip language show-locale-info
# List all available interface languages
prcodesnip language list-languages
๐ Language Support Explanation
๐ฅ๏ธ CLI Interface Languages:
- Changes the language of CodeSnip's interface (menus, messages, help text)
- Affects number formatting, currency display, date formats
- 25+ languages supported (Spanish, French, German, Japanese, etc.)
- Use:
prcodesnip language set-language es
๐ป Programming Language Detection:
- Detects which programming languages are used in your repository
- Analyzes code files, configuration files, and project structure
- 60+ programming languages supported (Python, JavaScript, Go, Rust, etc.)
- Automatically installs appropriate development tools and linters
- Use:
prcodesnip language detect-languages --repo owner/repo
Example Output for Programming Language Detection:
๐ฏ Primary Language: python
๐ Detected Languages: python, javascript, dockerfile, yaml
โ๏ธ Installing tools for python, javascript...
โ
Tools installed: pytest, pylint, eslint, prettier, hadolint
๐ Security and Privacy
- Token Security: Tokens are never logged or stored in plain text
- API Calls: Only necessary data is sent to external APIs
- Local Processing: Most analysis happens locally
- Configurable: All external integrations are optional
โก Performance Tips
- Use Fast Mode:
analyze-fastfor CI/CD pipelines - Set Timeouts: Configure appropriate timeouts in config
- Cache Results: Results are cached for repeated analyses
- Parallel Processing: Multiple PRs can be analyzed simultaneously
๐ ๏ธ Development and Testing
Local Development
# Clone repository
git clone https://github.com/your-org/prcodesnip
cd prcodesnip
# Setup development environment
python -m venv venv
source venv/bin/activate # Linux/Mac
# or venv\Scripts\activate # Windows
# Install in development mode
pip install -e .[dev]
# Run tests
pytest
# Run with coverage
coverage run -m pytest
coverage report
Note: The venv/ folder is automatically created and should not be committed to version control. It's included in .gitignore.
Testing Your Changes
# Test with real PR
prcodesnip draft-release --pr 4 --repo your-username/your-repo
# Test risk prediction
prcodesnip predict-risk --pr 4 --repo your-username/your-repo --detailed
# Test full analysis
prcodesnip premerge-analyze --pr 4 --output test-analysis.json
๐ค Contributing
Contributions welcome! Please see our Contributing Guide for details.
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Support and Community
- ๐ Documentation
- ๐ Report Issues
- ๐ฌ Discussions
- ๐ง Email Support
Made with โค๏ธ by the PRCodeSnip team. Happy coding! ๐
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file prcodesnip-1.0.0.tar.gz.
File metadata
- Download URL: prcodesnip-1.0.0.tar.gz
- Upload date:
- Size: 98.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8c47be5f51491c5cf66338eaa7865d8ac77cd4f7a285fd3750bf58244cf0f7f9
|
|
| MD5 |
d942e11937284ff8b1a6a35dc5844035
|
|
| BLAKE2b-256 |
a6c3dd0033270859c52923047a6e75fb3013246699661183c059097075c0ff82
|
File details
Details for the file prcodesnip-1.0.0-py3-none-any.whl.
File metadata
- Download URL: prcodesnip-1.0.0-py3-none-any.whl
- Upload date:
- Size: 137.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
69b824633e208e411d783e9620b4471658dc187cda87ba825cf25a75faa3a1b7
|
|
| MD5 |
c8160fa6eb6d9430e3e2880b7fd4a729
|
|
| BLAKE2b-256 |
68db36b42594d985b80104477cb25e4a1c5a856787553dc6aef5255be9ebb23c
|