Communitygithub.com

コンテキストエンジニアリング

LLMタスクにおけるトークン使用量の監視、コンテキスト制限の確認、残り時間の追跡、コンテキスト障害のデバッグを行います。コンテキスト使用率、レート制限、使用状況警告、コンテキスト最適化、エージェントアーキテクチャ、メモリシステムについて質問する際に使用します。

コンテキストエンジニアリング とは?

このスキルは、LLMエージェントシステムにおけるコンテキストウィンドウの効率的な管理と最適化に焦点を当てています。トークン使用量の監視、コンテキストの圧縮・分割、マルチエージェント間のコンテキスト分離など、実践的なテクニックを提供し、コストとレイテンシを削減しながら推論品質を維持する方法を解説します。主な機能として、実行時の使用状況認識(PostToolUseフックによる自動注入)、70%と90%の閾値に基づく警告・最適化トリガー、コンテキスト分析・圧縮評価用のPythonスクリプトなどが含まれています。Claude CodeやCursorなどのAIエージェントプラットフォームで動作し、複雑なマルチエージェントシステムや長期セッションにおいて特に有効です。

対応✓Claude Code~Codex CLI~Cursor
npx skills add https://github.com/majiayu000/claude-skill-registry-data/tree/HEAD/context-management/context-engineering-hoanghd218-landing-page-ai-kien-2

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

コンテキストエンジニアリング は何をしますか?

コンテキストエンジニアリングは、LLMタスクに対して最小の高シグナルトークンセットを厳選します。目標は、トークン使用量を最小限に抑えながら推論品質を最大化することです。

アクティベーションが必要な場合

  • エージェントシステムの設計/デバッグ
  • コンテキスト制限がパフォーマンスを制約している場合
  • コスト/レイテンシの最適化
  • マルチエージェント連携の構築
  • メモリシステムの実装
  • エージェントパフォーマンスの評価
  • LLM駆動パイプラインの開発

コア原則

  1. コンテキストの質 > 量 - 高シグナルトークンは網羅的なコンテンツに勝る
  2. 注意は有限 - U字曲線は先頭/末尾の位置を優先する
  3. 段階的開示 - 情報をジャストインタイムで読み込む
  4. 分離による劣化防止 - サブエージェント間で作業を分割する
  5. 最適化前に測定する - ベースラインを把握する

重要:

  • 簡潔さのために文法を犠牲にすること
  • 高品質を維持しながらトークン効率を確保すること
  • これらのルールをサブエージェントに引き継ぐこと

クイックリファレンス

トピック使用タイミングリファレンス
基礎コンテキスト構造、注意メカニズムの理解context-fundamentals.md
劣化障害デバッグ、Lost-in-the-Middle、ポイズニングcontext-degradation.md
最適化コンパクション、マスキング、キャッシング、パーティショニングcontext-optimization.md
圧縮長期セッション、要約戦略context-compression.md
メモリセッション間永続化、ナレッジグラフmemory-systems.md
マルチエージェント連携パターン、コンテキスト分離multi-agent-patterns.md
評価エージェントテスト、LLM-as-Judge、メトリクスevaluation.md
ツール設計ツール統合、説明エンジニアリングtool-design.md
パイプラインプロジェクト開発、バッチ処理project-development.md
実行時認識使用制限、コンテキストウィンドウ監視runtime-awareness.md

主要メトリクス

  • トークン使用率: 警告70%、最適化トリガー80%
  • トークンのばらつき: エージェントパフォーマンスのばらつきの80%を説明
  • マルチエージェントコスト: シングルエージェントの約15倍
  • コンパクション目標: 50-70%削減、品質損失5%未満
  • キャッシュヒット目標: 安定したワークロードで70%以上

4バケット戦略

  1. 書き出す: コンテキストを外部に保存(スクラッチパッド、ファイル)
  2. 選択する: 関連コンテキストのみを取得(検索、フィルタリング)
  3. 圧縮する: 情報を保持しながらトークンを削減(要約)
  4. 分離する: サブエージェント間で分割(パーティショニング)

アンチパターン

  • 厳選されたコンテキストではなく網羅的なコンテキスト
  • 中間位置に重要な情報を配置
  • 制限前にコンパクショントリガーがない
  • 並列化可能なタスクに単一エージェント
  • 明確な説明がないツール

ガイドライン

  1. 重要な情報はコンテキストの先頭/末尾に配置する
  2. 使用率70-80%でコンパクションを実行する
  3. コンテキスト分離にはロールプレイではなくサブエージェントを使用する
  4. ツールは4質問フレームワーク(何を、いつ、入力、戻り値)で設計する
  5. リクエストあたりのトークン数ではなく、タスクあたりのトークン数を最適化する
  6. プローブベースの評価で検証する
  7. 本番環境でKVキャッシュヒット率を監視する
  8. 最小限から始め、必要な場合のみ複雑性を追加する

