AGENT SKILL

check-history

Check closed PR history for issue.

License 许可
MIT
最近更新
2026-11-15
Stars
★ 4
Forks
1

01 前言 Front Matter

name
check-history
description
Check closed PR history for issue.
allowed-tools
[ "Bash", "Read" ]
user-invocable
false

03 SKILL.md 正文

check-history

Before implementing changes for an issue or MR, review the repository's merge history to understand what decisions were made previously and why.

When this fires (automatically)

  • Starting work on any issue that involves modifying existing code
  • Before proposing changes to CI/CD templates, shared infrastructure, or configuration files
  • When the change touches code that has been refactored in prior MRs

First: is the issue already done or in progress?

Before reviewing past history, confirm the issue still needs a new PR. Two checks (skipping them wastes a whole issue-pick):

  • Already resolved on main? An issue can go stale — fixed incidentally by a later change (e.g. a dependency bump). Re-read the issue body against current main before implementing.

    gh issue view <N> --json state,title,body | cat   # VIEW_ISSUE — also: is it already closed?
    
  • Existing open PR for it? Search open PRs for one that already addresses the issue, so you don't open a second, parallel PR for the same work.

    gh pr list --state open --json number,title,headRefName,body,author,assignees \
      --jq '.[] | select(((.body // "") | test("#<N>\\b")) or (.title | test("#<N>\\b"))) | "#\(.number) \(.title) [\(.headRefName); \(.author.login); assignees: \([.assignees[].login] | join(","))]"'   # LIST_PRS
    
  • On a long-lived or foundational issue, the issue text AND any design-doc status header can lag the code by several PRs. A mature feature (a phased effort, or anything with a dedicated design doc) may be partly or mostly implemented even when the issue reads as unstarted. The work can land across sibling PRs that never updated this issue or that header. Before scoping new code, verify the actual implementation state against the code: read the key source files implementing the feature and the test files, not just the issue body. (Seen on sparta: issue #164 / #240 read as "phase 4b not done", but the core feature was already fully implemented and tested across sibling PRs — nearly rebuilt already-completed work. The right move was to audit, correct the stale issue/doc status, and pick the genuine next slice.)

If an open PR already covers it and passes memories/reviewing-prs.md's scope test (opened by or assigned to the invoking user, explicitly requested, or authored by the GitHub Actions app), drive that PR to clean instead of re-implementing. Scope establishes authorization, not that the branch is free: read the PR's claim state first per claim-pr, skip it while another session's claim is live (a hold off comment with a push or comment in the last 2 hours), and take over an unclaimed or expired one by posting your own claim comment before the first push. If it covers the issue but fails that test, leave both the PR and the issue alone and report that the PR exists, so the user can assign or name it. If main already satisfies the issue, stand it down and report — don't open a no-op PR. When the issue is only partly done, don't rebuild the done part: audit it, correct the stale issue/doc status, and scope only the genuine remaining slice.

Procedure

  1. Check the issue for an already-open PR. Before writing any code, look at the issue itself for an open PR that already addresses it (one whose body says Closes #<N>). A parallel session — or an issues-sweep run on another machine — may already be on it; building anyway produces a duplicate PR.

    GitHub:

    gh pr list --state open --limit 100 --json number,title,body,author,assignees \
      --jq '.[] | select((.body // "") | test("(Closes|Fixes|Resolves) #<N>\\b"; "i")) | "#\(.number) \(.title) [\(.author.login); assignees: \([.assignees[].login] | join(","))]"'   # LIST_PRS
    

    GitLab:

    glab mr list --state opened --per-page=50 --output json 2>/dev/null \
      | jq -r '.[] | select((.description // "") | test("(Closes|Fixes|Resolves) #<N>\\b"; "i")) | "!\(.iid) \(.title) [\(.author.username); assignees: \([.assignees[].username] | join(","))]"'
    

    If an open PR already covers the issue, apply the scope test above to the author and assignee logins the listing prints: review or extend it when it passes and the same claim check clears (another session's live claim still blocks you, and an expired one is taken over by posting your own claim comment first), and leave it untouched (reporting it to the user) when it fails. Either way, do not open a competing one. This catches in-flight work; the merged/closed history below catches settled decisions.

  2. List recent merged MRs touching the same area:

    GitHub:

    gh pr list --state merged --limit 20 --json number,title,headRefName | cat   # LIST_PRS
    

    GitLab:

    glab mr list --merged --per-page=20 2>&1 | cat
    
  3. Identify relevant MRs — look for titles/branches that relate to the files or subsystem you're about to modify.

  4. Read their descriptions for rationale:

    GitHub:

    gh pr view <N> --json body --jq '.body' | cat   # VIEW_PR
    

    GitLab:

    glab mr view <N> 2>&1 | cat
    
  5. Check for contradictions — if a prior MR/PR explicitly chose approach A and you're about to implement approach B, understand why A was chosen. Common patterns:

    • MR/PR #X switched to strategy A for performance → don't blindly revert to B
    • MR/PR #Y removed code as dead → verify it's still dead before re-adding
    • MR/PR #Z added a guard/check → understand what it prevents before removing
  6. Document the relationship in your commit message or MR/PR description:

    • "This resolves the incompatibility between #X and #Y"
    • "Supersedes the approach from #Z because [reason]"
    • "Preserves the intent of #X (no wasted resources) while also..."

What to look for

  • Intentional trade-offs documented in MR descriptions
  • Reverted MRs — if something was tried and reverted, don't repeat it without understanding why it failed
  • Sequential MRs that built on each other — your change might break an assumption from a later MR
  • Closed (not merged) MRs — rejected approaches that shouldn't be retried

Output

Report a brief summary to the user:

  • Which MRs are relevant to the current work
  • Any potential conflicts or trade-offs identified
  • Confirmation that the proposed approach is compatible with prior decisions

If a conflict is found, surface it before writing code — don't implement first and discover the regression later.

Proactive hook compliance

  • warn-stale-issue-edit.py: Intercepts Write, Edit, and NotebookEdit tool calls and warns if an issue-driven modification begins without a fresh VIEW_ISSUE (gh issue view <N>) and remote default-branch check (git fetch origin main). Running the initial inspection in this skill satisfies the guard proactively (see memories/hooks.md).

04 同仓库更多 Skills