Repatch is an autonomous engineering agent that takes a GitHub issue, reproduces the bug, authors a failing test, plans a surgical fix, applies it, verifies it in a sandbox, and opens a PR — all without human intervention.
It implements an Inviolable Loop: a 7-step state machine (UNDERSTAND → EXPLORE → REPRODUCE → PLAN → EXECUTE → VERIFY → SUBMIT) with built-in backtracking. If verification fails, it returns to PLAN and tries again — a surgical retry without repeating work.
Key differentiator: Every fix is grounded in a reproduction test authored before any code modification. No hallucinated patches. No unverified changes.
| Step | Purpose | Key Mechanism | Output |
|---|---|---|---|
| 1. UNDERSTAND | Parse issue, build context | Issue parsing + entry point identification | IssueContext |
| 2. EXPLORE | Find relevant files | LLM-guided tools + Map of Truth file tree | FileSet |
| 3. REPRODUCE | Author failing test | Empirical TDD — test written before any fix | TestCase |
| 4. PLAN | Design surgical fix | Minimal diff based on reproduction | FixPlan |
| 5. EXECUTE | Apply fix | Fuzzy surgical matching + path validation | Patch |
| 6. VERIFY | Run tests + lint | Sandbox execution, backtrack on failure | Verified |
| 7. SUBMIT | Open PR | Engineering narrative + diff + context | PR |
Backtracking: If VERIFY fails, the loop returns to PLAN (not the beginning) — surgical retries without repeating UNDERSTAND/EXPLORE.
Inference Layer — Strategy Pattern per step. Each step has its own LLM prompt and tool subset. Providers: OpenAI (GPT-4o, DeepSeek), Anthropic (Claude 3.5 Sonnet), Google Gemini (native API + CLI fallback), Mimo (Gitlawb OpenGateway). Temperature 0.1 for determinism.
Sandbox Layer — Isolated execution per run. Nixpacks auto-detects language (Node.js, Python, Go, Rust, Java, Ruby, PHP, and more). Docker provides OCI isolation. Local fallback works without Docker. Configurable: 4GB RAM, 2 CPUs, no network by default. Fresh container each run.
Tool Library — LLM-guided codebase operations: list_files, read_file, grep_search, edit_file, write_file, run_command, create_reproduction_test. All writes validated against path traversal.
# Linux / macOS
curl -fsSL https://raw.githubusercontent.com/Sagar-024/Repatch/main/install.sh | bash
# Windows (PowerShell)
irm https://raw.githubusercontent.com/Sagar-024/Repatch/main/install.ps1 | iexDownloads a pre-built standalone binary (~60 MB). No Node.js, Docker, or npm required.
# Homebrew (macOS)
brew tap Sagar-024/repatch
brew install repatch
# Scoop (Windows)
scoop bucket add repatch https://github.com/Sagar-024/scoop-repatch
scoop install repatchrepatch --help
repatch check # Validates environment: Docker, Git, API keys# From a natural language description
repatch fix https://github.com/owner/repo -i "Login form returns 500 on empty email"
# From a GitHub issue URL
repatch fix https://github.com/owner/repo -i "https://github.com/owner/repo/issues/42"
# With a hint to guide exploration
repatch fix https://github.com/owner/repo -i "Issue description" -h "Check the auth middleware"
# Local execution (skip Docker sandbox)
repatch fix https://github.com/owner/repo -i "Issue description" --localrepatch reproduce https://github.com/owner/repo -i "Issue description"repatch pr https://github.com/owner/repo/pull/123 # Analysis only
repatch pr https://github.com/owner/repo/pull/123 --fix # Analyze and fixrepatch explore . # Project summary
repatch explore . -q "How does auth work?" # Specific question
repatch explore . -i # Interactive REPLrepatch configuremodel: "gpt-4o" # Options: gpt-4o, claude-3-5-sonnet-latest, gemini-1.5-pro, mimo-v2.5-pro
openai:
apiKey: "sk-..."
baseUrl: "https://api.openai.com/v1"
anthropic:
apiKey: "sk-ant-..."
gemini:
apiKey: "AIzaSy..."
mimo:
apiKey: "ogw_..."
baseUrl: "https://opengateway.gitlawb.com/v1"
github:
token: "ghp_..."
sandbox:
memory: "4g"
cpus: 2
network: falseOPENAI_API_KEY, ANTHROPIC_API_KEY, GEMINI_API_KEY, MIMO_API_KEY, GH_TOKEN, AI_MODEL
| Language | Detection File(s) |
|---|---|
| Node.js | package.json |
| Python | requirements.txt, pyproject.toml, setup.py |
| Go | go.mod |
| Rust | Cargo.toml |
| Java | pom.xml, build.gradle |
| Ruby | Gemfile |
| PHP | composer.json |
Additional languages supported when Nixpacks is installed.
| Decision | Why It Matters |
|---|---|
| Strategy Pattern per step | Each step is a self-contained class with its own prompt and tool subset — testable, swappable, debuggable |
| Map of Truth | File tree generated upfront grounds the LLM, prevents path hallucinations |
| Fuzzy Surgical Matching | Normalized sliding window search finds intended edit location even when LLM snippet doesn't exactly match |
| Path Traversal Protection | All write operations validated to stay within repo directory |
| Empirical TDD | Reproduction test authored before any fix — proves bug exists, verifies fix works |
| Backtracking (VERIFY → PLAN) | Surgical retry on verification failure without repeating UNDERSTAND/EXPLORE |
These are honest constraints, not marketing omissions.
- Gemini CLI tool parsing — Multi-strategy parsing (code blocks → full JSON → regex) but may struggle with deeply nested tool arguments
- Per-run sandbox — No shared container pool or caching between runs
- Language detection — Fallback heuristics cover 8 languages; Nixpacks (when installed) handles more
- No plugin system — Custom steps/tools require modifying source code
- No event bus — Limited observability hooks for external monitoring
git clone https://github.com/Sagar-024/Repatch.git
cd Repatch
npm install
npm run build
npm test # Run all tests
npm run test:watch # Watch mode
npm run test:coverage # Coverage reportPrerequisites: Node.js 20+, Docker Desktop (optional), Git
Active development. The core loop (UNDERSTAND → EXPLORE → REPRODUCE → PLAN → EXECUTE → VERIFY → SUBMIT) works end-to-end. Iterating on reliability, language support, and edge-case hardening.
Built by Sagar Kharal — AI Agentic Software Engineer · Full-Stack.
MIT — see LICENSE for details.