agentleFS
maee-comaee-co/cc-autoship/skills/pr-context-summary/SKILL.md

pr-context-summary

Skill0 starsChanged 5 months agoMITView on GitHub

Carry decisions forward: on PR creation or after merge, append a summary of the decisions made with the maintainer to a GitHub Issue for whoever picks up next.

  • Reads credentials

The file

We split this skill into the rules it gives an agent

11 rules. About 0 are common, 6 are distinctive, and 5 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈6

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 5

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Avoid double posting: put an HTML comment marker at the top of each comment, and do not post again if a marker for the same mode already …

    line 45
  2. Very specific:

    If --pr was not given, get the PR linked to the current branch:

    line 74
  3. Distinctive:

    If that fails, exit with an error:

    line 80
  4. Very specific:

    If --issue was not given, extract Closes #XX from the PR body:

    line 85
  5. Distinctive:

    Not found → skip it and comment on the PR itself (fallback)

    line 96
  6. Distinctive:

    Do not post again if a marker for the same mode already exists in the comments.

    line 100
  7. Very specific:

    When falling back to the PR itself, check the same way with gh pr view "$PR_NUM" --json comments.

    line 113
  8. Very specific:

    Issue metadata: if the issue was resolved, gh issue view "$ISSUE" --json title,body

    line 124
  9. Distinctive:

    No detailed extraction from the conversation: do not dig into chosen options, rejected options, or maintainer decisions — write only what …

    line 127
  10. Very specific:

    Do not confuse the two: calling --mode post-merge --lightweight routes into the thin template section (step 6, "lightweight post-merge …

    line 173
  11. Distinctive:

    If it was skipped because a summary for the same mode already exists, say so

    line 297

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

/pr-context-summary

A skill that summarizes the decisions, requests, and rejected options exchanged with the maintainer during a session, and leaves them as a comment on the GitHub issue linked to the PR. Use it for retrospectives and for handing the direction to follow-up work.

Usage

# pre-merge: call when the PR has been created (auto-chained from the end of /commit-push)
/pr-context-summary --mode pre-merge

# post-merge: call when the merge completes (auto-chained from the end of /auto-merge on MERGED)
/pr-context-summary --mode post-merge

# Give the PR / issue number explicitly
/pr-context-summary --mode pre-merge --pr 226
/pr-context-summary --mode post-merge --pr 226 --issue 226

# For light PRs (docs-only / test-only / small internal changes), skip the detailed extraction from the conversation
/pr-context-summary --mode pre-merge --pr 226 --lightweight

# Reconstruct post-merge from GitHub state, independent of the conversation (F1, e.g. detecting a manual merge)
/pr-context-summary --mode post-merge --reconstruct --pr 226

Arguments

ArgumentDescriptionDefault
--modepre-merge / post-mergeRequired
--prPR numberInferred from the current branch
--issueGitHub issue numberExtracted from Closes #XX in the PR body
--lightweightFor docs-only / test-only / small internal changes. Builds a minimal summary from PR metadata, the issue, and the commits using a thin dedicated template, without extracting details from the conversationfalse
--reconstructUsed with --mode post-merge. In a session with no conversation context (a separate session after a manual merge, SessionStart detection, and the like), fills the normal post-merge template (the one with slots for review findings, maintainer adjustments, and additional decisions) from GitHub state — reviews, comments, and the pre-merge summary — rather than from the conversation. A separate path from --lightweight (see step 5, "Reconstructing post-merge from GitHub state")false

Key rules

  • Avoid double posting: put an HTML comment marker at the top of each comment, and do not post again if a marker for the same mode already exists in the comments
  • When several issues are linked: post only to the first Closes #XX (a GitHub issue) in the PR body. Linear picks the comment up automatically through the GitHub sync, so never post to Linear directly
  • Medium granularity (20-30 lines): enough to hand over to follow-up work, not so much that it becomes noise
  • No personal information or secrets: strip API keys, tokens, and .env contents before output

Procedure

Step 1: Parse the arguments

const argString = args || '';
const modeMatch = argString.match(/--mode\s+(pre-merge|post-merge)/);
const prMatch = argString.match(/--pr\s+(\d+)/);
const issueMatch = argString.match(/--issue\s+#?(\d+)/);
const lightweight = /\s--lightweight(\s|$)/.test(` ${argString} `);
const reconstruct = /\s--reconstruct(\s|$)/.test(` ${argString} `);

const mode = modeMatch?.[1];
let pr = prMatch?.[1];
let issue = issueMatch?.[1];

if (!mode) {
  // error: --mode is required
  return error('--mode pre-merge|post-merge is required');
}

Step 2: Resolve the PR number

If --pr was not given, get the PR linked to the current branch:

PR_NUM=$(gh pr view --json number -q .number 2>/dev/null)

If that fails, exit with an error:

  • No PR is linked to the current branch. Specify one with --pr

Step 3: Resolve the issue number

If --issue was not given, extract Closes #XX from the PR body:

gh pr view "$PR_NUM" --json body --jq '.body' \
  | /usr/bin/grep -oiE '(close[sd]?|fixe[sd]?|resolve[sd]?|complete[sd]?|implement[sd]?)\s+#[0-9]+' \
  | head -1 \
  | /usr/bin/grep -oE '#[0-9]+' \
  | tr -d '#'
  • Found → use that issue number
  • Not found → skip it and comment on the PR itself (fallback)

Step 4: Check for a duplicate post

Do not post again if a marker for the same mode already exists in the comments.

# When posting a comment on the issue
EXISTING=$(gh issue view "$ISSUE" --json comments --jq '.comments[].body' \
  | /usr/bin/grep -c "<!-- pr-context-summary:${MODE}:PR#${PR_NUM} -->" || true)

if [ "${EXISTING:-0}" -gt 0 ]; then
  echo "A ${MODE} summary has already been posted (PR #${PR_NUM}). Skipping"
  exit 0
fi

When falling back to the PR itself, check the same way with gh pr view "$PR_NUM" --json comments.

Step 5: Generate the summary

Where the content comes from depends on --lightweight / --reconstruct (--lightweight uses a thin dedicated template; --reconstruct fills the normal template from GitHub state — see the respective sections).

lightweight mode

For light PRs with few additional maintainer decisions: docs-only, test-only, small internal workflow changes, and the like.

  • PR metadata: gh pr view "$PR_NUM" --json title,body,commits,files,additions,deletions
  • Issue metadata: if the issue was resolved, gh issue view "$ISSUE" --json title,body
  • Commit information: the PR's commit titles and bodies
  • A rough classification of the diff: judge docs-only / test-only / infra / code from the files
  • No detailed extraction from the conversation: do not dig into chosen options, rejected options, or maintainer decisions — write only what is already in the PR body and the issue

Even in lightweight mode, the marker, the destination, and the duplicate check are the same as in normal mode.

Normal mode

Claude refers to the current session context and extracts the following.

pre-merge mode

Covers everything from the start of the session to PR creation:

  • The initial instruction and background: the maintainer's first request, the preconditions
  • Design options and the decision: the options considered and the one the maintainer chose
  • Rejected options and why: what was considered and not adopted
  • Key implementation points: the important design decisions (the reasoning, not the concrete diff)
  • Open items and candidate next directions: what this PR did not cover but should follow

post-merge mode

Covers everything from PR creation to the merge:

  • Review findings and how they were addressed: the /review findings plus the fixes
  • The maintainer's adjustment requests: anything the maintainer instructed additionally in PR comments or conversation
  • Additional decisions after the merge: directions settled just before or just after merging
  • Next actions: candidate follow-up issues or PRs

Reconstructing post-merge from GitHub state (conversation-independent, F1, --reconstruct)

When --mode post-merge --reconstruct is called outside the original session (a separate session after a manual merge, or via SessionStart detection), that session has no conversation context, so normal mode's "Claude refers to the session context" is unavailable. Use this path rather than --lightweight (they are separate paths — see "The difference between --reconstruct and --lightweight" below).

The output is the normal post-merge template (the one with the three slots described in step 6: review findings, maintainer adjustments and additional decisions, and next actions after the merge). Only the content of each section comes from GitHub state instead of the conversation:

  • The existing pre-merge summary comment on the issue (identified by the marker <!-- pr-context-summary:pre-merge:PR#N -->): carries forward the initial instruction, the design decisions, and the open items
  • The PR's comments and reviews: gh pr view <PR> --json comments,reviews,mergedAt,mergeCommit
    • "Review findings and how they were addressed" → extracted from reviews (the review comments posted by /review and friends)
    • "The maintainer's adjustment requests and additional decisions" → extracted from comments (the maintainer's additional instructions on the PR)
  • The state of the closing issue: whether the issue is closed (used together with mergedAt / mergeCommit to corroborate the merge result)

For any section the sources above cannot fill, state "none" or "nothing extractable from GitHub state" explicitly (never fall back to the conversation log).

The difference between --reconstruct and --lightweight
  • --reconstruct: the template stays the normal one (the three slots are preserved). Only the source of information is swapped from the conversation to GitHub state (the pre-merge summary, PR reviews and comments, issue state)
  • --lightweight: the template itself is a thin dedicated one (it has no slot for review findings and the like). It is designed for "light PRs with few additional maintainer decisions" and deliberately skips digging into reviews and comments

Do not confuse the two: calling --mode post-merge --lightweight routes into the thin template section (step 6, "lightweight post-merge template") and never reaches the reconstruction logic in this section.

The duplicate-post marker <!-- pr-context-summary:post-merge:PR#N --> is shared by the inline path (the normal call from /auto-merge) and the F1 path (this section), so whichever posts first, the duplicate check in step 4 suppresses the other (there is no need for separate marker schemes).

Step 6: Format with a template

Output language: write the summary body in the language of the session (the templates below are the English sample and are not strings to copy verbatim). docs/rules/output-language.md is the SSoT for the fixed label translations and the language-invariant tokens.

Always emit regardless of language (never translate or omit): the duplicate-post marker <!-- pr-context-summary:<mode>:PR#<N> --> on the first line of every template. The duplicate check in step 4 looks only at this marker, so translating or omitting it causes the same summary to be posted twice.

--reconstruct adds no new template. It uses the normal pre-merge / post-merge templates below as they are, filling each section with what step 5 extracted from GitHub state (the posted format is identical to the inline call). The thin dedicated template is used only with --lightweight.

lightweight pre-merge template

<!-- pr-context-summary:pre-merge:PR#${PR_NUM} -->
## 🤖 PR context summary (at PR creation, light)

**PR**: #${PR_NUM}

### Background
{1-2 lines from the issue title / PR title}

### Classification of the change
- {docs-only / test-only / infra / code, and the like}
- Change size: +{additions} / -{deletions}

### Implementation summary
- {1-3 points from the PR metadata and commits}

### Open items
- {whatever is stated in the PR body; "none" if there is nothing}

---
🤖 Generated automatically by `/pr-context-summary --mode pre-merge --lightweight`

lightweight post-merge template

<!-- pr-context-summary:post-merge:PR#${PR_NUM} -->
## 🤖 PR context summary (appended after merge, light)

**PR**: #${PR_NUM} (merged)

### Merge result
- Merged {PR title}

### Next actions
- {open items stated in the issue / PR body; "none" if there is nothing}

---
🤖 Generated automatically by `/pr-context-summary --mode post-merge --lightweight`

pre-merge template

<!-- pr-context-summary:pre-merge:PR#${PR_NUM} -->
## 🤖 PR context summary (at PR creation)

**PR**: #${PR_NUM}

### The initial instruction and background
{summarize in 1-3 lines}

### Design options and the maintainer's decision
- **Adopted**: {the chosen option} — {why}
- **Considered and rejected**: {the rejected option} — {why} (bullet several if there are several; omit the whole section if there are none)

### Key implementation points
- {point 1}
- {point 2}

### Open items and candidate next directions
- {open item 1}
- {what would be good to do next}

---
🤖 Generated automatically by `/pr-context-summary --mode pre-merge`

post-merge template

<!-- pr-context-summary:post-merge:PR#${PR_NUM} -->
## 🤖 PR context summary (appended after merge)

**PR**: #${PR_NUM} (merged)

### Review findings and how they were addressed
- {finding 1} → {action} ("no Critical/Major" if there were none)

### The maintainer's adjustment requests and additional decisions
- {request 1} → {action}
- {additional decision 1}

### Next actions after the merge
- {candidate follow-up issue / PR}

---
🤖 Generated automatically by `/pr-context-summary --mode post-merge`

Sections with nothing to report may say "none" or be omitted.

Step 7: Post the comment

# Post to the issue if one was resolved, otherwise fall back to the PR
if [ -n "${ISSUE:-}" ]; then
  gh issue comment "$ISSUE" --body "$SUMMARY"
  echo "✅ Posted the context summary on issue #${ISSUE}"
else
  gh pr comment "$PR_NUM" --body "$SUMMARY"
  echo "✅ Posted the context summary on PR #${PR_NUM} (fallback: no issue resolved)"
fi

Step 8: Report

Report to the maintainer:

  • Where it was posted (issue number or PR number)
  • The mode (pre-merge / post-merge)
  • If it was skipped because a summary for the same mode already exists, say so

Edge cases

CaseResponse
No PR on the current branchExit with an error and prompt for --pr
No Closes # in the PR bodyFall back to posting on the PR itself
A marker for the same mode already existsSkip (do not post again)
post-merge called before pre-mergePost anyway (the order does not matter)
The conversation is nearly empty (a short session)State "nothing notable exchanged" and leave a minimal summary
A token or API key appears in the conversationReplace the value with [REDACTED] before posting

Callers in the chain

  • /commit-push: calls it automatically with --mode pre-merge right after the PR is created
  • /auto-merge: calls it automatically with --mode post-merge right after a successful merge (on a gate failure it hands off and stops, and the F1 detection in SessionStart covers the manual-merge case, {ISSUE-ID})
  • SessionStart (task 6, F1 detection): when it finds a manually merged PR with no post-merge summary, it calls --mode post-merge --reconstruct --pr <N> (not --lightweight). Passing --reconstruct explicitly guarantees the route into step 5, "Reconstructing post-merge from GitHub state", even with no conversation context

See the "PR context summary" section of ${CLAUDE_PLUGIN_ROOT}/rules/dev-flow.md for details.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.