A GitHub App built with Probot that automates issue resolution with the power of AI. This bot uses Aider to generate code fixes based on GitHub issue descriptions.
- Smart Mode Selection: Automatically determines the best mode (architect, patcher, or hybrid) for handling each issue based on labels and content
- Multi-Pass Processing: Can perform architectural changes followed by detailed fixes for complex issues
- Custom Repository Configurations: Repositories can customize behavior through a config file
- Visual Indicators: Clear badges and labels to indicate which modes were used to fix issues
- Interactive Commands: Respond to issue comments to analyze or select specific processing modes
- An issue is opened or labeled with a trigger label (e.g.,
patchmycode:fix
) - The bot analyzes the issue to select the appropriate mode
- Code changes are generated using Aider with the selected mode
- A pull request is created with the changes
- Visual badges show which modes were used in the PR
Designed for architectural changes, refactoring, and major restructuring. This mode focuses on:
- Improving code organization
- Implementing design patterns
- Enhancing overall architecture
- Refactoring for maintainability
Focused on targeted bug fixes and immediate problem resolution. This mode emphasizes:
- Precise bug fixing
- Minimal changes
- Fast turnaround
- Preserving existing code structure
Special purpose modes for specific tasks:
Security: For vulnerability fixes and security improvements
Performance: For optimizing code and improving efficiency
TypeScript: For TypeScript migrations and type improvements
Use these commands in issue comments:
/analyze
- Analyze the issue and recommend the best mode/mode architect
- Use architect mode for this issue/mode patcher
- Use patcher mode for this issue/mode hybrid:security
- Use security-focused hybrid mode/mode hybrid:performance
- Use performance-focused hybrid mode/mode hybrid:typescript
- Use TypeScript-focused hybrid mode/mode multipass
- Use a multi-pass approach (architect followed by patcher)/fix
- Fix the issue using the currently selected mode
Create a .patchmycode/config.json
file in your repository to customize behavior:
{
"defaultMode": "patcher",
"modeLabels": {
"architect": ["architecture", "refactor", "design"],
"patcher": ["bug", "fix", "typo"],
"hybrid:security": ["security", "vulnerability"]
},
"systemPrompts": {
"architect": "Custom system prompt for architect mode...",
"patcher": "Custom system prompt for patcher mode..."
},
"modelMap": {
"architect": "claude-3-7-sonnet",
"patcher": "gpt-4o",
"hybrid:security": "claude-3-opus-20240229"
},
"providerMap": {
"architect": "anthropic",
"patcher": "openai",
"hybrid:security": "anthropic"
}
}
- Node.js 18+
- Aider installed (
pip install aider-chat
) - GitHub App credentials
- OpenAI API key and/or Anthropic API key
- Go to GitHub Developer Settings and click "New GitHub App"
- Fill in the following details:
- GitHub App name: Choose a name for your app (e.g., "My patchmycode App")
- Homepage URL: Your website or repository URL
- Webhook URL: The URL where GitHub will send webhook events (e.g.,
https://your-domain.com/api/github/webhooks
or use smee.io for development) - Webhook secret: Create a random string and save it for later
- Set the following permissions:
- Repository permissions:
- Contents: Read & write (for creating branches and commits)
- Issues: Read & write (for reading and commenting on issues)
- Pull requests: Read & write (for creating PRs)
- Metadata: Read-only
- Subscribe to events:
- Issues
- Issue comment
- Label
- Pull request
- Repository permissions:
- Choose whether to install the app on all repositories or select repositories
- Click "Create GitHub App"
- After creation, note your App ID at the top of the page
- Generate a Private key by clicking "Generate a private key" in the "Private keys" section
- Install the app on your repositories by clicking "Install App" in the sidebar
# Clone the repository
git clone https://github.com/stevengonsalvez/probot-aider-bot.git
cd probot-aider-bot
# Install dependencies
npm install
# Copy the example environment file
cp .env.example .env
# Edit the .env file with your GitHub App credentials and API keys
# Set APP_ID, PRIVATE_KEY, WEBHOOK_SECRET, and API keys
# Run the bot
npm start
APP_ID
: Your GitHub App IDPRIVATE_KEY
: Your GitHub App's private key (contents of the .pem file)PRIVATE_KEY_PATH
: Alternative to PRIVATE_KEY, specify path to the .pem file (recommended for security)WEBHOOK_SECRET
: Your GitHub App's webhook secretWEBHOOK_PROXY_URL
: URL for webhook proxying (for local development with smee.io)LOG_LEVEL
: Logging level (debug
,info
,warn
, orerror
)
You can configure multiple API providers:
-
OpenAI Configuration:
OPENAI_API_KEY
: Single API key for OpenAI modelsOPENAI_API_KEYS
: Multiple comma-separated keys for load balancing
-
Anthropic Configuration:
ANTHROPIC_API_KEY
: Single API key for Claude modelsANTHROPIC_API_KEYS
: Multiple comma-separated keys for load balancing
-
OpenRouter Configuration:
OPENROUTER_API_KEY
: API key for accessing multiple models through OpenRouter
You can set models globally or per mode:
-
Global model setting:
PATCH_MODEL
: Default model for all modes if no mode-specific model is set
-
Mode-specific models:
PATCH_MODEL_ARCHITECT
: Model for architect modePATCH_MODEL_PATCHER
: Model for patcher modePATCH_MODEL_HYBRID_SECURITY
: Model for security hybrid modePATCH_MODEL_HYBRID_PERFORMANCE
: Model for performance hybrid modePATCH_MODEL_HYBRID_TYPESCRIPT
: Model for TypeScript hybrid mode
-
Model provider configuration:
PATCH_MODEL_PROVIDER
: Explicitly specify which provider to use (openai, anthropic, openrouter)PATCH_MODEL_PROVIDER_ARCHITECT
: Provider for architect modePATCH_MODEL_PROVIDER_PATCHER
: Provider for patcher modePATCH_MODEL_PROVIDER_HYBRID_SECURITY
: Provider for security hybrid modePATCH_MODEL_PROVIDER_HYBRID_PERFORMANCE
: Provider for performance hybrid modePATCH_MODEL_PROVIDER_HYBRID_TYPESCRIPT
: Provider for TypeScript hybrid mode
-
Model-specific arguments:
PATCH_EXTRA_ARGS
: Global extra arguments for AiderPATCH_EXTRA_ARGS_ARCHITECT
: Arguments specific to architect modePATCH_EXTRA_ARGS_PATCHER
: Arguments specific to patcher modePATCH_EXTRA_ARGS_HYBRID_SECURITY
: Arguments specific to security mode
To set the default mode and mode selection behavior:
PATCH_DEFAULT_MODE
: Default processing mode (architect
,patcher
, or a hybrid mode)PATCH_ENABLE_MULTIPASS
: Whether to enable multi-pass processing for complex issuesPATCH_MULTIPASS_SEQUENCE
: The sequence of modes for multi-pass processing
# Run with hot reload
npm run dev
# Run tests
npm test
- Go to smee.io and click "Start a new channel"
- Copy the URL and set it as
WEBHOOK_PROXY_URL
in your.env
file - Install the smee client:
npm install -g smee-client
- Run the client:
smee -u https://smee.io/your-channel -t http://localhost:3000/api/github/webhooks
- Start your Probot app in another terminal:
npm start
# Build the Docker image
docker build -t patchmycode .
# Run the Docker container
docker run -p 3000:3000 --env-file .env patchmycode
- Heroku: Push to Heroku with the Procfile included
- Fly.io: Deploy with the included fly.toml
- GitHub Actions: Deploy using GitHub Actions workflows
- Vercel/Netlify: Deploy serverless with adapter
ISC © 2025 steven gonsalvez