
Cli Gh
Automate GitHub branch naming, label selection, and pull request creation from the terminal with gh and a bash workflow.
Overview
cli-gh is an agent skill for the Ship phase that automates GitHub branch setup, label hints, and pull request creation using bash and the gh CLI.
Install
npx skills add https://github.com/paulrberg/agent-skills --skill cli-ghWhat is this skill?
- Interactive branch naming from issue number and kebab-case description
- Auto-suggests PR labels from branch patterns (bug, feat, docs, test, refactor)
- Supports draft PRs via --draft flag
- Creates and checks out branch when not already on target branch
- Bash script with set -euo pipefail for safer automation
- Label heuristics for 5 branch pattern families (bug/fix, feat, docs, test, refactor)
Adoption & trust: 1.7k installs on skills.sh; 62 GitHub stars; 2/3 security scanners passed (skills.sh audits).
What problem does it solve?
You finished a fix or feature locally but opening a properly labeled, consistently named PR still means manual gh flags and copy-paste discipline.
Who is it for?
Solo builders using gh who want scripted PR creation with label heuristics from branch names.
Skip if: Teams on GitLab-only workflows, repos without gh installed, or flows that need complex PR templates filled from issue bodies without extending the script.
When should I use this skill?
You need to open a GitHub PR with consistent branch naming and labels using gh from the terminal.
What do I get? / Deliverables
You get a scripted path from branch name through label rules to gh pr create, including optional draft mode, ready to paste or run in your repo.
- Executed or adapted auto-pr-create.sh workflow
- Named feature branch
- Opened or draft pull request via gh
Recommended Skills
Journey fit
Opening and labeling PRs is the handoff from local work to team review, which maps to the Ship phase review subphase. Review is where changes leave the branch and enter the PR queue—this skill standardizes that step rather than ad-hoc gh commands.
How it compares
Use instead of one-off gh pr create chat instructions when you want a repeatable bash recipe with branch and label conventions.
Common Questions / FAQ
Who is cli-gh for?
Indie developers and agent users who ship via GitHub and want a small bash script to standardize branches, labels, and PR creation with gh.
When should I use cli-gh?
Use it in Ship when you are ready to open or draft a PR after coding—especially when branch names should drive labels (bug/fix, feat, docs, test, refactor).
Is cli-gh safe to install?
It runs shell and git operations against your repo; review the Security Audits panel on this page and inspect the script before executing in sensitive repositories.
SKILL.md
READMESKILL.md - Cli Gh
#!/usr/bin/env bash # auto-pr-create.sh - Automated Pull Request Creation # Usage: ./auto-pr-create.sh [branch-name] [--draft] set -euo pipefail # Configuration DEFAULT_BASE="main" DRAFT_FLAG="" BRANCH_NAME="${1:-}" # Parse arguments for arg in "$@"; do case $arg in --draft) DRAFT_FLAG="--draft" shift ;; esac done # Function to generate branch name from ticket/issue generate_branch_name() { echo "Enter issue/ticket number (or leave empty):" read -r ISSUE_NUM echo "Brief description (kebab-case):" read -r DESCRIPTION if [ -n "$ISSUE_NUM" ]; then echo "issue-${ISSUE_NUM}-${DESCRIPTION}" else echo "${DESCRIPTION}" fi } # Get or generate branch name if [ -z "$BRANCH_NAME" ]; then BRANCH_NAME=$(generate_branch_name) fi # Determine PR labels based on branch name determine_labels() { local branch=$1 local labels=() case "$branch" in *bug*|*fix*) labels+=("bug") ;; *feat*|*feature*) labels+=("enhancement") ;; *docs*|*documentation*) labels+=("documentation") ;; *test*) labels+=("tests") ;; *refactor*) labels+=("refactoring") ;; esac # Join labels with comma IFS=',' echo "${labels[*]}" } # Check if on correct branch CURRENT_BRANCH=$(git branch --show-current) if [ "$CURRENT_BRANCH" != "$BRANCH_NAME" ]; then echo "Creating and switching to branch: $BRANCH_NAME" git checkout -b "$BRANCH_NAME" else echo "Already on branch: $BRANCH_NAME" fi # Check for uncommitted changes if ! git diff-index --quiet HEAD --; then echo "⚠️ You have uncommitted changes. Commit them first." exit 1 fi # Push branch to remote echo "Pushing branch to remote..." git push -u origin "$BRANCH_NAME" # Determine labels LABELS=$(determine_labels "$BRANCH_NAME") # Create PR with smart defaults echo "Creating pull request..." PR_ARGS=( "--base" "$DEFAULT_BASE" "--head" "$BRANCH_NAME" "--fill" # Auto-fill from commits ) # Add draft flag if specified if [ -n "$DRAFT_FLAG" ]; then PR_ARGS+=("$DRAFT_FLAG") fi # Add labels if any if [ -n "$LABELS" ]; then PR_ARGS+=("--label" "$LABELS") fi # Create PR and capture URL PR_URL=$(gh pr create "${PR_ARGS[@]}") echo "✅ Pull request created: $PR_URL" # Optionally open in browser read -p "Open PR in browser? (y/N): " -n 1 -r echo if [[ $REPLY =~ ^[Yy]$ ]]; then gh pr view --web fi #!/usr/bin/env bash # issue-triage.sh - Bulk Issue Labeling and Assignment # Usage: ./issue-triage.sh [--repo owner/repo] set -euo pipefail # Configuration REPO="" DRY_RUN=false # Parse arguments while [[ $# -gt 0 ]]; do case $1 in --repo) REPO="$2" shift 2 ;; --dry-run) DRY_RUN=true shift ;; *) echo "Unknown option: $1" exit 1 ;; esac done # Set repo context if [ -n "$REPO" ]; then REPO_FLAG="--repo $REPO" else REPO_FLAG="" fi # Function to apply triage rules triage_issues() { echo "🔍 Fetching unlabeled issues..." # Get all unlabeled issues ISSUES=$(gh issue list $REPO_FLAG --label="" --limit 100 --json number,title,body,author) if [ -z "$ISSUES" ] || [ "$ISSUES" = "[]" ]; then echo "No unlabeled issues found." return fi echo "Found $(echo "$ISSUES" | jq 'length') unlabeled issues" echo "" # Process each issue echo "$ISSUES" | jq -c '.[]' | while read -r issue; do NUMBER=$(echo "$issue" | jq -r '.number') TITLE=$(echo "$issue" | jq -r '.title') BODY=$(echo "$issue" | jq -r '.body // ""') AUTHOR=$(echo "$issue" | jq -r '.author.login') echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" echo "Issue #$NUMBER: $TITLE" echo "Author: $AUTHOR" LABELS=() ASSIGNEE="" # Auto-label based on keywords if echo "$TITLE $BODY" | grep -qi "bug\|error\|crash\|broken"; then LABELS+=("bug") fi if echo "$TITLE $BODY" | grep -qi "feat\|feature\|enhance"; then LABELS+=("enhancement") fi if echo "$TITLE $BODY" | g