Skip to content
Development
Skill

/pr-auto-update

Auto-update PR description and labels from changes. Trigger with "update PR description", "refresh PR", "update labels".

From plugin
claude-code-cookbook
1.1k39 skills9 agents39 commands8 MCP

Claude Code

$ npx -y skills add wasabeef/claude-code-cookbook --skill pr-auto-update --agent claude-code

SKILL.md

pr-auto-update.SKILL.md
description: 'Auto-update PR description and labels from changes. Trigger with "update PR description", "refresh PR", "update labels".'
allowed-tools:
  - Bash(gh *)
  - Bash(git *)
  - Read
  - Grep
  - Glob

Auto-update PR description and labels from changes

Overview

A command that automatically updates Pull Request descriptions and labels. Analyzes Git changes to generate and set appropriate descriptions and labels.

Usage

/pr-auto-update [options] [PR number]

Options

  • `--pr <number>`: Specify target PR number (automatically detected from current branch if omitted)
  • `--description-only`: Update only the description (keep labels unchanged)
  • `--labels-only`: Update only labels (keep description unchanged)
  • `--dry-run`: Show generated content without making actual updates
  • `--lang <language>`: Specify language (en)

Basic Examples

# Auto-update PR for current branch
/pr-auto-update

# Update specific PR
/pr-auto-update --pr 1234

# Update description only
/pr-auto-update --description-only

# Check with dry-run
/pr-auto-update --dry-run

Feature Details

1. PR Auto Detection

Automatically detects the corresponding PR from the current branch:

# Search PR from branch
gh pr list --head $(git branch --show-current) --json number,title,url

2. Change Analysis

Collects and analyzes the following information:

  • **File changes**: Added, deleted, or modified files
  • **Code analysis**: Changes to imports, function definitions, class definitions
  • **Tests**: Presence and content of test files
  • **Documentation**: Updates to README, docs
  • **Configuration**: Changes to package.json, pubspec.yaml, configuration files
  • **CI/CD**: Changes to GitHub Actions, workflows

3. Automatic Description Generation

Template Processing Priority

1. **Existing PR description**: Completely follows already written content 2. **Project template**: Gets structure from `.github/PULL_REQUEST_TEMPLATE.md` 3. **Default template**: Fallback when above don't exist

Rules for Preserving Existing Content

**Important**: Do not modify existing content

  • Keep existing sections
  • Only complete empty sections
  • Keep functional comments (like Copilot review rules)

Using Project Templates

# Parse structure of .github/PULL_REQUEST_TEMPLATE.md
parse_template_structure() {
  local template_file="$1"

  if [ -f "$template_file" ]; then
    # Extract section structure
    grep -E '^##|^###' "$template_file"

    # Identify comment placeholders
    grep -E '<!--.*-->' "$template_file"

    # Completely follow existing template structure
    cat "$template_file"
  fi
}

4. Automatic Label Setting

Label Retrieval Mechanism

**Priority**:

1. **`.github/labels.yml`**: Get from project-specific label definitions 2. **GitHub API**: Get existing labels with `gh api repos/{OWNER}/{REPO}/labels --jq '.[].name'`

Automatic Determination Rules

**File Pattern Based**:

  • Documentation: `*.md`, `README`, `docs/` → labels containing `documentation|docs|doc`
  • Tests: `test`, `spec` → labels containing `test|testing`
  • CI/CD: `.github/`, `*.yml`, `Dockerfile` → labels containing `ci|build|infra|ops`
  • Dependencies: `package.json`, `pubspec.yaml`, `requirements.txt` → labels containing `dependencies|deps`

**Change Content Based**:

  • Bug fixes: `fix|bug|error|crash|correction` → labels containing `bug|fix`
  • New features: `feat|feature|add|implement|new-feature|implementation` → labels containing `feature|enhancement|feat`
  • Refactoring: `refactor|clean|restructure` → labels containing `refactor|cleanup|clean`
  • Performance: `performance|perf|optimize|optimization` → labels containing `performance|perf`
  • Security: `security|secure|vulnerability` → labels containing `security`

