Overview
SWE-agent is an open-source coding agent from researchers at Princeton and Stanford. You give it a GitHub issue and the language model of your choice, such as Claude Sonnet 4 or GPT-4o, and it works through the problem on its own: it reads files, edits code, and runs tests inside a real repository until it produces a fix.
The project is built around a single YAML configuration file, which makes its behavior easy to read, change, and reproduce. It was designed for research, so it is meant to be simple and hackable. The same agent can also tackle general coding challenges or, in its EnIGMA mode, hunt for cybersecurity vulnerabilities.
The maintainers note that most active development has moved to mini-swe-agent, a much simpler successor that matches SWE-agent's performance. SWE-agent itself remains available and is state of the art on the SWE-bench benchmark among open-source projects.
What it does
- Takes a GitHub issue and tries to fix it automatically, editing and testing code in the real repository
- Works with the language model of your choice, including Claude Sonnet 4 and GPT-4o
- Governed by a single YAML file, so the agent's behavior is fully documented and reproducible
- State of the art on SWE-bench among open-source projects
- EnIGMA mode for offensive cybersecurity and capture-the-flag challenges
- Simple and hackable by design, built for research and easy customization
Getting started
Install SWE-agent from source, set the API key for your chosen model, then run it against a GitHub issue. You can also try it instantly in GitHub Codespaces from the repo.
Clone the repository
Download the source code from GitHub.
git clone https://github.com/SWE-agent/SWE-agent.gitInstall the package
From the repository root, upgrade pip and install SWE-agent in editable mode.
python -m pip install --upgrade pip && pip install --editable .Check the install
Confirm the command-line tool is available. If the command is not found, try python -m sweagent instead.
sweagent --helpRun it on a GitHub issue
Set your model's API key first (via an environment variable or a .env file), then point the agent at a repository and an issue. This example fixes a simple syntax error in the project's test repo.
sweagent run \
--agent.model.name=claude-sonnet-4-20250514 \
--agent.model.per_instance_cost_limit=2.00 \
--env.repo.github_url=https://github.com/SWE-agent/test-repo \
--problem_statement.github_url=https://github.com/SWE-agent/test-repo/issues/1Commands and code are distilled from the project's own documentation — always check the official repo for the latest.
When to use it
- Automatically fixing issues in a real GitHub repository by letting an LLM edit and test the code
- Solving general coding challenges or custom programming tasks with an autonomous agent
- Finding cybersecurity vulnerabilities and solving capture-the-flag challenges through EnIGMA mode
- Benchmarking and researching LLM coding agents, for example on SWE-bench
How SWE-agent compares
SWE-agent alongside other open-source autonomous coding agents tools AI/TLDR tracks, ranked by GitHub stars.
| Tool | Stars | What it does |
|---|---|---|
| opencode | ★ 208k | OpenCode is an open source AI coding agent that runs in your terminal, with built-in build and plan agents and an optional desktop app. |
| Claude Code | ★ 146k | Anthropic's agentic coding tool for the terminal, IDE and GitHub: it understands your codebase, executes routine tasks, explains code and handles git workflows from natural-language commands. |
| OpenAI Codex | ★ 125k | OpenAI's cloud and CLI coding agent that writes features, fixes bugs, and proposes code changes across a repo, running tasks in parallel. |
| Gemini CLI | ★ 107k | An open-source command-line AI agent from Google that connects your terminal to Gemini models for reading code, editing files, running shell commands, and searching the web. |
| Pi | ★ 107k | Minimal terminal coding agent harness with four built-in tools, extended through TypeScript extensions, skills and prompt templates instead of forks. |
| autoresearch | ★ 96.2k | Karpathy's minimal harness that hands a coding agent a single-GPU LLM training script and lets it run fixed five-minute experiments, keeping or discarding each change on its own. |
| OpenHands | ★ 88.4k | An open-source AI software-development agent that plans tasks, edits files, runs commands, and tests code, usable from a terminal CLI, a local web GUI, or a Python SDK. |
| SWE-agent | ★ 20.4k | Point a language model at a GitHub issue and let it fix the code on its own |
