スキル一覧に戻る

context-engineering

guia-matthieu
更新日 Yesterday
3 閲覧
111
20
111
GitHubで表示
その他automation

について

このスキルは、パフォーマンスの低下や指示の無視を防ぐために、大規模な会話コンテキスト(5万トークン以上)を管理する開発者を支援します。トークン使用量の最適化戦略やマルチエージェントワークフローの計画策定を提供します。セッションが30分を超える場合や「lost-in-middle」問題が発生した際にご利用ください。

クイックインストール

Claude Code

推奨
メイン
npx skills add guia-matthieu/clawfu-skills -a claude-code
プラグインコマンド代替
/plugin add https://github.com/guia-matthieu/clawfu-skills
Git クローン代替
git clone https://github.com/guia-matthieu/clawfu-skills.git ~/.claude/skills/context-engineering

このコマンドをClaude Codeにコピー&ペーストしてスキルをインストールします

ドキュメント

Context Engineering

Overview

Core principle: Context is a finite resource with diminishing returns. Find the smallest high-signal token set, not the largest.

200K tokens is shared space: system prompt + conversation history + your processing. As context grows, performance degrades predictably.

When to Use

  • Session > 30 minutes or 50k+ tokens
  • Instructions being ignored or forgotten
  • Repeated clarifications needed
  • Planning multi-agent workflows
  • Preparing handoffs between sessions

Quick Reference

ProblemSymptomFix
Lost-in-middleMid-conversation instructions ignoredMove critical info to start/end
Context poisoningErrors compounding, hallucinations referencedSummarize and reset
Context distractionIrrelevant info degrading performancePrune aggressively
Context confusionConflicting guidance causing inconsistencyConsolidate instructions

Degradation Patterns

1. Lost-in-Middle Effect

Information in context middle gets 10-40% lower recall than edges.

[START - High attention]
  ↓
[MIDDLE - Low attention zone]  ← Instructions here get ignored
  ↓
[END - High attention]

Fix: Strategic placement

  • Critical instructions → START (system prompt, first user message)
  • Recent decisions → END (last few messages)
  • Reference material → MIDDLE (acceptable for lookup, not instructions)

2. Context Poisoning

Early hallucination gets referenced → compounds → becomes "fact".

Symptoms:

  • Confident statements contradicting earlier facts
  • "As we discussed..." referencing things never said
  • Circular reasoning citing own previous errors

Fix: Checkpoint and summarize

Every 10-15 exchanges, create explicit checkpoint:

"Let me summarize what we've established:
1. [Verified fact]
2. [Verified fact]
3. [Decision made]

Continuing from here..."

3. Context Distraction

Irrelevant tokens compete for attention budget.

Symptoms:

  • Responses reference unrelated earlier topics
  • Focus drifts from current task
  • Unnecessary caveats about old context

Fix: Aggressive pruning

  • Use /clear + summary for fresh context
  • In multi-agent: give subagents ONLY relevant context
  • Remove resolved discussions from active consideration

4. Context Confusion

Multiple conflicting instructions create inconsistent behavior.

Symptoms:

  • Alternating between approaches
  • "On one hand... on the other hand..." hedging
  • Ignoring some instructions to satisfy others

Fix: Consolidate

Before: "Use TypeScript" (message 3) + "Keep it simple" (message 12) + "Add types everywhere" (message 27)

After: "TypeScript with practical typing - types where they help, skip where obvious"

Optimization Techniques

Compaction

When approaching limits, summarize context sections:

## Session Summary (compacted)

**Goal:** [One sentence]
**Decisions made:**
- [Decision 1]
- [Decision 2]
**Current state:** [What's done, what's next]
**Key constraints:** [Still-active requirements]

---
[Continue with fresh context]

Observation Masking

Replace verbose tool outputs with compact references:

Before: [500 lines of file content in context]
After: "Read src/app/page.tsx - React component with Hero, About, FAQ sections"

Context Partitioning (Multi-Agent)

Isolate subtasks in separate agents with clean contexts:

Main Agent (orchestrator):
  - High-level plan
  - Synthesis of results

Subagent 1 (search):        Subagent 2 (implement):
  - Only search context       - Only implementation context
  - Returns summary           - Returns code

Rule: Subagents get task + minimum required context, NOT full conversation history.

Practical Workflow

For Long Sessions (>1 hour)

digraph context_management {
  "Every 15-20 min" [shape=diamond];
  "Context healthy?" [shape=diamond];
  "Continue" [shape=box];
  "Create checkpoint summary" [shape=box];
  "Consider /clear + summary" [shape=box];

  "Every 15-20 min" -> "Context healthy?";
  "Context healthy?" -> "Continue" [label="yes"];
  "Context healthy?" -> "Create checkpoint summary" [label="degrading"];
  "Create checkpoint summary" -> "Consider /clear + summary";
}

