create-pr
The user likes the state of the code.
There are $git status --porcelain | wc -l | tr -d ' ' uncommitted changes.
The current branch is $git branch --show-current.
The target branch is origin/main.
$git rev-parse --abbrev-ref @{upstream} 2>/dev/null && echo "Upstream branch exists." || echo "There is no upstream branch yet."
Existing PR: $gh pr view --json number,title,url --jq '"#\(.number): \(.title) - \(.url)"' 2>/dev/null || echo "None"
The user requested a PR.
Follow these exact steps:
Phase 1: Review the code
- Review test coverage
- Check for silent failures
- Verify code comments are accurate
- Review any new types
- General code review
Phase 2: Create/Update PR
- Run
git diffto review uncommitted changes - Commit them. Follow any instructions the user gave you about writing commit messages.
- Push to origin.
- Use
git diff origin/main...to review the full PR diff - Check if a PR already exists for this branch:
- If PR exists:
- Draft/update the description in a temp file (e.g.
/tmp/pr-body.txt). - Update the PR body using the non-deprecated script:
./.agents/skills/create-pr/scripts/pr-body-update.sh --file /tmp/pr-body.txt
- Re-fetch the body with
gh pr view --json body --jq .bodyto confirm it changed.
- Draft/update the description in a temp file (e.g.
- If no PR exists: Use
gh pr create --base mainto create a new PR. Keep the title under 80 characters and the description under five sentences.
The PR description should summarize ALL commits in the PR, not just the latest changes.
Phase 3: Monitor CI and Address Issues
Note: Keep commands CI-safe and avoid interactive gh prompts. Ensure GH_TOKEN or GITHUB_TOKEN is set in CI.
- Watch CI status and feedback using the polling script (instead of running
ghin a loop):
- Run
./.agents/skills/create-pr/scripts/poll-pr.sh --triage-on-change --exit-when-green(polls every 30s for 10 mins). - If checks fail, use
gh pr checksorgh run listto find the failing run id, then:- Fetch the failed check logs using
gh run view <run-id> --log-failed - Analyze the failure and fix the issue
- Commit and push the fix
- Continue polling until all checks pass
- Fetch the failed check logs using
- Check for merge conflicts:
- Run
git fetch origin main && git merge origin/main - If conflicts exist, resolve them sensibly
- Commit the merge resolution and push
- Use the polling script output to notice new reviews and comments (avoid direct polling via
gh):
- If you need a full snapshot, run
./.agents/skills/create-pr/scripts/triage-pr.shonce. - If you need full context after the script reports a new item, fetch details once with
gh pr view --commentsorgh api .... - Address feedback:
- For bot reviews, read the review body and any inline comments carefully
- Address comments that are clearly actionable (bug fixes, typos, simple improvements)
- Skip comments that require design decisions or user input
- For addressed feedback, commit fixes with a message referencing the review/comment
Phase 4: Merge and Cleanup
-
Once CI passes and the PR is approved, ask the user if they want to merge the PR.
-
If the user confirms, merge the PR:
- Use
gh pr merge --squash --delete-branchto squash-merge and delete the remote branch
- Use
-
After successful merge, check if we're in a git worktree:
- Run:
[ "$(git rev-parse --git-common-dir)" != "$(git rev-parse --git-dir)" ] - If in a worktree: Use the ask user question tool (
request_user_input) to ask if they want to clean up the worktree. If yes, runwt remove --yes --forceto remove the worktree and local branch, then switch back to the main worktree. - If not in a worktree: Just switch back to main with
git checkout main && git pull
- Run:
Completion
Report the final PR status to the user, including:
- PR URL
- CI status (passed/merged)
- Any unresolved review comments that need user attention
- Cleanup status (worktree removed or branch switched)
If any step fails in a way you cannot resolve, ask the user for help.
More from cartridge-gg/docs
controller-setup
Integrate Cartridge Controller wallet into Starknet applications. Use when setting up Controller for the first time, installing packages, configuring chains/RPC endpoints, or troubleshooting basic integration issues. Covers installation, Controller instantiation, ControllerConnector vs SessionConnector choice, chain configuration, and package compatibility.
69controller-sessions
Configure session keys and policies for Cartridge Controller to enable gasless, pre-approved transactions. Use when defining contract interaction policies, setting spending limits, configuring signed message policies, or implementing error handling for session-based transactions. Covers SessionPolicies type, policy definitions, verified sessions, and error display modes.
68controller-react
Integrate Cartridge Controller into React applications using starknet-react. Use when building React/Next.js web apps with Controller, setting up StarknetConfig provider, using hooks like useConnect/useAccount, or implementing wallet connection components. Covers ControllerConnector setup, provider configuration, and transaction execution patterns.
67controller-signers
Configure authentication methods for Cartridge Controller including passkeys, social login, and external wallets. Use when implementing user authentication, adding multiple signers for account recovery, customizing signup options, or integrating external wallets like MetaMask or Phantom. Covers WebAuthn passkeys, Google/Discord/Twitter OAuth, wallet connections, and dynamic authentication flows.
65controller-backend
Integrate Cartridge Controller into backend services using Node.js, Rust, or headless mode. Use when building server-side applications, game backends, automated bots, or any non-browser environment that needs to execute Starknet transactions. Covers SessionProvider for Node.js, Rust SDK setup, and headless Controller with custom signing keys.
61slot-vrng
Integrate Cartridge's verifiable random number generator (vRNG) into onchain games.
59