openhands/extensions/github-issue-to-pr

Claude Code and agent skill by openhands/extensions

Trust tier 2
  • community
LLM review pending
Source check pending

Checking that the SKILL.md file is still in the repository.

Create an automation that implements GitHub issues when a configurable trigger label is applied. Polls one or more repositories deterministically, clones the default branch, starts one OpenHands conversation per label event, then commits, pushes, and opens the pull request itself.

Install

npx vskill@latest install openhands/extensions/github-issue-to-pr

SKILL.md

The same SKILL.md was published earlier as openhands/extensions/github-issue-to-pr.

GitHub Issue to PR Automation

Agent Canvas catalog

For new Agent Canvas installations, use the GitHub issue to PR catalog entry. Its deterministic worker.py scanner delegates each eligible issue to a stable conversation using the selected agent profile. The manual upload flow below remains for existing deployments and is deprecated for new installations.

Create a cron automation that watches one or more GitHub repositories for issues with a trigger label, starts an OpenHands conversation once per label event with the repository's default branch already checked out, and opens a pull request with whatever the agent produced.

The automation script is deterministic: issue discovery, label-event tracking, state persistence, the clone, the branch, the commit, the push, the pull request, the issue comments, and the clone's removal are all handled in Python. The LLM is invoked only to write the code.

The agent is told which issue to implement, not what it says. It fetches the description, the discussion, and whatever they link to itself, so nothing in the prompt goes stale between dispatch and the moment the agent reads it.

That needs read access, so the conversation is handed exactly one secret, GITHUB_PERSONAL_ACCESS_TOKEN, and no MCP servers. AGENT_SECRET_NAMES stays an allow-list: the rest of the deployment's secret store is not reachable from a conversation whose instructions came from an issue.

The agent also finishes the job: it commits, pushes its branch, and opens the pull request, so the pull request appears when the agent stops rather than on the next poll. The script does not trust that it happened - when the conversation ends it asks GitHub whether the pull request exists, and opens it itself when it does not. origin still carries no credential, so every GitHub command the agent runs has to name GITHUB_PERSONAL_ACCESS_TOKEN; the SDK only puts a secret in the environment of a command that mentions it, and masks it in the output.


The script imports shared GitHub transport from scripts/github_client.py, installed with this skill. Include it beside main.py when packaging manually, as shown below; catalog bundles include it automatically.

Prerequisites

Required secret

Verify that the following secret is set in OpenHands Settings -> Secrets:

Secret nameToken typeMinimum permissions
GITHUB_PERSONAL_ACCESS_TOKENClassic PATrepo, plus workflow
GITHUB_PERSONAL_ACCESS_TOKENFine-grained PATContents: Read and write, Metadata: Read, Issues: Read and write, Pull requests: Read and write, Workflows: Read and write

The workflow scope is not optional in practice. An issue asking for a CI change is a normal issue, and GitHub rejects the whole push when a token without it touches .github/workflows/: "refusing to allow a Personal Access Token to create or update workflow ... without `workflow` scope". The branch is rejected in full, so the pull request never opens.

Contents write access is required because the script pushes the branch, and pull request write because it opens the pull request. A read-only token will poll happily and then fail at the point of pushing.

When several repositories are monitored, the token must cover all of them.

Check with:

bash
curl -s https://api.github.com/user \
-H "Authorization: Bearer $GITHUB_PERSONAL_ACCESS_TOKEN" \
| python3 -c "import json,sys; d=json.load(sys.stdin); print(d.get('login') or d.get('message'))"

If the token is missing or invalid, inform the user and stop.


Setup Workflow

Follow these steps in order.

Step 1 - Verify GITHUB_PERSONAL_ACCESS_TOKEN

Run the curl check above.

  • If absent: *"GITHUB_PERSONAL_ACCESS_TOKEN is not set. Please add it in

OpenHands Settings -> Secrets."* Stop.

  • If the API returns {"message": "Bad credentials"}: tell the user the token is

invalid and ask them to update it. Stop.

Step 2 - Collect repositories

