Get the FREE Ultimate OpenClaw Setup Guide →

pr

npx machina-cli add skill NorthShoreAutomation/trellis/pr --openclaw
Files (1)
SKILL.md
4.4 KB

User Input

$ARGUMENTS

You MUST consider the user input before proceeding (if not empty).

Create a pull request for the current branch.

Instructions

1. Verify Branch State

  1. Run git branch --show-current to get current branch name
  2. If empty (detached HEAD state): STOP and inform user they must checkout a branch first
  3. If on main/master: STOP and inform user they must be on a feature branch to create a PR
  4. Run gh pr view --json number,state,url to check if a PR already exists
    • If command succeeds with state "OPEN": STOP and inform user with the PR URL
    • If command succeeds with state "CLOSED" (not merged): Ask user if they want to reopen the existing PR or create a new one
    • If command succeeds with state "MERGED": Warn user the branch was already merged; suggest creating a new branch
    • If command fails with exit code 1 (no PR): Continue to create one
    • If command fails with other errors (auth, network, rate limit): STOP and inform user of the connectivity/auth issue

2. Check for Uncommitted Changes

  1. Run git status to see all staged and unstaged changes
  2. If there are uncommitted changes:
    • Ask user if they want to commit them before creating the PR
    • If yes, follow the commit process from /trellis:push (includes changelog updates)
    • If no, warn that uncommitted changes won't be in the PR

3. Sync Beads (if configured)

  1. If beads is configured (.beads/ directory exists and bd command available):
    • Run bd sync --from-main to pull latest beads updates
    • Run bd list --status=in_progress to see related issues for the PR description
    • If bd commands fail with "not a beads repository": Continue without beads
    • If bd commands fail with "database locked" or "merge conflict": Warn user to run bd sync manually before merging

4. Push to Remote

  1. Check if branch has an upstream: git rev-parse --abbrev-ref @{upstream} 2>/dev/null
  2. If no upstream, push with: git push -u origin $(git branch --show-current)
  3. If upstream exists, push with: git push
  4. If push fails: STOP and inform user with the error

5. Create Pull Request

  1. Analyze the commits and changes to draft a PR description:
    • Run git log main..HEAD --oneline for commit summary (use master if main doesn't exist)
    • Run git diff main..HEAD --stat for files changed
    • If beads in-progress issues were found in step 3, include them in Related Issues
  2. Determine if this should be a draft PR:
    • If user arguments include "draft" or "--draft", add --draft flag
    • Otherwise, create a regular PR
  3. Create the PR:
gh pr create --title "<title>" --body "$(cat <<'EOF'
## Summary
<!-- 1-3 bullet points describing the changes -->

## Changes
<!-- List of specific changes made -->

## Test Plan
<!-- How to test these changes -->

## Related Issues
<!-- Link to any related beads issues or GitHub issues -->
EOF
)" [--draft]
  1. Use a concise, descriptive title following conventional commit style when appropriate
  2. If user provided arguments (other than "draft"), incorporate them into the title or description
  3. If PR creation fails: STOP and inform user with the specific error message. Common failures:
    • "pull request already exists": Another PR was created between check and create
    • "required status check": Branch protection rules blocking PR creation
    • "permission denied": User lacks write access to repository

6. Report Success

  1. Run gh pr view --json url -q .url to get the PR URL
    • If this fails, inform user: "PR created but URL retrieval failed. Run gh pr view to see the PR."
  2. Display the PR URL to the user
  3. Inform user they can now:
    • Request reviews
    • Run /trellis:release when ready to merge and release

Important

  • Must be on a feature branch — will not create PR from main/master
  • One PR per branch — will not create duplicate PRs
  • Supports draft PRs — add "draft" to arguments to create a draft PR
  • Keep PR titles short and meaningful (50 chars or less if possible)
  • Do not include files that look like secrets (.env, credentials, etc.) without asking
  • If there are multiple unrelated changes, suggest splitting into separate PRs
  • NEVER use --force or --force-with-lease push unless explicitly requested by the user
  • Warn the user if they request a force push to main/master branches

Source

git clone https://github.com/NorthShoreAutomation/trellis/blob/main/skills/pr/SKILL.mdView on GitHub

Overview

This skill automates opening a pull request for your active feature branch. It validates branch state, checks for an existing PR, and composes a structured description so you can quickly solicit reviews and merge changes.

How This Skill Works

It identifies the active branch and its upstream, checks PR status with gh pr view, and pushes changes when needed. It then drafts and creates the PR with gh pr create, including a clear title and body and an optional --draft flag, and reports the resulting URL.

When to Use It

  • Open a PR for your current feature branch after finishing work on it.
  • Your branch is on main/master or detached HEAD; switch to a feature branch before creating a PR.
  • A PR does not already exist for this branch (no existing OPEN PR), so you can create one.
  • There are uncommitted changes you want included or staged for the PR.
  • Beads are configured and you want related issues included in the PR description.

Quick Start

  1. Step 1: Ensure you’re on a feature branch: git branch --show-current (don’t be on detached HEAD or on main).
  2. Step 2: Push if needed and create the PR: git push -u origin $(git branch --show-current) (or git push if upstream exists), then gh pr create --title <title> --body <body> [--draft].
  3. Step 3: Retrieve and share the PR URL: gh pr view --json url -q .url and provide it to reviewers.

Best Practices

  • Always work on a feature branch; do not create PRs from main.
  • Review and commit changes you intend to include before PR creation.
  • Provide a clear, conventional title and a structured body with test plans.
  • Include related beads issues in the PR description when applicable.
  • Verify upstream/push permissions and address any merge conflicts before PR creation.

Example Use Cases

  • Opening a PR for feature/authentication after implementing a login flow.
  • Draft PR for bugfix/timeout with the --draft flag while awaiting reviews.
  • PR includes Related Issues from beads to link related work.
  • Pushing to origin when there is no upstream, then creating the PR.
  • Sharing the OPEN PR URL with teammates after gh pr view.

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers