PatchPro can be used locally by developers to analyze and fix code issues before committing or pushing changes.
# Install PatchPro locally
pip install git+https://github.com/A3copilotprogram/patchpro-bot.git@agent-dev
# Install analysis tools
pip install ruff semgrepAnalyze changes before committing:
# Analyze staged changes
git diff --cached --name-only | grep '\.py$' | xargs python -m patchpro_bot.cli run-ci --base-dir .
# Or analyze specific files
python -m patchpro_bot.cli run-ci --base-dir src/my_module --artifacts .patchproAnalyze changes before pushing:
# Analyze changes since last push
git diff origin/main...HEAD --name-only | grep '\.py$' | \
xargs python -m patchpro_bot.cli run-ci --base-dir . --artifacts .patchproUse PatchPro as a local code reviewer:
# Analyze current working directory
python -m patchpro_bot.cli analyze . --format table
# Generate patches for fixable issues
python -m patchpro_bot.cli run-ci --base-dir . --artifacts .patchpro
# Apply patches interactively
git apply .patchpro/patch_combined_*.diff# VS Code extension command
# Ctrl+Shift+P -> "PatchPro: Analyze Current File"
# Vim integration
:!python -m patchpro_bot.cli analyze %
# IntelliJ plugin
# Tools -> PatchPro -> Analyze ProjectCreate .patchpro.toml in your project root:
[analysis]
tools = ["ruff", "semgrep"]
exclude_patterns = ["tests/", "__pycache__/", ".venv/"]
[ruff]
config_file = "pyproject.toml"
select = ["E", "F", "W", "C90", "I", "N", "D", "UP", "YTT", "ANN", "S", "BLE", "FBT", "B", "A", "COM", "C4", "DTZ", "T10", "EM", "EXE", "ISC", "ICN", "G", "INP", "PIE", "T20", "PYI", "PT", "Q", "RSE", "RET", "SLF", "SIM", "TID", "TCH", "ARG", "PTH", "ERA", "PGH", "PL", "TRY", "FLY", "NPY", "RUF"]
[semgrep]
config = ".semgrep.yml"
[llm]
model = "gpt-4o-mini"
max_tokens = 4000
temperature = 0.1
[output]
artifacts_dir = ".patchpro"
format = "json"
include_patches = trueAdd to .git/hooks/pre-commit:
#!/bin/bash
# Run PatchPro on staged files
STAGED_FILES=$(git diff --cached --name-only | grep '\.py$' | tr '\n' ' ')
if [ -n "$STAGED_FILES" ]; then
echo "🔍 Running PatchPro analysis on staged files..."
# Create temp directory with staged files
mkdir -p .patchpro/staged
for file in $STAGED_FILES; do
cp "$file" ".patchpro/staged/"
done
# Run analysis
python -m patchpro_bot.cli run-ci --base-dir .patchpro/staged --artifacts .patchpro
# Check if critical issues found
if [ -f ".patchpro/report.md" ]; then
CRITICAL_ISSUES=$(grep -c "error:" .patchpro/report.md || echo "0")
if [ "$CRITICAL_ISSUES" -gt 0 ]; then
echo "❌ Critical issues found! Check .patchpro/report.md"
echo "Run 'git apply .patchpro/patch_combined_*.diff' to apply suggested fixes"
exit 1
fi
fi
echo "✅ PatchPro analysis passed"
fiAdd to .git/hooks/pre-push:
#!/bin/bash
# Run PatchPro on changes since origin/main
echo "🔍 Running PatchPro analysis on push changes..."
CHANGED_FILES=$(git diff origin/main...HEAD --name-only | grep '\.py$' | tr '\n' ' ')
if [ -n "$CHANGED_FILES" ]; then
python -m patchpro_bot.cli run-ci --base-dir . --artifacts .patchpro
# Show summary
if [ -f ".patchpro/report.md" ]; then
echo "📊 PatchPro Summary:"
grep -E "Total findings|Patches generated" .patchpro/report.md
fi
fi# Check what needs attention today
python -m patchpro_bot.cli analyze . --format table
# Focus on high-priority issues
python -m patchpro_bot.cli analyze . --format json | jq '.findings[] | select(.severity == "error")'
# Generate fixes for quick wins
python -m patchpro_bot.cli run-ci --base-dir . --artifacts .patchpro
git apply .patchpro/patch_combined_*.diff# Start feature
git checkout -b feature/user-auth
# Develop...
# Test changes with PatchPro
python -m patchpro_bot.cli run-ci --base-dir src/auth --artifacts .patchpro
# Review suggested improvements
cat .patchpro/report.md
# Apply automatic fixes
git apply .patchpro/patch_combined_*.diff
# Commit clean code
git add . && git commit -m "feat: implement user authentication"# Before creating PR
python -m patchpro_bot.cli run-ci --base-dir . --artifacts .patchpro
# Ensure no critical issues
CRITICAL=$(grep -c "severity.*error" .patchpro/report.md || echo "0")
if [ "$CRITICAL" -eq 0 ]; then
echo "✅ Ready for PR"
git push origin feature/user-auth
else
echo "❌ Fix critical issues first"
cat .patchpro/report.md
fi- Early Issue Detection: Catch problems before they reach CI/CD
- Learning Tool: Understand code quality patterns and best practices
- Time Saving: Automatic fixes for common issues
- Consistency: Same analysis as CI, no surprises
- Offline Capable: Works without internet (except LLM features)
- Customizable: Adapt rules to team/project standards
# Auto-analyze on file changes
python -m patchpro_bot.cli watch src/# Only analyze changed lines
python -m patchpro_bot.cli analyze --diff-only --base=origin/main# Share team config via git
git add .patchpro.toml
git commit -m "Add team PatchPro config"# Use same config as CI
python -m patchpro_bot.cli run-ci --config-from=.github/workflows/patchpro.ymlThis local developer workflow makes PatchPro a powerful daily development tool, not just a CI/CD component!