Claude Codeのplanモード:コードと照合するplan-checkスキル
Dmitriy Solodukha、Caprock開発者 · 公開日
にClaude CodeとCodexでテスト済み
Claude Codeのplanモードは承認まで編集を止めます。plan-checkは計画の内容を定め、各行を事前にコードと照合します。
Claude Codeのplanモードは、計画の承認まで編集を止めます。plan-checkは計画の内容を定め、最初の編集前にコードと照合します。ファイル、手順、検証方法、リスク、対象外の作業を記し、ツールで各行を確認して誤りを直してから編集します。planモードのないエージェントでは、スキル内の停止・実行判断を区切りにします。
plan-checkスキルをインストールする
エージェントごとに1コマンド。スキルはSKILL.md 1ファイルで、インストール時に何も実行しません。
9スキルをプラグインとして導入します。Claude Code内で次を入力してください:
このスキルだけを導入する場合は、プロジェクトのフォルダーで次を実行します:
全プロジェクトに導入するには -g を追加します。
プロジェクトのフォルダーでターミナルから実行:
全プロジェクトに導入するには -g を追加します。
プロジェクトのフォルダーでターミナルから実行:
全プロジェクトに導入するには -g を追加します。 OpenCodeでは未検証です。オープンな形式の通常の指示ですが、OpenCodeでの実行確認はしていません。
プロジェクトのフォルダーでターミナルから実行:
全プロジェクトに導入するには -g を追加します。 Cursorでは未検証です。オープンな形式の通常の指示ですが、Cursorでの実行確認はしていません。
plan-checkスキルを使うプロンプト
依頼の内容が説明と合うと、エージェントがスキルを選びます。名前を指定すると確実です。プロンプトをクリックしてコピーできます。
plan-checkがClaude Codeのplanモードに追加するもの
Claude Codeのplanモードは、編集せず調査・計画を行い、承認まで待つことを強制します。ただし、良い計画の内容や照合方法は定めません。このスキルはそれを補います:
- 計画の前に読む:変更するファイル、呼び出し元、テストと実行方法、プロジェクトのエージェント向け指示、過去の決定を読みます。
- 5項目の計画:Files(実在するパス)、Steps(それぞれ検証できる小ささ)、Verify(このプロジェクトに実在するコマンド)、Risks、そして空欄にしないNot doing。
- 1行ずつの照合:各ファイルが実在するか、名前がコードと一致するか、すべての呼び出し元を含むか、検証コマンドが動くか、プロジェクトのルールと決定を守るかを確認します。各行をOK、FIXED、OPENで締めます。
- 停止か実行か:OPENの疑問、決定の撤回、データ削除があれば停止して尋ねます。それ以外は計画を実行し、報告します。
planモードでは両方を使います。plan-checkの形式で計画を作り、承認前に照合するよう依頼してください。
実行したテストとエージェントの動作
各スキルは2026年11月29日に、専用の使い捨てリポジトリへプロジェクトスキルとしてインストールして実行しました。小さなPythonリポジトリで、src/prices.py内のformat_priceをcart_totalとreceipt_lineが呼び、make testでテストします。
Claude Code (claude -p --model sonnet)
Plan first, then do it: format_price should take a currency code (USD default, EUR uses the euro sign after the number). Do not touch anything until the plan is checked.
2回実行しました。どちらもplan-checkを呼び、ファイルと呼び出し元を読み、Caprockのcurrent_decisionsを呼びました(一方は権限を拒否され、その旨を明記)。その後currency="USD"を追加し、不明なコードにはValueErrorを出すようにして、新しいtests/test_prices.pyを作成しました。make testは7件中7件成功しました。最終報告では見送った内容も列挙しました。cart_totalとreceipt_lineは引き続きドルを表示し、負の金額の既存の書式不具合(-5が$-1.95になる)は変更していません。
Codex (0.163.0, codex exec)
The same prompt.
.agents/skills/plan-check/SKILL.mdを読み、スキルの5項目で計画を書きました(current_decisionsの呼び出しは失敗)。コードと照合し、両方の呼び出し元が既定のUSDに依存することと、make -n testで検証コマンドを確認してから編集しました。報告(空行と最後の文を省略):
Implemented after checking the plan. - `format_price(150)` → `$1.50` - `format_price(150, "EUR")` → `1.50€` - Unsupported codes raise `ValueError`. All 6 tests pass; `git diff --check` passes. No deviations from the plan.
検証したエージェント
- Claude Code:2026年11月29日に、
.claude/skills/にプロジェクトスキルとしてインストールし、claude -p --model sonnetで検証しました。 - Codex:2026年11月29日にCodex 0.163.0(
codex exec)、.agents/skills/内のスキルで検証しました。 - OpenCodeとCursor:未検証です。オープンなAgent Skills形式の通常の指示ですが、どちらでも実行して確認していません。
制限
- planモードのないエージェントでは、編集禁止は機能として強制されません。スキルの停止・実行判断は指示であり、モード切り替えではありません。
- 照合の精度はエージェントの検索次第です。リフレクションや文字列経由の呼び出し元は見落とす可能性があります。
- 1行の修正なら計画は不要と伝え、計画の手順を省略します。
Caprockがある場合とない場合
Caprock MCPサーバーに接続している場合、スキルはcurrent_decisionsを呼び、変更で守るべき過去の決定を探します。接続がなければ、同じファイルの決定記録と最近のコミットメッセージを調べます。Caprockはコンピューター上の全コーディングエージェントのセッションを記録する無料のオープンソースアプリです。スキルのほかの機能に必須ではありません。
SKILL.md全文
dspv/skillsのリビジョンdfce799にあるファイルそのものです。手動で導入する場合、プロジェクト内の、Claude Codeは.claude/skills/plan-check/SKILL.md、Codexは.agents/skills/plan-check/SKILL.mdに保存してください。
---
name: plan-check
description: >
Write a short plan before changing code (files to touch, steps, how the change will be verified,
risks, what will not be done), then check every line of that plan against the actual code before
the first edit. Use when the user says "plan first", "make a plan before you code", "plan mode",
"claude code plan mode", "think before editing", "don't touch anything yet", or asks for a change
that spans several files, a refactor, a migration, or anything hard to undo. Works in any coding
agent; in Claude Code, plan mode is the built-in equivalent.
license: Apache-2.0
---
# Plan, check, then change
A plan written from memory of the code is a guess. This skill makes the agent write the plan down,
check it against the files as they are, fix what the check finds, and only then edit.
## When to use it, and when not
Use it before any change that touches more than one file, changes a public interface, moves data,
or is hard to undo, and whenever the user asks for a plan first.
Skip it for a one-line fix the user has already located, a typo, or a question that needs no edit.
Say in one line that no plan is needed and why.
## Step 1: Read before you plan
Read the code the change will touch before writing a word of the plan:
- the files you expect to edit, and their callers (search for each function, type, route or
config key you will change);
- the tests that cover them, and how the project runs its tests (README, Makefile,
package.json scripts, CI config);
- the project's agent instructions (CLAUDE.md, AGENTS.md or similar) for rules the change must keep.
**Earlier decisions.** If the Caprock MCP tool `current_decisions` is available, call it (it takes an
optional `project`, the repository folder's name, and `limit`) and keep the decisions that touch this
change. Without it, look for decision records in the repository (ADRs, a `docs/` decisions file,
recent commit messages on the same files with `git log --oneline -- <path>`). A plan that reverses an
earlier decision says so in Risks and asks the user. Caprock (https://caprock.dev, free, open source,
runs locally) provides that tool; nothing else here needs it.
## Step 2: Write the plan
Keep it short: a reviewer should read it in under a minute. Use exactly these sections.
```markdown
## Plan: <one-line goal>
**Files**
- `path/to/file.ext`: what changes (new function, edited block, deleted)
- `path/to/new_file.ext` (new): what it holds
**Steps**
1. <smallest step that leaves the code working>
2. ...
**Verify**
- `<exact command>`: what passing looks like
- <manual check, if a command cannot show it>
**Risks**
- <what could break, who calls it, what data it touches>
**Not doing**
- <tempting work left out of scope: refactors, renames, upgrades, unrelated fixes>
```
Rules for the plan:
- Every file is a real path. Every function, flag or command is named exactly as it appears in code.
- Each step is small enough to verify on its own; order steps so the code builds after each.
- Verify names commands that exist in this project, not generic ones.
- Not doing is never empty: name at least one thing you will deliberately leave alone.
## Step 3: Check the plan against the code
Go through the plan line by line and confirm each claim with a tool call (read, search, run), not
from memory:
| Check | How |
| --------------- | ------------------------------------------------------------------ |
| Files exist | List or read each path; a "(new)" path must not exist yet |
| Names are right | Search each function, type, key; note its exact signature |
| Callers covered | Search every use of what changes; each caller is in Files or Risks |
| Verify runs | The test or build command exists (script, target, binary) |
| Rules kept | Compare steps with the project's agent instructions |
| Decisions kept | Compare with the decisions found in Step 1 |
Then add a short block under the plan:
```markdown
**Check**
- OK: <claim confirmed, with the file or command that showed it>
- FIXED: <claim that was wrong, and what the plan says now>
- OPEN: <question only the user can answer>
```
If a check fails, fix the plan and re-check that line. Do not start editing with a FIXED line you
have not re-checked.
## Step 4: Stop or go
- **Stop and ask** when there is an OPEN line, when the plan reverses an earlier decision, when it
deletes data or files the user did not mention, or when the check found the task is much larger
than the user described. Show the plan and the Check block, ask the open questions, and wait.
- **Go** when every line is OK or a re-checked FIXED, and the user asked you to do the work (not
only to plan). If the user asked only for a plan, stop after the Check block.
## Step 5: Carry out the plan
- Follow the steps in order. Run the Verify commands at the end, and after any step that names its own
check.
- If the code turns out different from the plan (a caller you missed, a test that does not exist),
stop editing, update the plan and the Check block, and decide stop or go again. Do not drift.
- Touch nothing listed under Not doing.
## Step 6: Report
Always end with this report, in this shape, even when the change is small: it is how the user
sees whether the plan held.
```markdown
**Done**: <goal>
- Changed: `path` (what), ...
- Verify: `<command>`: <result, pasted or summarized>
- Differed from plan: <what and why, or "nothing">
- Left out: <the Not doing list, and anything found along the way>
```
## Plan mode in Claude Code
Claude Code has a built-in plan mode: Claude reads files and runs commands to explore, writes a plan,
and makes no edits until you approve it (Claude Code docs, permission modes page, read 2026-11-29).
Ways in:
- press `Shift+Tab` until the status bar shows plan mode on, or prefix a single prompt with `/plan`;
- start the session with `claude --permission-mode plan`;
- make it the project default with `"permissions": { "defaultMode": "plan" }` in `.claude/settings.json`.
At the approval prompt you can approve, keep planning, or press `Ctrl+G` to edit the plan in your
editor. Plan mode enforces "no edits yet"; this skill adds what to put in the plan and the check
against the code. Use both: in plan mode, write the plan in Step 2's format and run Step 3 before
asking for approval. In an agent without a plan mode, the skill's Stop or go step is the gate.
plan-checkスキルについての質問
- Claude Codeのplanモードを有効にするには?
- ステータスバーがplanモードになるまで`Shift+Tab`を押すか、プロンプトに`/plan`を付けるか、`claude --permission-mode plan`で起動します。既定にするには`.claude/settings.json`に`"permissions": { "defaultMode": "plan" }`を設定します。
- plan-checkはplanモードに何を追加しますか?
- 5項目の固定形式で計画し、承認前にツールで各行をコードと照合します。誤りは修正し、未解決の疑問は質問します。
- 計画をチェックするスキルはCodexでも使えますか?
- 使えます。スキルの停止・実行判断が区切りになります。Codex 0.163.0は2026年11月29日のテストで、計画、照合、編集の順に従いました。
- 誤字の修正でも計画しますか?
- 行いません。場所が分かっている1行の修正、誤字、質問では、計画不要と理由を1行で示します。