context-engineering
Skill2 starsChanged 7 months agoMITView on GitHub
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.
82 other projects use a version of this.
Adopted by
Most recently taken up by
- GuillemRoca/agent-skills-androidtheir own version, first seen Oct 3, 2026
- paruff/uFawkesAItheir own version, first seen Oct 3, 2026
- addyosmani/agent-skillstheir own version, first seen Oct 3, 2026
- weisser-dev/agentic-skillstheir own version, first seen Oct 3, 2026
- Rvey/agent-engineering-kittheir own version, first seen Oct 1, 2026
- rohitg00/pro-workflowtheir own version, first seen Sep 29, 2026
Used with
Projects with it also use using-agent-skills, constraint-driven-development and 10 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
LLl0k0laDSkillusing-agent-skills
Use when starting a session or when you need to discover which skill applies to the current task. This is the meta-skill that governs how all other skills are discovered and invoked.
Also in 24 projects that use this
vinvcnSkillconstraint-driven-development
把一个项目的质量线确立为书面契约,并阻止 agent 悄悄降低它。通过访谈确定用户在意哪些维度,当用户心里没有数字时提供合理的默认阈值,把一切记录进 CONSTRAINTS.md,并盯住 diff 中质量线被削弱的迹象——新增的 @ts-ignore 或 eslint-disable 抑制注释、被跳过或删除的测试、被剥掉的断言、未实现的 stub、被调低的阈值。当没有任何质量线被写下来时使用;当用户说 "set up constraints" 或 "define our standards" 时;当用户希望把他们在意的维度——无障碍性、Web 性能、覆盖率——设置成被强制执行的约束时;当 agent 为了变绿不断静默检查或跳过测试时;当你需要一个覆盖率或性能阈值却不知道该选什么数字时;或者当 agent 写下的代码超出任何人会读的体量时。
Also in 4 projects that use this
LLl0k0laDSkillshipping-and-launch
Use when preparing to deploy to production. Use when you need a pre-launch checklist, when setting up monitoring, when planning a staged rollout, or when you need a rollback strategy.
Also in 26 projects that use this
galandoSkillsource-driven-development
Version-aware, source-driven development — fetch official docs before writing framework code
Also in 25 projects that use this
az9713Skilldeprecation-and-migration
Manages deprecation and migration. Use when removing old systems, APIs, or features. Use when migrating users from one implementation to another. Use when deciding whether to maintain or sunset existing code.
Also in 22 projects that use this
- +7 more from LLl0k0laD
Other versions82 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 82
- addyosmani/agent-skills★ 101ksame name
- rohitg00/pro-workflow★ 2.9ksame name
- mrgoonie/claudekit-skills★ 2.2ksame name
- NeoLabHQ/context-engineering-kit★ 1.7ksame name
- kdlbs/kandev★ 899same name
- Owl-Listener/ai-design-skills★ 178same name
- shashankswe2020-ux/whoop-mcp★ 165same name
- tranhieutt/software_development_department★ 72same name
- nahid-sparktales/agent-dispatcher★ 59same name
- drvoss/everything-copilot-cli★ 47same name
72 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository40 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- ai-skillsSkill
- analyze-localSkill
- analyze-prodSkill
- analyzeSkill
- architectureSkill
- asset-validationSkill
- blog-postSkill
- bugfixSkill
- cloud-platformsSkill
- code-reviewSkill
- content-creationSkill
- create-prSkill
- deployment-proceduresSkill
- deploy-productionSkill
- deploy-stagingSkill
- docsSkill
- feature-devSkill
- geo-writerSkill
- humanizerSkill
- infra-changeSkill
- marketing-operationsSkill
- marketingSkill
- ml-pipelineSkill
- planSkill
- pre-commitSkill
- productSkill
- project-initSkill
- prompt-engineeringSkill
- qaSkill
- releaseSkill
- run-testsSkill
- security-scanSkill
- seo-reviewSkill
- social-media-managerSkill
- test-localSkill
- test-strategySkill
- ui-ux-designSkill
- worktree-isolationSkill
The file
We split this skill into the rules it gives an agent
2 rules. 0 are common, 2 are distinctive, and 0 are very specific to this project.
0
Common
Most of the 77 edited versions we read keep these.
2
Distinctive
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 72
Rule: keep policy/instructions (Layers 1-2) separate from knowledge (Layer 5).
- Distinctive: line 84
Treat context window as a finite resource with explicit budget per layer:
“Common” is measured: kept by at least 6 in 10 of the 77 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Context Engineering
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.
When to Use
- Designing context pipelines for AI agents (what enters the LLM context window, in what order)
- Reviewing context quality and token efficiency of existing systems
- Building RAG systems (retrieval pipeline, chunking, packing, grounding)
- Implementing memory (session, working, long-term, organizational, tool-output)
- Designing agent harness (init/continuation prompts, state management, token budgets, caching)
- Multi-agent orchestration (context boundaries, payload schemas, fan-out merge)
- Production readiness assessment for AI systems (8-checklist gate)
- Privacy and compliance for AI features (multi-tenant isolation, consent, data residency)
When NOT to Use
- Prompt technique selection and template patterns → use
prompt-engineeringskill - Security audit of individual prompts → use
prompt-engineeringskill →security-checklist.md - Non-AI software engineering tasks → use
software-engineerrole + stack-specific role - Infrastructure and deployment → use
devops-engineerrole
Context Engineering vs Prompt Engineering
These are complementary disciplines:
- Prompt engineering = designing the instruction text (technique selection, template patterns, formatting, few-shot)
- Context engineering = designing the full context PIPELINE (what enters the window, in what order, how it's managed across turns, how it degrades gracefully)
Context engineering is the system; prompt engineering is one layer within it.
Key Concepts
First Principles
- Attention is finite — curate, don't stuff. "More context" is not monotonically better
- Position effects — critical info at beginning and end ("lost-in-the-middle"). Models use tokens near the start and end more effectively than those buried in the middle
- High-signal tokens > high-volume tokens — compact, discriminative context beats verbose dumps
- Separation of concerns — policy, knowledge, examples, output contract in distinct layers. Enables independent swap, A/B testing, failure analysis
- Context is a pipeline — produced by a system (retrieval, ranking, summarization, memory, policy filters, schema enforcement), not concatenated strings
The Context Stack (8-Layer Architecture)
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: Codex package rules, role overlays, and AGENTS.md guidance |
| 3. Tool contracts | Schemas, descriptions, permissions, failure modes, retry policies | Tool descriptions ARE prompts — optimize them |
| 4. Runtime state | Current project context, AGENTS.md, active file, task state, structured state blob | Maps to: Codex AGENTS.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
Cacheable Prefix Design
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).
Token Budget Allocation
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).
Resource Files
| File | Contents | Guide §§ |
context-stack-model.md | 8-layer architecture, layer design patterns, position effects, mapping to Codex 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 |
Integration
- Follows rules:
prompt-engineerrole (prompt-level techniques, security, eval-first quality) - Used by workflows:
ai-skillsskill (context engineering validation),feature-devskill (AI features),planskill (AI work packages),code-reviewskill (context quality review) - Companion skill:
prompt-engineeringskill (technique selection, template patterns, eval, security checklist) - Collaborates with roles:
solution-architectrole (AI system design),product-managerrole (agent contracts),sre-engineerrole (context observability),software-engineerrole (implementation) - Primary source:
guides/context_engineering_guide.md
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

