Context Engineering 4 패턴 (Write · Select · Compress · Isolate)
Concept (개념)aidraftTue May 12

Context Engineering 4 패턴 (Write · Select · Compress · Isolate)

별칭: 컨텍스트 엔지니어링 4 패턴 · Karpathy context patterns · WSCI patterns

#context-engineering#karpathy#langchain#4-patterns#token-efficiency

정의

entity/karpathyContext Engineering 정의 — "다음 단계를 위해 바로 그 적절한 정보로 context window 를 채우는 섬세한 예술과 과학."

영문 원문: "The delicate art and science of filling the context window with just the right information for the next step."

→ LangChain 의 concept/context-engineering 정의를 4 가지 패턴 으로 구조화.

4 패턴 + CLAUDE.md 매핑 표

#패턴정의CLAUDE.md 기반 구현
1Write context윈도우 외부 에 정보 저장 → 검색 가능term/claude-md + .claude/rules/ + term/agent-memory
2Select context필요할 때 관련 정보만 가져옴Skills 의 필요 시 로드 + paths glob 경로별 규칙
3Compress context필수 토큰만 유지/compact + Karpathy 간결성 원칙 + 200 줄 한계
4Isolate context여러 에이전트·환경 으로 분리Subagents + context: fork skill + 워크트리

★ Context 위험 5 가지 (방어 대상)

장기 실행 에이전트 작업이 토큰을 누적할 때 발생:

  • Context poisoning (오염) — 잘못된 정보가 정착
  • Context distraction (산만) — 노이즈로 핵심 묻힘
  • Context confusion (혼동) — 충돌 지침으로 임의 선택
  • Context clash (충돌) — 명시적 모순
  • Window 초과 — 잘림·오류·비용·지연시간 폭증

5 가지를 CLAUDE.md + Skills + Hooks + Subagents 의 4 층 인프라 로 막는다.

★ Cognition 의 진단 (LangChain 재인용)

"Context engineering is effectively the #1 job of engineers building AI agents."

본 강의의 핵심 주장 — CLAUDE.md = 헌법 의 정당화.

강의 활용

  • Ch1 — Context = 가장 희소한 자원 + 4 패턴 도입
  • Ch6 §6.4 — 4 층 인프라가 4 패턴의 직접 구현 임을 명시
  • Ch9 §9.5 — 토큰 차익거래 ([[synthesis_horim_token-economy-and-experience-arbitrage]]) 의 경제학적 변형