Skip to content
Back to skills

To Pull Requests

ASecurity

Opens the PR/MR for a pushed issue branch after explicit confirmation and, once the developer confirms the merge, closes the ticket, unblocks dependent tickets and cleans up; with `--release <epic>`, opens the release PR of the epic's integration branch and closes the epic. Use explicitly after /implement or /fast-implement; not for an unpushed branch and never to merge.

  • 11 stars
  • 0 votes
  • 0 copies
  • 6 views
  • Added October 19, 2026
developmentpythongoshellbashgitapibackend

Works with

  • claude code
  • terminal
  • cli
  • api

Security analysis

A100/100

Scanned November 22, 2026

npx -y skills add PVMalove/claude-agent-harness --skill to-pull-requests --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of To Pull Requests?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for To Pull Requests
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/pvmalove-to-pull-requests/badge)](https://www.skillsdirectory.com/skills/pvmalove-to-pull-requests)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: to-pull-requests
description: Opens the PR/MR for a pushed issue branch after explicit confirmation and, once the developer confirms the merge, closes the ticket, unblocks dependent tickets and cleans up; with `--release <epic>`, opens the release PR of the epic's integration branch and closes the epic. Use explicitly after /implement or /fast-implement; not for an unpushed branch and never to merge.
disable-model-invocation: true
---

# To Pull Requests

Create the pull request for the named ticket. This is a manual command: never run it merely because `/implement` completed. With `--release <epic>`, read `references/release.md` and follow it instead of the steps below.

On GitLab, name the project explicitly: every `glab` command takes `-R <project-url>`, and every `glab api` call is written `GITLAB_HOST=<host> glab api projects/<project-id>/...`. `<host>`, `<project-url>` and `<project-id>` are defined in `.harness/instructions/issue-tracker.md` → GitLab → Conventions. A GitLab merge request is referenced as `!<iid>` and an issue as `#<iid>`; on GitHub both are `#<n>`.

A project with a valid `backend-orchestration` opt-in verifies the exact candidate and target pair through `coordinator.py integration` commands; such a project is called "opt-in" below. Every such command is `python .harness/orchestration/coordinator.py --repo . <command>`, and `<ticket-branch>` stands for `--ticket "#<ID>" --branch "<current-issue-branch>"`. For an opt-in project and a ticket not labeled `pipeline::fast`, read `references/integration-route.md` and run the part that a step names. Without the opt-in, or for a `pipeline::fast` ticket, skip those parts.

On the local markdown tracker (`.scratch/<feature>/issues/NN-*.md`) there is no PR or MR (`.harness/instructions/git-workflow.md` §2, step 6), so steps 0 and 3–7 do not apply. Take the target branch from the ticket's `**Integration branch:**` line, or `base_branch` for an epic-less ticket, and run the branch checks of step 2; skip its upstream checks when the repository has no remote. Ask the developer to merge the issue branch into that target themselves and to confirm the merge; never merge it yourself. After the confirmation, require `git merge-base --is-ancestor HEAD <target-ref>` to succeed, where `<target-ref>` is `origin/<target-branch>` after a fetch, or the local `<target-branch>` when the repository has no remote. Then set the ticket file's `**Workflow:**` line to `done` (when it carries `**Task report:** required`, fold the completion report into that same update) and continue with steps 8 and 9.

0. Find an existing PR/MR of the current issue branch — GitHub: `gh pr list --head <branch> --state all --json number,state,baseRefName`; GitLab: `glab mr list -R <project-url> --source-branch <branch> --all --output json`. None: start at step 1. Open: run step 1, then step 6a for an opt-in project and step 7. Merged: run the merge checks of step 7, then steps 8 and 9.
1. Resolve the ticket and its exact PR target branch from the ticket's `## Integration Branch` section, its parent epic, or `base_branch` for an epic-less ticket. If this cannot be resolved, stop and ask the developer.
2. Verify that the current branch matches `branch_pattern`, is neither `base_branch` nor `integration/*`, has no uncommitted changes, and has no commits absent from its upstream branch. If the branch has not been pushed, stop and ask the developer to return to `/implement` or `/fast-implement`, whichever route the ticket is on. Fetch its upstream and require `git rev-parse HEAD` to equal the upstream branch SHA; if it differs, fast-forward the clean local branch before continuing.
3. Verify before the PR. For an opt-in project, run part A of `references/integration-route.md`: it validates the accepted QA evidence of the exact SHA (`qa evidence`) and ends at `integration next` step `confirm-pr`. Do not rerun `/qa-gate` when this validation succeeds; instead, from the PR branch checkout verified in step 2, run `bash "${CLAUDE_PROJECT_DIR:-$(git worktree list --porcelain | sed -n '1s/^worktree //p')}/.claude/hooks/record-qa-gate-pass.sh"` so the PR hook accepts that SHA; without `CLAUDE_PROJECT_DIR` the script comes from the main worktree. For a refreshed SHA this marker only permits opening the PR; it is not QA of the new candidate, which step 6a verifies after the PR exists. If the project is not a valid opt-in, or if the ticket is `pipeline::fast`, run `/qa-gate` if this repository provides it and stop on failure.
4. Prepare the PR body using `.harness/instructions/git-workflow.md` §3. Store it only at `.harness/.sandboxes/pr_body/pr-body-<issue>-<slug>.md`, never in `docs/tasks/`. A developer may manually run `pr-composer` in the coding application; otherwise fill in the template directly. Either way the body is built from the ticket and the verification evidence, not from the diff alone:
   - Read the ticket body through the tracker CLI, and its parent epic when it names `## Parent: #<epic>`.
   - The evidence is the `/qa-gate` result of step 3; for an opt-in project, the accepted QA evidence and the `handoff` of `integration next` (`candidate_sha`, `qa_source`, `reference`); and the checks section of the `/developer` report when this session has one.
   - Under Verification, list every `Action -> Verify` criterion of `## Acceptance criteria` with its command and result from that evidence. A criterion without evidence goes under Not verified & risks.
   - Use the ticket's `Out of scope` and the epic's `## Non-Goals & Rejected Alternatives` to state what the PR deliberately does not change.

   Choose the footer by `.harness/instructions/git-workflow.md` §2 step 6 → Ticket footer for the step 1 target branch; step 7 always checks the ticket state.
5. Ask the developer for explicit, separate confirmation that the branch is ready to become a PR; this question is never merged with another. State the QA result in it; for an opt-in project also the exact `candidate_sha` and `target_sha` from `integration next`, the PR target branch and `qa_source`. The confirmation covers only that pair. Stop for their answer.
6. After approval, open the PR/MR from the branch checkout verified in step 2. For an opt-in project run `integration next <ticket-branch>` once more immediately before: if `candidate_sha`, `target_sha` or `step` (`confirm-pr`) changed, the confirmation is void; repeat the steps above and ask again. The PR title and body follow `.harness/instructions/git-workflow.md` §1 "Project-Only Metadata". `<target-branch>` is the step 1 target; without it, both CLIs would target the default branch. `<title>` is the ticket title in single quotes, with each apostrophe written as `'\''` in a POSIX shell or as `''` in PowerShell. Run one publication command per shell call:
    - **GitHub:** `gh pr create --base <target-branch> --title '<title>' --body-file <path>`.
    - **GitLab:** `glab mr create -R <project-url> --target-branch <target-branch> --title '<title>' --description-file <path> --yes`. The MR is `!<iid>`, where `<iid>` is the last segment of the `.../-/merge_requests/<iid>` URL the command prints.

    Delete the `.harness/.sandboxes/pr_body/` body file only after that command succeeds; on failure, retain it for retry. If the ticket carries `task-report::required`, publish its completion report on the ticket, unless the developer asked to skip it. Write it in the `## Completion report` format of `.harness/instructions/project-memory.md` (a marked JSON object with `ticket`, `role`, `outcome` and `output`), because `memory sync` skips any other comment. Save it to `.harness/.sandboxes/pr_body/issue-comment-<issue>-<slug>.md`, then post it with `gh issue comment <ID> --body-file <path>` on GitHub or `GITLAB_HOST=<host> glab api projects/<project-id>/issues/<ID>/notes -F body=@<path>` on GitLab.
   **6a. Verify the opened or updated PR (opt-in project).** Run part B of `references/integration-route.md` after opening the PR and after any later update of its branch; it ends at `integration next` step `handoff`.
7. Return the PR/MR link in the primary session (on GitLab, also as `!<iid>`). For an opt-in project show the `handoff` of `integration next --pull-request <n>` before asking the developer to merge: the verified `candidate_sha` and `target_sha`, the `qa_source` (`original-qa`, `ci` or `local-qa`) with its `reference`, and whether the branch was refreshed. State that this verification belongs to exactly that pair and does not promise that nothing changes before the merge. Do not enable server branch protection or a merge queue. Ask whether the developer wants to review it, and repeat `integration next --pull-request <n>` right before the merge: a newly detected target means refresh and a new verification, never a reuse of the old one. Never merge it. Act on the ticket only after the developer confirms the merge; when that confirmation comes in a later session, step 0 brings you back here:
    - **Check the merge** as `.harness/instructions/git-workflow.md` §2 step 7 → Close the ticket after merge describes, with the step 1 target as the expected target. If it is not merged into that target, leave the ticket open and tell the developer.
    - **Check the tree.** For an opt-in project, compare the tree of the commit the merge created on the target branch with the pair's `candidate_tree_sha`. Take the merge commit — GitHub: `gh pr view <n> --json mergeCommit --jq .mergeCommit.oid`; GitLab: `merge_commit_sha`, or `squash_commit_sha` when it is null, from `glab mr view <iid> -R <project-url> -F json` — run `git fetch <remote> <target-branch>`, then `integration next <ticket-branch> --pull-request <n> --merge-commit <sha>`. On `step: merged` continue. On `step: merge-tree-mismatch` stop with a blocker: do not close the ticket, and tell the developer that the merged tree is not the tree QA checked, so the next merge from the target branch needs a new full QA of its head. Without the opt-in skip this check.
    - **Close or verify the ticket** by its footer (`Related to #<ID>` or `Closes #<ID>`), with the commands of `.harness/instructions/git-workflow.md` §2 step 7 → Close the ticket after merge. On GitLab, post any closing comment first through the notes API, as in step 6.
8. **Unblock dependencies after every close, in the same session.** Only a confirmed merge and normal close of a predecessor releases a dependency; a push, publish, accepted QA or an open PR never does. Leave the closed ticket's own `status::in-progress` label as is: the closed state is its terminal `done`. Then find every open ticket this one blocked and move each one whose blockers are now all closed:
    - **GitHub:** list open `status::blocked` issues (`gh issue list --state open --label status::blocked --json number`). For each, read its native blockers (`gh api repos/<owner>/<repo>/issues/<n>/dependencies/blocked_by --jq '[.[] | select(.state=="open")] | length'`) and any `Blocked by:` line in its body. If both show no open blocker, run `gh issue edit <n> --remove-label status::blocked --add-label status::ready`.
    - **GitLab:** list open `status::blocked` issues (`glab issue list -R <project-url> --label status::blocked --output json`). For each, read its native blocking links (`GITLAB_HOST=<host> glab api projects/<project-id>/issues/<n>/links`), where an entry with `link_type` `is_blocked_by` and `state` `opened` is an open blocker; GitLab Free has no such links. Also read every `#<M>` in its description's `Blocked by` lines (`glab issue view <n> -R <project-url> -F json`): that blocker is open while `glab issue view <M> -R <project-url> -F json` reports `state` `opened`. If both show no open blocker, run `glab issue update <n> -R <project-url> --unlabel status::blocked --label status::ready`.
    - **Local tracker** (`.scratch/<feature>/issues/*.md`): check `**Blocked by:** #<ID>` and set `**Workflow:** status::ready` once every listed blocker is resolved. Drafts in `docs/tasks/` are not tickets (`.harness/instructions/artifacts.md`).
    - Report which tickets moved to `status::ready` and which stay blocked, and by what. When the closed ticket was the last open child of its epic, offer `/to-pull-requests --release <epic>`.
9. **Cleanup:** After confirming the PR is merged and the ticket is closed, clean up the local environment to prevent garbage accumulation. Switch out of the issue worktree first, then remove it with the tool that created it:
    - A managed worktree under `.harness/.sandboxes/worktrees/`: `python .harness/orchestration/coordinator.py worktree remove --repo . --path <path>`, which removes a clean worktree through `harness-runtime` and keeps its branch.
    - A worktree the session created with its runtime's worktree tool (Claude Code: `EnterWorktree`): that tool's remove action (`ExitWorktree` with `remove`).
    - Any other worktree: `git worktree remove <path>`. If it fails because `.git/worktrees` is read-only in the sandbox, give the developer that command to run outside the sandbox and stop the cleanup there.

    Then handle the local branch:
    - **With a PR:** prove the merge from the PR, not from Git history. A squash or rebase merge leaves the branch commits outside the target history, so `git branch -d` and `git merge-base --is-ancestor` fail although the work is merged. GitHub: `gh pr view <n> --json state,headRefOid` (`state` is `MERGED` and `headRefOid` equals `git rev-parse <branch-name>`). GitLab: `glab mr view <iid> -R <project-url> -F json` (`state` is `merged` and `sha` equals `git rev-parse <branch-name>`).
    - **The check passes:** ask the developer whether to delete the local branch. On a yes, run `harness branch-delete <repo> <branch-name>`: it deletes the branch only when the branch matches `branch_pattern`, no worktree has it checked out, and its tip is reachable from `refs/remotes/origin/*` or is the head commit of a merged PR/MR. On a refusal, report the condition it names and keep the branch. The hook `block-dangerous-git.sh` blocks `git branch -D` for an agent in every form, so never run it and never work around the block.
    - **The PR is not merged or the SHAs differ:** keep the branch and tell the developer.
    - **Local markdown tracker (no PR):** after the `git merge-base --is-ancestor` check from the local-tracker paragraph succeeds, delete the branch with `git branch -d <branch-name>`.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.