/pr
Creates or updates a pull request (GitHub) or merge request (GitLab) for the current branch in the Conventional PR format — intent, summary, changes, rationale, and test plan. Pushes the branch if needed (asks before any force-push) and captures the implementation conversation's
$ npx -y skills add oprogramadorreal/optimus-claude --skill pr --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
- Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.
- You can call itInvoke it directly when you want it.
- Slash command
/pr
Context preview
The summary Claude sees to decide when to auto-load this skill.
Creates or updates a pull request (GitHub) or merge request (GitLab) for the current branch in the Conventional PR format — intent, summary, changes, rationale, and test plan. Pushes the branch if needed (asks before any force-push) and captures the implementation conversation's
SKILL.md
pr.SKILL.mddescription: Creates or updates a pull request (GitHub) or merge request (GitLab) for the current branch in the Conventional PR format — intent, summary, changes, rationale, and test plan. Pushes the branch if needed (asks before any force-push) and captures the implementation conversation's intent into the PR description. Use when a feature branch is ready for review or to refresh an existing PR/MR description.
disable-model-invocation: true
Pull Request / Merge Request
This skill never commits working-tree changes — it only pushes existing commits and manages the PR/MR.
Step 1: Pre-flight
If the current directory has no `.git/` directory, read `$CLAUDE_PLUGIN_ROOT/skills/init/references/multi-repo-detection.md` and apply it. In a detected workspace:
- Filter to child repos on a non-default branch with commits ahead of the default branch (detect the default branch per `$CLAUDE_PLUGIN_ROOT/skills/pr/references/default-branch-detection.md`, run inside each repo). Warn and skip any repo whose default branch cannot be detected.
- 0 candidates → "No repositories in this workspace have branches with changes ready for a PR." Stop. 1 → announce which repo was detected and run Steps 2–7 inside it. Multiple → ask (AskUserQuestion): **All** or one specific repo.
- **All** → run Steps 2–7 per repo sequentially (show a `## <repo-name>` heading before Step 2; run all commands inside that repo). Any per-repo stop condition (unknown platform, CLI cancel, update-flow Cancel, …) stops only that repo — record the outcome for the Step 8 summary and continue with the next. Only the gates below halt the whole run.
**Verify git state** (stop gates):
1. Not inside a git repository → inform the user and stop. 2. Default-branch detection (reference above) fails → "Could not detect the default branch. Ensure `origin` is configured and has been fetched." Stop. 3. On the default branch → "You're on the default branch (`<branch>`). Switch to a feature branch first." Stop.
Step 2: Platform Detection
Read `$CLAUDE_PLUGIN_ROOT/skills/pr/references/platform-detection.md` and apply the **Platform Detection Algorithm**. Unknown platform → inform the user and stop.
Step 3: CLI Availability
Apply the reference's **CLI Verification** section. If the CLI is missing, offer to install it per its **CLI Installation** section (ask: **Install** / **Cancel**). On Cancel or install failure → provide manual installation instructions and stop. Installed but unauthenticated → "Run `gh/glab auth login` to authenticate, then re-run `/optimus:pr`." Stop.
Step 4: Push and Existing PR/MR Check
If the branch is not on the remote (`git ls-remote --heads origin <branch>`): with no commits on the branch → "No commits on this branch yet. Commit your changes first." Stop. Otherwise `git push -u origin <branch>`.
If the branch is on the remote with unpushed commits, check divergence first: `git rev-list --count HEAD..origin/<branch>`
- Count `0` → fast-forward push: `git push origin <branch>`
- Count `> 0` → the remote has commits not in local history (typical after a rebase). NEVER plain-push. Ask (AskUserQuestion "Diverged branch"): **Force push** → run `git push --force-with-lease origin <branch>`; if the lease is rejected → "Force push rejected — the remote gained new commits since your last fetch. Review them before overwriting." Stop. **Cancel** → tell the user to reconcile and push manually, then re-run `/optimus:pr`. Stop.
Check for an existing PR/MR:
- **GitHub:** `gh pr view --json number,state,title,body,url,baseRefName 2>/dev/null`
- **GitLab:** `glab mr view --output json 2>/dev/null`
Open PR/MR → save its `baseRefName` / `target_branch` as the **target branch** and go to Step 6 (Update Flow). Closed/merged or none → Step 5 (Create Flow).
Step 5: Create Flow
Default branch: on GitHub, `gh repo view --json defaultBranchRef --jq '.defaultBranchRef.name'` is authoritative over Step 1's local detection (local `origin/HEAD` may be stale); on GitLab, use Step 1's detection.
Gather the branch's commits and diff vs `origin/<default-branch>`. No commits ahead → "This branch has no changes compared to `<default-branch>`." Stop.
Detect intent context
Classify into one of three states before generating content:
1. **Conversation context** — this conversation implemented the branch: Edit/Write/NotebookEdit calls touched files in the diff, or the conversation discussed the problem, design decisions, or non-goals. A `## TDD Summary` block with `### Behaviors Implemented` (literal, case-sensitive — emitted by `/optimus:tdd`) is a strong state-1 signal; apply the population rule below. 2. **Existing PR body has `## Intent`** (Update Flow only — see the detection rule in the template). 3. **None** — when uncertain, prefer this state over fabricating. Ask (AskUserQuestion "Intent capture"): **Add intent now** → have the user reply with Problem / Scope / Non-goals / Key decisions on separate lines in a plain message (blank lines skip a sub-field); **Skip** → omit the section entirely, no stub.
Suppress the state-3 prompt in states 1 and 2.
Generate content
Read `$CLAUDE_PLUGIN_ROOT/skills/pr/references/pr-template.md` and generate a title and body. Populate `## Intent` from the conversation (state 1) or the user's reply (state 3), including only sub-fields the source actually answers.
**TDD Summary population rule** — when the handoff signal fired, fill the body from the summary block:
- **Intent → Scope**: one bullet per `### Behaviors Implemented` row with Status `✓ Complete`, description verbatim.
- **Intent → Non-goals**: one bullet per `Not started` row; omit if none.
- **Intent → Key decisions**: refactor-step reasoning captured in the conversation; omit rather than invent.
- **Intent → Problem**: quote/summarize the spec or JIRA task file loaded in the conversation, else the initiating brief.
- **Test plan**: one verification item per `✓ Complete` row plus the project's test command; if
Read more
description: Creates or updates a pull request (GitHub) or merge request (GitLab) for the current branch in the Conventional PR format — intent, summary, changes, rationale, and test plan. Pushes the branch if needed (asks before any force-push) and captures the implementation conversation's intent into the PR description. Use when a feature branch is ready for review or to refresh an existing PR/MR description. disable-model-invocation: true
Pull Request / Merge Request
This skill never commits working-tree changes — it only pushes existing commits and manages the PR/MR.
Step 1: Pre-flight
If the current directory has no `.git/` directory, read `$CLAUDE_PLUGIN_ROOT/skills/init/references/multi-repo-detection.md` and apply it. In a detected workspace:
- Filter to child repos on a non-default branch with commits ahead of the default branch (detect the default branch per `$CLAUDE_PLUGIN_ROOT/skills/pr/references/default-branch-detection.md`, run inside each repo). Warn and skip any repo whose default branch cannot be detected.
- 0 candidates → "No repositories in this workspace have branches with changes ready for a PR." Stop. 1 → announce which repo was detected and run Steps 2–7 inside it. Multiple → ask (AskUserQuestion): **All** or one specific repo.
- **All** → run Steps 2–7 per repo sequentially (show a `## <repo-name>` heading before Step 2; run all commands inside that repo). Any per-repo stop condition (unknown platform, CLI cancel, update-flow Cancel, …) stops only that repo — record the outcome for the Step 8 summary and continue with the next. Only the gates below halt the whole run.
**Verify git state** (stop gates):
1. Not inside a git repository → inform the user and stop. 2. Default-branch detection (reference above) fails → "Could not detect the default branch. Ensure `origin` is configured and has been fetched." Stop. 3. On the default branch → "You're on the default branch (`<branch>`). Switch to a feature branch first." Stop.
Step 2: Platform Detection
Read `$CLAUDE_PLUGIN_ROOT/skills/pr/references/platform-detection.md` and apply the **Platform Detection Algorithm**. Unknown platform → inform the user and stop.
Step 3: CLI Availability
Apply the reference's **CLI Verification** section. If the CLI is missing, offer to install it per its **CLI Installation** section (ask: **Install** / **Cancel**). On Cancel or install failure → provide manual installation instructions and stop. Installed but unauthenticated → "Run `gh/glab auth login` to authenticate, then re-run `/optimus:pr`." Stop.
Step 4: Push and Existing PR/MR Check
If the branch is not on the remote (`git ls-remote --heads origin <branch>`): with no commits on the branch → "No commits on this branch yet. Commit your changes first." Stop. Otherwise `git push -u origin <branch>`.
If the branch is on the remote with unpushed commits, check divergence first: `git rev-list --count HEAD..origin/<branch>`
- Count `0` → fast-forward push: `git push origin <branch>`
- Count `> 0` → the remote has commits not in local history (typical after a rebase). NEVER plain-push. Ask (AskUserQuestion "Diverged branch"): **Force push** → run `git push --force-with-lease origin <branch>`; if the lease is rejected → "Force push rejected — the remote gained new commits since your last fetch. Review them before overwriting." Stop. **Cancel** → tell the user to reconcile and push manually, then re-run `/optimus:pr`. Stop.
Check for an existing PR/MR:
- **GitHub:** `gh pr view --json number,state,title,body,url,baseRefName 2>/dev/null`
- **GitLab:** `glab mr view --output json 2>/dev/null`
Open PR/MR → save its `baseRefName` / `target_branch` as the **target branch** and go to Step 6 (Update Flow). Closed/merged or none → Step 5 (Create Flow).
Step 5: Create Flow
Default branch: on GitHub, `gh repo view --json defaultBranchRef --jq '.defaultBranchRef.name'` is authoritative over Step 1's local detection (local `origin/HEAD` may be stale); on GitLab, use Step 1's detection.
Gather the branch's commits and diff vs `origin/<default-branch>`. No commits ahead → "This branch has no changes compared to `<default-branch>`." Stop.
Detect intent context
Classify into one of three states before generating content:
1. **Conversation context** — this conversation implemented the branch: Edit/Write/NotebookEdit calls touched files in the diff, or the conversation discussed the problem, design decisions, or non-goals. A `## TDD Summary` block with `### Behaviors Implemented` (literal, case-sensitive — emitted by `/optimus:tdd`) is a strong state-1 signal; apply the population rule below. 2. **Existing PR body has `## Intent`** (Update Flow only — see the detection rule in the template). 3. **None** — when uncertain, prefer this state over fabricating. Ask (AskUserQuestion "Intent capture"): **Add intent now** → have the user reply with Problem / Scope / Non-goals / Key decisions on separate lines in a plain message (blank lines skip a sub-field); **Skip** → omit the section entirely, no stub.
Suppress the state-3 prompt in states 1 and 2.
Generate content
Read `$CLAUDE_PLUGIN_ROOT/skills/pr/references/pr-template.md` and generate a title and body. Populate `## Intent` from the conversation (state 1) or the user's reply (state 3), including only sub-fields the source actually answers.
**TDD Summary population rule** — when the handoff signal fired, fill the body from the summary block:
- **Intent → Scope**: one bullet per `### Behaviors Implemented` row with Status `✓ Complete`, description verbatim.
- **Intent → Non-goals**: one bullet per `Not started` row; omit if none.
- **Intent → Key decisions**: refactor-step reasoning captured in the conversation; omit rather than invent.
- **Intent → Problem**: quote/summarize the spec or JIRA task file loaded in the conversation, else the initiating brief.
- **Test plan**: one verification item per `✓ Complete` row plus the project's test command; if
Showing the first part of this file.
Primes your project for peak Claude Code performance
Other skills on optimus.
- /brainstorm
Runs a structured design conversation — clarifies intent, proposes 2-3 approaches with trade-offs, iterates the design — and writes a user-approved engineering spec to docs/specs/ that /optimus:tdd auto-detects. No implementation happens until the spec is approved. With the
Open skill - /code-review
Reviews local changes, an open PR/MR, or a branch diff against the project's own coding guidelines, running parallel agents that each cover a different lens — bugs, security, guidelines, architecture, simplification, plus test coverage and API contracts when relevant. Excludes
Open skill - /commit
Stages, commits, and optionally pushes local changes with a Conventional Commits message — always previews and confirms first, and offers a feature branch on protected branches. Modes: "suggest" proposes a message without committing (read-only); "branch [description]" creates
Open skill - /deep
Runs an iterative auto-fix loop on a chosen target — review, refactor, or coverage — dispatching the base skill into fresh subagent contexts per iteration, applying fixes automatically without per-change approval, running tests with bisection on failure, and
Open skill - /gauntlet
Runs a Gauntlet Loop: turns an ambitious goal and optional quality references into a minimal builder/critic prompt judged against a concrete comparison bar, confirms with the user, then executes it as the lead agent until the output beats the bar or the user stops the run — or
Open skill - /handoff
Compacts the current conversation into one self-contained, tool-agnostic handoff document at docs/handoffs/<slug>.md so any fresh agent or teammate can resume the work from that file alone. References pushed artifacts by path or URL, inlines anything not on the remote, and
Open skill

