Automate PR creation and merging. Commits uncommitted changes, creates a PR targeting main, waits for CI/CD checks, and squash merges on success. Triggers on: ship it, ship this, create and merge pr, ship pr, merge to main.
Automate the full PR lifecycle: commit changes, create a PR, wait for CI/CD, and squash merge into main.
Follow each step sequentially. Stop and report to the user if any step fails.
Run these checks before anything else. If any fail, stop and tell the user why.
git branch --show-current. If in detached HEAD state, stop — tell the user to check out a named branch.git remote -v. If no remote is configured, stop — tell the user to add a remote.gh auth status. If not authenticated, stop — tell the user to run gh auth login.pnpm lint. If there are any errors or warnings, fix them before proceeding. Fixing means applying best-practice corrections that honor the intent of the rule — never suppress a rule, add a disable comment, or weaken a configuration to make a warning disappear. If you are unfamiliar with the rule, look up its documentation to understand why it exists and what the correct fix is. It does not matter whether the issue was introduced by current work or pre-existing — we do not leave lint errors or warnings in the codebase.pnpm typecheck. If there are errors, fix them at the root cause. The same principles apply: understand the type system's complaint, fix the root cause, never use @ts-ignore, @ts-expect-error, any casts, or other suppressions to silence the error.pnpm build. If the build fails, diagnose and fix the root cause.Skip condition for quality gates (items 4–6): These steps may only be skipped if git status --porcelain produces no output AND the checks already passed earlier in the same session with no intervening file changes. When in doubt, run them.
Save the current branch name for later use.
git status --porcelain to check for uncommitted changes (staged, unstaged, and untracked).main, skip to Step 3. If the working tree is clean and on main, stop — there is nothing to ship.git add <file1> <file2> ... with explicit file paths. Never use git add -A or git add ..git diff --cached --stat and git diff --cached to understand the changes.main, create a feature branch before committing (see Step 2b below).This step is called from Step 2.6 when the current branch is main. The branch must be created before the commit so that local main stays clean and avoids divergence after the PR is squash-merged.
feat/add-user-validation, fix/null-pointer-in-parser). Use kebab-case with a conventional prefix (feat/, fix/, chore/, refactor/, etc.).git checkout -b <branch-name> to create and switch to the new branch. Staged changes carry over to the new branch.git push -u origin HEAD to push the branch to the remote.gh pr view --json number,url 2>/dev/null.
git log main..HEAD --oneline.gh pr create --base main --title "<title>" --body "<body>".gh pr checks to get check status.gh pr merge --squash --delete-branch to squash merge and delete the remote branch.git checkout main.git pull origin main to get the merged changes.git branch -d <branch-name> (using the branch name saved in Step 1).main stays clean.gh.@ts-ignore, cast to any, or weaken configuration. Look up unfamiliar rules to understand the intent before fixing.