Ask: "Which GitHub repositories should be watched? (Format: `owner/repo`, e.g. `myorg/backend`. List several separated by commas to serve them all from one automation.)"

Validate access to each repository, and confirm the token can push:

bash
curl -s "https://api.github.com/repos/{owner}/{repo}" \
-H "Authorization: Bearer $GITHUB_PERSONAL_ACCESS_TOKEN" \
| python3 -c "
import json, sys
d = json.load(sys.stdin)
if 'message' in d:
print('ERROR:', d['message'])
else:
perms = d.get('permissions', {})
print(f\"Accessible. Default branch: {d.get('default_branch')}. Push: {perms.get('push')}\")
"

Record every accepted repository into REPOS = ["{owner}/{repo}", ...]. If one repository fails the check, say which and ask whether to continue without it. If Push: False, say that the automation cannot open pull requests there and ask for a token with write access.

Each repository is polled independently and keeps its own state, so issue numbers never collide between them. The trigger label, branch prefix, and schedule are shared; a repository needing different settings wants its own automation.

Step 3 - Collect trigger label

Ask: "Which issue label should trigger an implementation? (Press Enter for the default: `openhands`.)"

Record the answer as TRIGGER_LABEL. If the label does not exist yet, tell the user that GitHub will still record the event once the label is created and applied to an issue.

The automation works an issue when it sees the latest matching labeled event for that label. To ask for another attempt later, remove and re-apply the label - that opens a second branch and a second pull request rather than overwriting the first.

Step 4 - Collect the pull request mode

Ask: *"Should the pull requests be opened as drafts?

  1. Draft (default) - opened as a draft, ready for a human to mark ready
  2. Ready for review - opened as a normal pull request

(Press Enter for Draft)"*

Map the choice to DRAFT_PULL_REQUEST (True or False).

Step 5 - Collect the branch prefix

Ask: "What branch prefix should the automation use? (Press Enter for the default: `openhands/issue`, which produces `openhands/issue-42`.)"

Record as BRANCH_PREFIX. Keep it free of spaces and of characters git rejects in a ref name.

Step 6 - Collect cron schedule

Ask: "How often should the automation poll for labelled issues? (Press Enter for the default: every 5 minutes. Use a cron expression for a different interval, e.g. `0 ` = hourly)"

Default: */5 * * * *.

Record as CRON_SCHEDULE.

Step 7 - Confirm the secret scope

The agent is handed GITHUB_PERSONAL_ACCESS_TOKEN, because it reads the issue and its discussion itself. Ask: "Beyond the GitHub token, does the repository's build need a secret of its own - a package registry token, for example? (Press Enter for none.)"

Record the answers appended to the default, as AGENT_SECRET_NAMES = ["GITHUB_PERSONAL_ACCESS_TOKEN", "NAME", ...].

Keep it an allow-list. Forwarding the whole secret store would put every credential in the deployment behind a prompt written by whoever opened the issue. If the repositories are public and you would rather the conversation held no credential at all, set the list to [] - the agent can still read a public issue unauthenticated, and private repositories then stop working.

Step 8 - Generate the automation script

Read scripts/main.py from this skill's directory. Apply exactly five constant substitutions near the top of the file:

The script also reads a config.json shipped beside it, if there is one, over
these constants. That is how the catalog entry
(automations/catalog/github-issue-to-pr/) configures an unmodified copy,
since a declarative host cannot rewrite Python. This setup path substitutes the
constants and ships no config.json, so the two never collide.
PlaceholderReplace with
REPOS = ["owner/repo"]REPOS = ["{owner_repo}", ...] - one entry per repository collected in Step 2
TRIGGER_LABEL = "openhands"TRIGGER_LABEL = "{trigger_label}"
BRANCH_PREFIX = "openhands/issue"BRANCH_PREFIX = "{branch_prefix}"
DRAFT_PULL_REQUEST = TrueDRAFT_PULL_REQUEST = {True or False}
AGENT_SECRET_NAMES: list[str] = []AGENT_SECRET_NAMES: list[str] = ["{name}", ...]

Leave MAX_NEW_PER_RUN and DEFAULT_OPENHANDS_URL alone unless the user asks for a different cap or a non-default OpenHands URL.

A repository may be given as owner/repo, as a clone URL, or as an SSH remote; the script normalizes each one at startup and names the value it could not read rather than blaming the token.

Use a safe string writer such as json.dumps(value) when inserting user-provided repository names, labels, or prefixes into Python string literals. json.dumps(list_of_repos) produces the whole REPOS list safely in one step.

Run these commands from this skill's directory and write the customized script to a temporary build directory:

bash
mkdir -p /tmp/issue-to-pr-build
cp -L scripts/github_client.py /tmp/issue-to-pr-build/github_client.py
# write the customized main.py to /tmp/issue-to-pr-build/main.py

Validate syntax before packaging:

bash
python3 -m py_compile /tmp/issue-to-pr-build/main.py && echo "Syntax OK"

Fix any syntax errors before proceeding.

Step 9 - Package and upload

Determine the Automation backend URL and auth from the <RUNTIME_SERVICES> block in your system context:

  • OPENHANDS_HOST: the Automation backend url_from_agent
  • Auth: X-Session-API-Key: $OPENHANDS_AUTOMATION_API_KEY
bash
tar -czf /tmp/issue-to-pr.tar.gz -C /tmp/issue-to-pr-build .
TARBALL_PATH=$(curl -s -X POST \
"${OPENHANDS_HOST}/api/automation/v1/uploads?name=github-issue-to-pr" \
-H "X-Session-API-Key: $OPENHANDS_AUTOMATION_API_KEY" \
-H "Content-Type: application/gzip" \
--data-binary @/tmp/issue-to-pr.tar.gz \
| python3 -c "import json,sys; print(json.load(sys.stdin)['tarball_path'])")
echo "Uploaded: $TARBALL_PATH"
Step 10 - Register the automation
bash
curl -s -X POST "${OPENHANDS_HOST}/api/automation/v1" \
-H "X-Session-API-Key: $OPENHANDS_AUTOMATION_API_KEY" \
-H "Content-Type: application/json" \
-d "{
\"name\": \"GitHub Issue to PR: {repo_summary} label {trigger_label}\",
\"trigger\": {\"type\": \"cron\", \"schedule\": \"{cron_schedule}\"},
\"tarball_path\": \"$TARBALL_PATH\",
\"entrypoint\": \"python3 main.py\",
\"timeout\": 900
}" | python3 -m json.tool

