SWE-agent: GitHub Issue Resolution Cheatsheet

MD
R
Markdown

A concise guide for AI programmers to configure and utilize SWE-agent to autonomously address and resolve issues documented on GitHub. https://swe-agent.com/1.0/usage/cl_tutorial/ Parameters: --agent.model.name: Specifies the AI model (e.g., claude-3-7-sonnet-latest). --agent.model.per_instance_cost_limit: Sets the maximum cost for processing a single instance. --env.repo.github_url: The URL of the repository SWE-agent will work on. --problem_statement.github_url: The URL of the specific GitHub issue to address.

1. Define the Task: Open/Identify a GitHub Issue

Ensure the GitHub issue is well-described, detailing the problem and ideally suggesting a fix.

Example Issue: Title: Add support for dark mode #5

Problem: The next.js app styled by tailwindcss.css is prepared for white mode only.

Fix: Add an icon on the top bar to support dark mode (e.g., a sun icon). The tailwindcss.css tags across the app must be updated to support both dark and white modes.

2. Setup SWE-agent

Clone the Repository:

git clone https://github.com/SWE-agent/SWE-agent.git
cd SWE-agent

Install Dependencies:

python -m pip install --upgrade pip
pip install --editable .
touch .env

Populate .env with your API keys:

ANTHROPIC_API_KEY='sk-ant-api...'
GITHUB_TOKEN='github_pat_...'

Run SWE-agent:

sweagent --help
export SSL_CERT_FILE="/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/certifi/cacert.pem"

sweagent run
--agent.model.name=claude-3-7-sonnet-latest
--agent.model.per_instance_cost_limit=2.00
--env.repo.github_url=https://github.com/claudiotx/claudioteixeira
--problem_statement.github_url=https://github.com/claudiotx/claudioteixeira/issues/5

Monitor and Debug:

cat web_api.log

Apply the swe-agent generated patch.

cd /path/to/your/local/claudiotx/claudioteixeira
git checkout main # Or your primary branch
git pull origin main
git status # Ensure there are no uncommitted changes
git checkout -b fix/issue-5 # Or a descriptive branch name

git apply /Users/ctxm1pro/dev/SWE-agent/trajectories/ctxm1pro/anthropic_filemap__claude-3-7-sonnet-latest__t-0.00__p-1.00__c-2.00___claudiotx__claudioteixeira-i5/claudiotx__claudioteixeira-i5/claudiotx__claudioteixeira-i5.patch

git add .
git commit -m "Fix: Apply patch for issue #5 - Add dark mode support" # Or a more descriptive commit message
git push origin fix/issue-5 # Push your new branch to the remote repository

3. Review and Test the Changes

Review the generated patch file contents before applying After applying the patch, test the changes locally: Start your development server Verify dark mode functionality works as expected Check for any visual regressions Test the mode toggle interaction

4. Complete the Pull Request

Add a descriptive PR title referencing the issue (#5) Include in the PR description: What was changed How to test the changes Screenshots (before/after) Closes #5 (to auto-close the issue when merged) Request code review from team members Address any feedback or comments Once approved, merge the PR Delete the feature branch after merging Go to your repository on GitHub (e.g., https://github.com/claudiotx/claudioteixeira). GitHub will usually detect the newly pushed branch and show a prompt to "Compare & pull request". Click this button.

Created on 5/19/2025