AI Tools
チュートリアル11 分2026年3月24日執筆:AIGCDev

Claude Sonnet 4.6で大規模リポジトリをレビューする方法:安全なコードレビューと計画の進め方

まず結論

Claude Sonnet 4.6 は、いまや大規模リポジトリの code review と implementation planning の最初の一手として十分に使える。ただし、本当にレバレッジが高いのは「先に review、あとで patch」という運用だ。2026-03-24 時点の Anthropic 公式情報では、Sonnet 4.6 は Claude Free / Pro のデフォルトモデルで、Claude Code と API で利用でき、価格は input 100 万 token あたり 3 ドル、output 100 万 token あたり 15 ドルのまま。さらに、公式ドキュメント上は最大 1M context と 64K max output が案内されている。一方で Anthropic は、Opus 4.6 を深い refactor、multi-agent coordination、そして誤答コストが高い task 向けの強いモデルとして引き続き位置づけている。

実務で安全な流れは次の通り。

  • repo 全体の安定ルールを CLAUDE.md に書く
  • 最初は Plan Mode か read-only analysis から始める
  • コードに触る前に repo map、unknowns、failure modes を出させる
  • file boundary と test boundary を先に承認する
  • patch の適用は分ける
  • merge 前に /review か同等の diff review を行う

一つ重要な注意がある。Anthropic の現行ドキュメントは 1M context を実在する能力として扱っているが、context window の文書では依然として beta/API 条件付きの説明が残っている。つまり、long context は快適さを上げるが、scope control を不要にするものではない。

Sonnet 4.6 で変わったこと

Anthropic は 2026-02-17 に Sonnet 4.6 を発表した。重要なのは、Sonnet が以前より coding に強くなったことだけではない。Claude Code を取り巻く workflow 全体が、ようやく chat の中だけでなく repo に残せる形になってきたことが大きい。

Sonnet 4.6 によって repo の理解、risk review、implementation planning の初回コストが下がった。Claude Code 側では、その流れを chat-only の属人的運用にしないための要素が揃っている。CLAUDE.md memory、/init や /review のような slash commands、Plan Mode、そして project commands / skills だ。

これを組み合わせると、大きい repo でも現実的な workflow になる。

  • shared rules が chat history ではなく repository に残る
  • review と planning が editing より先に来る
  • model に越えてはいけない境界を文章で渡せる
  • 最終 patch は diff と test で外から検証できる

公式ソースから実務的に意味がある変更点

公式情報 大規模 repo review での意味
Sonnet 4.6 は Claude Free / Pro のデフォルトで、Anthropic は Claude plans、Claude Code、API、主要クラウドで使えるとしている 特別な setup なしで同じ workflow を試しやすい
Sonnet の価格は $3 input / $15 output per MTok のまま planning-first の一巡を日常的に回しやすい
Opus 4.6 は $5 input / $25 output per MTok で、最も強い深い reasoning モデルとして位置づけられている 高コストモデルに上げる基準を明確に持てる
Anthropic の models overview は Sonnet 4.6 を 64K max output としている 長い review notes、plans、issue lists を 1 回で返しやすい
release note と context docs は 1M context を beta と説明し、models overview は Sonnet 4.6 の 1M context support を示している 大きい repo や長い spec を扱いやすいが、利用面が完全に同じとは限らない
Anthropic は Sonnet 4.6 で adaptive thinking / extended thinking を文書化している task が曖昧になった時に、すぐ Opus に上げる前に reasoning effort を増やせる
Anthropic はなお Opus 4.6 を codebase refactoring、multi-agent coordination、高リスク reasoning に向くと位置づけている Sonnet は default reviewer であり、final approver ではない

ここで見落としやすいのは、long context は境界が明確な時にだけ価値が大きいという点だ。file shortlist、unknowns、model 外の verification を置き換えるものではない。

Sonnet 4.6 を最初に使ってよい task

次の条件が揃う時、Sonnet 4.6 はよい default になる。

  • 既存 repository を理解してから change したい
  • task を review、planning、bounded edit に落とし込める
  • patch を作る前に verification を定義できる
  • 最初の判断を外しても catastrophic ではない

向いている例:

  • bug fix 前の repo mapping
  • pull request の first-pass review
  • bounded refactor 前の shared logic の追跡
  • 既存 convention に照らした implementation option の比較
  • 大きい diff や ticket からの test plan 抽出

向いていない例:

  • auth、billing、security、compliance の change
  • rollback-sensitive な schema / data work
  • hidden second-order effect がある cross-system refactor
  • root cause がまだ不明な incident
  • team がまだ書いていない product intent に依存する task

大規模 repo 向け Claude Code workflow

Step 1: 安定ルールを CLAUDE.md に置く

