Auto-update PR descriptions based on Git change analysis
Automatically update Pull Request descriptions by analyzing Git changes. Preserves existing content and only fills in empty sections.
--pr <number>: Target PR number (auto-detected from current branch if omitted)--dry-run: Show generated content without actually updating--lang <en|ja>: Force output language (en or ja)# Auto-detect from current branch
gh pr list --head $(git branch --show-current) --json number,title,url --jq '.[0]'
# Or use specified PR number
gh pr view <number> --json number,title,url,body,labels
--pr <number> is specified in $ARGUMENTS, use that PR# Get changed files
gh pr diff <number> --name-only
# Get diff content (limit to first 1000 lines for large PRs)
gh pr diff <number> | head -1000
# Get commit history
gh pr view <number> --json commits --jq '.commits[].messageHeadline'
Analyze the following dimensions:
.github/PULL_REQUEST_TEMPLATE.md structure if available## What does this change? format as fallback<!-- ... -->): always preserve---): always preserve--lang is specified, use that languageIf --dry-run is specified, display the generated description without updating:
=== DRY RUN ===
Description:
<generated description>
Description — Use GitHub API to preserve HTML comments:
# IMPORTANT: Use gh api with --field to avoid HTML comment escaping
# Do NOT use `gh pr edit --body` as it escapes <!-- --> to <!-- -->
gh api \
--method PATCH \
"/repos/{owner}/{repo}/pulls/<number>" \
--field body="<description>"
# Verify the update
gh pr view <number> --json body --jq '{body: .body[:100]}'
<!-- ... --> must remain intactgh api --field body= for description updates (preserves HTML comments)gh pr edit --body (escapes HTML comments)--dry-run for first-time use on a repository.env files