From ac-git
Creates GitHub pull requests via CLI after authenticating user, validating branches, and checking for uncommitted changes. Use /pull-request or keywords like 'pull request'.
How this skill is triggered — by the user, by Claude, or both
Slash command
/ac-git:pull-requestThis skill is limited to the following tools:
The summary Claude sees in its skill listing — used to decide when to auto-load this skill
Creates a comprehensive GitHub Pull Request with authentication validation and structured documentation.
Creates a comprehensive GitHub Pull Request with authentication validation and structured documentation.
/pull-request [target_branch] [gh_user]
Arguments:
target_branch: Base branch for PR (default: main)gh_user: Expected GitHub username (default: $GH_USER env var)Examples:
/pull-request # Uses main, $GH_USER
/pull-request master # Target master branch
/pull-request main my-username # Explicit user override
INSTRUCTION: Verify GitHub CLI authentication before any other operation.
ROOT=$(git rev-parse --show-toplevel)
BRANCH=$(git rev-parse --abbrev-ref HEAD)
# Get authenticated user
echo "Checking GitHub authentication..."
GH_AUTH_OUTPUT=$(gh auth status 2>&1)
echo "$GH_AUTH_OUTPUT"
# Extract authenticated username
AUTH_USER=$(echo "$GH_AUTH_OUTPUT" | grep -oE "Logged in to github.com account [^ ]+ " | sed 's/Logged in to github.com account //' | tr -d ' ' || echo "")
# Alternative extraction if format differs
if [ -z "$AUTH_USER" ]; then
AUTH_USER=$(echo "$GH_AUTH_OUTPUT" | grep -oE "account [^(]+" | head -1 | sed 's/account //' | tr -d ' ')
fi
echo "Authenticated as: $AUTH_USER"
Validation Logic:
AUTH_USER from gh auth status outputgh_user argument provided -> use it$GH_USER env var set -> use itAUTH_USER with expected userERROR: GitHub authentication mismatch
- Authenticated as: <AUTH_USER>
- Expected user: <EXPECTED_USER>
Please run: gh auth login
Or switch accounts: gh auth switch
# Check not on protected branch
if [ "$BRANCH" = "master" ] || [ "$BRANCH" = "main" ]; then
echo "ERROR: Cannot create PR from protected branch: $BRANCH"
exit 1
fi
# Determine target branch
TARGET="${1:-main}" # Default to main
# Verify target exists on remote
if ! git -C "$ROOT" rev-parse --verify "origin/$TARGET" >/dev/null 2>&1; then
echo "ERROR: Target branch 'origin/$TARGET' does not exist"
echo "Available remote branches:"
git -C "$ROOT" branch -r | grep -v HEAD
exit 1
fi
# Check for uncommitted changes
if [ -n "$(git -C "$ROOT" status --porcelain)" ]; then
echo "WARNING: Uncommitted changes detected"
git -C "$ROOT" status --short
fi
echo "Fetching latest $TARGET from origin..."
git -C "$ROOT" fetch origin "$TARGET"
echo "Commits on this branch (since $TARGET):"
echo "========================================"
git -C "$ROOT" log "origin/$TARGET..HEAD" --oneline
echo ""
COMMITS_AHEAD=$(git -C "$ROOT" rev-list --count "origin/$TARGET..HEAD")
echo "Total commits: $COMMITS_AHEAD"
echo ""
echo "Files changed (summary):"
echo "========================"
git -C "$ROOT" diff "origin/$TARGET...HEAD" --stat
echo ""
echo "Detailed diff:"
echo "=============="
git -C "$ROOT" diff "origin/$TARGET...HEAD"
CWD_FROM_ROOT=${PWD#$ROOT/}
# Search for CHANGELOG files
for changelog in "CHANGELOG.md" "changelog.md" "CHANGES.md"; do
CHANGELOG_PATH="$CWD_FROM_ROOT/$changelog"
if git -C "$ROOT" ls-files "$CHANGELOG_PATH" 2>/dev/null | grep -q .; then
echo ""
echo "CHANGELOG found: $CHANGELOG_PATH"
echo "Recent entries:"
git -C "$ROOT" show "HEAD:$CHANGELOG_PATH" 2>/dev/null | head -80
break
fi
done
echo ""
echo "Remote tracking status:"
git -C "$ROOT" status -sb
INSTRUCTION: Analyze all gathered context to create a comprehensive PR.
Format: <type>(<scope>): <concise description>
Type Classification (from changes):
| Type | When to Use |
|---|---|
feat | New functionality |
fix | Bug fixes |
refactor | Code restructuring |
docs | Documentation only |
test | Test additions/fixes |
chore | Maintenance tasks |
perf | Performance improvements |
Scope: Derive scope from primary modified paths. Use consistent naming (e.g., component/subcomponent). Omit scope if changes span unrelated areas.
CRITICAL: Use this EXACT structure for the PR body.
## Summary
<1-3 sentence overview explaining WHAT this PR does and WHY>
<Bulleted list of key changes/improvements>
### Root Cause (if applicable)
<What problem was being solved - include error traces, user reports, or investigation findings>
### Key Changes
<Detailed breakdown organized by component/area>
**Component 1:**
- Change description with context
**Component 2:**
- Change description with context
## Test Plan
- [ ] <Specific test case 1>
- [ ] <Specific test case 2>
- [ ] Run existing test suite: `pytest <path>`
- [ ] Deploy to staging environment
- [ ] Verify in staging with sample data
## Files Changed
**Category 1 (e.g., Core Logic):**
- `path/to/file.py` - Brief description of changes
**Category 2 (e.g., Configuration):**
- `path/to/config.json` - Brief description of changes
**Category 3 (e.g., Documentation):**
- `path/to/spec.md` - Brief description of changes
## Related
- **Spec**: `path/to/spec.md` (if applicable)
- **Ticket**: [TICKET-123](link) (if applicable)
- **Trace**: `trace-id` (if applicable)
- **Previous PR**: `#123` (if applicable)
Generated with [Claude Code](https://claude.com/claude-code)
# Check if branch needs to be pushed
UPSTREAM=$(git -C "$ROOT" rev-parse --abbrev-ref --symbolic-full-name @{upstream} 2>/dev/null || echo "")
if [ -z "$UPSTREAM" ]; then
echo "Pushing branch to origin with upstream tracking..."
git -C "$ROOT" push -u origin "$BRANCH"
else
# Check if local is ahead of remote
LOCAL_SHA=$(git -C "$ROOT" rev-parse HEAD)
REMOTE_SHA=$(git -C "$ROOT" rev-parse "@{upstream}" 2>/dev/null || echo "")
if [ "$LOCAL_SHA" != "$REMOTE_SHA" ]; then
echo "Pushing latest commits to origin..."
git -C "$ROOT" push origin "$BRANCH"
else
echo "Branch is up-to-date with remote"
fi
fi
CRITICAL FORMATTING RULES:
# characters that could be interpreted as issue references
## Summary) are OK - GitHub interprets these correctly#123 without context MUST be escaped: \#123 or wrapped: `#123`gh pr create \
--base "$TARGET" \
--title "<GENERATED_TITLE>" \
--body "$(cat <<'EOF'
<GENERATED_PR_BODY>
EOF
)"
After PR creation, output:
========================================
PR CREATED
========================================
PR URL: <URL from gh pr create>
Branch: <BRANCH> -> <TARGET>
Title: <PR_TITLE>
Summary:
- <Key point 1>
- <Key point 2>
- <Key point 3>
Files included: <N> files changed
Next steps:
1. Review PR: <URL>
2. Request reviewers if needed: gh pr edit --add-reviewer <user>
3. Monitor CI checks
========================================
Authentication-First Approach
Default to main (not master)
mainHEREDOC for PR Body
'EOF' prevents variable expansion in bodyComprehensive Context Gathering
Structured PR Template
Claude Code Attribution
WARNING: No commits ahead of $TARGET
Branch may already be merged or rebased.
Prompt user to verify before proceeding.
Check with gh pr list --head $BRANCH and warn if PR exists:
WARNING: Open PR already exists for this branch
PR #123: <title>
URL: <url>
Would you like to update the existing PR instead?
ERROR: Target branch 'origin/$TARGET' not found
Available branches:
- origin/main
- origin/master
- origin/develop
Please specify correct target: /pull-request <branch>
npx claudepluginhub waterplanai/agentic-config --plugin ac-gitCreates draft pull requests via GitHub CLI: gathers git context with status/logs/diffs, generates conventional commit titles, formats markdown bodies. Triggers on PR creation phrases.
Creates GitHub pull requests from the current branch, analyzes diffs, applies PR templates, and prompts for effort and testing details.
Creates GitHub Pull Requests using GitHub CLI: detects existing PRs for branches, pushes changes, generates titles/bodies from commits. Handles monorepos/submodules. Use for /create-pr or PR/review requests.