Use the single repository as {repo_summary} when there is one, and something like 3 repos when there are several. A poll clones a repository per queued issue and pushes finished branches, so the timeout allows for that; a run never waits for an agent to finish, only for it to be started.

Record the returned id.

Step 11 - Confirm

Tell the user:

✅ GitHub Issue to PR is running!
- Automation ID: {id}
- Repositories: {owner}/{repo}, ... (one line each)
- Trigger label: {trigger_label}
- Branch prefix: {branch_prefix}
- Pull requests: {draft or ready for review}
- Polling schedule: {cron_schedule}
- State file per repository:
~/.openhands/workspaces/automation-state/github_issue_to_pr_{id}_{owner}__{repo}.json
Apply the {trigger_label} label to an issue to queue an implementation. Each
label event is processed once. To ask for another attempt, remove and re-apply
the label - that opens a second branch and pull request.
The agent runs without GitHub credentials; the automation pushes the branch and
opens the pull request once the agent has stopped.

Runtime Behaviour (per poll)

This is the start of the file. Read the full SKILL.md on GitHub.

Security

  • Security scanPassed, 100 of 100Pattern checks on the skill's files.
  • Model reviewNot runA model review is scheduled for the next rescan.

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
137
Repository forks
78
7-day trend score
25

Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/openhands/extensions/github-issue-to-pr/badge)](https://verified-skill.com/skills/openhands/extensions/github-issue-to-pr)

Something wrong with this skill or its page? Tell us.