Resolve Issue
Take an issue from labeled to "draft PR opened." Load repo-setup
first to prepare /workspace/repo on a feature branch.
Default to shipping a draft PR. A best-effort first cut is more
valuable than a "too big" comment. Other agents will review it, fix CI,
and respond to feedback.
Workflow
Phase 1: Context Gathering
Read the issue. Lean toward the smallest interpretation.
Check for existing PRs that reference this issue:
gh api "repos/<owner>/<repo>/issues/<number>/timeline" --paginate \
--jq '[.[] | select(.event=="cross-referenced" and .source.issue.pull_request != null) | {number: .source.issue.number, state: .source.issue.state, title: .source.issue.title, url: .source.issue.html_url}]'
Also search PR titles and bodies for the issue number:
gh pr list --search "<number>" --repo <owner>/<repo> --json number,title,state,headRefName,url
- Open PR exists → check it out (
gh pr checkout <number>),
review what's done, and continue from there instead of starting
fresh. Load review skill to assess quality first.
- Draft/stale PR exists → same as above. Rebase onto the
default branch if needed (see conflict resolution below).
- Only closed/merged PRs → the issue may already be resolved.
Verify before starting new work.
- No linked PRs → proceed with fresh implementation.
Understand repo conventions. Delegate this survey to the
explore subagent (read-only, cheaper model) and use its brief; ask
it to report:
CONTRIBUTING.md, AGENTS.md, DEVELOPMENT.md, or similar docs
- Recent commit history:
git log --oneline -20 (commit style)
- Linter config:
biome.json, .eslintrc*, .prettierrc*,
ruff.toml, pyproject.toml [tool.ruff], .golangci.yml, etc.
- Test framework config:
jest.config*, vitest.config*,
pytest.ini, pyproject.toml [tool.pytest], go.mod, etc.
- CI workflow files:
.github/workflows/*.yml — note the test
command and count the number of check/job names
- Existing utility functions relevant to the issue
Note for later: coding conventions, test command, lint command,
PR template path (if any), and CI check count.
Phase 2: Bug Verification
Classify the issue: bug report or feature request.
- Feature request → skip to step 6 (planning).
- Bug report → continue to verification.
Verify the bug exists. You may delegate the code-path reading
to explore (e.g. "find and summarize the code paths involved in
"), but make the root-cause judgment yourself:
a. Read the relevant code paths identified in the issue body.
b. Cross-check against the default branch HEAD — is the described
behavior actually present in the current code?
c. Try to write a minimal reproduction: a test case, a script, or
a specific input that triggers the bug.
d. If reproducible: report the root cause ("This breaks because
X, in Y path, after Z condition.").
e. If not reproducible: report what was tried and why it failed.
Local Sentry telemetry: For a reproducible web application, browser
client, HTTP server, or local-agent bug, check whether the repository already
has compatible Sentry initialization and a runnable local command. If it
does, create an isolated local telemetry configuration that prevents the
launched app from using its normal DSN (including client-side DSN injection),
then inspect sentry local --help and run sentry local serve with bounded
output. Configure the app to send only to the local endpoint (normally via
SENTRY_SPOTLIGHT when supported), and reproduce the smallest failing flow.
Use the correlated trace ID, spans, logs, and errors as root-cause evidence.
Do not add or reconfigure Sentry solely for this check, print credentials, or
send local telemetry remotely. If the app cannot run, its SDK is incompatible,
remote ingestion cannot be prevented, or the bug remains unreproducible,
state that limitation and continue with the normal investigation path.
If the bug cannot be reproduced:
- Post a comment on the issue asking for specific details:
reproduction steps, environment, version, logs, or a minimal
example. Be specific about what you tried.
- Stop. Do not attempt a fix. A follow-up
issue_comment
webhook will arrive in this session when the reporter replies,
and work will resume from this step.
Phase 3: Planning
- Create a detailed plan. Based on the root cause (from step 5) or the feature
scope (from step 4), produce a plan that includes:
- The root cause or feature scope summary.
- Every file to change and what each change does.
- What tests to add or modify (if the repo has a test suite).
- The verification method: which test to run, which script to
execute, or what behavior to check.
This plan will be embedded in the PR description.
Phase 4: Implementation
Implement the plan. Once your plan from step 6 is precise, hand
the first-pass edits to the implement subagent (cheaper coding model),
giving it: the full plan, the working directory (/workspace/repo), the
coding conventions from step 3, and the exact files/changes/tests to write.
Then review implement's output yourself before trusting it — the
correctness judgment stays with you. For small or subtle changes,
just do them directly.
Verify the implementation.
- Check that every item in the plan was implemented (your judgment).
- Run the test suite (use the test command from step 3) — you may
delegate the test run + failure summary to
implement.
- If this was a bug fix, run the reproduction from step 5.
Loop if failing. If tests fail or the issue isn't resolved:
- Return to step 6: re-plan with the new information (test output,
error messages, what the implementation got wrong).
- Maximum 2 retries (3 total attempts including the first).
- After 3 failed attempts, commit what you have and note the
remaining issues in the PR description.
Phase 5: Cleanup and PR
Clean up.
- Load
deslop skill — strip AI noise from the diff.
- Load
review skill — self-review. If findings exist, fix them,
re-run deslop and review. Repeat at most 3 rounds.
- Run the lint command from step 3 (if one was found). Fix lint
issues before committing.
Commit and push.
- Commit with
Fixes #<number> in the message.
- Check for conflicts with the default branch and rebase if
needed (see conflict resolution below).
- Push.
Open a draft PR. Load pr skill with:
- The implementation summary from step 6.
- What was tested (test command, results).
- The CI check count from step 3 (for dynamic cron scheduling).
- The issue number for linking (
Closes #<number>).
- Post a concise issue comment after the draft is opened, linking the PR
and letting collaborators know it is ready for review. Post only one such
comment per draft PR. A failed comment does not block the draft PR.
Conflict resolution
Before pushing, check for conflicts with the default branch:
DEFAULT_BRANCH=$(gh repo view --json defaultBranchRef --jq .defaultBranchRef.name)
git fetch origin "$DEFAULT_BRANCH"
git rebase "origin/$DEFAULT_BRANCH"
If the rebase has conflicts:
- Check
git diff --name-only --diff-filter=U for conflicted files.
- For each file, read the conflict markers (
<<<<<<<, =======,
>>>>>>>), understand both sides, and resolve.
git add <resolved-file> then git rebase --continue.
- If the conflict is too complex to resolve confidently, abort with
git rebase --abort and note it in the PR description.
Never force-push to someone else's branch. On your own feature branch,
a rebase followed by git push --force-with-lease is acceptable.
Test discovery
Before committing, find and run the project's test suite. Check these
locations in order and use the first match:
package.json (Node/JS/TS):
jq -r '.scripts.test // empty' package.json
Run with npm test, bun test, pnpm test, or yarn test
depending on the lockfile present.
Makefile / Justfile:
grep -E '^test[ :]' Makefile Justfile 2>/dev/null
Run with make test or just test.
Python (pytest / unittest):
test -f pytest.ini || test -f pyproject.toml || test -f setup.cfg
Run with pytest or python -m pytest.
Go:
test -f go.mod
Run with go test ./....
CI workflows (fallback):
grep -r 'run:.*test' .github/workflows/ 2>/dev/null | head -5
Extract the test command from the workflow file.
If no test command is found within 30 seconds of searching, skip and
note "no test suite found" in the PR description. Don't spend more
than 2 minutes on a failing test suite that's unrelated to your
changes — note it and move on.
Command timeouts
Always set a timeout on bash commands that might hang. Use the
timeout parameter (milliseconds) on every bash tool call that
runs tests, builds, or installs dependencies:
pnpm install / npm install / bun install: 120000 (2 min)
tsc --noEmit / typecheck: 120000 (2 min)
vitest run / jest / test suites: 180000 (3 min)
biome check / eslint / lint: 60000 (1 min)
If a command times out, that's fine — note it in the PR description
and move on. Never run test/build commands without a timeout.
Also: many repos require a codegen or build step before typecheck/tests
work (e.g. pnpm run generate:sdk, pnpm run build). Check
package.json scripts for generate*, codegen*, or prebuild*
scripts and run them first. If they fail or are slow, skip them — the
typecheck/test failures from missing generated files are pre-existing
and not your fault.
Reserve BLOCKED for genuine impossibility (missing auth, deleted repo,
contradictory requirements). A best-effort draft PR is almost always
better than blocking.
1---2name: resolve-issue3description: Resolve a GitHub issue end-to-end — explore, plan, implement, clean up, and open a draft PR.4license: Apache-2.05---67# Resolve Issue89Take an issue from labeled to "draft PR opened." Load `repo-setup`10first to prepare `/workspace/repo` on a feature branch.1112**Default to shipping a draft PR.** A best-effort first cut is more13valuable than a "too big" comment. Other agents will review it, fix CI,14and respond to feedback.1516## Workflow1718### Phase 1: Context Gathering19201. **Read the issue.** Lean toward the smallest interpretation.21222. **Check for existing PRs** that reference this issue:23 ```sh24 gh api "repos/<owner>/<repo>/issues/<number>/timeline" --paginate \25 --jq '[.[] | select(.event=="cross-referenced" and .source.issue.pull_request != null) | {number: .source.issue.number, state: .source.issue.state, title: .source.issue.title, url: .source.issue.html_url}]'26 ```27 Also search PR titles and bodies for the issue number:28 ```sh29 gh pr list --search "<number>" --repo <owner>/<repo> --json number,title,state,headRefName,url30 ```31 - **Open PR exists** → check it out (`gh pr checkout <number>`),32 review what's done, and continue from there instead of starting33 fresh. Load `review` skill to assess quality first.34 - **Draft/stale PR exists** → same as above. Rebase onto the35 default branch if needed (see conflict resolution below).36 - **Only closed/merged PRs** → the issue may already be resolved.37 Verify before starting new work.38 - **No linked PRs** → proceed with fresh implementation.39403. **Understand repo conventions.** Delegate this survey to the41 `explore` subagent (read-only, cheaper model) and use its brief; ask42 it to report:43 - `CONTRIBUTING.md`, `AGENTS.md`, `DEVELOPMENT.md`, or similar docs44 - Recent commit history: `git log --oneline -20` (commit style)45 - Linter config: `biome.json`, `.eslintrc*`, `.prettierrc*`,46 `ruff.toml`, `pyproject.toml [tool.ruff]`, `.golangci.yml`, etc.47 - Test framework config: `jest.config*`, `vitest.config*`,48 `pytest.ini`, `pyproject.toml [tool.pytest]`, `go.mod`, etc.49 - CI workflow files: `.github/workflows/*.yml` — note the test50 command and count the number of check/job names51 - Existing utility functions relevant to the issue52 Note for later: coding conventions, test command, lint command,53 PR template path (if any), and CI check count.5455### Phase 2: Bug Verification56574. **Classify the issue**: bug report or feature request.58 - **Feature request** → skip to step 6 (planning).59 - **Bug report** → continue to verification.60615. **Verify the bug exists.** You may delegate the code-path *reading*62 to `explore` (e.g. "find and summarize the code paths involved in63 <behavior>"), but make the root-cause judgment yourself:64 a. Read the relevant code paths identified in the issue body.65 b. Cross-check against the default branch HEAD — is the described66 behavior actually present in the current code?67 c. Try to write a minimal reproduction: a test case, a script, or68 a specific input that triggers the bug.69 d. If reproducible: report the root cause ("This breaks because70 **X**, in **Y** path, after **Z** condition.").71 e. If not reproducible: report what was tried and why it failed.7273 **Local Sentry telemetry:** For a reproducible web application, browser74 client, HTTP server, or local-agent bug, check whether the repository already75 has compatible Sentry initialization and a runnable local command. If it76 does, create an isolated local telemetry configuration that prevents the77 launched app from using its normal DSN (including client-side DSN injection),78 then inspect `sentry local --help` and run `sentry local serve` with bounded79 output. Configure the app to send only to the local endpoint (normally via80 `SENTRY_SPOTLIGHT` when supported), and reproduce the smallest failing flow.81 Use the correlated trace ID, spans, logs, and errors as root-cause evidence.82 Do not add or reconfigure Sentry solely for this check, print credentials, or83 send local telemetry remotely. If the app cannot run, its SDK is incompatible,84 remote ingestion cannot be prevented, or the bug remains unreproducible,85 state that limitation and continue with the normal investigation path.8687 If the bug **cannot be reproduced**:88 - Post a comment on the issue asking for specific details:89 reproduction steps, environment, version, logs, or a minimal90 example. Be specific about what you tried.91 - **Stop.** Do not attempt a fix. A follow-up `issue_comment`92 webhook will arrive in this session when the reporter replies,93 and work will resume from this step.9495### Phase 3: Planning96976. **Create a detailed plan.** Based on the root cause (from step 5) or the feature98 scope (from step 4), produce a plan that includes:99 - The root cause or feature scope summary.100 - Every file to change and what each change does.101 - What tests to add or modify (if the repo has a test suite).102 - The verification method: which test to run, which script to103 execute, or what behavior to check.104 This plan will be embedded in the PR description.105106### Phase 4: Implementation1071087. **Implement the plan.** Once your plan from step 6 is precise, hand109 the first-pass edits to the `implement` subagent (cheaper coding model),110 giving it: the full plan, the working directory (`/workspace/repo`), the111 coding conventions from step 3, and the exact files/changes/tests to write.112 Then **review `implement`'s output yourself** before trusting it — the113 correctness judgment stays with you. For small or subtle changes,114 just do them directly.1151168. **Verify the implementation.**117 - Check that every item in the plan was implemented (your judgment).118 - Run the test suite (use the test command from step 3) — you may119 delegate the test run + failure summary to `implement`.120 - If this was a bug fix, run the reproduction from step 5.1211229. **Loop if failing.** If tests fail or the issue isn't resolved:123 - Return to step 6: re-plan with the new information (test output,124 error messages, what the implementation got wrong).125 - Maximum **2 retries** (3 total attempts including the first).126 - After 3 failed attempts, commit what you have and note the127 remaining issues in the PR description.128129### Phase 5: Cleanup and PR13013110. **Clean up.**132 - Load `deslop` skill — strip AI noise from the diff.133 - Load `review` skill — self-review. If findings exist, fix them,134 re-run `deslop` and `review`. Repeat at most **3 rounds**.135 - Run the lint command from step 3 (if one was found). Fix lint136 issues before committing.13713811. **Commit and push.**139 - Commit with `Fixes #<number>` in the message.140 - Check for conflicts with the default branch and rebase if141 needed (see conflict resolution below).142 - Push.14314412. **Open a draft PR.** Load `pr` skill with:145 - The implementation summary from step 6.146 - What was tested (test command, results).147 - The CI check count from step 3 (for dynamic cron scheduling).148 - The issue number for linking (`Closes #<number>`).149 - **Post a concise issue comment** after the draft is opened, linking the PR150 and letting collaborators know it is ready for review. Post only one such151 comment per draft PR. A failed comment does not block the draft PR.152153## Conflict resolution154155Before pushing, check for conflicts with the default branch:156157```sh158DEFAULT_BRANCH=$(gh repo view --json defaultBranchRef --jq .defaultBranchRef.name)159git fetch origin "$DEFAULT_BRANCH"160git rebase "origin/$DEFAULT_BRANCH"161```162163If the rebase has conflicts:1641651. Check `git diff --name-only --diff-filter=U` for conflicted files.1662. For each file, read the conflict markers (`<<<<<<<`, `=======`,167 `>>>>>>>`), understand both sides, and resolve.1683. `git add <resolved-file>` then `git rebase --continue`.1694. If the conflict is too complex to resolve confidently, abort with170 `git rebase --abort` and note it in the PR description.171172Never force-push to someone else's branch. On your own feature branch,173a rebase followed by `git push --force-with-lease` is acceptable.174175## Test discovery176177Before committing, find and run the project's test suite. Check these178locations in order and use the first match:1791801. **package.json** (Node/JS/TS):181 ```sh182 jq -r '.scripts.test // empty' package.json183 ```184 Run with `npm test`, `bun test`, `pnpm test`, or `yarn test`185 depending on the lockfile present.1861872. **Makefile / Justfile**:188 ```sh189 grep -E '^test[ :]' Makefile Justfile 2>/dev/null190 ```191 Run with `make test` or `just test`.1921933. **Python** (pytest / unittest):194 ```sh195 test -f pytest.ini || test -f pyproject.toml || test -f setup.cfg196 ```197 Run with `pytest` or `python -m pytest`.1981994. **Go**:200 ```sh201 test -f go.mod202 ```203 Run with `go test ./...`.2042055. **CI workflows** (fallback):206 ```sh207 grep -r 'run:.*test' .github/workflows/ 2>/dev/null | head -5208 ```209 Extract the test command from the workflow file.210211If no test command is found within 30 seconds of searching, skip and212note "no test suite found" in the PR description. Don't spend more213than 2 minutes on a failing test suite that's unrelated to your214changes — note it and move on.215216## Command timeouts217218**Always set a timeout on bash commands that might hang.** Use the219`timeout` parameter (milliseconds) on every `bash` tool call that220runs tests, builds, or installs dependencies:221222- `pnpm install` / `npm install` / `bun install`: **120000** (2 min)223- `tsc --noEmit` / typecheck: **120000** (2 min)224- `vitest run` / `jest` / test suites: **180000** (3 min)225- `biome check` / `eslint` / lint: **60000** (1 min)226227If a command times out, that's fine — note it in the PR description228and move on. **Never run test/build commands without a timeout.**229230Also: many repos require a codegen or build step before typecheck/tests231work (e.g. `pnpm run generate:sdk`, `pnpm run build`). Check232`package.json` scripts for `generate*`, `codegen*`, or `prebuild*`233scripts and run them first. If they fail or are slow, skip them — the234typecheck/test failures from missing generated files are pre-existing235and not your fault.236237Reserve BLOCKED for genuine impossibility (missing auth, deleted repo,238contradictory requirements). A best-effort draft PR is almost always239better than blocking.