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
Made with ❤️ by the PRCodeSnip team. Happy coding! 🚀
Metadata
Release files for prcodesnip 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| prcodesnip-1.0.0.tar.gz | 98.5 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| prcodesnip-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 236.2 kB
Release files / prcodesnip-1.0.0.tar.gz
| Download URL | prcodesnip-1.0.0.tar.gz |
|---|---|
| Size | 98.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8c47be5f51491c5cf66338eaa7865d8ac77cd4f7a285fd3750bf58244cf0f7f9
|
|
BLAKE2b-256 checksum How to use checksums |
a6c3dd0033270859c52923047a6e75fb3013246699661183c059097075c0ff82
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.3
|
Release files / prcodesnip-1.0.0-py3-none-any.whl
| Download URL | prcodesnip-1.0.0-py3-none-any.whl |
|---|---|
| Size | 137.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
69b824633e208e411d783e9620b4471658dc187cda87ba825cf25a75faa3a1b7
|
|
BLAKE2b-256 checksum How to use checksums |
68db36b42594d985b80104477cb25e4a1c5a856787553dc6aef5255be9ebb23c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.3
|
Security for prcodesnip 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.