ScriptsMar 28, 2026·2 min read

Sweep — Turn GitHub Issues into Pull Requests

AI agent that turns GitHub issues into pull requests automatically. Handles bug fixes and small features with context-aware code generation.

TL;DR
Sweep reads your GitHub issues, generates code changes, and opens pull requests automatically for bug fixes and small features.
§01

What it is

Sweep is an AI-powered GitHub bot that reads issue descriptions and generates pull requests with the corresponding code changes. You write an issue describing a bug or a small feature, tag Sweep, and it analyzes your codebase, generates a fix, and opens a PR for review.

The project originally ran as a hosted service. The Sweep team has since pivoted to building a JetBrains AI coding assistant plugin, but the codebase remains available as an open-source reference for building AI code generation agents.

§02

How it saves time or tokens

For routine bug fixes and small feature additions, the cycle of reading code, writing a fix, and opening a PR can take 30 minutes or more. Sweep reduces this to the time it takes to write an issue description. The estimated token cost is approximately 496 tokens per workflow.

Sweep also demonstrates a pattern for AI agent design: it scans the full repository for context, plans changes across multiple files, and handles the git workflow (branch, commit, PR) automatically.

§03

How to use

  1. The hosted Sweep bot is no longer actively maintained. To use Sweep, run it locally or study the codebase:
git clone https://github.com/sweepai/sweep.git
cd sweep
pip install -r requirements.txt
  1. Configure your GitHub token and OpenAI API key in the environment.
  1. Run the agent against a repository:
export GITHUB_TOKEN=ghp_...
export OPENAI_API_KEY=sk-...
python -m sweepai.app
§04

Example

# GitHub Issue (tagged for Sweep)

Title: Fix broken pagination on /api/users endpoint

Body:
The /api/users endpoint returns all users instead of
respecting the `page` and `limit` query parameters.
The SQL query in `src/routes/users.ts` is missing
OFFSET and LIMIT clauses.

# Sweep generates a PR:
# - Modifies src/routes/users.ts to add OFFSET/LIMIT
# - Updates the test file to cover pagination
# - Opens PR with description explaining the changes
§05

Related on TokRepo

§06

Common pitfalls

  • The hosted Sweep bot is no longer actively maintained. Expect to run and modify the codebase yourself if you want to use it.
  • Sweep works best for small, well-described issues. Complex multi-file refactors or architectural changes are beyond its current capability.
  • Generated PRs still need human review. Sweep can introduce subtle bugs, especially in code with complex business logic or edge cases.

Frequently Asked Questions

Is Sweep still actively maintained?+

The Sweep team has pivoted to building a JetBrains AI plugin. The original GitHub bot codebase is archived but still available. It serves as a reference implementation for building AI code agents.

Can I self-host Sweep?+

Yes. The codebase is open-source and can be run locally with your own GitHub token and OpenAI API key. However, you may need to update dependencies and adapt the code since it is no longer actively maintained.

What size of changes can Sweep handle?+

Sweep is designed for small to medium changes: bug fixes, adding a new endpoint, updating configuration. It works across multiple files but struggles with large refactors or changes that require deep architectural understanding.

What LLMs does Sweep use?+

Sweep uses OpenAI's GPT models for code generation. The codebase can be adapted to use other LLM providers that support the OpenAI API format.

How does Sweep understand my codebase?+

Sweep indexes your repository, builds a map of files and their relationships, and uses this context when generating code. It reads relevant files based on the issue description to understand the code that needs to change.

Citations (3)
🙏

Source & Thanks

sweep — ⭐ 7,600+ JetBrains AI Plugin

Thanks to the Sweep team for pioneering the issue-to-PR workflow. The concept influenced many subsequent AI coding tools.

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets