# SWE-agent

> Point a language model at a GitHub issue and let it fix the code on its own

- Category: AI Coding / Autonomous Coding Agents
- Language: Python
- Licence: MIT
- Repository: https://github.com/SWE-agent/SWE-agent
- Website: https://swe-agent.com
- Canonical page: https://ai-tldr.dev/tools/swe-agent/

## In short

SWE-agent is an open-source coding agent from researchers at Princeton and Stanford. It sits in the Autonomous Coding Agents category of the AI Coding tools and is open-source, written in Python and licensed MIT. To get started: clone the repository.

## 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.

1. Clone the repository

   Download the source code from GitHub.

```bash
git clone https://github.com/SWE-agent/SWE-agent.git
```

2. Install the package

   From the repository root, upgrade pip and install SWE-agent in editable mode.

```bash
python -m pip install --upgrade pip && pip install --editable .
```

3. Check the install

   Confirm the command-line tool is available. If the command is not found, try python -m sweagent instead.

```bash
sweagent --help
```

4. Run 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.

```bash
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/1
```

## 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
