.claude/skills/context-engineering/SKILL.md
Context engineering knowledge base — context stack architecture (8-layer model), memory engineering (taxonomy, CRUD, conflict resolution, compression), agent harness patterns (init/continuation, state blobs, token budgeting, caching, failure modes), RAG pipeline design (chunking, packing, degradation signals), multi-agent orchestration (boundaries, payload schemas, fan-out patterns), production AI checklists (8 checklists), reference implementation templates (grounding envelope, untrusted wrapper, tool error envelope), privacy and compliance for AI systems. Use when designing AI agent systems, reviewing context quality, building RAG pipelines, implementing memory, planning multi-agent architectures, or preparing AI systems for production.
npx skillsauth add avav25/ai-assets context-engineeringInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Context engineering is the discipline of systematically selecting, structuring, and delivering the smallest possible set of high-signal tokens that make a task plausibly solvable for an LLM — reliably, safely, and cost-effectively.
This skill provides actionable patterns, checklists, and templates for the full context pipeline — from first principles through production readiness.
prompt-engineering skillprompt-engineering skill → security-checklist.mdAgent(software-engineer) + stack-specific roleAgent(devops-engineer)These are complementary disciplines:
Context engineering is the system; prompt engineering is one layer within it.
Ordered layers, top = highest priority. Higher layers override lower on conflict.
| Layer | What Goes Here | Design Notes | |---|---|---| | 1. System policy & safety | Non-negotiable constraints, content policies, refusal rules | First in window — highest attention. Cacheable | | 2. Developer instructions | Role definitions, hard rules, reasoning protocols, conventions | Maps to: Claude Code rules ((auto-loaded), (agent)) | | 3. Tool contracts | Schemas, descriptions, permissions, failure modes, retry policies | Tool descriptions ARE prompts — optimize them | | 4. Runtime state | Current project context, CLAUDE.md, active file, task state, structured state blob | Maps to: Claude Code CLAUDE.md files | | 5. Knowledge context (RAG) | Retrieved documents, search results, file contents | Must be wrapped as untrusted data with grounding envelopes | | 6. Memory | Session, working, long-term, organizational, tool-output | Must be scoped, filtered, and conflict-resolved | | 7. Examples (few-shot) | Minimal, high-leverage exemplars aligned to output contract | Dynamic selection preferred; skip if schema suffices | | 8. Output contract | JSON Schema, format instructions, constraints, error handling | End of context — recency bias helps compliance |
Rule: keep policy/instructions (Layers 1-2) separate from knowledge (Layer 5). Mixing them is a root cause of prompt injection and "obedience confusion."
→ Full reference: context-stack-model.md
Layers 1-3 rarely change → group all static content at the beginning of the prompt to enable KV cache reuse. Append dynamic content (Layer 4-8) at the end. Never interleave static and dynamic blocks.
Track cache_prefix_ratio = cached_tokens / total_input_tokens (target > 0.3).
Treat context window as a finite resource with explicit budget per layer:
| Allocation | Suggested % | Notes | |---|---|---| | System + rules + tools (L1-3) | 15-25% | Stable, cacheable prefix | | Runtime state (L4) | 5-10% | Structured state blob | | Knowledge / RAG (L5) | 30-40% | Dynamic, highest signal variance | | Memory (L6) | 10-15% | Filtered, relevance-ranked | | Examples (L7) | 0-10% | Only when needed | | Output contract (L8) | 5-10% | Schema + error handling |
Overflow strategy: truncate lowest-priority layers first (L7 → L6 → L5).
| File | Contents | Guide §§ |
|---|---|---|
| context-stack-model.md | 8-layer architecture, layer design patterns, position effects, mapping to Claude Code assets | §3 |
| memory-engineering.md | Memory taxonomy, CRUD lifecycle, conflict handling, compression strategies | §6 |
| agent-harness-patterns.md | Init/continuation, state blobs, token budgets, caching, failure modes, streaming | §7 |
| rag-engineering.md | Pipeline blueprint (7 stages), chunking, packing, degradation signals | §5 |
| multi-agent-patterns.md | Context boundaries, payload schemas, return contracts, fan-out, contamination | §7.6, §14 |
| production-checklists.md | All 8 production readiness checklists | §11 |
| reference-templates.md | Grounding envelope, untrusted wrapper, structured output, tool error envelope | §12 |
| privacy-compliance-ai.md | Multi-tenant isolation, data controls, consent, regional compliance | §9 |
Agent(prompt-engineer) (prompt-level techniques, security, eval-first quality)/ai-assets (context engineering validation), /feature-dev (AI features), /feature-plan (AI work packages), /code-review (context quality review)prompt-engineering skill (technique selection, template patterns, eval, security checklist)Agent(solution-architect) (AI system design), Agent(product-manager) (agent contracts), Agent(sre-engineer) (context observability), Agent(software-engineer) (implementation)guides/context_engineering_guide.mddevelopment
Use this skill when running the recurring (daily) knowledge-base rescan for a repo that already has knowledge/.knowledge-sync.yml — the main-thread dispatcher that reads the config, computes the git delta since last_scanned_sha, maps changed paths to affected doc areas, early-exits cheaply when nothing changed, then fans out one Agent(content-writer) per affected area, applies the propose/direct update policy, advances the baseline only on success, and writes an L4 run log — all with the G1 untrusted-content choke-point, secret-scan, deny-list, and budget controls woven in. For first-time setup use /knowledge-sync-init.
development
Use this skill when bootstrapping scheduled knowledge-base sync for a repo that has no knowledge/.knowledge-sync.yml yet — to run one-time setup that detects the knowledge_root from CLAUDE.md/AGENTS.md, maps doc areas to source globs, records opt-in external sources (Linear/Notion/WebFetch, all disabled by default), captures a baseline last_scanned_sha, sets the per-area update policy, generates or seeds knowledge/CONVENTIONS.md, provisions the L4 memory dir, and offers to register the daily routine. Routes ongoing recurring sync operations to /knowledge-sync.
tools
Use this skill when bootstrapping a target repository to be ai-skills-aware — on the first run of any ai-skills workflow in a fresh repo, when adopting the ai-skills plugin in an existing repo, or after upgrading to a plugin version that adds new memory paths or templates, including when the user does not say "init" but asks to "set up" or "onboard" the repo — to detect codebase type, create CLAUDE.md + AGENTS.md scaffolding, initialize the .ai-skills-memory/ directory tree from L1 templates, and configure .gitignore. Idempotent — safe to re-run. Accepts `--codebase-type <type>` and `--overwrite`. Not for re-initializing only memory — use `/memory-init` instead.
tools
Use this skill when extending, repairing, or improving plugin assets, when ingesting a `/feedback` report as a fix-cycle backlog, or when you do not remember which lower-level command is right for the job — the umbrella workflow for ai-skills plugin-asset authoring and maintenance: creating, auditing, fixing, improving, refactoring, and migrating skills, agents, rules, hooks, prompts, schemas, and rubrics inside the plugin. Auto-classifies the request, loads the right knowledge skills (`@prompt-engineering`, `@context-engineering`, `@team-protocols`), and spawns the right subagents (`prompt-engineer`, `system-architect`, `python-engineer`, `software-engineer`, `qa-engineer`, `eval-judge`) via the `Agent` tool.