---
name: issue-to-pr-resolver
description: Implement a GitHub issue end-to-end — create a worktree branch, implement the feature with tests, create a draft PR, then iteratively resolve all CI failures and review comments until the PR is clean. Use when you need to fully implement a GitHub issue from start to merge-ready. Triggers on "implement issue", "resolve issue", "/issue-to-pr-resolver <number>".
argument-hint: "<issue-number>"
allowed-tools: Bash, Read, Edit, Write, Glob, Grep, WebFetch, WebSearch
title: issue-to-pr-resolver
canonical_url: https://skilld.dev/gh/homeassistant-ai/ha-mcp/issue-to-pr-resolver
last_updated: 2026-11-12T06:30:57.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> If the user asked to install this Skill, run `npx skilld install homeassistant-ai/ha-mcp/issue-to-pr-resolver`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/issue-to-pr-resolver`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/homeassistant-ai/ha-mcp/issue-to-pr-resolver) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/issue-to-pr-resolver`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/issue-to-pr-resolver --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/issue-to-pr-resolver --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# Issue-to-PR Resolver

Implement GitHub issue #$ARGUMENTS in `homeassistant-ai/ha-mcp` end-to-end.

## Phase 1: Setup

**Read the issue:**
```bash
gh issue view "$ARGUMENTS" --repo homeassistant-ai/ha-mcp --json title,body,labels,comments,author
```

**Create a worktree from repo root:**
```bash
cd "$(git rev-parse --show-toplevel)"
git checkout master && git pull origin master
git worktree add "worktree/issue-$ARGUMENTS" -b "feature/issue-$ARGUMENTS"
git -C "worktree/issue-$ARGUMENTS" submodule update --init --recursive
cd "worktree/issue-$ARGUMENTS"
```

## Phase 2: Implement

- Analyze codebase structure and patterns before writing code
- Follow project conventions (see `AGENTS.md` for patterns, naming, error handling)
- Write tests — all new MCP tools in `src/ha_mcp/tools/` need E2E tests
- Make atomic, well-described commits using conventional commit prefixes

**Philosophy:** Work autonomously. Don't ask about every small decision. Fix unrelated test failures encountered. Document all choices for the final summary.

If a non-obvious choice has significant consequences, present the available options to the user and let them choose.

## Phase 3: Create PR

Write the PR body to `local/pr-body-$ARGUMENTS.md` first. `local/` is git-ignored, so a new worktree does not have it; create it with `mkdir -p local` if it does not exist. Build the body from `.github/pull_request_template.md`: keep its headings, put `Closes #$ARGUMENTS` and the description under `## What does this PR do?`, and delete `## Future improvements` unless the user has confirmed work to defer. Then push and create the PR:

```bash
git push -u origin "feature/issue-$ARGUMENTS"
PR_NUMBER=$(gh pr create --draft \
  --repo homeassistant-ai/ha-mcp \
  --title "<descriptive title>" \
  --body-file "local/pr-body-$ARGUMENTS.md" | grep -oE '[0-9]+$')
```

Wait for CI:
```bash
gh pr checks "$PR_NUMBER" --repo homeassistant-ai/ha-mcp --watch
```

Before marking ready (`gh pr ready`), update the PR description to reflect all changes made.

## Phase 4: Resolution Loop

Repeat until all checks green and no unresolved threads:

**Check for issues:**
```bash
gh pr checks "$PR_NUMBER" --repo homeassistant-ai/ha-mcp
gh api repos/homeassistant-ai/ha-mcp/pulls/"$PR_NUMBER"/comments \
  --jq '.[] | {id, path, line, author: .user.login, body}'
gh api graphql -F pr="$PR_NUMBER" -f query='query($pr: Int!) { repository(owner:"homeassistant-ai", name:"ha-mcp") { pullRequest(number:$pr) { reviewThreads(first:100) { nodes { id isResolved comments(first:1) { nodes { databaseId body } } } } } } }'
```

**Resolve each comment (both steps required):**
```bash
# 1. Reply on the inline thread
gh api repos/homeassistant-ai/ha-mcp/pulls/"$PR_NUMBER"/comments/<COMMENT_ID>/replies \
  -f body="✅ Fixed in [commit]. [explanation]"
# or: -f body="📝 Not addressing because [reason]."

# 2. Resolve the thread via GraphQL
gh api graphql -f query='mutation($threadId: ID!) { resolveReviewThread(input: {threadId: $threadId}) { thread { id isResolved } } }' \
  -f threadId="<PRRT_...>"
```

**After pushing fixes**, wait and re-check:
```bash
gh pr checks "$PR_NUMBER" --repo homeassistant-ai/ha-mcp --watch
```

## Phase 5: Final Report

Once all checks pass and all threads resolved:

```bash
gh pr comment "$PR_NUMBER" --repo homeassistant-ai/ha-mcp --body "## Implementation Summary

**Choices Made:**
- [key technical decisions with rationale]

**Problems Encountered:**
- [issues faced and how resolved]
- [unrelated test failures fixed, if any]
"
```

Report to user: PR number, status, key choices.

## Rules

- **Never commit to master** — always work in the worktree
- **Always create PRs as draft** — never mark ready without user request
- Maximum 5 resolution iterations before reporting blockers
- **Discovered improvements**: fix-in-place by default. See AGENTS.md § *Boy Scout Rule — Handling Discovered Improvements* for the full rubric. Never open a follow-up PR or issue without explicit user approval; never populate `## Future improvements` without the user explicitly confirming the work is out of scope.