Anthropic の Claude Code docs は project memory file として CLAUDE.md を明示的にサポートしており、memory docs では @path で他ファイルを読み込む使い方も案内している。毎回同じルールを prompt に書き直すより、こちらの方が安定する。

最小限なら次の形で十分だ。

# Review defaults

Read @README.md for architecture and @package.json for scripts.

- Map files and unknowns before suggesting edits.
- Prefer the smallest diff that solves the task.
- Name tests and manual checks explicitly.
- Stop if the task crosses a public API, schema, or auth boundary.

repo に CLAUDE.md がまだないなら、Anthropic は /init をそのための built-in command として文書化している。

これが効く理由は次の通り。

  • rules が session を越えて残る
  • 次の review run も同じ boundary を継承する
  • human teammate も workflow 自体を見て修正できる

Step 2: 最初は Plan Mode か read-only pass で始める

Claude Code を使うなら、最初の一手は Plan Mode が安全だ。patch を書く前に model を analysis state に置けるからだ。

CLI での分かりやすい入口はこれだ。

claude --permission-mode plan

最初の prompt 例:

Analyze this repository task in review mode.

Return only:
1. the files or directories to inspect first
2. the architecture you infer from them
3. what is still unclear
4. likely failure modes
5. whether this should stay on Sonnet 4.6 or escalate

Do not write code yet.

Task:
[paste the ticket, bug, or PR description]

この step は一度に 3 つの役割を果たす。

  • implementation 前に repo reading を強制する
  • 自分でも検証できる file shortlist を作る
  • confident patch の中に uncertainty を隠させない

Claude Code 以外でも、Claude chat や API で同じ構造は使える。重要なのは UI ではなく、analysis と editing を分けることだ。

Step 3: solution ではなく risk-first review をさせる

repo map が出たら、次は code を書かせるのではなく、どう壊れ得るかを先に見させる。

Based on the repository context you gathered, review this task as if you were trying to prevent a bad patch.

Return:
- likely files affected
- public contracts that might break
- hidden dependencies or assumptions
- tests and manual checks that must pass
- one reason to stop before editing

Do not write code yet.

日常の実務で Sonnet が最も価値を出しやすいのはこの段階だ。広い表面積を素早く見られ、しかもコストが低いので、誰かが file を触る前に plan を止められる。

それでも回答が guessy なら、そこが signal だ。thinking effort を上げるか、Opus に上げるべきであって、Sonnet を無理に押し切るべきではない。

Step 4: 最小安全 plan を作らせる

risk review の後で、最も狭くて安全な implementation path を出させる。

Now produce the smallest safe implementation plan.

Constraints:
- touch no more than 5 files unless you hit a blocker
- preserve public API names unless change is unavoidable
- avoid new dependencies
- stop if the fix implies an architecture or schema change

Return only:
1. files to edit
2. exact change summary by file
3. tests or commands to run
4. what would make this plan invalid

ここで Sonnet 4.6 の長めの出力と instruction following の改善が効く。clever patch より bounded plan の方が、読みやすく、比較しやすく、reject しやすい。

Step 5: thinking loop と editing loop を分ける

同じ session に architecture discovery と repository rewrite の両方を任せるべきではない。

より安全な順序はこれだ。

  1. Sonnet が repo map を作る
  2. Sonnet が risk review を書く
  3. Sonnet が bounded plan を書く
  4. 自分か別ツールが patch を適用する
  5. Sonnet が diff を review する

Claude Code 内なら、Anthropic が /review を built-in command として案内しているので、diff ができた後の最後の pass に自然に置ける。

通常の diff-review prompt でもよい。

Review this diff against the approved plan.

Flag:
- scope drift
- duplicated logic
- missing tests
- claims the patch does not actually prove
- places where the repository's conventions were ignored

loop を分けると workflow が見える化される。model が途中で task をすり替えるのも起きにくい。

Step 6: long context は bonus として使う

Sonnet 4.6 の long-context story は本物だが、扱いは慎重でよい。Anthropic の context-window docs は 1M context を Claude Sonnet 4 の API beta として説明しつつ、models overview では Sonnet 4.6 の 1M context support を示している。

実務では次の運用が安全だ。

  • structured prompt の方が raw context size より重要だと考える
  • 大きい spec、長い PR、logs、code を同時に入れる必要がある時だけ 1M context を使う
  • long-context session でも file shortlist と unknowns を出させ続ける

もし会話が散らかり始めたら boundary を引き直す。Anthropic は /compact も文書化しており、承認済みの plan だけを持ち越したい時に役立つ。

Standard Sonnet、thinking 増し、Opus の使い分け

Anthropic の現在の product positioning から、routing rule はかなり明確だ。

