write-pr

GitHub

分析 Git diff 和提交历史,依据项目模板生成符合规范的 PR 标题和描述。自动检测基础分支、收集变更统计信息并智能读取文件内容,最终输出结构化 PR 内容,仅用于撰写而非提交操作。

data/skills-md/2ykwang/agent-skills/write-pr/SKILL.md NeverSight/learn-skills.dev

Trigger Scenarios

需要为当前分支撰写或起草 Pull Request 描述 需要生成与项目风格匹配的 PR 标题 需要根据实际代码变更填写 PR 模板

Install

npx skills add NeverSight/learn-skills.dev --skill write-pr -g -y
More Options

Non-standard path

npx skills add https://github.com/NeverSight/learn-skills.dev/tree/main/data/skills-md/2ykwang/agent-skills/write-pr -g -y

Use without installing

npx skills use NeverSight/learn-skills.dev@write-pr

指定 Agent (Claude Code)

npx skills add NeverSight/learn-skills.dev --skill write-pr -a claude-code -g -y

安装 repo 全部 skill

npx skills add NeverSight/learn-skills.dev --all -g -y

预览 repo 内 skill

npx skills add NeverSight/learn-skills.dev --list

SKILL.md

Frontmatter
{
    "name": "write-pr",
    "version": "0.0.3",
    "category": "productivity",
    "description": "Analyzes git diff and commit history to write PR title and description based on the project's PR template.",
    "argument-hint": "[base-branch]"
}

PR Content Writer

You are a pull request writing expert who transforms code changes into clear, structured PR descriptions. Analyze git history and diffs to produce PR titles and bodies that match the project's existing conventions.

Use this skill when

  • Writing or drafting a pull request description for the current branch
  • Generating a PR title that matches the project's commit/PR style
  • Filling in a PR template based on actual code changes

Do not use this skill when

  • The request is to actually open or push a pull request
  • There are no commits ahead of the base branch
  • The user only wants a commit message, not a PR description

This skill is read-only. Never run any command that modifies state: gh pr create, gh pr edit, git push, or any other write operation.

Context

The user wants a ready-to-use PR title and body based on what changed in the current branch. Focus on intent and impact, not raw diff output. Respect the project's existing PR style.

Instructions

Step 1: Detect Base Branch

If $ARGUMENTS is provided, use it as the base branch.

Otherwise, auto-detect in this order:

  1. Run git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null — extract branch name (e.g., origin/mainmain)
  2. If that fails, check which of main, master, develop exists: git branch -r | grep -E 'origin/(main|master|develop)'
  3. Use the first match found

Step 2: Collect Change Information

Run these commands in order:

git log <base>..<HEAD> --oneline
git diff <base>...<HEAD> --stat
git diff <base>...<HEAD> --shortstat

Use --shortstat output (e.g., 12 files changed, 340 insertions(+), 50 deletions(-)) to determine diff size:

  • If changed files ≤ 20 AND insertions+deletions ≤ 500: read the full diff with git diff <base>...<HEAD>
  • If changed files > 20 OR insertions+deletions > 500: do NOT read the full diff. From the --stat output, identify the file with the most changes per directory/module and read only those representative files

Step 3: Find PR Template

This step is mandatory. Do not skip or assume the file does not exist.

Attempt to read all paths below in parallel using a file read tool:

  • .github/PULL_REQUEST_TEMPLATE.md
  • .github/pull_request_template.md
  • docs/pull_request_template.md
  • PULL_REQUEST_TEMPLATE.md

Also check if .github/PULL_REQUEST_TEMPLATE/ directory exists — if so, list files and read the first one.

Use the first path that successfully returns content.

If a template file is successfully read:

  • Use its structure exactly as-is for the PR body
  • Preserve all sections, headings, and HTML comments (<!-- ... -->) in their original positions
  • Fill in content where appropriate; for sections that cannot be determined from the diff (e.g., Screenshots, Related Issues), leave the original placeholder or HTML comment intact — do not delete or summarize them
  • Do not reorder, merge, or omit any section

If all paths fail (file not found): use this default structure:

## Summary
<!-- What does this PR do and why? -->

## Changes
<!-- Key changes made -->

## Test Plan
<!-- How was this tested? -->

Step 4: Identify PR Title Style

Run:

gh pr list --state merged --limit 10 --json title 2>/dev/null

If gh returns results, analyze the title patterns (e.g., feat: ..., [PROJ-123] ..., Fix: ...).

If gh fails for any reason (not installed, auth error, not a GitHub repo), fall back to:

git log --oneline -20

Extract the dominant pattern from commit messages.

If no clear pattern is found, use Conventional Commits format (type: description).

Step 5: Write PR Content

Title:

  • If the style detected in Step 4 is clear and consistent: produce 1 title
  • If the style is ambiguous or mixed: produce 2–3 title candidates, clearly labeled

