- Python 3.10 or higher
- Poetry (Python dependency manager)
- Git
-
Clone the repository:
git clone https://github.com/yourusername/patchsmith.git cd patchsmith -
Install dependencies:
poetry install
-
Verify installation:
poetry run patchsmith --version
-
Run Patchsmith:
poetry run patchsmith --help
# Create virtual environment
python3 -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install with Poetry
poetry install
# Patchsmith is now available as a command
patchsmith --help# From the project root
poetry buildThis creates two files in dist/:
patchsmith-0.1.0.tar.gz(source distribution)patchsmith-0.1.0-py3-none-any.whl(wheel)
pip install dist/patchsmith-0.1.0-py3-none-any.whlOr install from the source distribution:
pip install dist/patchsmith-0.1.0.tar.gzpatchsmith --versionOnce published to PyPI, you'll be able to install with:
pip install patchsmithPatchsmith requires these external tools:
CodeQL is required for static analysis.
macOS (Homebrew):
brew install codeqlLinux/macOS (Manual):
# Download from GitHub releases
wget https://github.com/github/codeql-cli-binaries/releases/latest/download/codeql-linux64.zip
unzip codeql-linux64.zip
export PATH="$PWD/codeql:$PATH"
# Add to your shell profile for persistence
echo 'export PATH="/path/to/codeql:$PATH"' >> ~/.bashrcVerify installation:
codeql versionRequired for AI-powered features (triage, detailed analysis, fix generation).
- Sign up at https://console.anthropic.com/
- Generate an API key
- Configure the API key using one of these methods:
Option A: User config file (Recommended - most convenient)
Run patchsmith init and it will prompt you to save your API key:
patchsmith init --save-api-keyThis saves your key to ~/.patchsmith/config.yaml with secure permissions (600).
Option B: Environment variable (Good for CI/CD or temporary use)
export ANTHROPIC_API_KEY='your-api-key-here'Make it permanent by adding to your shell profile:
# For bash
echo 'export ANTHROPIC_API_KEY="your-key"' >> ~/.bashrc
source ~/.bashrc
# For zsh
echo 'export ANTHROPIC_API_KEY="your-key"' >> ~/.zshrc
source ~/.zshrcOption C: Manual user config file
Create ~/.patchsmith/config.yaml:
anthropic_api_key: 'your-api-key-here'Then set secure permissions:
chmod 600 ~/.patchsmith/config.yamlPriority: Environment variable > User config file
Git is required for fix application features (branching, commits).
Install:
- macOS:
brew install gitor comes pre-installed - Linux:
apt-get install gitoryum install git - Windows: Download from https://git-scm.com/
If you installed with Poetry:
# Use poetry run
poetry run patchsmith --help
# OR activate the virtual environment
poetry shell
patchsmith --helpIf you installed with pip:
# Check if it's in your PATH
which patchsmith
# If not found, your Python scripts directory may not be in PATH
# Add it to PATH (adjust path as needed):
export PATH="$HOME/.local/bin:$PATH"Make sure CodeQL is installed and in your PATH:
# Check installation
which codeql
codeql version
# If not found, add to PATH
export PATH="/path/to/codeql:$PATH"# Set the environment variable
export ANTHROPIC_API_KEY='your-key'
# Verify it's set
echo $ANTHROPIC_API_KEYIf you get import errors:
# Reinstall dependencies
poetry install --no-cache
# OR with pip
pip install --force-reinstall -e .# Install for current user only
pip install --user dist/patchsmith-0.1.0-py3-none-any.whlFor development with editable installation:
# Clone and install in editable mode
git clone https://github.com/yourusername/patchsmith.git
cd patchsmith
poetry install
# Now code changes take effect immediately
poetry run patchsmith --helppip uninstall patchsmith# Remove virtual environment
poetry env remove pythonAfter installation:
-
Verify everything works:
patchsmith --version patchsmith --help codeql version echo $ANTHROPIC_API_KEY
-
Initialize a project:
cd /path/to/your/project patchsmith init -
Run your first analysis:
patchsmith analyze
-
Read the documentation:
If you encounter issues:
- Check this troubleshooting section
- Review the CLI Guide
- Search GitHub Issues
- Open a new issue with:
- Your OS and Python version
- Complete error message
- Steps to reproduce