context-engineering
Skill39 starsChanged 8 months agoMITView on GitHub
Context Engineering is the discipline of maximizing agent output quality while minimizing token expenditure.
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 · 1
- itallstartedwithaidea/claude-googleadsagent★ 2100% same
Edited · 0
None found.
Wrote their own version · 81
- 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
71 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 repository74 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- continuous-learningSkill
- entity-memory-managementSkill
- knowledge-base-injectionSkill
- long-horizon-workflowsSkill
- mcp-server-creationSkill
- memory-persistenceSkill
- multi-model-routingSkill
- parallel-agent-orchestrationSkill
- proactive-intelligenceSkill
- token-optimizationSkill
- adversarial-resilienceSkill
- agent-instinct-systemSkill
- anthropic-tool-masterySkill
- cognitive-scaffoldingSkill
- multi-harness-portabilitySkill
- prompt-architectureSkill
- self-healing-agentsSkill
- session-archaeologySkill
- verification-loopsSkill
- ad-copy-generationSkill
- audience-targetingSkill
- budget-optimizationSkill
- competitor-analysisSkill
- conversion-trackingSkill
- google-ads-auditSkill
- keyword-researchSkill
- landing-page-auditSkill
- pmax-optimizationSkill
- quality-score-optimizationSkill
- remarketing-strategySkill
- shopping-adsSkill
- ci-cd-pipelinesSkill
- cloudflare-workersSkill
- configuration-managementSkill
- edge-renderingSkill
- observabilitySkill
- service-discoverySkill
- ml-model-integrationSkill
- programmatic-videoSkill
- web-asset-generationSkill
- ai-chat-studioSkill
- assistant-presetsSkill
- batch-processingSkill
- knowledge-base-ragSkill
- low-code-generationSkill
- workflow-orchestrationSkill
- bioinformaticsSkill
- cheminformaticsSkill
- data-analysisSkill
- database-lookupSkill
- geospatial-analysisSkill
- machine-learningSkill
- research-methodologySkill
- scientific-writingSkill
- agent-security-scanningSkill
- codeql-semgrepSkill
- sandbox-hardeningSkill
- secret-protectionSkill
- The first 60 shown.
The file
Files
Context Engineering
Part of Agent Skills™ by googleadsagent.ai™
Description
Context Engineering is the discipline of maximizing agent output quality while minimizing token expenditure. In a world where every token carries cost and latency implications, the ability to surgically curate what enters an agent's context window separates production-grade systems from expensive toys. This skill codifies the techniques pioneered across the googleadsagent.ai™ platform, where Buddy™ routinely operates within 200k-token windows while maintaining domain-expert-level accuracy.
The core insight is that context is not merely "what you send to the model" — it is working memory, and it must be engineered with the same rigor as any other system resource. Information density optimization, structured loading sequences, and progressive disclosure patterns ensure the agent receives precisely the right information at precisely the right moment. Poorly engineered context leads to hallucination, instruction drift, and ballooning costs.
This skill teaches agents to treat context as a finite, managed resource: measure it, compress it, prioritize it, and reclaim it. The techniques here apply universally across Claude Code, Cursor, Codex, and Gemini harnesses.
Use When
- Agent responses degrade in quality as conversations grow longer
- Token costs are exceeding budget thresholds for production workloads
- The agent needs to reason over large codebases without losing focus
- You need to inject domain knowledge without consuming the entire context window
- Multi-step workflows require carrying forward only essential state between steps
- The agent is hallucinating due to context window saturation or dilution
How It Works
graph TD
A[Raw Context Sources] --> B[Relevance Scoring]
B --> C{Score > Threshold?}
C -->|Yes| D[Compression Engine]
C -->|No| E[Context Archive]
D --> F[Priority Queue]
F --> G[Token Budget Allocator]
G --> H[Context Window Assembly]
H --> I[Agent Execution]
I --> J[Context Reclamation]
J --> K{Session Active?}
K -->|Yes| B
K -->|No| L[Session Summary → Memory]The context lifecycle begins with raw sources — files, previous messages, tool outputs, knowledge bases — flowing through a relevance scoring pass. Items scoring below the threshold are archived rather than discarded, available for retrieval if needed. High-relevance items enter a compression engine that reduces token footprint while preserving semantic content. A priority queue orders compressed items by recency, importance, and task relevance. The token budget allocator enforces hard limits, ensuring the assembled context window never exceeds the target budget. After agent execution, context reclamation identifies items that are no longer needed for subsequent turns.
Implementation
Token Budget Enforcement:
class ContextBudget {
constructor(maxTokens = 180000) {
this.maxTokens = maxTokens;
this.reservedForOutput = 20000;
this.reservedForSystem = 5000;
this.available = maxTokens - this.reservedForOutput - this.reservedForSystem;
this.allocations = new Map();
}
allocate(category, tokens) {
const currentUsage = this.currentUsage();
if (currentUsage + tokens > this.available) {
return this.evictAndAllocate(category, tokens);
}
this.allocations.set(category, (this.allocations.get(category) || 0) + tokens);
return true;
}
evictAndAllocate(category, needed) {
const sorted = [...this.allocations.entries()]
.sort((a, b) => a[1] - b[1]);
for (const [cat, tokens] of sorted) {
if (cat === category) continue;
this.allocations.delete(cat);
if (this.available - this.currentUsage() >= needed) break;
}
return this.allocate(category, needed);
}
currentUsage() {
return [...this.allocations.values()].reduce((sum, t) => sum + t, 0);
}
}Progressive Disclosure Pattern:
function buildProgressiveContext(task, depth = 0) {
const layers = [
{ level: 0, content: getTaskSummary(task), tokens: 200 },
{ level: 1, content: getRelevantFiles(task), tokens: 2000 },
{ level: 2, content: getFileContents(task), tokens: 10000 },
{ level: 3, content: getFullDependencyTree(task), tokens: 40000 },
];
return layers
.filter(layer => layer.level <= depth)
.map(layer => layer.content);
}Context Compression via Summarization:
def compress_context(messages, budget_tokens):
"""Compress conversation history to fit within token budget."""
total = count_tokens(messages)
if total <= budget_tokens:
return messages
system_msgs = [m for m in messages if m["role"] == "system"]
recent = messages[-4:]
middle = messages[len(system_msgs):-4]
summary = summarize_messages(middle)
compressed = system_msgs + [{"role": "system", "content": f"Prior conversation summary: {summary}"}] + recent
if count_tokens(compressed) > budget_tokens:
return system_msgs + recent[-2:]
return compressedBest Practices
- Measure before optimizing — instrument token usage per category (system prompt, conversation history, tool outputs, knowledge) before applying compression techniques.
- Reserve output headroom — always allocate 15-20% of the context window for the model's response; running the window to capacity guarantees truncation.
- Prefer structured over narrative — JSON, YAML, and tabular formats carry higher information density per token than prose descriptions.
- Apply progressive disclosure — start with summaries and load detail on demand; most agent turns need only a fraction of available context.
- Implement context reclamation — after each tool call, evaluate whether the full tool output is still needed or can be replaced with a summary.
- Separate hot and cold context — keep frequently referenced items (system instructions, current task) in every turn; archive infrequently accessed items behind retrieval.
- Version your context schemas — as prompts and knowledge bases evolve, track which context configuration produced which quality outcomes.
- Test at the margins — validate agent behavior at 50%, 80%, and 95% context utilization to understand degradation curves.
Platform Compatibility
| Feature | Claude Code | Cursor | Codex | Gemini CLI |
| Context budget enforcement | ✅ Full | ✅ Full | ✅ Full | ✅ Full |
| Progressive disclosure | ✅ Native | ✅ Via skills | ✅ Via prompts | ✅ Via prompts |
| Token counting | ✅ Anthropic API | ✅ Via extensions | ✅ tiktoken | ✅ Vertex API |
| Context compression | ✅ Full | ✅ Full | ✅ Full | ✅ Full |
| Session summarization | ✅ Hooks | ✅ Rules | ✅ Instructions | ✅ System prompts |
Mythos Preview Reference
In Mythos Preview evaluation, Anthropic ranks each file 1–5 by how likely it is to contain interesting, vulnerability-relevant logic (e.g., constants-only files vs. network parsing or auth). They then process the highest-ranked files first instead of burning budget on every path equally.
Adopt the same idea for any large corpus: score likely signal density up front, sort descending, and load or assign work in that order so the context window and agent time go to the most promising sources first. Source: Mythos Preview.
Related Skills
- Cognitive Scaffolding - Attention-aware content placement that maximizes the value of each token in the context budget
- Prompt Architecture - Layered prompt design that integrates with progressive disclosure and token budget allocation
- Anthropic Tool Mastery - Tool result management that requires context-aware caching and compression strategies
Keywords
context-engineering, token-optimization, context-window, information-density, progressive-disclosure, context-compression, working-memory, token-budget, context-lifecycle, agent-skills
© 2026 googleadsagent.ai™ | Agent Skills™ | MIT License
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.

