plan-merge-order

plan-merge-order is a command for Claude Code from s977043/river-review. It costs 25 tokens per session (2,206 once invoked), scanned A, original, MIT.

A command that plans the order for merging several pull requests (PRs), which are proposed code changes reviewed before entering a shared branch. It checks their status and file changes, then studies dependencies and overlap to reduce rebasing work.

In plain words
What is it for?
It is for verifying candidate PRs, collecting their changed files, finding containment and dependency relationships, and choosing a lower-cost merge sequence.
Why use it?
It helps avoid planning around PRs that are already merged, duplicate work, or merge conflicts caused by an unsuitable order. It also requires checking for related work already in progress.

Command for Claude Code

Written for Claude Code: allowed-tools in frontmatter. Also seen: mentions AGENTS.md.

Part of the river-review plugin — 138 skills, 18 commands, 5 agents, 3 hooks shipped together

Good fit It is for verifying candidate PRs, collecting their changed files, finding containment and dependency relationships, and choosing a lower-cost merge sequence.

Compare 6 commands from other repositories ↓
Install with agentmods
npx agentmods add commands/s977043/river-review/plan-merge-order
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Clone the repo
git clone --depth 1 https://github.com/s977043/river-review

Made for: Claude Code.

Or install river-review, the plugin that ships this one along with the rest of its 138 skills, 18 commands, 5 agents, 3 hooks.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for plan-merge-order

README.md
[![agentmods](https://agentmods.dev/badge/commands/s977043/river-review/plan-merge-order/github.svg)](https://agentmods.dev/commands/s977043/river-review/plan-merge-order)
Your own site
<a href="https://agentmods.dev/commands/s977043/river-review/plan-merge-order"><img src="https://agentmods.dev/badge/commands/s977043/river-review/plan-merge-order/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for plan-merge-order

Your own site · 80×15
<a href="https://agentmods.dev/commands/s977043/river-review/plan-merge-order"><img src="https://agentmods.dev/badge/commands/s977043/river-review/plan-merge-order.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 25 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 2,206 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00025 $0.02206
Opus 5 $0.00013 $0.01103
Sonnet 5 $0.00005 $0.00441
Haiku 4.5 $0.00003 $0.00221

Measured 9d ago against content hash 04df793342ab, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-09, from the pricing page.

Security

Grade A, and why

plan-merge-order scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 9d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/commands/plan-merge-order.md · 146 lines

How it starts

The opening of the file, as written. The whole thing — 146 lines — stays where its author put it; the contents beside it link to each section on GitHub.

複数の PR を作成・マージする際の順序を事前計画してください。対象: $ARGUMENTS

手順

0. Preflight 検証 (前提)

マージ順序を計算する前に、対象 PR が本当にマージ対象かを検証する。/preflight $ARGUMENTS を先に実行するか、以下を直接実行する:

git fetch origin main
git log origin/main --oneline -15                                    # main に関連コミットが既にあるか目視

# 対象 PR ごとに REST API で state を直接取得 (gh pr view の GraphQL はキャッシュ遅延あり)
for pr in <PR numbers>; do
  gh api repos/OWNER/REPO/pulls/$pr --jq '{number, state, merged, merged_at, mergeable_state}'
done

# 類似キーワードで並行 in-flight PR を検索
gh pr list --state open --search "<keyword>" --json number,title,headRefName,author

# 直近 close 済 PR も確認 (並行作業の痕跡)
gh pr list --state closed --search "<keyword>" --limit 5 --json number,title,mergedAt

判定基準:

  • 対象 PR に merged=true が含まれる → その PR を対象から除外してユーザーに報告
  • 類似 keyword の別 open PR が存在 → 並行作業あり、続行前にユーザー確認
  • main に同内容のコミット既に存在 → タスク obsolete の可能性、続行前にユーザー確認

この Step を飛ばして依存グラフ作成に進んではならない。gh pr list のキャッシュ遅延で closed PR を OPEN と誤判定し、重複作業・force-push 計画・stale commits 分析に時間を費やした事例が複数回発生している (2026-04-11 セッションで 4 重複 PR)。

1. 対象 PR の収集

各 PR について以下を取得:

gh pr diff <number> --name-only

変更ファイルリストを記録する。

2. 依存グラフの作成

PR 間の関係を3種類に分類:

  • 包含関係: PR A の変更が PR B に全て含まれている → A をマージして B をクローズ
  • ファイル衝突: 同じファイルを変更する → 先にマージした方の変更を他方がリベースで取り込む必要あり
  • 独立: 変更ファイルが重ならない → 順序に依存しない

3. マージ順序の決定

優先ルール:

  1. 独立 PR を最初にマージ — コンフリクトリスクなし
  2. 包含される PR を先にマージ — 上位 PR は後で rebase
  3. ファイル衝突 PR はボトムアップ — 変更量の少ない PR を先に
  4. hot file を触る PR は特に慎重src/lib/review-engine.mjs, src/lib/local-runner.mjs, src/lib/verifier.mjs など

4. レポート出力

以下の形式(プレースホルダー)で結果を報告:

<!-- 以下は出力テンプレート例。実際の PR 番号・ファイル名・行番号に置き換えて使用 -->

## マージ順序計画

### 依存グラフ

- PR #<number> → PR #<number> (ファイル衝突: <file>, <file>)
- PR #<number> (独立)

### 推奨マージ順序

1. PR #<number>(独立、ファイル衝突なし)
2. PR #<number>(ボトムアップ: 変更量少)
3. PR #<number>(リベース必要: 上流マージ後にファイル X が変更されている)

### リベース予想コスト

- PR #<number>: `<file>:<line>` 付近で約 N 行のコンフリクト見込み

Hot File リスト

Read the full file on GitHub · 146 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 9d ago First seen · 146 lines · 25 tokens per session scan A 04df793342ab

Subscribe to this mod's changes

plan-merge-order is a command published in the GitHub repository s977043/river-review (3 stars, last pushed today), licensed MIT. It adds 25 tokens to every session and 2,206 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.