open-swe
Build asynchronous coding agents using LangChain's Open SWE framework — agents that plan, code, test, and iterate on software engineering tasks. Use when: building coding bots, automating issue resolution, creating SWE agents that work on repos asynchronously.
What this skill does
# Open SWE
## Overview
Open SWE (by LangChain) is an open-source framework for building asynchronous software engineering agents that can autonomously plan, code, test, and submit pull requests. Unlike synchronous coding assistants, Open SWE agents work in the background — pick up a GitHub issue, work on it for minutes to hours, and deliver a ready-to-review PR.
```
GitHub Issue (labeled "ai-fix")
↓ webhook
Open SWE Agent
├── Planner: analyze issue, explore codebase, create plan
├── Coder: implement changes following plan
├── Tester: run tests, fix failures
└── Reviewer: self-review before PR
↓
Pull Request with description + test results
```
## Instructions
When a user asks to build an async coding agent, automate issue resolution, or create SWE bots:
1. **Install Open SWE** — `pip install open-swe langgraph langchain-anthropic`
2. **Configure the agent** — Instantiate `SWEAgent` with an LLM, repo path, and tools
3. **Connect to GitHub** — Use `GitHubIntegration` to listen for labeled issues
4. **Decompose complex tasks** — Use `TaskPlanner` for multi-step issues
5. **Enable test loops** — Set `run_tests=True` so the agent iterates until tests pass
### Basic Agent Setup
```python
from open_swe import SWEAgent
from langchain_anthropic import ChatAnthropic
llm = ChatAnthropic(model="claude-sonnet-4-20250514")
agent = SWEAgent(llm=llm, repo_path="/path/to/repo", tools=["bash", "file_editor", "search"])
result = await agent.solve(
issue="Fix the login timeout bug - sessions expire after 5 minutes instead of 30",
)
print(result.patch) # unified diff
print(result.explanation) # what was changed and why
```
### GitHub Integration
```python
from open_swe.integrations import GitHubIntegration
github = GitHubIntegration(token=os.environ["GITHUB_TOKEN"], repo="owner/repo")
@github.on_issue(labels=["ai-fix"])
async def handle_issue(issue):
agent = SWEAgent(llm=llm, repo_path=github.clone())
result = await agent.solve(issue=issue.body)
if result.success:
pr = await github.create_pr(
title=f"Fix: {issue.title}",
body=f"Resolves #{issue.number}\n\n{result.explanation}",
branch=f"ai-fix/{issue.number}",
patch=result.patch,
)
await issue.comment(f"PR created: {pr.url}")
else:
await issue.comment(f"Could not resolve automatically:\n{result.error}")
```
## Examples
### Example 1: Decompose a Complex Feature into Subtasks
```python
from open_swe.planner import TaskPlanner
planner = TaskPlanner(llm=llm)
tasks = await planner.decompose(
issue="Add user avatar upload with S3 storage and image resizing",
codebase_context=agent.explore_codebase(),
)
# Returns: [
# "Add S3 upload utility in lib/storage.ts",
# "Create avatar resize middleware using sharp",
# "Add PUT /api/users/:id/avatar endpoint",
# "Write tests for upload and resize",
# "Update user profile component to show avatar",
# ]
for task in tasks:
result = await agent.solve(issue=task)
agent.apply_patch(result.patch)
```
### Example 2: Process Multiple Issues in Parallel with Test Loops
```python
import asyncio
from open_swe import SWEAgent
async def process_issues(issues: list[str]):
tasks = []
for issue in issues:
agent = SWEAgent(llm=llm, repo_path=clone_repo())
tasks.append(agent.solve(issue=issue, max_iterations=5, run_tests=True, test_command="pytest"))
return await asyncio.gather(*tasks)
results = asyncio.run(process_issues([
"Fix SQL injection in search endpoint",
"Add rate limiting to API",
"Update deprecated dependencies",
"Add input validation to signup form",
"Fix timezone bug in event scheduler",
]))
for r in results:
for i, attempt in enumerate(r.iterations):
print(f"Attempt {i+1}: {'PASS' if attempt.tests_passed else 'FAIL'}")
```
## Guidelines
- **Explore first** — The agent should read relevant files before coding
- **Plan before code** — Create an implementation plan, get approval for large changes
- **Test after change** — Run tests after every modification to catch regressions early
- **Self-review** — Check own code for issues before submitting a PR
- **Incremental** — Apply changes file by file, testing between each step
Related in AI Agents
skill-development
IncludedComprehensive meta-skill for creating, managing, validating, auditing, and distributing Claude Code skills and slash commands (unified in v2.1.3+). Provides skill templates, creation workflows, validation patterns, audit checklists, naming conventions, YAML frontmatter guidance, progressive disclosure examples, and best practices lookup. Use when creating new skills, validating existing skills, auditing skill quality, understanding skill architecture, needing skill templates, learning about YAML frontmatter requirements, progressive disclosure patterns, tool restrictions (allowed-tools), skill composition, skill naming conventions, troubleshooting skill activation issues, creating custom slash commands, configuring command frontmatter, using command arguments ($ARGUMENTS, $1, $2), bash execution in commands, file references in commands, command namespacing, plugin commands, MCP slash commands, Skill tool configuration, or deciding between skills vs slash commands. Delegates to docs-management skill for official documentation.
reprompter
IncludedTransform messy prompts into well-structured, effective prompts — single or multi-agent. Use when: "reprompt", "reprompt this", "clean up this prompt", "structure my prompt", rough text needing XML tags and best practices, "reprompter teams", "repromptception", "run with quality", "smart run", "smart agents", multi-agent tasks, audits, parallel work, anything going to agent teams. Don't use when: simple Q&A, pure chat, immediate execution-only tasks. See "Don't Use When" section for details. Outputs: Structured XML/Markdown prompt, quality score (before/after), optional team brief + per-agent sub-prompts, agent team output files. Success criteria: Single mode quality score ≥ 7/10; Repromptception per-agent prompt quality score 8+/10; all required sections present, actionable and specific.
adaptive-compaction
IncludedAdaptive add-on policy and recovery layer that decides WHEN to compact, prune, snapshot, or fork -- replacing fixed-percent auto-compaction across Claude Code, Codex, and MCP-capable hosts. Trigger on auto-compact timing or damage: "when should I compact", "is it safe to compact now or start a fresh session", "auto-compact fires too early/mid-task", "switching to an unrelated task but the window still has space", "context rot", "answers get worse the longer the session runs", "the agent forgot the plan or my decisions after it summarized", "add a layer on top that manages context without changing the agent", raising autoCompactWindow to give the policy room, or installing/tuning a cross-tool compaction policy or PreCompact hook -- even when "compaction" is never said but the problem is context-window pressure or post-summarization memory loss. Do NOT use to summarize a conversation, build RAG, write a summarization prompt (decides WHEN not HOW), or answer max-context-length trivia.
agent-skill-creator
IncludedCreate cross-platform agent skills from workflow descriptions. Activates when users ask to create an agent, automate a repetitive workflow, create a custom skill, or need advanced agent creation. Triggers on phrases like create agent for, automate workflow, create skill for, every day I have to, daily I need to, turn process into agent, need to automate, create a cross-platform skill, validate this skill, export this skill, migrate this skill. Supports single skills, multi-agent suites, transcript processing, template-based creation, interactive configuration, cross-platform export, and spec validation.
llm-wiki
IncludedUse when building or maintaining a persistent personal knowledge base (second brain) in Obsidian where an LLM incrementally ingests sources, updates entity/concept pages, maintains cross-references, and keeps a synthesis current. Triggers include "second brain", "Obsidian wiki", "personal knowledge management", "ingest this paper/article/book", "build a research wiki", "compound knowledge", "Memex", or whenever the user wants knowledge to accumulate across sessions instead of being re-derived by RAG on every query.
skill-master
IncludedAgent Skills authoring, evaluation, and optimization. Create, edit, validate, benchmark, and improve skills following the agentskills.io specification. Use when designing SKILL.md files, structuring skill folders (references, scripts, assets), ingesting external documentation into skills, running trigger evals, benchmarking skill quality, optimizing descriptions, or performing blind A/B comparisons. Keywords: agentskills.io, SKILL.md, skill authoring, eval, benchmark, trigger optimization.