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.Save the current branch name for later use.
git status --porcelain to check for uncommitted changes (staged, unstaged, and untracked).mainmaingit 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.