Situation 最初の一手 理由
repo orientation、file discovery、first-pass PR review standard Sonnet 4.6 速く、安く、多くのケースで十分
曖昧さはあるが bounded な bug / refactor Sonnet 4.6 + more thinking effort すぐに Opus 料金へ行かずに reasoning を強められる
high-risk architecture change / multi-system refactor Opus 4.6 Anthropic も deeper reasoning 向けに Opus を位置づけている
costly production change の final sign-off Opus 4.6 または human review ここでは speed より mistake cost が大きい
product intent / business rule が曖昧 human decision first model は正しい requirement を発明できない

要点は単純で、Sonnet は default reviewer / planner、Opus は judgment cost が高い task への escalation path だ。

そのまま使える daily prompt stack

毎日使える再現性の高い流れが 1 つ欲しいなら、この 4 本で足りる。

Prompt 1: Repo map

Read this repository context and identify the smallest set of files I should inspect first.
Explain the architecture in plain English, list unknowns, and do not propose fixes yet.

Prompt 2: Risk review

Review this task for likely regressions, hidden dependencies, and tests that must pass.
Prefer warnings over solutions.

Prompt 3: Bounded plan

Produce the smallest safe plan.
List exact files to touch, what changes in each file, and what would make this plan invalid.

Prompt 4: Diff review

Review this diff against the original plan.
Flag:
- scope drift
- duplicated logic
- missing tests
- claims the patch does not actually prove

意図的に boring な stack だが、それでよい。Sonnet を reviewer / planner に留め、overconfident autopilot にしないためだ。

よくある失敗パターン

Failure mode 実際に起きること 実務的な fix
long context を理解保証だと思う 1M context は多くの資料を入れられるだけで、repo を正しく理解した証明にはならない unknowns、weak assumptions、最小 relevant file list を毎回出させる
repo rules を chat にしか置かない 次の session が同じ boundary を学び直す必要がある durable rules を CLAUDE.md に置く
review 前に implementation を求める model が correctness より momentum を優先する repo map と risk review を先に強制する
model に静かに scope を広げさせる cleanup opportunity を理由に broad rewrite を正当化しやすい exact file list を要求し、具体理由のない scope expansion を拒否する
人間しか決められないことまで Sonnet に任せる product intent や hidden business rule は model では補えない Sonnet には tradeoff を出させ、決定は人がする

FAQ

Sonnet から Opus に上げるべきなのはいつか?

高コストなのが reading speed ではなく judgment になった時だ。具体的には、高リスク architecture work、multi-system refactor、重い production sign-off、あるいは 1 つの誤った前提が高くつく task である。

この workflow に 1M context は必須か?

必須ではない。workflow の本質は context size ではなく、file shortlist、unknowns、risk review、bounded plan という構造にある。1M beta window は、利用できる時に大きい task を少し楽にする程度と考えるのがよい。

/review と Plan Mode はどちらから始めるべきか?

最初は Plan Mode か read-only analysis pass にするべきだ。/review は diff ができてから使うのが自然だ。

どの repo にも CLAUDE.md は必要か?

同じ repo で Claude Code を繰り返し使うなら、ほぼ yes だ。小さくても明確な CLAUDE.md は、毎回同じ rules を打ち直すより長期的に得をしやすい。

Bottom Line

Claude Sonnet 4.6 が今 worth using なのは、AI-assisted development の中で最も安くて重要な部分、つまり「コードに触る前に repo を理解する工程」を大きく改善したからだ。

大規模 repository では Sonnet 4.6 を default reviewer / planner に使い、stable rules は CLAUDE.md に置き、patch は bounded に保ち、verification は model の外に置く。そして、間違えるコストが高い task にだけ Opus を使う。これが今のところ最も実務的な使い方だ。

検証メモ

2026-03-24 に Anthropic の公式ソースで確認した内容:

  • Sonnet 4.6 の公開日、Claude での default availability、Claude Code / API availability、Sonnet の $3 / $15 pricing、1M context beta の説明、Opus と Sonnet の positioning は https://www.anthropic.com/news/claude-sonnet-4-6
  • Sonnet 4.6 / Opus 4.6 の current positioning、max output、thinking-mode support は https://platform.claude.com/docs/en/about-claude/models/overview
  • 1M context の beta scope と API 条件は https://docs.anthropic.com/en/docs/build-with-claude/context-windows
  • CLAUDE.md memory、@path imports、/init、/review、/compact、Claude Code common workflows は https://docs.anthropic.com/en/docs/claude-code/memory、https://docs.anthropic.com/en/docs/claude-code/slash-commands、https://docs.anthropic.com/en/docs/claude-code/common-workflows
  • Claude pricing の現行コンテキストは https://claude.com/pricing
claudecode-reviewdeveloper-workflowpromptinglarge-codebaseai-coding