Health check questions:

  • Are recent instructions being followed?
  • Is focus staying on current task?
  • Are responses becoming vague or hedgy?

For Handoffs (/save-session)

Capture for next session:

  1. Goal state - What were we trying to achieve?
  2. Current state - What's done, what's broken?
  3. Key decisions - Why did we choose X over Y?
  4. Active constraints - What rules still apply?
  5. Next steps - Where to pick up?

For Subagents

## Subagent Prompt Template

**Task:** [Specific deliverable]
**Context:** [ONLY what's needed - 50-200 words max]
**Constraints:** [Hard requirements]
**Output format:** [What to return]

[Do NOT include: conversation history, resolved discussions, unrelated files]

Anti-Patterns

Anti-PatternWhy it failsBetter approach
"Include everything just in case"Dilutes attention, causes distractionInclude only what's needed NOW
Repeating instructions every messageWastes tokens, implies they weren't heardTrust system prompt, reinforce only when ignored
Long file dumps without summaryLost-in-middle effectRead → summarize → reference summary
Keeping resolved threads activeContext confusionSummarize resolution, move on

Token Budget Guidelines

Context sizeExpected qualityAction
< 20kOptimalContinue normally
20-50kGoodMonitor for degradation
50-100kDegradingActive management needed
100-150kPoorSummarize and reset soon
> 150kCriticalReset with checkpoint

Key Insight

"The goal isn't to use all 200K tokens. It's to use the fewest tokens that achieve your outcome."

Informativity over exhaustiveness. Include what matters for current decisions, exclude everything else, and design systems that access additional information on demand.


What Claude Does vs What You Decide

Claude handlesYou provide
Monitoring context healthDecision to reset or continue
Creating checkpoint summariesValidation that summary is accurate
Pruning irrelevant contentJudgment on what's still needed
Structuring subagent promptsStrategic task decomposition
Detecting degradation patternsTiming of interventions

Skill Boundaries

This skill excels for:

  • Long sessions (>30 min, >50k tokens)
  • Multi-agent workflows with handoffs
  • Complex projects spanning multiple sessions
  • Debugging "forgotten instruction" issues

This skill is NOT ideal for:

  • Short, focused interactions → Not needed
  • Single-turn queries → Overhead unnecessary
  • Tasks with naturally bounded context → Already constrained

Skill Metadata

name: context-engineering
category: meta
version: 2.0
author: GUIA
source_expert: Anthropic research, NeoLabHQ context-engineering-kit
difficulty: advanced
mode: centaur
tags: [context, tokens, memory, multi-agent, handoff, optimization]
created: 2026-02-03
updated: 2026-02-03

GitHub リポジトリ

guia-matthieu/clawfu-skills
パス: skills/meta/context-engineering
0
ai-skillsanthropicclaude-codeclaude-skillsmarketingmcp-server

関連スキル

llamaguard

その他

LlamaGuardは、暴力やヘイトスピーチなど6つの安全性カテゴリーにおいて、LLMの入力と出力をモデレートするMetaの70-80億パラメータモデルです。94〜95%の精度を提供し、vLLM、Hugging Face、Amazon SageMakerを使用してデプロイ可能です。このスキルを使用して、AIアプリケーションにコンテンツフィルタリングと安全策を簡単に統合できます。

スキルを見る

cost-optimization

その他

このClaudeスキルは、リソースの適正サイジング、タグ付け戦略、支出分析を通じて、開発者がクラウドコストを最適化することを支援します。AWS、Azure、GCPにわたるクラウド支出の削減とコストガバナンスの実施のためのフレームワークを提供します。インフラコストの分析、リソースの適正サイジング、または予算制約への対応が必要な際にご利用ください。

スキルを見る

quantizing-models-bitsandbytes

その他

このスキルは、bitsandbytesを使用してLLMを8ビットまたは4ビット精度に量子化し、精度の低下を最小限に抑えつつ50〜75%のメモリ削減を実現します。限られたGPUメモリでより大規模なモデルを実行したり、推論を高速化するのに理想的で、INT8、NF4、FP4などのフォーマットをサポートしています。HuggingFace Transformersと統合され、QLoRAトレーニングや8ビットオプティマイザーを可能にします。

スキルを見る

dispatching-parallel-agents

その他

このClaudeスキルは、複数のエージェントを配備し、3つ以上の独立した問題を並行して調査・修正します。共有状態や依存関係がなく解決可能な、無関係な障害が発生するシナリオ向けに設計されています。中核となる機能は並列問題解決であり、効率を最大化するために独立した問題領域ごとに1つのエージェントを割り当てます。

スキルを見る