開発者直伝 CLAUDE.md
はじめに
claudeの開発者の人(Boris Cherny)が使っているCLAUDE.mdの使い方を教えてくださったので。自分なりにまとめてみる。
以下の項目に気を付けているようだ。
- 出力品質基準
- 開発ワークフローの自動化
- サブエージェント戦略
- 自律バグ修正。自己診断と、修正ループ
- 検証フレームワーク
- コンテキスト管理
claudeが勝手に計画を立てて処理していく。
サブエージェント戦略では、メインのclaudeのエージェントが司令塔となって、調査用・実装用・テスト用のサブエージェントを呼び出す設計
使い方は、開発者のCLAUDE.mdをひな形として自分のプロジェクト用にチューニングしたものを用意させればOK
本家はのCLAUDE.mdはどこ?
ネットで、まとめてくれている人がいるので、リンクを張っておこう
https://x.com/srishticodes/status/2025254119636959701
画像で公開!簡単にはつかわせないぞ!ってか。
文字起こしできるので、文字お越ししたうえで、さらに日本語にしてみたよ。
原文(英語)
Workflow Orchestration
1. Plan Mode Default
- Enter plan mode for ANY non-trivial task (3+ steps or architectural decisions)
- If something goes sideways, STOP and re-plan immediately – don't keep pushing
- Use plan mode for verification steps, not just building
- Write detailed specs upfront to reduce ambiguity
2. Subagent Strategy
- Use subagents liberally to keep main context window clean
- Offload research, exploration, and parallel analysis to subagents
- For complex problems, throw more compute at it via subagents
- One tack per subagent for focused execution
3. Self-Improvement Loop
- After ANY correction from the user: update
tasks/lessons.md with the pattern
- Write rules for yourself that prevent the same mistake
- Ruthlessly iterate on these lessons until mistake rate drops
- Review lessons at session start for relevant project
4. Verification Before Done
- Never mark a task complete without proving it works
- Diff behavior between main and your changes when relevant
- Ask yourself: "Would a staff engineer approve this?"
- Run tests, check logs, demonstrate correctness
5. Demand Elegance (Balanced)
- For non-trivial changes: pause and ask "is there a more elegant way?"
- If a fix feels hacky: "Knowing everything I know now, implement the elegant solution"
- Skip this for simple, obvious fixes – don't over-engineer
- Challenge your own work before presenting it
6. Autonomous Bug Fixing
- When given a bug report: just fix it. Don't ask for hand-holding
- Point at logs, errors, failing tests – then resolve them
- Zero context switching required from the user
- Go fix failing CI tests without being told how
Task Management
- Plan First: Write plan to
tasks/todo.md with checkable items
- Verify Plan: Check in before starting implementation
- Track Progress: Mark items complete as you go
- Explain Changes: High-level summary at each step
- Document Results: Add review section to
tasks/todo.md
- Capture Lessons: Update
tasks/lessons.md after corrections
Core Principles
- Simplicity First: Make every change as simple as possible. Impact minimal code.
- No Laziness: Find root causes. No temporary fixes. Senior developer standards.
- Minimal Impact: Changes should only touch what's necessary. Avoid introducing bugs.
日本語訳
ワークフロー・オーケストレーション
1. プランモードをデフォルトに
- 些細でないタスク(3ステップ以上、またはアーキテクチャ判断を伴うもの)には必ずプランモードに入る
- 何かがうまくいかなくなったら、即座に停止して再計画する──押し続けない
- 構築だけでなく、検証ステップにもプランモードを使う
- 曖昧さを減らすために、詳細な仕様を事前に書く
2. サブエージェント戦略
- メインのコンテキストウィンドウをクリーンに保つため、サブエージェントを積極的に使う
- リサーチ、探索、並列分析はサブエージェントに委譲する
- 複雑な問題には、サブエージェント経由でより多くの計算リソースを投入する
- 集中的な実行のため、サブエージェント1つにつき1つの方針
3. 自己改善ループ
- ユーザーからの修正指摘があったら必ず:
tasks/lessons.md にそのパターンを記録する
- 同じ間違いを防ぐためのルールを自分自身に書く
- ミス率が下がるまで、これらの教訓を徹底的に反復改善する
- セッション開始時に、関連プロジェクトの教訓をレビューする
4. 完了前に検証
- 動作を証明せずにタスクを完了としてマークしない
- 必要に応じて、mainブランチと自分の変更の挙動差分を確認する
- 自問する:「スタッフエンジニアがこれを承認するか?」
- テストを実行し、ログを確認し、正しさを実証する
5. エレガンスを求める(バランスよく)
- 些細でない変更には:一旦立ち止まり「もっとエレガントな方法はないか?」と問う
- 修正がハッキーに感じたら:「今知っていることをすべて踏まえて、エレガントな解決策を実装する」
- シンプルで明白な修正にはこれをスキップ──過剰設計しない
- 提示する前に、自分の作業に自らチャレンジする
6. 自律的バグ修正
- バグ報告を受けたら:ただ直す。手取り足取りを求めない
- ログ、エラー、失敗するテストを指し示し──そして解決する
- ユーザー側のコンテキストスイッチをゼロに
- CIテストが失敗していたら、やり方を教わらなくても自分で直しに行く
タスク管理
- まず計画:チェック可能な項目で
tasks/todo.md に計画を書く
- 計画を確認:実装開始前にチェックインする
- 進捗を追跡:進めながら完了項目をマークする
- 変更を説明:各ステップで概要レベルのサマリーを出す
- 結果を文書化:
tasks/todo.md にレビューセクションを追加する
- 教訓を記録:修正後に
tasks/lessons.md を更新する
コア原則
- シンプルさ第一:すべての変更を可能な限りシンプルに。影響するコードは最小限に。
- 怠惰なし:根本原因を見つける。一時的な修正はしない。シニア開発者の基準で。
- 最小限の影響:変更は必要な箇所だけに留める。バグを持ち込まない。