/optimus:prfrom optimus
Creates or updates a GitHub pull request or GitLab merge request for the current branch using Conventional PR format. Pushes the branch if needed and captures the implementation conversation's intent into the PR description.
Ships in optimus. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description, though model invocation is off: only you can start it.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
This skill never commits working-tree changes — it only pushes existing commits and manages the PR/MR.
If git rev-parse --is-inside-work-tree does not return true, read $CLAUDE_PLUGIN_ROOT/skills/init/references/multi-repo-detection.md and apply it. When it returns true, resolve the repository root with git rev-parse --show-toplevel, including in a linked worktree or subdirectory. In a detected workspace:
$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.## <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):
origin is configured and has been fetched." Stop.<branch>). Switch to a feature branch first." Stop.Read $CLAUDE_PLUGIN_ROOT/skills/pr/references/platform-detection.md and apply the Platform Detection Algorithm. Unknown platform → inform the user and stop.
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.
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>
0 → fast-forward push: git push origin <branch>> 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:
gh pr view --json number,state,title,body,url,baseRefName 2>/dev/nullglab mr view --output json 2>/dev/nullOpen 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).
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.
Classify into one of three states before generating content:
## TDD Summary block with ### Behaviors Implemented (literal, case-sensitive — emitted by /optimus:tdd) is a strong state-1 signal; apply the population rule below.## Intent (Update Flow only — see the detection rule in the template).Suppress the state-3 prompt in states 1 and 2.
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 a ## TDD Summary block is present, fill the body from the summary block:
### Behaviors Implemented row with Status ✓ Complete, description verbatim.Not started row, and per Skipped row with its reason and skipped test name; omit if none.✓ Complete row plus the project's test command; if a ### Coverage section with Before: / After: / Delta: lines is present, append one line Coverage: <Before> → <After> (<Delta>).Show the generated title and body under ## PR Preview (append — <repo-name> in a multi-repo run). Ask (AskUserQuestion): Create PR → proceed; Adjust → ask what to change, apply, and preview again.
Run mktemp ./pr-body-XXXXXX — a relative path, never /tmp (on Windows, Git Bash's /tmp is unresolvable by native gh.exe/glab.exe, which would silently submit an empty body). Write the body to the printed path with the Write tool, substitute that literal path for <body-file> below (shell variables do not persist between Bash calls), and rm -f <body-file> after the attempt.
gh pr create --title "<title>" --body-file <body-file> --base <default-branch>glab mr create --title "<title>" --description "$(cat <body-file>)" --target-branch <default-branch>PRs/MRs are created ready for review (not draft). Proceed to Step 7.
Show the existing PR/MR (number, title, URL, current body), then ask (AskUserQuestion "Update PR"):
## Intent preserved verbatim.## Intent preserved verbatim.## Intent section (or add one if missing); everything else untouched.Regenerate Intent only: re-detect intent context, treating the existing PR Intent as replaceable (the user opted in). Use conversation context when present; otherwise prompt directly for Problem / Scope / Non-goals / Key decisions in a plain reply (not the state-3 meta-prompt). Empty reply or all sub-fields blank → keep the existing Intent, report "No replacement Intent provided — existing ## Intent kept as-is. No changes will be made." and stop (do not enter Phase 3). Otherwise replace ## Intent in place (or insert it before ## Summary), skip Phases 1–2, and jump to Phase 3.
Phase 1 — fresh content. Gather commits and diff against the PR's saved target branch (not the repo default) and generate new content from the template. This is the authoritative content; do not present yet.
Phase 2 — preservation scan. Review the existing title and body for information that cannot be derived from the code changes:
## Intent — always preserve verbatim and re-insert before ## Summary. Never silently overwrite it with fresh inference. If conversation context also exists, the existing section still wins; add a note to the Phase 3 preview: "Existing ## Intent section preserved. The current conversation suggests possible updates — choose 'Regenerate Intent only' if you want to revise."## Test plan. When regenerating the title, carry issue references into the new title.## Intent and the conversation has no implementation context, the update must complete without any intent-related prompting — only the Phase 3 preview runs.Phase 3 — preview. If non-diff content was carried over, note it briefly above the preview. Ask (AskUserQuestion): Update → proceed; Adjust → apply changes and preview again.
Apply using the Step 5 temp-file pattern:
gh pr edit <number> --title "<title>" --body-file <body-file> (omit --title when keeping the title)glab mr update <number> --title "<title>" --description "$(cat <body-file>)"## PR/MR [Created / Updated] [— repo-name]
- URL: [url]
- Title: [title]
- Target: [target-branch]
In a multi-repo run, continue with the next repo (back to Step 2); hold all recommendations until every repo is done.
After a multi-repo run, show a combined table: Repo | PR/MR | Status (Created / Updated / Skipped (reason)) | URL.
Recommend /optimus:code-review in a fresh conversation for a quality review before merging — it gathers its own context from the PR description.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
pull-request, merge-request, github, gitlab, conventional-pr
19 skills in this plugin
/brainstormRuns 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 scaffold argument, creates docs/product/ steering skeletons instead (never overwrites, authors no content). Recommends /optimus:init first./code-reviewCode ReviewReviews local changes, an open PR/MR, or a branch diff for bugs, security issues, and violations of the project's own coding guidelines, through review lenses applied inline on a small diff or in parallel agents on a larger one. Excludes style and linter-catchable issues. Read-only: applies fixes or posts PR/MR comments only on explicit approval. For an iterative auto-fix loop, use /optimus:deep review./commitStages, 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 and switches to a conventionally named branch, never committing or altering local changes. Multi-repo aware./deepDeep ModeRuns 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 checkpoint-committing until convergence or the cap. Requires /optimus:init and a test command in .claude/CLAUDE.md./dreamDream — prune and consolidate auto-memoryPrunes and consolidates the project's auto-memory to keep it minimal — deletes stale, wrong, or redundant memories, merges overlapping ones into existing files, and trims the index. Strong bias against growth: never creates new memory files and never stores new facts. Verifies staleness against the current codebase, then presents the plan and asks before deleting. Requires Claude Code auto-memory; run periodically after heavy stretches of work./gauntletRuns a Gauntlet Loop: turns an ambitious goal into a builder/critic prompt judged against a concrete quality bar, confirms with the user, then leads the run until the output beats the bar or the user stops it — or exports a paste-ready /goal prompt for a fresh session. Use for long-horizon goals with an inspectable reference. Long-running; spawns many subagents, edits project files, and commits and pushes finished pieces to a feature branch.npx claudepluginhub oprogramadorreal/optimus-claude --plugin optimusOther plugins' skills for the same job