skills/ah-create-pr/SKILL.md
Create or update a GitHub Pull Request with the "ah" prefix. Use for "ah create pr", "ah create pull request", or "ah pr". Analyzes the current branch, runs quality checks, and generates a PR with summary, changes, tests, and linked issues. Updates an existing open PR via `gh pr edit`, otherwise creates one via `gh pr create`.
npx skillsauth add arinhubcom/arinhub ah-create-prInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Analyze current branch and create or update a well-structured GitHub Pull Request. If an open PR already exists for the current branch, update it instead of creating a duplicate. The diff against the base branch is the single source of truth for all PR content.
main, develop). If the user did not provide it, STOP and ask before proceeding (or, when autonomous, fail fast with a clear error). Never assume or default to any branch.42, #42). If not provided by the user, do not infer it from the branch name -- omit issue references from the PR.bug,urgent, feature,frontend). If not provided by the user, auto-detect labels in step 2.autonomous to run non-interactively. Every point that would otherwise STOP and ask the user (missing base branch, gh auth failure, uncommitted changes, failed quality checks, base-branch mismatch on an existing PR) instead fails fast with a clear error -- the PR is not created and the caller (e.g. ah-workflow) escalates. The skill also suppresses its own Step 5 user report (returns only the PR URL + status). Default off (interactive). Set by ah-workflow / ah-finalize-code.Determine autonomy: if the user passed autonomous, set AUTONOMOUS=1, else AUTONOMOUS=0. When AUTONOMOUS=1, never prompt the user -- every STOP/ask below becomes a fail-fast error.
Verify GitHub CLI authentication and check for uncommitted changes before proceeding.
gh auth status
# Warn if there are uncommitted changes that won't be included in the PR
git status --porcelain
If gh auth status fails, stop and ask the user to authenticate with gh auth login. If there are uncommitted changes (staged or unstaged), warn the user that these changes will not be included in the PR and ask whether to continue or wait. When AUTONOMOUS=1, do not ask: fail fast on gh auth failure, and fail fast if there are uncommitted changes (the caller must hand over a clean, committed tree).
Run quality checks to catch issues before creating the PR. If any check fails, report the failure and ask the user how to proceed. When AUTONOMOUS=1, do not ask -- fail fast with the failing check output so the workflow escalates instead of creating a PR on a broken build.
pnpm preflight
pnpm preflight:build
Also compare .env* files in the repo root: identify missing keys across them and flag any security risks or naming inconsistencies.
If the user did not provide a base branch, STOP and ask for it before proceeding.
BASE_BRANCH=<user-provided base branch>
CURRENT_BRANCH=$(git branch --show-current)
# Compute merge base for reliable diffing (works even if origin isn't fetched)
git fetch origin "${BASE_BRANCH}" --quiet
MERGE_BASE=$(git merge-base "origin/${BASE_BRANCH}" HEAD)
# Diff against merge base. Lead with --stat (cheap summary); write the full diff
# to a file instead of into context, and read hunks from it only as needed.
git diff "${MERGE_BASE}" --stat
DIFF_FILE=$(mktemp /tmp/pr-diff.XXXXXX.patch)
git diff "${MERGE_BASE}" > "${DIFF_FILE}"
echo "Full diff: ${DIFF_FILE} ($(wc -l < "${DIFF_FILE}") lines)"
# Commit history on this branch
git log "${MERGE_BASE}"..HEAD --no-decorate
# Branch tracking status
git status -sb
# Check for existing open PR on this branch (single API call)
EXISTING_PR=$(gh pr list --head "${CURRENT_BRANCH}" --state open --json number,url,baseRefName --jq '.[0]')
EXISTING_PR_NUMBER=$(echo "${EXISTING_PR}" | jq -r '.number // empty')
EXISTING_PR_URL=$(echo "${EXISTING_PR}" | jq -r '.url // empty')
EXISTING_PR_BASE=$(echo "${EXISTING_PR}" | jq -r '.baseRefName // empty')
If an open PR already exists for the current branch, the skill updates it in Step 4 instead of creating a new one. If the existing PR targets a different base branch than the one the user provided, warn the user and ask how to proceed before continuing. When AUTONOMOUS=1, do not ask -- fail fast with a clear error describing the base-branch mismatch.
If the user provided an issue number, use it for the PR references. Do not infer issue numbers from the branch name or commit messages.
If the user provided labels, use them as-is. Otherwise, auto-detect labels by analyzing:
gh label list --limit 100 --json name,description
feat, fix, refactor, docs, test, perf, chore) to matching labels (e.g., feat -> feature/enhancement, fix -> bug/bugfix, docs -> documentation)apps/app-name/ -> app-name, changes in src/api/ -> api/backend, changes in src/components/ -> frontend/ui, changes in infra/ -> infrastructure)Read the PR body template from references/pr-body.md and follow its structure and rules exactly.
Title format: <type>: <brief description> -- keep under 70 characters.
feat, fix, refactor, chore, test, docs, perfapp-name/feat: descriptionDraft mode: Create as draft if any of these apply:
Push the branch to the remote if it has not been pushed yet or is behind:
git push -u origin ${CURRENT_BRANCH}
EXISTING_PR_NUMBER is set)Update the existing PR with the newly generated content:
gh pr edit ${EXISTING_PR_NUMBER} \
--title "<type>: <brief description>" \
--add-label "<label1>" --add-label "<label2>" \
--body "$(cat <<'EOF'
<PR body from references/pr-body.md>
EOF
)"
Omit --add-label flags entirely if no labels were determined.
Create a new PR (include --label flags for each determined label):
gh pr create \
--base "${BASE_BRANCH}" \
--head "${CURRENT_BRANCH}" \
--title "<type>: <brief description>" \
--label "<label1>" --label "<label2>" \
--body "$(cat <<'EOF'
<PR body from references/pr-body.md>
EOF
)"
Omit --label flags entirely if no labels were determined.
When AUTONOMOUS=1, skip this user-facing report; return only the PR URL and a one-line status (created/updated) to the caller.
Interactive mode (AUTONOMOUS=0) -- after creating or updating the PR, provide:
Before submitting the PR, verify:
When AUTONOMOUS=1, every "STOP and ask" / "prompt the user" below becomes a fail-fast error (clear message, no PR created) so the caller can escalate.
development
Use when: (1) building a skill/command that orchestrates other skills by spawning subagents, (2) a delegated sub-skill reads git working-tree state (e.g. `git branch --show-current`) instead of taking it as an argument, (3) a sub-skill is supposed to "reflect on this session" / capture session learnings (like revise-claude-md) but runs in a subagent, (4) base branch ends up wrong or a session-reflection step sees an empty/trivial context. Keywords: orchestrator, subagent isolated context, git branch --show-current, base branch checkout, revise-claude-md, this session.
development
Run the full ArinHub feature-development pipeline end-to-end with the "ah" prefix. Use for "ah workflow", "ah run workflow", "ah full workflow", a GitHub issue URL to take from issue to PR, or any request to run the whole ah pipeline at once. Takes a feature description + issue number + base branch, OR a GitHub issue URL (resolved via references/resolve-gh-issue.md). Sequentially launches subagents: ah-create-prd-adr -> ah-create-tasks -> ah-implement-tasks -> optional ah-check-qa verification -> ah-finalize-code (creates the PR), anchored with /goal and guarded by retry + escalation.
testing
Verify that a PR or local changes fully implement requirements from a linked GitHub issue, with the "ah" prefix. Use for "ah verify requirements coverage", "ah verify requirements coverage issue 42", "ah verify requirements coverage PR 123", or both ("PR 123, issue 42").
development
Submit a completed code review with line-specific comments and suggestions to a GitHub PR, with the "ah" prefix. Use for "ah submit code review 123".