PR Body:

  • Use the template structure from Step 3
  • Fill each section based on the change analysis from Step 2
  • Focus on why the change was made, not just what files changed
  • Flag these explicitly if present in the diff:
    • Breaking changes (API/interface changes, removed fields)
    • New dependencies added
    • Architecture or structural changes
  • Do not paste raw diff or file lists into the body
  • For sections that cannot be filled (e.g., Screenshots, Demo, Related Issues): keep the original HTML comment or placeholder from the template — do not delete the section

Output Format

Present the output in this order:

Title

<single best title>

(If ambiguous, list alternatives labeled Alt 1, Alt 2)


PR Body

<filled-in PR body — exact template structure preserved>

Branch: <base><current> · Commits: N · Files changed: N

Version History

  • e0220ca Current 2026-07-05 21:09

Same Skill Collection

data/skills-md/00prabalk00/claude-skills/knowledge-base-gap-finder/SKILL.md
data/skills-md/01000001-01001110/agent-jira-skills/jira-agile/SKILL.md
data/skills-md/01000001-01001110/agent-jira-skills/jira-auth/SKILL.md
data/skills-md/01000001-01001110/agent-jira-skills/jira-issues/SKILL.md
data/skills-md/01000001-01001110/agent-jira-skills/jira-project-management/SKILL.md
data/skills-md/01000001-01001110/agent-jira-skills/jira-projects/SKILL.md
data/skills-md/01000001-01001110/agent-jira-skills/jira-safe/SKILL.md
data/skills-md/01000001-01001110/agent-jira-skills/jira-search/SKILL.md
data/skills-md/01000001-01001110/agent-jira-skills/jira-spaces/SKILL.md
data/skills-md/01000001-01001110/agent-jira-skills/jira-transitions/SKILL.md
data/skills-md/0731coderlee-sudo/wechat-publisher/wechat-publisher/SKILL.md
data/skills-md/0froq/skills/conventionalcommits/SKILL.md
data/skills-md/0froq/skills/nuxt/SKILL.md
data/skills-md/0froq/skills/oq/SKILL.md
data/skills-md/0froq/skills/pinia/SKILL.md
data/skills-md/0froq/skills/pnpm/SKILL.md
data/skills-md/0froq/skills/slidev/SKILL.md
data/skills-md/0froq/skills/tsdown/SKILL.md
data/skills-md/0froq/skills/turborepo/SKILL.md
data/skills-md/0froq/skills/unocss/SKILL.md
data/skills-md/0froq/skills/vitepress/SKILL.md
data/skills-md/0froq/skills/vitest/SKILL.md
data/skills-md/0froq/skills/vue-best-practices/SKILL.md
data/skills-md/0froq/skills/vue-router-best-practices/SKILL.md
data/skills-md/0froq/skills/vue-testing-best-practices/SKILL.md
data/skills-md/0froq/skills/vue/SKILL.md
data/skills-md/0froq/skills/vueuse-functions/SKILL.md
data/skills-md/0froq/skills/web-design-guidelines/SKILL.md
data/skills-md/0juano/agent-skills/bondterminal-x402/SKILL.md
data/skills-md/0juano/agent-skills/edgeone-pages-deploy/SKILL.md
data/skills-md/0juano/agent-skills/ley-ar/SKILL.md
data/skills-md/0juano/agent-skills/ticktick/SKILL.md
data/skills-md/0juano/agent-skills/x-image-cards/SKILL.md
data/skills-md/0juano/x-image-cards/x-image-cards/SKILL.md
data/skills-md/0x0funky/agent-sprite-forge/generate2dsprite/SKILL.md
data/skills-md/0x0funky/agent-sprite-forge/video2dsprite/SKILL.md
data/skills-md/0x2e/superpowers/brainstorming/SKILL.md
data/skills-md/0x2e/superpowers/dispatching-parallel-agents/SKILL.md
data/skills-md/0x2e/superpowers/executing-plans/SKILL.md
data/skills-md/0x2e/superpowers/finishing-a-development-branch/SKILL.md
data/skills-md/0x2e/superpowers/receiving-code-review/SKILL.md
data/skills-md/0x2e/superpowers/requesting-code-review/SKILL.md
data/skills-md/0x2e/superpowers/subagent-driven-development/SKILL.md
data/skills-md/0x2e/superpowers/systematic-debugging/SKILL.md
data/skills-md/0x2e/superpowers/test-driven-development/SKILL.md
data/skills-md/0x2e/superpowers/using-git-worktrees/SKILL.md
data/skills-md/0x2e/superpowers/using-superpowers/SKILL.md
data/skills-md/0x2e/superpowers/verification-before-completion/SKILL.md
data/skills-md/0x2e/superpowers/writing-plans/SKILL.md
data/skills-md/0x2e/superpowers/writing-skills/SKILL.md

Metadata

Files
0
Version
f4b4cf1
Hash
c2dcbe12
Indexed
2026-07-05 21:09

Главная - Вики-сайт
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-09 09:11
浙ICP备14020137号-1 $Гость$