modernize
Bring a stale PR up to date: judge whether its idea still belongs, then rebase it, rework it or recommend closing it.
- License 许可
- MIT
- 最近更新
- 2026-11-05
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- modernize
- description
- Bring a stale PR up to date: judge whether its idea still belongs, then rebase it, rework it or recommend closing it.
- argument-hint
- PR number
- disable-model-invocation
- true
03 SKILL.md 正文
<!-- Adapted from t3dotgg/tstack@1085050 skills/modernize, MIT (© 2026 Theo Browne). Changed for dk-agent-kit: user-invoked; the base from docs/agents/workflow.md, the worktree from dk:issue-flow step 2, detached at the observed head, an old worktree reused only when clean and its checkout keeping ignored files; an open PR only, its number digits only; the branch name and the base limited to letters, digits, ., _, - and / and checked with git check-ref-format before any shell use, then quoted; the push is --force-with-lease="refs/heads/<branch>:<observed sha>" to "HEAD:refs/heads/<branch>", from the worktree's literal path so the gate runs; a base mismatch stops before any change to the branch; a fork PR assessed read-only from refs/pull/<PR>/head, stopping before the rebase; checks from AGENTS.md; comments open with dk:issue-flow step 6's attribution note; Codex agents/openai.yaml not taken. -->
Modernize
Modernize the idea, not just the branch. A clean rebase does not prove the PR still belongs in the product.
The grant covers rebasing the PR's commits and updating its branch. Merging, closing, retargeting the base and widening the scope stay the maintainer's. A PR comment is posted only when the user asked for one, and opens with the attribution note from dk:issue-flow step 6's Comments. paragraph.
1. Record the PR
<PR> is the PR's number, digits only; anything else, stop and ask for the number.
gh pr view <PR> --json url,state,title,body,author,baseRefName,headRefName,headRefOid,isCrossRepository,reviewDecision,statusCheckRollup,closingIssuesReferences,commits
gh pr diff <PR>
A PR whose state is not OPEN stops here: report the state and change nothing. Read its linked issues, its comments and review threads too. The base is the one docs/agents/workflow.md names (pre-main unless it names another); a PR whose baseRefName differs stops here, before any change to its branch: report it, never retarget it, and go on only on the user's word, with the PR's actual base as <base>. A PR whose isCrossRepository is true lives in a fork, so its branch is not this skill's to push: assess it read-only, report, and stop before step 4 whatever the disposition.
Then git fetch -q origin. For a PR you can push, <branch> is headRefName, and it reaches the shell only when it holds only letters, digits, ., _, - and / (Git also accepts $, backticks and ", which double quotes still expand) and git check-ref-format --branch "<branch>" exits 0; when either check fails, stop and report the name. <base> passes the same two checks before its first shell use. Quote both in every command, and check git ls-remote origin "refs/heads/<branch>" prints headRefOid; for a fork PR, fetch its head with git fetch -q origin pull/<PR>/head and check git rev-parse FETCH_HEAD prints it. That SHA is the observed sha, the lease the push is held to. Record the merge base: git merge-base "origin/<base>" <observed sha>.
Done when you can state, in one sentence, the smallest coherent goal the PR was trying to reach, before judging how it reached it.
2. Check what changed around it
Read the base's commits since the merge base (git log --stat "<merge-base>..origin/<base>"), first those touching the PR's files, then the rest for moved boundaries. Search merged and open PRs (gh pr list --state all --search "<term>", with each <term> a word or path holding none of ", $, \ or a backtick) where titles, paths or behaviour suggest a replacement or a competing implementation.
A conceptual conflict is one Git cannot see. Look for each:
- the same user-facing problem already solved;
- APIs, types, schemas, dependencies or module boundaries changed;
- both sides now owning the same behaviour or invariant;
- the code being changed deleted, moved or deliberately simplified;
- landing the PR restoring an old behaviour, or making two ways to do one thing;
- the original benefit no longer worth its maintenance cost.
Done when each bullet has a finding or a "none found" backed by the commit or PR you checked. A PR with no textual conflicts is still unjudged until then.
3. Choose one disposition
- MODERNIZE: the goal is still useful and the implementation is still the right shape. Go to step 4.
- REWORK: the goal is still useful, but a mechanical rebase would keep the wrong implementation. Describe the smallest credible rewrite and stop before pushing, unless the user also asked for the rework.
- CLOSE: the PR is superseded, obsolete, pointed the wrong way, or no longer worth its cost. Cite the evidence and stop. Closing is the maintainer's call.
Be willing to recommend CLOSE. Age alone is not evidence, and sunk effort is no reason to keep a PR alive.
4. Rebase without losing intent
For MODERNIZE only:
-
Make the worktree as
dk:issue-flowstep 2 does, with<N>the PR's issue (the PR number when it links none), detached at the observed sha so no local branch is touched:git worktree add --detach ~/workspace/<prefix>-<N> <observed sha>. When the PR's old worktree is still at that path, its uncommitted work is the user's: reuse it detached only whengit -C <path> status --porcelainprints nothing andgit -C <path> checkout --detach --no-overwrite-ignore <observed sha>succeeds (a clean status still hides ignored files, which a plain checkout replaces with the PR's tracked copy), and otherwise add~/workspace/<prefix>-<N>-modernizebeside it. Run the fresh-worktree setup fromworkflow.md. Items 2 to 5 run inside that worktree:cd <that path>first, orgit -C <that path>. -
git rebase "origin/<base>". -
Resolve each conflict by the PR's intent and the base's newer invariants. A conflict that exposes a product or architecture disagreement sends you back to step 3, not to a guess.
-
Compare the commit series before and after:
git range-diff <merge-base>..<observed sha> "origin/<base>..HEAD", then read the final diff (git diff "origin/<base>...HEAD"). Done when no intended behaviour has dropped out and no behaviour the base already landed comes back. -
Run the checks
AGENTS.mdlists for the touched area. Tell a real failure from one the base already has (run it onorigin/<base>) or an infrastructure failure. -
Push from the path item 1 chose,
~/workspace/<prefix>-<N>or~/workspace/<prefix>-<N>-modernize, written literally so the gate runs on the tree you checked (dk:issue-flowstep 6):cd <that path> && git push --force-with-lease="refs/heads/<branch>:<observed sha>" origin "HEAD:refs/heads/<branch>"A refused lease means someone pushed since step 1: fetch, go back to step 1, and judge the new head before any second push.
Report
Lead with MODERNIZE, REWORK or CLOSE and the reason. Then:
- the base's meaningful changes since the merge base;
- each conceptual conflict, or that none was found and what was checked;
- the rebase and push result, with the range-diff's verdict, when performed;
- the checks run, each with its result;
- the decision or work left, with the PR's link.
Keep observed facts apart from judgment, and name what you could not verify.
04 同仓库更多 Skills
writing-for-agents
Writing documents for agents. Use when creating or editing skills, or modifying AGENTS.md or CLAUDE.md.
verify
Prove a change works by driving it in a stack you started, against a control run of the pre-fix state. Use before calling any change verified, or when asked to verify or prove a fix.
verify-doc-check
Monthly check that this repo's docs/agents/verify.md still starts the stack: read every claim against the source, run the recipe in a fresh worktree, fix or file each drifted step.
triage
Move issues and external PRs through a state machine of triage roles, categorise, verify, grill if needed, and write agent-ready briefs.
to-tickets
Break a plan, spec, or the current conversation into a set of tracer-bullet tickets, each declaring its blocking edges, published to the configured tracker (edges as text in one file per ticket locally, or native blocking links on a real tracker).
to-spec
Turn the current conversation into a spec and publish it to the project issue tracker: no interview, just synthesis of what you've already discussed.