実行時認識

システムはPostToolUseフックを介して使用状況認識を自動的に注入します:

<usage-awareness>
Claude Usage Limits: 5h=45%, 7d=32%
Context Window Usage: 67%
</usage-awareness>

閾値:

  • 70%: 警告 - 最適化/コンパクションを検討
  • 90%: 重大 - 即時対応が必要

データソース:

  • 使用制限: Anthropic OAuth API (https://api.anthropic.com/api/oauth/usage)
  • コンテキストウィンドウ: ステータスライン一時ファイル (/tmp/ck-context-{session_id}.json)

スクリプト

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

majiayu000/claude-skill-registry-data

Edit existing BMAD agents while maintaining compliance

majiayu000/claude-skill-registry-data

Edit existing BMAD agents while maintaining compliance

majiayu000/claude-skill-registry-data

Edit existing BMAD modules while maintaining coherence

majiayu000/claude-skill-registry-data

Edit existing BMAD modules while maintaining coherence

majiayu000/claude-skill-registry-data

Analyzes current state and user query to answer BMad questions or recommend the next workflow or agent. Use when user says what should I do next, what do I do now, or asks a question about BMad

majiayu000/claude-skill-registry-data

Build AI agents with Google ADK Python (Agent Development Kit). Use for multi-agent systems, workflow agents (sequential/parallel/loop), Vertex AI deployment, tool integration, human-in-the-loop.

majiayu000/claude-skill-registry-data

Build AI agents with Google ADK Python (Agent Development Kit). Use for multi-agent systems, workflow agents (sequential/parallel/loop), Vertex AI deployment, tool integration, human-in-the-loop.

majiayu000/claude-skill-registry-data

Portfolio allocation and rebalancing optimizer. Manages asset allocation across stocks/cash/bonds, performs periodic rebalancing, and ensures diversification according to market regime and risk tolerance.

majiayu000/claude-skill-registry-data

Create a hilarious and ultra-realistic video of an anthropomorphic animal acting like a human vlogger in a real-world setting.

majiayu000/claude-skill-registry-data

Speech-to-text transcription and translation via OpenAI Audio API -- models, response formats, timestamps, prompting, streaming, chunking, and diarization

majiayu000/claude-skill-registry-data

This skill should be used when the user asks about libraries, frameworks, API references, or needs code examples. Activates for setup questions, code generation involving libraries, or mentions of specific frameworks like React, Vue, Next.js, Prisma, Supabase, etc.

majiayu000/claude-skill-registry-data

小省导购员数字人带货版即梦视频提示词生成系统,基于四大智能体协同(提示词生成师、质量管控师、知识库运维师、跨环节适配师),按照"主体+运动+场景+(镜头语言+光影+氛围)"公式输出中英文双版提示词,适配5s短视频。确保人物一致性、视觉连贯性、情绪连贯性,支持知识库智能复用和跨工具适配(Suno音乐、AI绘画),为数字人带货视频提供高质量提示词生成服务。

majiayu000/claude-skill-registry-data

Upload and manage files using Google Gemini File API via scripts/. Use for uploading images, audio, video, PDFs, and other files for use with Gemini models. Supports file upload, status checking, and file management. Triggers on "upload file", "file API", "upload image", "upload PDF", "upload video", "file management".

majiayu000/claude-skill-registry-data

Analyze images/audio/video with Gemini API (better vision than Claude). Generate images (Imagen 4), videos (Veo 3). Use for vision analysis, transcription, OCR, design extraction, multimodal AI.

majiayu000/claude-skill-registry-data

Analyze images/audio/video with Gemini API (better vision than Claude). Generate images (Imagen 4), videos (Veo 3). Use for vision analysis, transcription, OCR, design extraction, multimodal AI.

majiayu000/claude-skill-registry-data

Skill for discovering and researching autonomous AI agents, tools, and ecosystems using the AgentFolio directory.

majiayu000/claude-skill-registry-data

Conduct domain and industry research. Use when the user says "lets create a research report on [domain or industry]

majiayu000/claude-skill-registry-data

Conduct market research on competition and customers. Use when the user says "create a market research report about [business idea]".

majiayu000/claude-skill-registry-data

Conduct technical research on technologies and architecture. Use when the user says "create a technical research report on [topic]".

majiayu000/claude-skill-registry-data

Builds, edit or validate Agent Skill through conversational discovery. Use when the user requests to "Create an Agent", "Optimize an Agent" or "Edit an Agent".

関連スキル