GitHub Issue Resolver
Autonomous agent for discovering, analyzing, and fixing open GitHub issues — with a 5-layer guardrail system.
⚠️ GUARDRAILS — Read First
Every action goes through guardrails. Before any operation:
- Load
guardrails.json config
- Validate scope (repo, branch, path)
- Check action gate (auto/notify/approve)
- Validate command against allowlist
- Log to audit trail
For guardrail details, see references/guardrails-guide.md.
Key Rules (Non-Negotiable)
- Never touch protected branches (main, master, production)
- Never modify .env, secrets, CI configs, credentials
- Never force push
- Never modify dependency files without explicit approval
- Never modify own skill/plugin files
- One issue at a time — finish or abandon before starting new
- All dangerous actions require user approval (write code, commit, push, PR)
- Everything is logged to
audit/ directory
Workflow
Phase 1 — Issue Discovery
Trigger: User provides a GitHub repository (owner/repo).
Steps:
Validate repo against guardrails:
python3 scripts/guardrails.py repo <owner> <repo>
If blocked, tell the user and stop.
Fetch, score, and present issues using the recommendation engine:
python3 scripts/recommend.py <owner> <repo>
This automatically fetches open issues, filters out PRs, scores them by severity/impact/effort/freshness, and presents a formatted recommendation.
Always use recommend.py — never manually format issue output. The script ensures consistent presentation every time.
For raw JSON (e.g., for further processing):
python3 scripts/recommend.py <owner> <repo> --json
⏹️ STOP. Wait for user to select an issue.
Phase 2 — Fixing
Trigger: User selects an issue.
Steps:
Lock the issue (one-at-a-time enforcement):
python3 scripts/guardrails.py issue_lock <owner> <repo> <issue_number>
Read full issue thread including comments.
Clone the repo (Gate: notify):
python3 scripts/sandbox.py run git clone https://github.com/<owner>/<repo>.git /tmp/openclaw-work/<repo>
Create a safe branch (Gate: auto):
python3 scripts/sandbox.py run git checkout -b fix-issue-<number>
Explore codebase — read relevant files. For each file:
python3 scripts/guardrails.py path <file_path>
Plan the fix — explain approach to user:
## Proposed Fix
- Problem: [root cause]
- Solution: [what changes]
- Files: [list of files and what changes in each]
- Estimated diff size: [lines]
⏹️ STOP. Wait for user to approve the plan before implementing.
- Implement the fix (Gate:
approve):
- Apply changes
- Check diff size:
python3 scripts/guardrails.py diff <line_count>
- Log:
python3 scripts/audit.py log_action write_code success
Phase 3 — Testing
After implementing:
Find and run tests (Gate: notify):
python3 scripts/sandbox.py run npm test # or pytest, cargo test, etc.
If tests fail AND autoRollbackOnTestFail is true:
- Revert all changes
- Notify user
- Suggest alternative approach
If no tests exist, write basic tests covering the fix.
Report results to user.
Phase 4 — Draft PR for Review (Approval REQUIRED)
⚠️ NEVER create PR automatically. Always ask first.
Do NOT dump full diffs in chat. For any non-trivial project, push the branch
and let the user review on GitHub where they get syntax highlighting, file-by-file
navigation, and inline comments.
Commit changes (Gate: approve):
python3 scripts/sandbox.py run git add .
python3 scripts/sandbox.py run git commit -m "Fix #<number>: <title>"
Show a change summary (NOT the raw diff) — keep it concise:
## Changes
- **src/models.py** — Added field validation (title length, enum checks)
- **app.py** — Added validation to POST endpoint, 400 error responses
- **tests/test_app.py** — 22 new tests covering validation rules
- 4 files changed, ~100 lines of source + ~150 lines of tests
- All tests passing ✅
Ask explicitly: "Ready to push and create a draft PR?"
Only after user says "yes" (Gate: approve):
python3 scripts/sandbox.py run git push -u origin fix-issue-<number>
python3 scripts/sandbox.py run gh pr create --draft --title "..." --body "..."
Note: PRs are always created as draft by default.
The PR body should include a detailed description of all changes, test results,
and link to the issue (Closes #N).
Share the PR link — user reviews on GitHub.
Unlock the issue:
python3 scripts/guardrails.py issue_unlock
Scripts Reference
| Script |
Purpose |
Run Without Reading |
scripts/recommend.py |
Primary entry point — fetch, score, and present issues |
✅ |
scripts/fetch_issues.py |
Raw issue fetcher (used internally by recommend.py) |
✅ |
scripts/analyze_issue.py |
Deep analysis of single issue |
✅ |
scripts/create_pr.py |
PR creation wrapper |
✅ |
scripts/guardrails.py |
Guardrail enforcement engine |
✅ |
scripts/sandbox.py |
Safe command execution wrapper |
✅ |
scripts/audit.py |
Action logger |
✅ |
References
- references/quick-reference.md — GitHub API reference, scoring rubric, test commands
- references/guardrails-guide.md — Full guardrails documentation and customization
1---2name: github-issue-resolver3description: Autonomous GitHub Issue Resolver Agent with guardrails. Use when the user wants to discover, analyze, and fix open issues in GitHub repositories. Triggers on requests like "fix GitHub issues", "resolve issues in repo", "work on GitHub bugs", or when the user provides a GitHub repository URL and asks for issue resolution. Supports the full workflow from issue discovery to PR submission with safety guardrails preventing scope creep, unauthorized access, and dangerous operations.4---5
6# GitHub Issue Resolver
7
8Autonomous agent for discovering, analyzing, and fixing open GitHub issues — with a 5-layer guardrail system.
9
10## ⚠️ GUARDRAILS — Read First
11
12**Every action goes through guardrails.** Before any operation:
13
141. Load `guardrails.json` config
152. Validate scope (repo, branch, path)
163. Check action gate (auto/notify/approve)
174. Validate command against allowlist
185. Log to audit trail
19
20For guardrail details, see [references/guardrails-guide.md](references/guardrails-guide.md).
21
22### Key Rules (Non-Negotiable)
23- **Never touch protected branches** (main, master, production)
24- **Never modify** .env, secrets, CI configs, credentials
25- **Never force push**
26- **Never modify dependency files** without explicit approval
27- **Never modify own skill/plugin files**
28- **One issue at a time** — finish or abandon before starting new
29- **All dangerous actions require user approval** (write code, commit, push, PR)
30- **Everything is logged** to `audit/` directory
31
32---
33
34## Workflow
35
36### Phase 1 — Issue Discovery
37
38**Trigger:** User provides a GitHub repository (`owner/repo`).
39
40**Steps:**
41
421. **Validate repo** against guardrails:
43 ```bash
44 python3 scripts/guardrails.py repo <owner> <repo>
45 ```
46 If blocked, tell the user and stop.
47
482. **Fetch, score, and present issues** using the recommendation engine:
49 ```bash
50 python3 scripts/recommend.py <owner> <repo>
51 ```
52 This automatically fetches open issues, filters out PRs, scores them by severity/impact/effort/freshness, and presents a formatted recommendation.
53
54 **Always use `recommend.py`** — never manually format issue output. The script ensures consistent presentation every time.
55
56 For raw JSON (e.g., for further processing):
57 ```bash
58 python3 scripts/recommend.py <owner> <repo> --json
59 ```
60
61**⏹️ STOP. Wait for user to select an issue.**
62
63---
64
65### Phase 2 — Fixing
66
67**Trigger:** User selects an issue.
68
69**Steps:**
70
711. **Lock the issue** (one-at-a-time enforcement):
72 ```bash
73 python3 scripts/guardrails.py issue_lock <owner> <repo> <issue_number>
74 ```
75
762. **Read full issue thread** including comments.
77
783. **Clone the repo** (Gate: `notify`):
79 ```bash
80 python3 scripts/sandbox.py run git clone https://github.com/<owner>/<repo>.git /tmp/openclaw-work/<repo>
81 ```
82
834. **Create a safe branch** (Gate: `auto`):
84 ```bash
85 python3 scripts/sandbox.py run git checkout -b fix-issue-<number>
86 ```
87
885. **Explore codebase** — read relevant files. For each file:
89 ```bash
90 python3 scripts/guardrails.py path <file_path>
91 ```
92
936. **Plan the fix** — explain approach to user:
94 ```
95 ## Proposed Fix
96 - Problem: [root cause]
97 - Solution: [what changes]
98 - Files: [list of files and what changes in each]
99 - Estimated diff size: [lines]
100 ```
101
102**⏹️ STOP. Wait for user to approve the plan before implementing.**
103
1047. **Implement the fix** (Gate: `approve`):
105 - Apply changes
106 - Check diff size: `python3 scripts/guardrails.py diff <line_count>`
107 - Log: `python3 scripts/audit.py log_action write_code success`
108
109---
110
111### Phase 3 — Testing
112
113**After implementing:**
114
1151. **Find and run tests** (Gate: `notify`):
116 ```bash
117 python3 scripts/sandbox.py run npm test # or pytest, cargo test, etc.
118 ```
119
1202. **If tests fail AND `autoRollbackOnTestFail` is true:**
121 - Revert all changes
122 - Notify user
123 - Suggest alternative approach
124
1253. **If no tests exist**, write basic tests covering the fix.
126
1274. **Report results** to user.
128
129---
130
131### Phase 4 — Draft PR for Review (Approval REQUIRED)
132
133**⚠️ NEVER create PR automatically. Always ask first.**
134
135**Do NOT dump full diffs in chat.** For any non-trivial project, push the branch
136and let the user review on GitHub where they get syntax highlighting, file-by-file
137navigation, and inline comments.
138
1391. **Commit changes** (Gate: `approve`):
140 ```bash
141 python3 scripts/sandbox.py run git add .
142 python3 scripts/sandbox.py run git commit -m "Fix #<number>: <title>"
143 ```
144
1452. **Show a change summary** (NOT the raw diff) — keep it concise:
146 ```
147 ## Changes
148 - **src/models.py** — Added field validation (title length, enum checks)
149 - **app.py** — Added validation to POST endpoint, 400 error responses
150 - **tests/test_app.py** — 22 new tests covering validation rules
151 - 4 files changed, ~100 lines of source + ~150 lines of tests
152 - All tests passing ✅
153 ```
154
1553. **Ask explicitly:** "Ready to push and create a draft PR?"
156
1574. **Only after user says "yes"** (Gate: `approve`):
158 ```bash
159 python3 scripts/sandbox.py run git push -u origin fix-issue-<number>
160 python3 scripts/sandbox.py run gh pr create --draft --title "..." --body "..."
161 ```
162 Note: PRs are always created as **draft** by default.
163 The PR body should include a detailed description of all changes, test results,
164 and link to the issue (Closes #N).
165
1665. **Share the PR link** — user reviews on GitHub.
167
1686. **Unlock the issue:**
169 ```bash
170 python3 scripts/guardrails.py issue_unlock
171 ```
172
173---
174
175## Scripts Reference
176
177| Script | Purpose | Run Without Reading |
178|--------|---------|---------------------|
179| `scripts/recommend.py` | **Primary entry point** — fetch, score, and present issues | ✅ |
180| `scripts/fetch_issues.py` | Raw issue fetcher (used internally by recommend.py) | ✅ |
181| `scripts/analyze_issue.py` | Deep analysis of single issue | ✅ |
182| `scripts/create_pr.py` | PR creation wrapper | ✅ |
183| `scripts/guardrails.py` | Guardrail enforcement engine | ✅ |
184| `scripts/sandbox.py` | Safe command execution wrapper | ✅ |
185| `scripts/audit.py` | Action logger | ✅ |
186
187## References
188
189- [references/quick-reference.md](references/quick-reference.md) — GitHub API reference, scoring rubric, test commands
190- [references/guardrails-guide.md](references/guardrails-guide.md) — Full guardrails documentation and customization