CClaude Code Catalog
全パターン

コンテキストウィンドウ管理

ワークフロー中級

大規模コードベースはClaudeのコンテキストウィンドウを容易に超過します。このパターンはセッションを生産的に保つ戦略を提供します:/compactで履歴を要約し、CLAUDE.mdに重要情報を優先配置し、タスクを集中セッションに分割し、モジュール全体ではなくファイル単位の要約を使用します。新しいセッションを開始するか現在のセッションをcompactするかの決定ツリーを含みます。

コンテキストメモリ大規模コードベースセッション管理

パターンコード

# Context Window Management Pattern ## Strategy 1: CLAUDE.md as Persistent Memory ```markdown # CLAUDE.md — Context Anchors ## Architecture Overview (always loaded first) - Monorepo: apps/ (3 apps), packages/ (7 shared packages) - Entry points: apps/{web,api,admin}/src/index.ts - Shared types: packages/types/src/index.ts ## Key Files (read these before making changes) - Database schema: packages/db/schema.ts - API routes map: apps/api/src/routes/index.ts - Environment config: packages/config/src/env.ts ## Recent Decisions (prevents re-discussion) - 2024-03-01: Switched from REST to tRPC for internal APIs - 2024-02-15: Adopted Drizzle ORM, removed Prisma - 2024-02-10: All new components use Radix UI primitives ``` ## Strategy 2: Session Splitting ```bash # Session 1: Analysis only — output to file claude -p "Analyze src/services/ and list all functions that need error handling improvements. Output to docs/error-audit.md" --output-file error-audit.md # Session 2: Fix based on analysis (fresh context) claude -p "Read docs/error-audit.md and fix each listed issue. Work through files one at a time." ``` ## Strategy 3: Compact Triggers ```markdown # CLAUDE.md — Compact Rules ## When to /compact - After completing a distinct subtask - Before switching to a different module - When you notice repeated file reads ## Compact Summary Format Always include in compact summary: 1. What was accomplished 2. Current file being worked on 3. Remaining items from the task list 4. Any blockers or decisions made ``` ## Strategy 4: Focused File Loading ```bash # Instead of "read the entire src/ directory" # Ask Claude to read specific files claude -p "Read only src/services/auth.ts and src/middleware/validate.ts. Fix the token refresh bug described in issue #234." ```

このパターンをプロジェクト設定にコピーして適用してください。

実行プレビュー

コンテキストウィンドウ管理

コンテキストウィンドウ管理について

Claude Codeパターンは、複雑な開発シナリオに対応するための実証済みアーキテクチャ設計とワークフロー構造です。コンテキストウィンドウ管理は中級レベルのワークフローパターンで、プロジェクトに合わせて応用できるテスト済みの再現可能なアプローチを提供し、より効率的で一貫した成果を実現します。

関連パターン