# SWE-agent — Automated Bug Fixing with AI Agents > AI agent system from Princeton NLP that autonomously fixes GitHub issues. Navigates codebases, writes patches, and submits pull requests. Resolves 12% of real-world SWE-bench tasks. 15,000+ stars. ## Install Save as a script file and run: ## Quick Use ```bash pip install swe-agent ``` ```bash # Fix a GitHub issue automatically swe-agent run \ --model claude-sonnet-4-20250514 \ --issue https://github.com/user/repo/issues/123 ``` SWE-agent clones the repo, analyzes the issue, navigates the codebase, writes a fix, and creates a patch. --- ## Intro SWE-agent is an AI agent system from Princeton NLP that autonomously resolves real-world GitHub issues with 15,000+ GitHub stars. Give it an issue URL and it clones the repository, navigates the codebase, identifies the bug, writes a patch, and validates the fix — achieving 12.5% on the SWE-bench benchmark of real-world software engineering tasks. It uses a custom Agent-Computer Interface (ACI) designed specifically for code navigation and editing. Best for researchers studying AI coding capabilities and teams experimenting with automated bug fixing. Works with: Claude, GPT-4. Setup time: under 5 minutes. --- ## How It Works ### 1. Issue Analysis SWE-agent reads the GitHub issue and understands: - What is broken - Expected vs actual behavior - Relevant error messages and stack traces ### 2. Codebase Navigation Using its Agent-Computer Interface (ACI): ```bash # The agent navigates like a developer find_file "auth_handler.py" open_file "src/auth/auth_handler.py" search_file "validate_token" goto_line 145 ``` ### 3. Bug Identification The agent reads relevant code, traces the logic, and pinpoints the issue: ``` Analyzing: src/auth/auth_handler.py:145 Issue: Token expiry check uses UTC timestamp but comparison uses local time Fix: Convert both to UTC before comparison ``` ### 4. Patch Generation Writes and applies the fix: ```python # Before if token.expiry < datetime.now(): # After (SWE-agent fix) if token.expiry < datetime.now(timezone.utc): ``` ### 5. Validation Runs existing tests to verify the fix: ```bash Running test suite... test_auth_valid_token: PASS test_auth_expired_token: PASS (was FAIL) test_auth_refresh: PASS All tests passing. ``` ### Agent-Computer Interface (ACI) Custom commands designed for code navigation: | Command | Action | |---------|--------| | `find_file` | Search for files by name | | `open_file` | Open and display file content | | `search_file` | Search within current file | | `search_dir` | Search across directory | | `goto_line` | Jump to specific line | | `edit` | Edit lines in current file | | `submit` | Submit the patch | ### SWE-bench Results | Model | Resolve Rate | |-------|-------------| | Claude Sonnet | 12.5% | | GPT-4 | 10.3% | | GPT-3.5 | 3.8% | ### Key Stats - 15,000+ GitHub stars - Princeton NLP research - 12.5% SWE-bench resolve rate - Custom Agent-Computer Interface - Supports Claude and GPT-4 ### FAQ **Q: What is SWE-agent?** A: SWE-agent is an AI system from Princeton NLP that autonomously fixes real-world GitHub issues by navigating codebases, writing patches, and validating fixes. **Q: Is SWE-agent free?** A: Yes, open-source under MIT license. You need LLM API keys. **Q: Can SWE-agent fix any bug?** A: It resolves about 12.5% of real-world software engineering tasks. It works best on well-specified bugs with clear reproduction steps. --- ## Source & Thanks > Created by [Princeton NLP](https://github.com/princeton-nlp). Licensed under MIT. > > [SWE-agent](https://github.com/princeton-nlp/SWE-agent) — ⭐ 15,000+ Thanks to Princeton NLP for advancing the frontier of automated software engineering. --- ## 快速使用 ```bash pip install swe-agent swe-agent run --model claude-sonnet-4-20250514 --issue https://github.com/user/repo/issues/123 ``` --- ## 简介 SWE-agent 是 Princeton NLP 开发的 AI Agent 系统,GitHub 15,000+ stars。自动克隆仓库、分析 issue、导航代码、编写补丁并验证修复。在 SWE-bench 真实软件工程任务基准上达到 12.5% 的解决率。适合研究 AI 编码能力和尝试自动化 bug 修复的团队。 --- ## 来源与感谢 > Created by [Princeton NLP](https://github.com/princeton-nlp). Licensed under MIT. > > [SWE-agent](https://github.com/princeton-nlp/SWE-agent) — ⭐ 15,000+ --- Source: https://tokrepo.com/en/workflows/ec5f0e4b-ca6b-4379-8ec2-0e0ef63b9fa5 Author: Agent Toolkit