Constraints

  • **Maximum 3**: Upper limit on automatically selected labels
  • **Existing labels only**: Creating new labels is prohibited
  • **Partial match**: Determined by whether keywords are contained in label names

Actual Usage Examples

**When `.github/labels.yml` exists**:

# Auto-retrieve from label definitions
grep "^- name:" .github/labels.yml | sed "s/^- name: '\?\([^']*\)'\?/\1/"

# Example: Use project-specific label system

**When retrieving from GitHub API**:

# Get list of existing labels
gh api repos/{OWNER}/{REPO}/labels --jq '.[].name'

# Example: Use standard labels like bug, enhancement, documentation

5. Execution Flow

#!/bin/bash

# 1. PR Detection & Retrieval
detect_pr() {
  if [ -n "$PR_NUMBER" ]; then
    echo $PR_NUMBER
  else
    gh pr list --head $(git branch --show-current) --json number --jq '.[0].number'
  fi
}

# 2. Change Analysis
analyze_changes() {
  local pr_number=$1

  # Get file changes
  gh pr diff $pr_number --name-only

  # Content analysis
  gh pr diff $pr_number | head -1000
}

# 3. Description Generation
generate_description() {
  local pr_number=$1
  local changes=$2

  # Get current PR description
  local current_body=$(gh pr view $pr_number --json body --jq -r .body)

  # Use existing content if available
  if [ -n "$current_body" ]; then
    echo "$current_body"
  else
    # Generate new from template
    local template_file=".github/PULL_REQUEST_TEMPLATE.md"
    if [ -f "$template_file" ]; then
      generate_from_template "$(cat "$template_file")" "$changes"
    else
      generate_from_template "" "$changes"
    fi
  fi
}

# Generate from template
generate_from_template() {
  local template="$1"
  local changes="$2"

  if [ -n "$template" ]; then
    # Use template as-is (preserve HTML comments)
    echo "$template"
  else
    # Generate in default format
    echo "## What does this change?"
    echo ""
    echo "$changes"
  fi
}

# 4. Label Determination
determine_labels() {
  local changes=$1
  local file_list=$2
  local pr_number=$3

  # Get available labels
  local available_labels=()
  if [ -f ".github/labels.yml" ]; then
    # Extract label names from labe
Read more
@wasabeef
Ships withclaude-code-cookbook

A collection of commands, roles, and automation scripts for Claude Code. Automate your workflow without unnecessary confirmations, allowing you to focus on what matters.

1.1k39 skills9 agents8 MCP
Get the whole plugin

Stars on GitHub

Momentum

stars in total
1.1k
Star history of wasabeef/claude-code-cookbook on GitHub, a chart by star-history.com

Other skills on claude-code-cookbook.

check-fact

check-fact

Verify information accuracy against codebase and documentation. Trigger with "is this correct?", "fact check", "verify this", "is…

More skills from other plugins.

brainstorming
Auto-invoked

brainstorming

You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or…

@obra@obraInstall Skill
ask-matt

ask-matt

Ask which skill or flow fits your situation. A router over the skills in this repo.

skills2w309k
@mattpocock@mattpocockInstall Skill
accessibility
Auto-invoked

accessibility

Design, implement, and audit accessible UI to WCAG 2.2 Level AA across Web, iOS, and Android — semantic ARIA roles and labels,…

ecc2w293k
@affaan-m@affaan-mInstall Skill
compiler-commit

compiler-commit

Use when you want to verify compiler changes and commit with the correct convention. Runs tests, lint, and format, then commits…

react5d252k
@facebook@facebookInstall Skill

Questions about pr-auto-update.

Which coding agents can use pr-auto-update?
pr-auto-update installs in Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode and Windsurf with the skills CLI, using each agent's flag shown on this page. Flowy's auto-invocation, which fires a skill when your prompt matches, runs in Claude Code only.