Creates GitHub pull requests with pre-flight validation, conventional title formatting, and structured summary generation. Runs parallel checks (tests, lint, type-check, security) before opening. Supports feature, bugfix, refactor, and hotfix PR types with milestone assignment via gh CLI. Use when opening PRs or submitting code for review.
Commandmedium
Invoke
/ork:create-pr
Create Pr Creates GitHub pull requests with pre-flight validation, conventional title formatting, and structured summary generation. Runs parallel checks (tests, lint, type-check, security) before opening. Supports feature, bugfix, refactor, and hotfix PR types with milestone assignment via gh CLI. Use when opening PRs or submitting code for review.
/ork:create-pr/ork:create-pr "Add user authentication"
CC ≥ 2.1.119 multi-host note (M122): PR creation works against GitHub, GitLab, Bitbucket, and GitHub Enterprise. Detect the target host from the configured remote (git remote -v) and branch on the host family for the right CLI:
Host family
CLI
github / github-enterprise
gh pr create (with GH_HOST=<host> for GHE)
gitlab / gitlab-self
glab mr create
bitbucket
bb pr create
Custom enterprise URLs: prUrlTemplate setting (see src/skills/configure/ and src/skills/chain-patterns/references/pr-from-platform.md).
TITLE = "$ARGUMENTS" # Optional PR title, e.g., "Add user authentication"# If provided, use as PR title. If empty, generate from branch/commits.# $ARGUMENTS[0] is the first token (CC 2.1.59 indexed access)
If claude ultrareview --help succeeds, optionally run it before opening the PR and surface findings in the PR body's ## Pre-flight section. The CLI subcommand returns structured --json output that can be filtered to high/medium severity for the body and full results posted as a follow-up comment.
if claude ultrareview --help >/dev/null 2>&1; then claude ultrareview "origin/$BASE..HEAD" --json > /tmp/ultra.json # Bucket by severity, put HIGH in PR body, MEDIUM/LOW as commentfi
Skip on CC < 2.1.120 (the subcommand doesn't exist there). The .github/workflows/ultrareview.yml workflow runs the same command on PR open as a backstop, so this pre-flight is purely a feedback-loop accelerant.
BEFORE doing ANYTHING else, create tasks to track progress:
# 1. Create main task IMMEDIATELYTaskCreate(subject="Create PR for {branch}", description="PR creation with validation", activeForm="Creating pull request")# 2. Create subtasks for each phaseTaskCreate(subject="Pre-flight checks", activeForm="Running pre-flight checks") # id=2TaskCreate(subject="Run validation agents", activeForm="Validating with agents") # id=3TaskCreate(subject="Run local tests", activeForm="Running local tests") # id=4TaskCreate(subject="Create PR on GitHub", activeForm="Creating GitHub PR") # id=5TaskCreate(subject="Generate PR playground", activeForm="Generating playground") # id=6# 3. Set dependencies for sequential phasesTaskUpdate(taskId="3", addBlockedBy=["2"]) # Agents need pre-flight to passTaskUpdate(taskId="4", addBlockedBy=["3"]) # Tests run after agent validationTaskUpdate(taskId="5", addBlockedBy=["4"]) # PR creation needs tests to passTaskUpdate(taskId="6", addBlockedBy=["5"]) # Playground after PR (needs title/summary)# 4. Before starting each task, verify it's unblockedtask = TaskGet(taskId="2") # Verify blockedBy is empty# 5. Update status as you progressTaskUpdate(taskId="2", status="in_progress") # When startingTaskUpdate(taskId="2", status="completed") # When done — repeat for each subtask
Before creating the PR, check for the branch activity ledger at .claude/agents/activity/\{branch\}.jsonl.
If it exists, generate agent attribution sections for the PR body:
Read .claude/agents/activity/\{branch\}.jsonl (one JSON object per line, full branch history)
Deduplicate by agent type (keep the entry with longest duration for each agent)
Generate the following sections to append to the PR body:
Badge row: shields.io badges for agent count, tests generated, vulnerabilities
Agent Team Sheet: Markdown table with Agent, Role, Stage (Lead/⚡ Parallel/Follow-up), Time
Credits Roll: Collapsible <details> section grouped by execution stage (Lead/Parallel/Follow-up)
If the ledger doesn't exist or is empty, skip this step — create PR normally.
CC 2.1.183 — attribution.sessionUrl: Web and Remote Control sessions append a claude.ai session link to the PR body. For public repos where that link should not be exposed, set attribution.sessionUrl: false (/config attribution.sessionUrl=false) before creating the PR. ork's agent-attribution sections above are independent of this setting.
Follow Read("$\{CLAUDE_SKILL_DIR\}/rules/pr-title-format.md") and Read("$\{CLAUDE_SKILL_DIR\}/rules/pr-body-structure.md"). Use HEREDOC pattern from Read("$\{CLAUDE_SKILL_DIR\}/references/pr-body-templates.md").
Include agent attribution sections (from Phase 3b) after the Test Plan section in the PR body.
TYPE="feat" # Determine: feat/fix/refactor/docs/test/choregh pr create --base dev \ --title "$TYPE(#$ISSUE): Brief description" \ --body "$(cat <<'EOF'## Summary[1-2 sentence description]## Changes- [Change 1]- [Change 2]## Test Plan- [x] Unit tests pass- [x] Lint/type checks pass## Agent Team Sheet| Agent | Role | Stage | Time ||-------|------|-------|------|| 🏗️ **backend-system-architect** | API design | Lead | 2m14s || 🛡️ **security-auditor** | Dependency audit | ⚡ Parallel | 0m42s || 🧪 **test-generator** | 47 tests, 94% coverage | ⚡ Parallel | 2m01s |<details><summary><strong>🎬 Agent Credits</strong> — 3 agents collaborated on this PR</summary>**Lead**- 🏗️ **backend-system-architect** — API design (2m14s)**⚡ Parallel** (ran simultaneously)- 🛡️ **security-auditor** — Dependency audit (0m42s)- 🧪 **test-generator** — 47 tests, 94% coverage (2m01s)---<sub>Orchestrated by <a href="https://github.com/yonatangross/orchestkit">OrchestKit</a> — 3 agents, 4m57s total</sub></details>Closes #$ISSUE---Generated with [Claude Code](https://claude.com/claude-code)EOF)"
First classify the archetype — a feature PR must not ship as a flat dashboard.
Read("$\{CLAUDE_PLUGIN_ROOT\}/skills/shared/rules/playground-visual-standard.md") and apply its §0 routing rule:
Visual PR (adds/changes a user-facing feature, flow, or a prioritization/decision surface) →
USER-STORY PLAYER or DECISION BOARD. Build to the standard: adapt the matching exemplar at
$\{CLAUDE_PLUGIN_ROOT\}/skills/shared/assets/playground-exemplars/ (user-story-player.template.html
or decision-board.template.html), and bring full design firepower (the frontend-design skill /
the ork:frontend-ui-developer agent). When delegating to playground:playground, brief it with the
archetype + persona + tokens — never hand it a pre-built HTML blob.
Non-visual PR (infra/CI/refactor/config/docs) → DASHBOARD — the default summary below is fine.
BRANCH=$(git branch --show-current)BRANCH_DIR = BRANCH.replace("/", "--") # feat/foo → feat--foo# Invoke the playground skill with a summary of the PR changes.# For a VISUAL PR, set archetype/persona/exemplar per playground-visual-standard.md instead of this default.Skill("playground:playground", args=f""" {PR_TITLE} — visualize the key changes in this PR. Archetype: <user-story-player | decision-board | dashboard> per playground-visual-standard.md §0. For visual archetypes: follow that standard's tokens/glass/motion and adapt the matching exemplar. Show: architecture/data flow, before/after, key components changed; presets for the main change areas. Dark glass theme, OrchestKit brand accents.""")# The playground skill writes to a temp path — move it to the correct location# Ensure file lands at: docs/{branch-dir}/<name>.htmlBash(f"mkdir -p docs/{BRANCH_DIR}")Bash(f"mv /tmp/*.html docs/{BRANCH_DIR}/playground.html 2>/dev/null || true")# Force-add (docs/feat--*/ is gitignored by design)Bash(f"git add -f docs/{BRANCH_DIR}/")Bash(f'git commit -m "docs: add PR playground for {BRANCH}"')Bash(f"git push origin {BRANCH}")
Add a "Live Preview" section to the PR body:
## Live Preview**[Open Interactive Playground](https://htmlpreview.github.io/?https://github.com/{OWNER}/{REPO}/blob/{BRANCH}/docs/{BRANCH_DIR}/playground.html)**
Why required: CI Stage 1d (playground-check) blocks merge if docs/\{branch-dir\}/*.html is missing. Bot PRs (dependabot, release-please) are exempt.
# Guard: Skip cron in headless/CI (CLAUDE_CODE_DISABLE_CRON)# if env CLAUDE_CODE_DISABLE_CRON is set, run a single check insteadCronCreate( schedule="*/5 * * * *", prompt="Check CI for PR #{pr_number}: gh pr checks {pr_number} --repo {repo}. All pass → CronDelete this job, report success. Any fail → alert with failure details.")
Run validation locally — Don't spawn agents for lint/test
All content goes to GitHub — PR body via gh pr create --body
Keep it simple — One command to create PR
Respect the gh rate-limit hint (CC ≥ 2.1.116) — when the Bash tool surfaces a GitHub rate-limit hint after a gh call (e.g. in a /loop 5m gh pr checks … watcher), stop the loop and wait for reset — do not blind-retry. See ork:github-operations for the full guidance.
Before claiming PR is ready, apply: Read("$\{CLAUDE_PLUGIN_ROOT\}/skills/shared/rules/verification-gate.md"). All tests must pass with fresh evidence. All CI checks green. No "should be fine."
If the AskUserQuestion picker stalls (schema break, not a CC input bug — orchestkit#1795, now guarded by tests/skills/structure/test-askuserquestion-schema.sh), set ORK_ASK_FALLBACK=text before starting CC. The lifecycle/ask-fallback-injector hook injects a reminder telling the assistant to pose options inline as a numbered list and ask the user to reply with the option number.
Always use Closes #N (not Fixes or Resolves) for consistency with CI auto-close
End body with Generated with [Claude Code](https://claude.com/claude-code) footer
Use --body "$(cat <<'EOF' ... EOF)" HEREDOC pattern for multi-line bodies
Keep Summary focused on "why" — the diff shows "what"
Test Plan checkboxes should reflect actual verification, not aspirational items
Incorrect:
## PRUpdated some files. Fixed the thing.
Correct:
## SummaryAdd JWT refresh token rotation to prevent token replay attacks.## Changes- Add refresh token rotation on each use- Store token family for replay detection- Add 7-day absolute expiry## Test plan- [x] Unit tests for token rotation- [x] Integration test for replay detectionCloses #456
Anti-patterns:
Empty PR body (even for tiny changes, include Summary + Test Plan)
Copy-pasting the full diff into the body
Generic "Updated files" without specifics
Unchecked test plan items (means tests were not actually run)
Reference: See references/pr-body-templates.md for full template examples.
Every PR creation must pass these checks before the gh pr create command runs.
Checklist (all must pass):
Branch check — Not on main or dev. Create a feature branch first.
Clean working tree — No uncommitted changes (git status --porcelain is empty). Commit or stash first.
Remote push — Branch exists on remote. Push with -u if needed.
Tests pass — Run the project's test suite. At minimum: unit tests with -x (fail fast).
Lint clean — No linting errors from the project's linter (ruff, eslint, etc.).
Type check clean — No type errors (mypy, tsc, pyright) if project uses type checking.
No secrets — No API keys, tokens, or credentials in the diff. Check with git diff --cached patterns.
Visual-style clean — PR title + body pass the Visual-Style lint (the CI check that has bitten non-bot PRs repeatedly). The body must use only the 12-glyph vocabulary; the classic trap is ✓/✗ (U+2713/U+2717) — use the white-check / red-X instead. Run the SAME engine CI runs, against your drafted title + body file, BEFORE gh pr create:
Clean here == clean in CI (both call bin/validate-visual-style.py), so it kills the red-CI round-trip.
Key rules:
Run checks locally, not via agents (faster, no token cost)
Fail fast: stop at first blocking error
For "Quick" PR type, skip validation steps 4-7 but always check 1-3
Report failures clearly with actionable fix instructions
Incorrect:
# Skip checks, create PR directly from main with uncommitted changesgh pr create --title "fix: login bug"# Result: PR from main branch, dirty working tree, CI fails
Correct:
# Run full preflight before creating PRgit status --porcelain # Must be emptygit branch --show-current # Must not be main/devnpm run lint && npm run typecheck # Must passnpm test -- --bail # Must passbin/check-pr-visual-style.sh --title "fix: login bug" --body-file /tmp/pr-body.md # Must passgh pr create --title "fix: login bug" # Now safe to create
Validation commands (adapt to project):
# Universal checksgit status --porcelain # Must be emptygit branch --show-current # Must not be main/dev# Python projectsruff format --check . && ruff check .pytest tests/unit/ -v --tb=short -x# Node projectsnpm run lint && npm run typechecknpm test -- --bail
Blocking vs warning:
Steps 1-3: BLOCK — Cannot proceed
Steps 4-6: BLOCK for Feature/Bug fix, WARN for Quick
Step 7 (secrets): ALWAYS BLOCK — No exceptions
Step 8 (visual-style): ALWAYS BLOCK — it is a hard CI gate (bypass only via the visual-style-override label, used sparingly)
Using Closes #N in the PR body auto-closes the issue when the PR merges to the default branch. This is handled by GitHub, not CI — but only works when merging to main/dev (the repository's default branch).
Before writing the PR body, review the full commit history:
BRANCH=$(git branch --show-current)ISSUE=$(echo "$BRANCH" | grep -oE '[0-9]+' | head -1)# See all commits on this branchgit log --oneline dev..HEAD# See overall diff statsgit diff dev...HEAD --stat# See full diff for PR body writinggit diff dev...HEAD
For Feature and Bug fix PRs, launch validation agents in parallel BEFORE creating the PR. All three agents run in ONE message using run_in_background=True.
Agent( subagent_type="ork:security-auditor", prompt="""Security audit for PR changes: 1. Check for secrets/credentials in diff 2. Dependency vulnerabilities (npm audit/pip-audit) 3. OWASP Top 10 quick scan Return: {status: PASS/BLOCK, issues: [...]} Scope: ONLY read files directly relevant to the PR diff. Do NOT explore the entire codebase. SUMMARY: End with: "RESULT: [PASS|WARN|BLOCK] - [N] issues: [brief list or 'clean']" """, run_in_background=True, max_turns=25)
Agent( subagent_type="ork:test-generator", prompt="""Test coverage verification: 1. Run test suite with coverage 2. Identify untested code in changed files Return: {coverage: N%, passed: N/N, gaps: [...]} Scope: ONLY read files directly relevant to the PR diff. Do NOT explore the entire codebase. SUMMARY: End with: "RESULT: [N]% coverage, [passed]/[total] tests - [status]" """, run_in_background=True, max_turns=25)
Agent( subagent_type="ork:code-quality-reviewer", prompt="""Code quality check: 1. Run linting (ruff/eslint) 2. Type checking (mypy/tsc) 3. Check for anti-patterns Return: {lint_errors: N, type_errors: N, issues: [...]} Scope: ONLY read files directly relevant to the PR diff. Do NOT explore the entire codebase. SUMMARY: End with: "RESULT: [PASS|WARN|FAIL] - [N] lint, [M] type errors" """, run_in_background=True, max_turns=25)