ce-pr-description
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCE PR Description
CE PR描述
Generate a conventional-commit-style title and a value-first body describing a pull request's work. Returns structured for the caller to apply — this skill never invokes or , and never prompts for interactive confirmation.
{title, body_file}gh pr editgh pr createWhy a separate skill: several callers need the same writing logic without the single-PR interactive scaffolding that lives in . 's splitting workflow runs this once per layer as a batch; runs it inside its full-flow and refresh-mode paths. Extracting keeps one source of truth for the writing principles.
ce-commit-push-prce-pr-stackce-commit-push-prNaming rationale: , not . Stacking and PR creation are GitHub features; the "PR" in the name refers to the GitHub artifact. Using the prefix matches the plugin naming convention for all skills.
ce-pr-descriptiongit-pr-descriptionce-生成符合约定式提交风格的标题和以价值为核心的正文,用于描述拉取请求的工作内容。返回结构化的供调用者应用——此技能从不调用或,也不会提示交互式确认。
{title, body_file}gh pr editgh pr create为何单独设置此技能:多个调用者需要相同的写作逻辑,但不需要中包含的单PR交互式脚手架。的拆分工作流会批量为每一层调用一次此技能;会在其完整流程和刷新模式路径中调用它。将写作逻辑抽离出来,确保写作原则的单一数据源。
ce-commit-push-prce-pr-stackce-commit-push-pr命名理由:使用而非。栈管理和PR创建是GitHub的功能;名称中的“PR”指GitHub的相关工件。使用前缀符合所有技能的插件命名规范。
ce-pr-descriptiongit-pr-descriptionce-Inputs
输入
Input is a free-form prompt. Parse it into two parts:
- A PR reference, if present. Any of these patterns counts: a full GitHub PR URL (),
https://github.com/owner/repo/pull/NNorpr:<number>, a bare hashmark form (pr:<URL>), or the argument being just a number (#NN). Extract the PR reference and treat the rest of the argument as steering text.561 - Everything else is steering text (a "focus" hint like "emphasize the benchmarks" or "do a good job with the perf story"). It may be combined with a PR reference or stand alone.
No specific grammar is required — read the argument as natural language and identify whichever PR reference is present. If no PR reference is present, default to describing the current branch.
输入为自由格式的提示语,解析为两部分:
- PR引用(若存在):以下任意格式均有效:完整GitHub PR URL()、
https://github.com/owner/repo/pull/NN或pr:<number>、纯井号格式(pr:<URL>),或参数仅为数字(#NN)。提取PR引用后,将参数的剩余部分视为指导文本。561 - 其余内容为指导文本(如“强调基准测试”或“完善性能相关内容”这类“聚焦”提示)。它可与PR引用结合使用,也可单独存在。
无需遵循特定语法——将参数视为自然语言,识别其中存在的PR引用。若未找到PR引用,则默认描述当前分支。
Mode selection
模式选择
| What the caller passes | Mode |
|---|---|
| No PR reference (empty argument or steering text only) | Current-branch mode — describe the commits on HEAD vs the repo's default base |
A PR reference (URL, | PR mode — describe the specified PR |
Steering text is always optional. If present, incorporate it alongside the diff-derived narrative; do not let it override the value-first principles or fabricate content unsupported by the diff.
Optional override (current-branch mode only). When a caller already knows the intended base branch (e.g., has detected or as the target), it can pass to pin the base explicitly. The ref must resolve locally. This overrides auto-detection for current-branch mode; PR mode ignores it (PRs already define their own base via ). Most invocations don't need this — auto-detection (existing PR's → ) covers the common case.
base:<ref>ce-commit-push-prorigin/developorigin/release/2026-04base:<ref>baseRefNamebaseRefNameorigin/HEADExamples:
- → current-branch, no focus, auto-detect base
ce-pr-description - → current-branch, focus = "emphasize the benchmarks"
ce-pr-description emphasize the benchmarks - → current-branch, base pinned to
ce-pr-description base:origin/developorigin/develop - → same + focus
ce-pr-description base:origin/develop emphasize perf - → PR #561, no focus
ce-pr-description pr:561 - → PR #561, focus = "do a good job with the perf story"
ce-pr-description #561 do a good job with the perf story - → PR #561 in foo/bar, focus = "emphasize safety"
ce-pr-description https://github.com/foo/bar/pull/561 emphasize safety
| 调用者传入内容 | 模式 |
|---|---|
| 无PR引用(空参数或仅含指导文本) | 当前分支模式——描述HEAD与仓库默认基准分支之间的提交 |
含PR引用(URL、 | PR模式——描述指定的PR |
指导文本始终为可选内容。若存在,则将其与基于差异生成的叙述内容结合;但不得让它覆盖以价值为核心的原则,或编造差异不支持的内容。
可选的覆盖(仅适用于当前分支模式)。当调用者已明确目标基准分支(例如检测到或为目标分支),可传入来明确固定基准分支。该引用必须能在本地解析。此设置会覆盖当前分支模式下的自动检测;PR模式会忽略此设置(PR已通过定义自身的基准分支)。大多数调用无需此设置——自动检测(现有PR的 → )可覆盖常见场景。
base:<ref>ce-commit-push-prorigin/developorigin/release/2026-04base:<ref>baseRefNamebaseRefNameorigin/HEAD示例:
- → 当前分支模式,无聚焦,自动检测基准分支
ce-pr-description - → 当前分支模式,聚焦为“emphasize the benchmarks”
ce-pr-description emphasize the benchmarks - → 当前分支模式,基准分支固定为
ce-pr-description base:origin/developorigin/develop - → 同上,增加聚焦内容
ce-pr-description base:origin/develop emphasize perf - → PR #561,无聚焦
ce-pr-description pr:561 - → PR #561,聚焦为“do a good job with the perf story”
ce-pr-description #561 do a good job with the perf story - → foo/bar仓库的PR #561,聚焦为“emphasize safety”
ce-pr-description https://github.com/foo/bar/pull/561 emphasize safety
Output
输出
Return a structured result with two fields:
- -- conventional-commit format:
titleortype: description. Under 72 characters. Choosetype(scope): descriptionbased on intent (feat/fix/refactor/docs/chore/perf/test), not file type. Pick the narrowest usefultype(skill or agent name, CLI area, or shared label); omit when no single label adds clarity.scope - -- absolute path to an OS temp file (created via
body_file) containing the body markdown that follows the writing principles below. Do not emit the body inline in the return.mktemp
The caller decides whether to apply via , , or discard, reading the body from (e.g., ). This skill does NOT call those commands itself. No cleanup is required — files live in OS temp storage, which the OS reaps on its own schedule.
gh pr editgh pr createbody_file--body "$(cat "$BODY_FILE")"mktemp返回包含两个字段的结构化结果:
- ——约定式提交格式:
title或type: description。长度不超过72字符。根据意图选择type(scope): description(feat/fix/refactor/docs/chore/perf/test),而非文件类型。选择最窄的有用type(技能或Agent名称、CLI领域或共享标签);若没有单一标签能增加清晰度,则省略。scope - ——操作系统临时文件的绝对路径(通过
body_file创建),文件内容为遵循以下写作原则的正文Markdown。不要在返回结果中直接内联正文。mktemp
调用者可决定是否通过、应用该结果,或直接丢弃,只需从读取正文(例如)。此技能不会自行调用这些命令。无需清理临时文件——创建的文件存储在操作系统临时目录中,操作系统会按自身计划自动清理。
gh pr editgh pr createbody_file--body "$(cat "$BODY_FILE")"mktempWhat this skill does not do
此技能不执行的操作
- No interactive confirmation prompts. If the diff is ambiguous about something important (e.g., the focus hint conflicts with the actual changes), surface the ambiguity in the returned output or raise it to the caller — do not prompt the user directly.
- No branch checkout. Current-branch mode describes the HEAD in the user's current checkout; PR mode describes the specified PR. Neither mode checks out a different branch.
- No compare-and-confirm narrative ("here's what changed since the last version"). The description describes the end state; the caller owns any compare-and-confirm framing.
- No auto-apply via or
gh pr edit. Return the output and stop.gh pr create
Interactive scaffolding (confirmation prompts, compare-and-confirm, apply step) is the caller's responsibility.
- 无交互式确认提示。若差异中存在重要的模糊点(例如聚焦提示与实际变更冲突),需在返回结果中指出该模糊点,或告知调用者——不得直接提示用户。
- 无分支检出操作。当前分支模式描述用户当前检出状态中的HEAD;PR模式描述指定的PR。两种模式均不会检出其他分支。
- 无对比确认叙述(“以下是与上一版本相比的变更内容”)。描述仅针对最终状态;对比确认的框架由调用者负责。
- 无通过或
gh pr edit自动应用的操作。返回输出后即停止。gh pr create
交互式脚手架(确认提示、对比确认、应用步骤)由调用者负责。
Step 1: Resolve the diff and commit list
步骤1:解析差异和提交列表
Parse the input (see Inputs above) and branch on which mode it selects.
解析输入(参见上述输入部分),根据选择的模式分支处理。
Current-branch mode (default when no PR reference was given)
当前分支模式(未指定PR引用时默认启用)
Determine the base against which to compare, in this priority order:
- Caller-supplied — if present, use it verbatim. The caller is asserting the correct base. The ref must resolve locally.
base:<ref> - Existing PR's — if the current branch already has an open PR on this repo, use that PR's base. Handles feature branches targeting non-default bases (e.g.,
baseRefName) when the PR is already open.develop - Repo default () — fall back for branches with no PR yet and no caller-supplied base.
origin/HEAD
bash
undefined按以下优先级确定对比基准:
- 调用者提供的——若存在,直接使用。调用者需确保该基准正确。该引用必须能在本地解析。
base:<ref> - 现有PR的——若当前分支已在该仓库打开PR,则使用该PR的基准分支。适用于针对非默认基准分支(如
baseRefName)的特性分支,且PR已打开的场景。develop - 仓库默认分支()——针对尚未创建PR且无调用者提供基准分支的分支,使用此回退方案。
origin/HEAD
bash
undefinedDetect current branch (fail if detached HEAD)
检测当前分支(若为分离HEAD状态则失败)
CURRENT_BRANCH=$(git branch --show-current)
if [ -z "$CURRENT_BRANCH" ]; then
echo "Detached HEAD — current-branch mode requires a branch. Pass a PR reference instead."
exit 1
fi
CURRENT_BRANCH=$(git branch --show-current)
if [ -z "$CURRENT_BRANCH" ]; then
echo "Detached HEAD — current-branch mode requires a branch. Pass a PR reference instead."
exit 1
fi
Priority: caller-supplied base: > existing PR's baseRefName > origin/HEAD > origin/main
优先级:调用者提供的base: > 现有PR的baseRefName > origin/HEAD > origin/main
if [ -n "$CALLER_BASE" ]; then
BASE_REF="$CALLER_BASE"
elif EXISTING_PR_BASE=$(gh pr view --json baseRefName --jq '.baseRefName'); then
BASE_REF="origin/$EXISTING_PR_BASE"
elif DEFAULT_HEAD=$(git rev-parse --abbrev-ref origin/HEAD); then
BASE_REF="$DEFAULT_HEAD"
else
BASE_REF="origin/main"
fi
Both `gh pr view` and `git rev-parse --abbrev-ref origin/HEAD` exit non-zero on the "not configured" paths; the elif chain drives off exit code rather than suppressed stderr. Stderr from a missing PR or unresolved `origin/HEAD` is informational and acceptable.
If `$BASE_REF` does not resolve locally (`git rev-parse --verify "$BASE_REF"` fails), the caller (or the user) needs to fetch it first. Exit gracefully with `"Base ref $BASE_REF does not resolve locally. Fetch it before invoking the skill."` — do not attempt recovery.
Gather merge base, commit list, and full diff:
```bash
MERGE_BASE=$(git merge-base "$BASE_REF" HEAD) && echo "MERGE_BASE=$MERGE_BASE" && echo '=== COMMITS ===' && git log --oneline $MERGE_BASE..HEAD && echo '=== DIFF ===' && git diff $MERGE_BASE...HEADIf the commit list is empty, report and exit gracefully — there is nothing to describe.
"No commits between $BASE_REF and HEAD"If an existing PR was found in step 1, also capture its body for evidence preservation in Step 3.
if [ -n "$CALLER_BASE" ]; then
BASE_REF="$CALLER_BASE"
elif EXISTING_PR_BASE=$(gh pr view --json baseRefName --jq '.baseRefName'); then
BASE_REF="origin/$EXISTING_PR_BASE"
elif DEFAULT_HEAD=$(git rev-parse --abbrev-ref origin/HEAD); then
BASE_REF="$DEFAULT_HEAD"
else
BASE_REF="origin/main"
fi
`gh pr view`和`git rev-parse --abbrev-ref origin/HEAD`在“未配置”路径下会返回非零退出码;elif链根据退出码而非抑制的stderr进行判断。缺少PR或无法解析`origin/HEAD`时的stderr为信息性内容,可接受。
若`$BASE_REF`无法在本地解析(`git rev-parse --verify "$BASE_REF"`失败),则调用者(或用户)需先拉取该引用。优雅退出并提示`"Base ref $BASE_REF does not resolve locally. Fetch it before invoking the skill."`——不得尝试恢复。
收集合并基准、提交列表和完整差异:
```bash
MERGE_BASE=$(git merge-base "$BASE_REF" HEAD) && echo "MERGE_BASE=$MERGE_BASE" && echo '=== COMMITS ===' && git log --oneline $MERGE_BASE..HEAD && echo '=== DIFF ===' && git diff $MERGE_BASE...HEAD若提交列表为空,报告并优雅退出——无可描述内容。
"No commits between $BASE_REF and HEAD"若步骤1中找到现有PR,还需捕获其正文,以便在步骤3中保留证据。
PR mode (when the input contained a PR reference)
PR模式(输入中包含PR引用时启用)
Normalize the reference into a form accepts: a bare number (), a full URL (), or the number extracted from or . 's positional argument accepts bare numbers, URLs, and branch names — not shorthand. For a cross-repo number reference without a URL, the caller would use ; this skill accepts a full URL as the simplest cross-repo path, and that's what most callers use.
gh pr view561https://github.com/owner/repo/pull/561pr:561#561gh pr viewowner/repo#NN-R owner/repobash
gh pr view <pr-ref> --json number,state,title,body,baseRefName,baseRefOid,headRefName,headRefOid,headRepository,headRepositoryOwner,isCrossRepository,commits,urlKey JSON fields: (PR head SHA — prefer over indexing into ), (base-branch SHA), + (PR source repo), . There is no field — the base repo is the one queried by itself.
headRefOidcommitsbaseRefOidheadRepositoryheadRepositoryOwnerisCrossRepositorybaseRepositorygh pr viewIf the returned is not , report and exit gracefully without output. Callers expecting must handle this empty case.
stateOPEN"PR <number> is <state> (not open); cannot regenerate description"{title, body_file}Determine whether the PR lives in the current working directory's repo by parsing the URL's path segments and comparing against (strip suffix; handle both and forms). If the URL repo matches 's repo, route to the local-git path (Case A). Otherwise route to the API-only path (Case B). Bare numbers and forms implicitly target the current repo → Case A.
<owner>/<repo>git remote get-url origin.gitgit@github.com:owner/repohttps://github.com/owner/repoorigin#NNCase A → Case B fallback: Even when the URL repo matches , the local clone may not be usable for this PR's refs — shallow clone, detached state missing the base branch, offline, auth issues, GHES quirks. If Case A's fetch or fails, fall back to Case B rather than failing the skill. Note the fallback in the caller-facing output.
origingit merge-baseCase A — PR is in the current repo:
Read the PR head SHA directly from in the JSON response above. Fetch the base ref and the head SHA in one call (the fetch is idempotent when refs are already local):
headRefOidbash
PR_HEAD_SHA=<headRefOid from JSON>
git fetch --no-tags origin <baseRefName> $PR_HEAD_SHAUsing the explicit in downstream commands avoids 's multi-ref ordering problem ( returns only the first fetched ref's SHA, which silently breaks a multi-ref fetch).
$PR_HEAD_SHAFETCH_HEADgit rev-parse FETCH_HEADbash
MERGE_BASE=$(git merge-base origin/<baseRefName> $PR_HEAD_SHA) && echo "MERGE_BASE=$MERGE_BASE" && echo '=== COMMITS ===' && git log --oneline $MERGE_BASE..$PR_HEAD_SHA && echo '=== DIFF ===' && git diff $MERGE_BASE...$PR_HEAD_SHAIf the explicit-SHA fetch is rejected (rare on GitHub, possible on some GHES configurations that disallow fetching non-tip SHAs), fall back to fetching and reading the PR head SHA from by pull-ref pattern:
refs/pull/<number>/head.git/FETCH_HEADbash
git fetch --no-tags origin "refs/pull/<number>/head"
PR_HEAD_SHA=$(awk '/refs\/pull\/[0-9]+\/head/ {print $1; exit}' "$(git rev-parse --git-dir)/FETCH_HEAD")Case B — PR is in a different repo:
Skip local git entirely. Read the diff and commit list from the API:
bash
gh pr diff <pr-ref>
gh pr view <pr-ref> --json commits --jq '.commits[] | [.oid[0:7], .messageHeadline] | @tsv'Same classification/framing/writing pipeline. Note in the caller-facing output that the API fallback was used.
Also capture the existing PR body for evidence preservation in Step 3 (both cases).
将引用标准化为可接受的格式:纯数字()、完整URL(),或从或中提取的数字。的位置参数接受纯数字、URL和分支名称——但不接受简写形式。对于跨仓库的数字引用且无URL的情况,调用者需使用;此技能接受完整URL作为最简单的跨仓库路径,这也是大多数调用者的选择。
gh pr view561https://github.com/owner/repo/pull/561pr:561#561gh pr viewowner/repo#NN-R owner/repobash
gh pr view <pr-ref> --json number,state,title,body,baseRefName,baseRefOid,headRefName,headRefOid,headRepository,headRepositoryOwner,isCrossRepository,commits,url关键JSON字段:(PR头部SHA——优先于从中索引)、(基准分支SHA)、 + (PR源仓库)、。不存在字段——基准仓库是查询的仓库本身。
headRefOidcommitsbaseRefOidheadRepositoryheadRepositoryOwnerisCrossRepositorybaseRepositorygh pr view若返回的不是,报告并优雅退出,不输出内容。期望的调用者需处理此空场景。
stateOPEN"PR <number> is <state> (not open); cannot regenerate description"{title, body_file}判断PR是否位于当前工作目录的仓库中:解析URL的路径段,并与比较(去除后缀;处理和两种格式)。若URL仓库与仓库匹配,则走本地Git路径(案例A);否则走仅API路径(案例B)。纯数字和形式默认指向当前仓库→案例A。
<owner>/<repo>git remote get-url origin.gitgit@github.com:owner/repohttps://github.com/owner/repoorigin#NN案例A→案例B回退:即使URL仓库与匹配,本地克隆也可能无法用于此PR的引用——浅克隆、缺少基准分支的分离状态、离线、认证问题、GHES特性差异。若案例A的拉取或失败,则回退到案例B,而非让技能失败。在面向调用者的输出中注明回退情况。
origingit merge-base案例A——PR位于当前仓库:
直接从上述JSON响应的读取PR头部SHA。一次调用拉取基准引用和头部SHA(当引用已在本地时,拉取操作是幂等的):
headRefOidbash
PR_HEAD_SHA=<headRefOid from JSON>
git fetch --no-tags origin <baseRefName> $PR_HEAD_SHA在下游命令中使用显式的可避免的多引用排序问题(仅返回第一个拉取引用的SHA,这会导致多引用拉取静默失败)。
$PR_HEAD_SHAFETCH_HEADgit rev-parse FETCH_HEADbash
MERGE_BASE=$(git merge-base origin/<baseRefName> $PR_HEAD_SHA) && echo "MERGE_BASE=$MERGE_BASE" && echo '=== COMMITS ===' && git log --oneline $MERGE_BASE..$PR_HEAD_SHA && echo '=== DIFF ===' && git diff $MERGE_BASE...$PR_HEAD_SHA若显式SHA拉取被拒绝(GitHub上罕见,但在某些不允许拉取非尖端SHA的GHES配置中可能发生),则回退到拉取并通过拉取引用模式从读取PR头部SHA:
refs/pull/<number>/head.git/FETCH_HEADbash
git fetch --no-tags origin "refs/pull/<number>/head"
PR_HEAD_SHA=$(awk '/refs\/pull\/[0-9]+\/head/ {print $1; exit}' "$(git rev-parse --git-dir)/FETCH_HEAD")案例B——PR位于其他仓库:
完全跳过本地Git操作。从API读取差异和提交列表:
bash
gh pr diff <pr-ref>
gh pr view <pr-ref> --json commits --jq '.commits[] | [.oid[0:7], .messageHeadline] | @tsv'使用相同的分类/框架/写作流程。在面向调用者的输出中注明使用了API回退。
同样需捕获现有PR正文,以便在步骤3中保留证据(两种案例均需)。
Step 2: Classify commits before writing
步骤2:编写前对提交进行分类
Scan the commit list and classify each commit:
- Feature commits -- implement the PR's purpose (new functionality, intentional refactors, design changes). These drive the description.
- Fix-up commits -- iteration work (code review fixes, lint fixes, test fixes, rebase resolutions, style cleanups). Invisible to the reader.
When sizing the description, mentally subtract fix-up commits: a branch with 12 commits but 9 fix-ups is a 3-commit PR.
扫描提交列表,对每个提交进行分类:
- 特性提交——实现PR的核心目标(新功能、有意重构、设计变更)。这些提交是描述的核心。
- 修正提交——迭代工作(代码评审修复、lint修复、测试修复、变基解决、样式清理)。对读者不可见。
确定描述篇幅时,需在心理上减去修正提交:一个包含12个提交但其中9个是修正提交的分支,实际上是3个提交的PR。
Step 3: Decide on evidence
步骤3:确定是否保留证据
Decide whether evidence capture is possible from the full branch diff.
Evidence is possible when the diff changes observable behavior demonstrable from the workspace: UI, CLI output, API behavior with runnable code, generated artifacts, or workflow output.
Evidence is not possible for:
- Docs-only, markdown-only, changelog-only, release metadata, CI/config-only, test-only, or pure internal refactors
- Behavior requiring unavailable credentials, paid/cloud services, bot tokens, deploy-only infrastructure, or hardware not provided
This skill does NOT prompt the user to capture evidence. The decision logic is:
- PR mode invocation (any form: bare number, ,
#NN, or a full URL — anything that resolves to an existing PR whose body we fetched) and the existing body contains apr:<N>or## Demosection with image embeds: preserve it verbatim unless the steering text asks to refresh or remove it. Include the preserved block in the returned body. This applies regardless of which input shape the caller used; what matters is that a PR exists and its body was read.## Screenshots - Current-branch mode or PR mode without an evidence block: omit the evidence section entirely. If the caller wants to capture evidence, the caller is responsible for invoking separately and splicing the result in, or for asking this skill to regenerate with updated steering text after capture.
ce-demo-reel
Do not label test output as "Demo" or "Screenshots". Place any preserved evidence block before the Compound Engineering badge.
判断是否可从完整分支差异中捕获证据。
可捕获证据:当差异改变了可从工作区演示的可观察行为时,包括UI、CLI输出、可运行代码的API行为、生成的工件或工作流输出。
不可捕获证据:
- 仅文档、仅Markdown、仅变更日志、发布元数据、仅CI/配置、仅测试或纯内部重构
- 需要不可用凭证、付费/云服务、机器人令牌、仅部署基础设施或未提供硬件的行为
此技能不会提示用户捕获证据。决策逻辑如下:
- PR模式调用(任意形式:纯数字、、
#NN或完整URL——任何可解析为现有PR且已获取其正文的调用)且现有正文包含带有图片嵌入的pr:<N>或## Demo部分:除非指导文本要求刷新或移除,否则原样保留。将保留的块包含在返回的正文中。无论调用者使用何种输入格式,只要PR存在且已读取其正文,此规则均适用。## Screenshots - 当前分支模式或无证据块的PR模式:完全省略证据部分。若调用者希望捕获证据,需单独调用并将结果插入,或在捕获后要求此技能使用更新的指导文本重新生成。
ce-demo-reel
不得将测试输出标记为“Demo”或“Screenshots”。将保留的证据块放在Compound Engineering徽章之前。
Step 4: Frame the narrative before sizing
步骤4:编写前构建叙述框架
Articulate the PR's narrative frame:
- Before: What was broken, limited, or impossible? (One sentence.)
- After: What's now possible or improved? (One sentence.)
- Scope rationale (only if 2+ separable-looking concerns): Why do these ship together? (One sentence.)
This frame becomes the opening. For small+simple PRs, the "after" sentence alone may be the entire description.
明确PR的叙述框架:
- 之前:存在哪些问题、限制或无法实现的功能?(一句话)
- 之后:现在可实现或改进了什么?(一句话)
- 范围理由(仅当存在2个及以上可分离的关注点时):为何这些变更要一起发布?(一句话)
此框架作为描述的开头。对于小型简单PR,仅“之后”一句话即可构成完整描述。
Step 5: Size the change
步骤5:评估变更规模
Assess size (files, diff volume) and complexity (design decisions, trade-offs, cross-cutting concerns) to select description depth:
| Change profile | Description approach |
|---|---|
| Small + simple (typo, config, dep bump) | 1-2 sentences, no headers. Under ~300 characters. |
| Small + non-trivial (bugfix, behavioral change) | Short narrative, ~3-5 sentences. No headers unless two distinct concerns. |
| Medium feature or refactor | Narrative frame (before/after/scope), then what changed and why. Call out design decisions. |
| Large or architecturally significant | Narrative frame + up to 3-5 design-decision callouts + 1-2 sentence test summary + key docs links. Target ~100 lines, cap ~150. For PRs with many mechanisms, use a Summary-level table to list them; do NOT create an H3 subsection per mechanism. Reviewers scrutinize decisions, not inventories — the diff and spec files carry the detail. If you find yourself writing 10+ subsections, consolidate to a table. |
| Performance improvement | Include before/after measurements if available. Markdown table works well. |
When in doubt, shorter is better. Match description weight to change weight. Large PRs need MORE selectivity, not MORE content.
评估变更规模(文件数量、差异量)和复杂度(设计决策、权衡、跨领域关注点),选择描述深度:
| 变更类型 | 描述方式 |
|---|---|
| 小型且简单(拼写错误、配置、依赖版本升级) | 1-2句话,无标题。约300字符以内。 |
| 小型但非 trivial( bug修复、行为变更) | 简短叙述,约3-5句话。除非存在两个不同关注点,否则无标题。 |
| 中型特性或重构 | 叙述框架(之前/之后/范围),然后说明变更内容及原因。突出设计决策。 |
| 大型或架构级变更 | 叙述框架 + 最多3-5个设计决策要点 + 1-2句话的测试总结 + 关键文档链接。目标约100行,上限约150行。对于包含多种机制的PR,使用摘要级表格列出这些机制;不得为每个机制创建H3子节。评审者关注的是决策,而非清单——差异和规范文件已包含详细信息。若发现自己编写了10+个子节,需合并为一个标题下的表格,每行对应一个机制。 |
| 性能优化 | 若有可用数据,包含前后对比测量结果。Markdown表格效果良好。 |
存疑时,优先选择更简短的描述。描述篇幅需与变更规模匹配。大型PR需要更高的选择性,而非更多内容。
Step 6: Apply writing principles
步骤6:应用写作原则
Writing voice
写作风格
If the repo has documented style preferences in context, follow those. Otherwise:
- Active voice. No em dashes or substitutes; use periods, commas, colons, or parentheses.
-- - Vary sentence length. Never three similar-length sentences in a row.
- Do not make a claim and immediately explain it. Trust the reader.
- Plain English. Technical jargon fine; business jargon never.
- No filler: "it's worth noting", "importantly", "essentially", "in order to", "leverage", "utilize."
- Digits for numbers ("3 files"), not words ("three files").
若仓库上下文有记录的风格偏好,需遵循这些偏好。否则:
- 使用主动语态。不要使用破折号或替代;使用句号、逗号、冒号或括号。
-- - 变换句子长度。不得连续使用三个相似长度的句子。
- 不要先提出主张再立即解释。信任读者的理解能力。
- 使用简洁英语。可使用技术术语;禁止使用业务术语。
- 无冗余内容:“值得注意的是”“重要的是”“本质上”“为了”“利用”“使用”等词汇一律删除。
- 数字使用阿拉伯数字(“3 files”),而非英文单词(“three files”)。
Writing principles
写作原则
- Lead with value: Open with what's now possible or fixed, not what was moved around. The subtler failure is leading with the mechanism ("Replace the hardcoded capture block with a tiered skill") instead of the outcome ("Evidence capture now works for CLI tools and libraries, not just web apps").
- No orphaned opening paragraphs: If the description uses headings anywhere, the opening must also be under a heading (e.g.,
##). For short descriptions with no sections, a bare paragraph is fine.## Summary - Describe the net result, not the journey: The description covers the end state, not how you got there. No iteration history, debugging steps, intermediate failures, or bugs found and fixed during development. This applies equally when regenerating for an existing PR: rewrite from the current state, not as a log of what changed since the last version. Exception: process details critical to understand a design choice.
- When commits conflict, trust the final diff: The commit list is supporting context, not the source of truth. If commits describe intermediate steps later revised or reverted, describe the end state from the full branch diff.
- Explain the non-obvious: If the diff is self-explanatory, don't narrate it. Spend space on things the diff doesn't show: why this approach, what was rejected, what the reviewer should watch.
- Use structure when it earns its keep: Headers, bullets, and tables aid comprehension, not mandatory template sections.
- Markdown tables for data: Before/after comparisons, performance numbers, or option trade-offs communicate well as tables.
- No empty sections: If a section doesn't apply, omit it. No "N/A" or "None."
- Test plan — only when non-obvious: Include when testing requires edge cases the reviewer wouldn't think of, hard-to-verify behavior, or specific setup. Omit when "run the tests" is the only useful guidance. When the branch adds test files, name them with what they cover.
- No Commits section: GitHub already shows the commit list in its own tab. A Commits section in the PR body duplicates that without adding context. Omit unless the commits need annotations explaining their ordering or shipping rationale.
- No Review / process section: Do not include a section describing how the reviewer should review (checklists of things to look at, process bullets). Process doesn't help the reviewer evaluate code. Call out specific non-obvious things to scrutinize inline with the change that warrants it.
- 以价值为开头:开头说明现在可实现的功能或已修复的问题,而非变更了哪些内容。常见错误是先描述机制(“将硬编码捕获块替换为分层技能”),而非结果(“证据捕获现在适用于CLI工具和库,而非仅Web应用”)。
- 无孤立开头段落:若描述中使用了标题,则开头也必须放在标题下(例如
##)。对于无章节的简短描述,可直接使用段落。## Summary - 描述最终结果,而非过程:描述针对最终状态,而非实现过程。不得包含迭代历史、调试步骤、中间失败或开发过程中发现并修复的bug。此规则同样适用于为现有PR重新生成描述:基于当前状态重写,而非记录自上一版本以来的变更。例外:对理解设计选择至关重要的过程细节。
- 提交与差异冲突时,信任最终差异:提交列表是辅助上下文,而非事实来源。若提交描述了后续被修改或回退的中间步骤,需基于完整分支差异描述最终状态。
- 解释非显而易见的内容:若差异可自行解释,则无需赘述。将篇幅用于差异未体现的内容:为何选择此方案、拒绝了哪些方案、评审者需关注的要点。
- 仅在必要时使用结构:标题、项目符号和表格有助于理解,但并非强制模板章节。
- 数据使用Markdown表格:前后对比、性能数据或选项权衡使用表格更清晰。
- 无空章节:若章节不适用,则省略。不得使用“N/A”或“无”。
- 测试计划——仅在非显而易见时包含:当测试需要评审者想不到的边缘案例、难以验证的行为或特定设置时,需包含测试计划。若“运行测试”是唯一有用的指导,则省略。当分支添加测试文件时,需注明文件对应的测试内容。
- 无提交章节:GitHub已在单独的标签页中显示提交列表。PR正文中的提交章节属于重复内容,无额外价值。除非提交需要注释说明其顺序或发布理由,否则省略。
- 无评审/流程章节:不得包含描述评审者应如何评审的章节(需检查事项清单、流程项目符号)。流程对评审者评估代码无帮助。若有特定非显而易见的要点需评审,需在对应的变更内容附近注明。
Visual communication
视觉传达
Include a visual aid only when the change is structurally complex enough that a reviewer would struggle to reconstruct the mental model from prose alone.
The core distinction — structure vs. parallel variation:
- Use a Mermaid diagram when the change has topology — components with directed relationships (calls, flows, dependencies, state transitions, data paths). Diagrams express "A talks to B, B talks to C, C does not talk back to A" in a way tables cannot.
- Use a markdown table when the change has parallel variation of a single shape — N things that share the same attributes but differ in their values. Tables express "option 1 costs X, option 2 costs Y, option 3 costs Z" cleanly.
Architecture changes are almost always topology (components + edges), so Mermaid is usually the right call — a table of "components that interact" loses the edges and becomes a flat list. Reserve tables for genuinely parallel data: before/after measurements, option trade-offs, flag matrices, config enumerations.
When to include (prefer Mermaid, not a table, for architecture/flow):
| PR changes... | Visual aid |
|---|---|
| Architecture touching 3+ interacting components (the components have directed relationships — who calls whom, who owns what, which skill delegates to which) | Mermaid component or interaction diagram. Do not substitute a table — tables cannot show edges. |
| Multi-step workflow or data flow with non-obvious sequencing | Mermaid flow diagram |
| State machine with 3+ states and non-trivial transitions | Mermaid state diagram |
| Data model changes with 3+ related entities | Mermaid ERD |
| Before/after performance or behavioral measurements (same metric, different values) | Markdown table |
| Option or flag trade-offs (same attributes evaluated across variants) | Markdown table |
| Feature matrix / compatibility grid | Markdown table |
When in doubt, ask: "Does the information have edges (A → B) or does it have rows (attribute × variant)?" Edges → Mermaid. Rows → table. Architecture has edges almost by definition.
When to skip any visual:
- Sizing routes to "1-2 sentences"
- Prose already communicates clearly
- The diagram would just restate the diff visually
- Mechanical changes (renames, dep bumps, config, formatting)
Format details:
- Mermaid (default for topology). 5-10 nodes typical, up to 15 for genuinely complex changes. Use direction. Source should be readable as fallback.
TB - ASCII diagrams for annotated flows needing rich in-box content. 80-column max.
- Markdown tables for parallel-variation data only.
- Place inline at point of relevance, not in a separate section.
- Prose is authoritative when it conflicts with a visual.
Verify generated diagrams against the change before including.
仅当变更结构足够复杂,导致评审者难以仅通过文字构建心智模型时,才包含视觉辅助内容。
核心区别——结构与并行变体:
- 当变更具有拓扑结构(组件间存在定向关系:调用关系、流程、依赖、状态转换、数据路径)时,使用Mermaid图。图可清晰表达“A调用B,B调用C,C不回调A”,而表格无法做到这一点。
- 当变更具有单一形态的并行变体(N个事物具有相同属性但值不同)时,使用Markdown表格。表格可清晰表达“选项1成本为X,选项2为Y,选项3为Z”。
架构变更几乎总是拓扑结构(组件+关联),因此Mermaid通常是正确选择——“交互组件”表格会丢失关联关系,变成扁平列表。表格仅适用于真正的并行数据:前后测量结果、选项权衡、标志矩阵、配置枚举。
何时包含(架构/流程优先选择Mermaid,而非表格):
| PR变更内容... | 视觉辅助 |
|---|---|
| 涉及3个及以上交互组件的架构变更(组件间存在定向关系——谁调用谁、谁拥有什么、哪个技能委托给哪个) | Mermaid组件或交互图。不得用表格替代——表格无法显示关联关系。 |
| 多步骤工作流或数据流程,且顺序非显而易见 | Mermaid流程图 |
| 包含3个及以上状态和复杂转换的状态机 | Mermaid状态图 |
| 涉及3个及以上相关实体的数据模型变更 | Mermaid实体关系图(ERD) |
| 前后性能或行为测量结果(同一指标,不同值) | Markdown表格 |
| 选项或标志权衡(同一属性在不同变体中的评估) | Markdown表格 |
| 特性矩阵/兼容性网格 | Markdown表格 |
存疑时,问自己:“信息是否有关联关系(A → B),还是有行(属性 × 变体)?” 关联关系→Mermaid。行→表格。架构变更几乎必然有关联关系。
何时跳过视觉辅助:
- 规模评估为“1-2句话”
- 文字已清晰传达内容
- 图仅为差异的视觉重复
- 机械变更(重命名、依赖升级、配置、格式调整)
格式细节:
- Mermaid(拓扑结构默认选择)。典型为5-10个节点,复杂变更最多15个节点。使用方向。源代码需可读,作为 fallback。
TB - ASCII图用于需要丰富内置内容的带注释流程。最大80列。
- Markdown表格仅用于并行变体数据。
- 内联在相关位置,而非单独章节。
- 当文字与视觉内容冲突时,以文字为准。
包含前需验证生成的图是否与变更一致。
Numbering and references
编号与引用
Never prefix list items with in PR descriptions — GitHub interprets , as issue references and auto-links them.
##1#2When referencing actual GitHub issues or PRs, use or the full URL. Never use bare unless verified.
org/repo#123#123PR描述中不得使用作为列表项前缀——GitHub会将、解析为问题引用并自动链接。
##1#2引用实际GitHub问题或PR时,使用或完整URL。除非已验证,否则不得使用纯。
org/repo#123#123Applying the focus hint
应用聚焦提示
If a hint was provided, incorporate it alongside the diff-derived narrative. Treat focus as steering, not override: do not invent content the diff does not support, and do not suppress important content the diff demands simply because focus did not mention it. When focus and diff materially disagree (e.g., focus says "include benchmarking" but the diff has no benchmarks), note the conflict in a way the caller can see (leave a brief inline note or raise to the caller) rather than fabricating content.
focus:若提供了提示,需将其与基于差异生成的叙述内容结合。将聚焦视为指导,而非强制覆盖:不得编造差异不支持的内容,也不得因聚焦未提及而压制差异要求的重要内容。当聚焦与差异存在实质性冲突(例如聚焦要求“包含基准测试”但差异中无基准测试),需以调用者可见的方式指出冲突(留下简短内联注释或告知调用者),而非编造内容。
focus:Step 7: Compose the title
步骤7:撰写标题
Title format: or .
type: descriptiontype(scope): description- Type is chosen by intent, not file extension or diff shape. for new functionality,
featfor a bug fix,fixfor a behavior-preserving change,refactorfor doc-only,docsfor tooling/maintenance,chorefor performance,perffor test-only. Wheretestandfixcould both seem to fit, default tofeat: a change that remedies broken or missing behavior isfixeven when implemented by adding code. Reservefixfor capabilities the user could not previously accomplish. The user may override.feat - Scope (optional) is the narrowest useful label: a skill/agent name, CLI area, or shared area. Omit when no single label adds clarity.
- Description is imperative, lowercase, under 72 characters total. No trailing period.
- If the repo has commit-title conventions visible in recent commits, match them.
Breaking changes use (e.g., ) or document in the body with a footer.
!feat!: ...BREAKING CHANGE:标题格式:或。
type: descriptiontype(scope): description- Type根据意图选择,而非文件扩展名或差异形态。用于新功能,
feat用于bug修复,fix用于不改变行为的变更,refactor用于仅文档变更,docs用于工具/维护,chore用于性能优化,perf用于仅测试变更。当test和fix均适用时,默认选择feat:修复损坏或缺失行为的变更,即使通过添加代码实现,也属于fix。fix仅用于用户之前无法实现的功能。用户可覆盖此选择。feat - Scope(可选)是最窄的有用标签:技能/Agent名称、CLI领域或共享领域。若没有单一标签能增加清晰度,则省略。
- Description为祈使语气、小写,总长度不超过72字符。无结尾句号。
- 若仓库近期提交有可见的标题规范,需匹配该规范。
破坏性变更使用(例如),或在正文中用脚注说明。
!feat!: ...BREAKING CHANGE:Step 8: Compose the body
步骤8:撰写正文
Assemble the body in this order:
- Opening -- the narrative frame from Step 4, at the depth chosen in Step 5. Under a heading (e.g., ) if the description uses any
## Summaryheadings elsewhere; a bare paragraph otherwise.## - Body sections -- only the sections that earn their keep for this change: what changed and why, design decisions, tables for data, visual aids when complexity warrants. Skip empty sections entirely.
- Test plan -- only when non-obvious per the writing principles. Omit otherwise.
- Evidence block -- only the preserved block from Step 3, if one exists. Do not fabricate or placeholder.
- Compound Engineering badge -- append a badge footer separated by a rule. Skip if the existing body (for
---input) already contains the badge.pr:
Badge:
markdown
---
[](https://github.com/EveryInc/compound-engineering-plugin)
Harness lookup:
| Harness | | |
|---|---|---|
| Claude Code | | |
| Codex | (omit logo param) | |
| Gemini CLI | | |
Model slug: Replace spaces with underscores. Append context window and thinking level in parentheses if known. Examples: , , .
Opus_4.6_(1M,_Extended_Thinking)Sonnet_4.6_(200K)Gemini_3.1_Pro按以下顺序组装正文:
- 开头——步骤4中的叙述框架,深度由步骤5确定。若描述中使用了任何标题,则开头需放在标题下(例如
##);否则直接使用段落。## Summary - 正文章节——仅包含对当前变更有必要的章节:变更内容及原因、设计决策、数据表格、复杂度需要时的视觉辅助。完全省略空章节。
- 测试计划——仅在写作原则要求的非显而易见场景下包含。否则省略。
- 证据块——仅包含步骤3中保留的块(若存在)。不得编造或占位。
- Compound Engineering徽章——添加由分隔的徽章页脚。若(针对
---输入的)现有正文已包含徽章,则跳过。pr:
徽章:
markdown
---
[](https://github.com/EveryInc/compound-engineering-plugin)
Harness查找:
| Harness | | |
|---|---|---|
| Claude Code | | |
| Codex | (省略logo参数) | |
| Gemini CLI | | |
Model slug: 将空格替换为下划线。若已知上下文窗口和思考级别,需在括号中添加。示例:、、。
Opus_4.6_(1M,_Extended_Thinking)Sonnet_4.6_(200K)Gemini_3.1_ProStep 8b: Compression pass
步骤8b:压缩优化
Before writing the body to the temp file, re-read the composed body and apply these cuts:
- If any body section restates content already in the , remove it. The Summary plus the diff should carry the reader.
## Summary - If "Testing" or "Test plan" has more than 2 paragraphs, compress to bullets.
- If a "Commits" section enumerates the commit log, remove it — GitHub shows it in its own tab.
- If a "Review" or process-oriented section lists how to review, remove it. Move any truly non-obvious review hints inline with the relevant change.
- If the body has 5+ H3 subsections that each describe one mechanism, consolidate them into a single table row per mechanism under one header. Reserve prose H3 callouts for 2-3 genuine design decisions.
- If the body exceeds the sizing-table target by more than 30%, compress the longest non-Summary section by half.
Value-lead check. Re-read the first sentence of the Summary. If it describes what was moved around, renamed, or added ("This PR introduces three-tier autofix..."), rewrite to lead with what's now possible or what was broken and is now fixed ("Document reviews previously produced 14+ findings requiring user judgment; this PR cuts that to 4-6.").
Large PRs benefit from selectivity, not comprehensiveness.
将正文写入临时文件前,重新阅读已撰写的正文并进行以下删减:
- 若任何正文章节重复了中的内容,删除该章节。摘要加差异应足以让读者理解。
## Summary - 若“Testing”或“Test plan”超过2段,压缩为项目符号。
- 若“Commits”章节枚举了提交日志,删除该章节——GitHub已在单独标签页中显示。
- 若“Review”或面向流程的章节列出了评审方式,删除该章节。将真正非显而易见的评审提示移至对应变更内容附近。
- 若正文有5个及以上H3子节,每个子节描述一个机制,需将它们合并为一个标题下的表格,每行对应一个机制。仅为2-3个真正的设计决策保留H3节。
- 若正文超出规模表目标30%以上,将最长的非摘要章节压缩一半。
价值开头检查。重新阅读摘要的第一句话。若它描述了变更的内容(“此PR引入三层自动修复...”),需重写为以价值开头(“文档评审之前会产生14+项需要用户判断的结果;此PR将其减少至4-6项。”)。
大型PR受益于选择性,而非全面性。
Step 9: Return {title, body_file}
{title, body_file}步骤9:返回{title, body_file}
{title, body_file}Write the composed body to an OS temp file, then return the title and the file path. Do not call , , or any other mutating command. Do not ask the user to confirm — the caller owns apply.
gh pr editgh pr createbash
BODY_FILE=$(mktemp "${TMPDIR:-/tmp}/ce-pr-body.XXXXXX") && cat > "$BODY_FILE" <<'__CE_PR_BODY_END__' && echo "$BODY_FILE"
<the composed body markdown goes here, verbatim>
__CE_PR_BODY_END__The quoted sentinel keeps , backticks, , and any literal inside the body from being expanded or clashing with the terminator. Keep chained with so a failed or write never yields a success exit status with a path to a missing file.
'__CE_PR_BODY_END__'$VAR${...}EOFecho "$BODY_FILE"&&mktempFormat the return as a clearly labeled block the caller can extract cleanly:
=== TITLE ===
<title line>
=== BODY_FILE ===
<absolute path to the mktemp body file>Do not emit the body markdown in the return block — the caller reads it from .
BODY_FILEIf Step 1 exited gracefully (closed/merged PR, invalid range, empty commit list), do not create a body file — just return the reason string.
The return block is a hand-off, not task completion. When invoked by a parent skill (e.g., ), emit the return block and then continue executing the parent's remaining steps (typically or with the returned title and body file). Do not stop after the return block unless invoked directly by the user with no parent workflow.
ce-commit-push-prgh pr creategh pr edit将撰写好的正文写入操作系统临时文件,然后返回标题和文件路径。不得调用、或任何其他变更命令。不得要求用户确认——应用操作由调用者负责。
gh pr editgh pr createbash
BODY_FILE=$(mktemp "${TMPDIR:-/tmp}/ce-pr-body.XXXXXX") && cat > "$BODY_FILE" <<'__CE_PR_BODY_END__' && echo "$BODY_FILE"
<the composed body markdown goes here, verbatim>
__CE_PR_BODY_END__带引号的标记可防止正文中的、反引号、和任何字面被展开或与终止符冲突。将与链式调用,确保或写入失败时不会返回成功状态和指向不存在文件的路径。
'__CE_PR_BODY_END__'$VAR${...}EOFecho "$BODY_FILE"&&mktemp将返回结果格式化为调用者可清晰提取的块:
=== TITLE ===
<title line>
=== BODY_FILE ===
<absolute path to the mktemp body file>不得在返回块中输出正文Markdown——调用者从读取。
BODY_FILE若步骤1优雅退出(PR已关闭/合并、无效范围、提交列表为空),则不创建正文文件——仅返回原因字符串。
返回块是交接点,而非任务完成。当被父技能(如)调用时,输出返回块后继续执行父技能的剩余步骤(通常是使用返回的标题和正文文件执行或)。除非被用户直接调用且无父工作流,否则不得在返回块后停止。
ce-commit-push-prgh pr creategh pr editCross-platform notes
跨平台说明
This skill does not ask questions directly. If the diff is ambiguous about something the caller should decide (e.g., focus conflicts with the actual changes, or evidence is technically capturable but the caller did not pre-stage it), surface the ambiguity in the returned output or a short note to the caller — do not invoke a platform question tool.
Callers that need to ask the user are responsible for using their own platform's blocking question tool: in Claude Code (call with first if its schema isn't loaded), in Codex, in Gemini, in Pi (requires the extension). Fall back to numbered options in chat only when no blocking tool exists in the harness or the call errors (e.g., Codex edit modes) — not because a schema load is required. Never silently skip the question.
AskUserQuestionToolSearchselect:AskUserQuestionrequest_user_inputask_userask_userpi-ask-user此技能不会直接提问。若差异中存在需调用者决定的模糊点(例如聚焦与实际变更冲突,或技术上可捕获证据但调用者未预先准备),需在返回结果中指出该模糊点,或向调用者发送简短说明——不得调用平台提问工具。
需要向用户提问的调用者需使用自身平台的阻塞式提问工具:Claude Code中的(若未加载其schema,需先调用并指定)、Codex中的、Gemini中的、Pi中的(需扩展)。仅当 harness中无阻塞式工具或调用出错(如Codex编辑模式)时,才回退到聊天中的编号选项——不得因需要加载schema而回退。不得静默跳过提问。
AskUserQuestionToolSearchselect:AskUserQuestionrequest_user_inputask_userask_userpi-ask-user