원클릭으로
context-management
Intelligent context window management with tiered content, token budgets, and LLM-powered summarization
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Intelligent context window management with tiered content, token budgets, and LLM-powered summarization
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Plan-and-Execute methodology for adaptive execution with replanning
Plan-and-Solve methodology for goal decomposition and plan creation
Multi-agent workflow coordination with routing, state management, and failure recovery
Plan validation with confidence scoring and adversarial challenge
Brand discovery methodology for establishing identity, voice, and messaging
Content creation methodology leveraging brand context for consistent, strategic content
| name | context-management |
| description | Intelligent context window management with tiered content, token budgets, and LLM-powered summarization |
| triggers | ["context","optimize","summarize","budget","token"] |
This skill teaches the methodology for managing context window efficiently. It prevents context bloat, enables long-running sessions, and preserves critical information through intelligent summarization.
Context windows have hard limits. Without management:
┌─────────────────────────────────────────────────────────────────────┐
│ CONTEXT TIER SYSTEM │
├─────────────────────────────────────────────────────────────────────┤
│ │
│ TIER 1: FULL CONTENT (Recent/Active) │
│ ══════════════════════ │
│ • Age: < 30 days │
│ • Token Retention: 100% │
│ • Content: Complete entries with all details │
│ • Preserves: Code snippets, full explanations, all context │
│ │
│ ──────────────────────────────────────────────────────────────── │
│ │
│ TIER 2: SUMMARY (Older) │
│ ══════════════════════ │
│ • Age: 30-90 days │
│ • Token Retention: 20-30% │
│ • Content: LLM-generated summaries │
│ • Preserves: Key insights, pattern names, problem-solution pairs │
│ │
│ ──────────────────────────────────────────────────────────────── │
│ │
│ TIER 3: INDEX ONLY (Archived) │
│ ═════════════════════════════ │
│ • Age: > 90 days │
│ • Token Retention: 5% │
│ • Content: Metadata only │
│ • Preserves: Date, title, domain, tags, reference path │
│ │
└─────────────────────────────────────────────────────────────────────┘
The total context window must be allocated across competing needs:
TOTAL BUDGET: ~150,000 tokens
────────────────────────────────────────────────────────────
Pool │ Soft Limit │ Hard Limit │ Purpose
───────────────┼────────────┼────────────┼───────────────────
Reserved │ 30,000 │ 35,000 │ System prompts,
│ │ │ playbooks, task
───────────────┼────────────┼────────────┼───────────────────
Learnings │ 20,000 │ 25,000 │ Project learnings
│ │ │ from builds
───────────────┼────────────┼────────────┼───────────────────
Backlog │ 15,000 │ 20,000 │ Epic/Feature/Task
│ │ │ hierarchy
───────────────┼────────────┼────────────┼───────────────────
Plans │ 30,000 │ 35,000 │ Current plan
│ │ │ details
───────────────┼────────────┼────────────┼───────────────────
Context7 │ 25,000 │ 30,000 │ External docs
│ │ │ from MCP
───────────────┼────────────┼────────────┼───────────────────
Working │ 30,000 │ 40,000 │ Agent workspace,
│ │ │ tool results
────────────────────────────────────────────────────────────
Different content types have different token densities:
Tokens ≈ Characters / 4
Example:
1000 characters of code ≈ 250 tokens
Tokens ≈ Words × 1.3
Example:
500 words of markdown ≈ 650 tokens
Tokens ≈ Characters / 3.3
Example:
2000 characters of JSON ≈ 606 tokens
When entries age into Tier 2, use Claude to create intelligent summaries.
Summarize this learning entry, preserving:
1. The key insight (one sentence)
2. Pattern names mentioned
3. Code snippets (keep if < 10 lines, describe otherwise)
4. Problem-solution pairs
Original entry:
[CONTENT]
Output format:
## [Date]: [Title] (summarized)
**Key Insight:** [One sentence capturing the main lesson]
**Patterns:** [Comma-separated pattern names]
**Ref:** [original-file-path]
Original (Tier 1, 800 tokens):
## 2025-11-15: Form Validation Pattern
**Context:** Building user registration (task_20251115_143052)
**What Worked:**
- Zod + react-hook-form for client-side validation
- Inline error display with immediate feedback
- Server-side validation mirroring client rules
- Using FormProvider for nested forms
**Problems Solved:**
- Problem: Form submission not showing errors
Solution: Added `mode: "onBlur"` to react-hook-form config
- Problem: Async validation for email uniqueness
Solution: Used resolver with async validation
**Pattern:**
```typescript
const schema = z.object({
email: z.string().email(),
password: z.string().min(8).regex(/[A-Z]/).regex(/[0-9]/)
});
const form = useForm({
resolver: zodResolver(schema),
mode: "onBlur",
reValidateMode: "onChange"
});
// For async validation
const resolver = async (data) => {
const result = schema.safeParse(data);
if (!result.success) return { values: {}, errors: result.error };
const emailExists = await checkEmail(data.email);
if (emailExists) {
return { values: {}, errors: { email: { message: "Email taken" } } };
}
return { values: data, errors: {} };
};
Anti-patterns:
**Summarized (Tier 2, 180 tokens):**
```markdown
## 2025-11-15: Form Validation Pattern (summarized)
**Key Insight:** Use Zod + react-hook-form with `mode: "onBlur"` for optimal validation UX; mirror validation rules server-side.
**Patterns:** zodResolver, FormProvider, async-resolver, onBlur-validation
**Problem-Solutions:**
- Form errors not showing → Add `mode: "onBlur"`
- Async email validation → Custom resolver with await
**Ref:** studio/learnings/frontend.md#2025-11-15
Summaries are cached to avoid re-summarization:
.studio/.cache/summaries/
├── frontend_2025-11-15.md
├── backend_2025-11-01.md
└── ...
./scripts/context-manager.sh status
./scripts/context-manager.sh scan
Output shows:
./scripts/context-manager.sh summarize studio/learnings/frontend.md 2025-11-15
After LLM generates summary:
#preserve#no-summarize tagThe context manager works with learnings.sh:
The orchestrator allocates context budgets:
At session start:
Check budget status at session start and after large operations.
Don't wait for hard limit. Summarize when warnings appear.
Recent content is more likely to be relevant. Preserve it.
30/90 day thresholds are tuned for typical project cycles.
Summaries are expensive. Never regenerate unnecessarily.
context-manager.sh optimize learnings#no-summarize"Manage context like memory: keep what's recent, summarize what's older, index what's ancient."