Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
itallstartedwithaidea avatar

Context Engineering

  • 64 installs
  • 31 repo stars
  • Updated April 12, 2026
  • itallstartedwithaidea/agent-skills

Context Engineering is an agent skill that maximizes agent output quality while minimizing token expenditure—usable whenever a solo builder needs to curate working memory before committing to a long agent run

About

Context Engineering is an agent skill that teaches procedural discipline for maximizing output quality while minimizing token spend. Solo builders shipping with Claude Code, Cursor, or Codex install it when long sessions, large repos, or stacked skills start to bloat the window and degrade answers. The skill frames context as engineered working memory—not a dump of everything available—and codifies density optimization, staged loading, and progressive disclosure so instructions and facts arrive when they matter. It addresses the production gap between demo agents and systems that stay on-spec under cost and latency pressure. Use it whenever you are composing prompts, chaining skills, or designing agent workflows, not only during initial integration setup. Poor context engineering shows up as hallucination and drift; this skill gives repeatable patterns to audit and tighten what the model actually sees.

  • Treats context as finite working memory with measure, compress, prioritize, and reclaim
  • Structured loading sequences and progressive disclosure for right info at the right moment
  • Information-density optimization to cut hallucination, instruction drift, and cost
  • Techniques aimed at large windows (e.g. ~200k tokens) with domain-expert accuracy
  • Universal application across Claude Code and similar agent environments

Context Engineering by the numbers

  • 64 all-time installs (skills.sh)
  • +3 installs in the week ending Aug 2, 2026 (Skillselion tracking)
  • Ranked #299 of 782 Skill Development skills by installs in the Skillselion catalog
  • Security screen: LOW risk (skills.sh audit)
  • Data as of Aug 4, 2026 (Skillselion catalog sync)
npx skills add https://github.com/itallstartedwithaidea/agent-skills --skill context-engineering

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs64
repo stars31
Security audit3 / 3 scanners passed
Last updatedApril 12, 2026
Repositoryitallstartedwithaidea/agent-skills

What it does

Engineer what enters the agent context window so outputs stay accurate without burning tokens on noise.

Who is it for?

Best when you're running multi-skill or large-repo agent sessions and need production-grade accuracy without runaway token bills.

Skip if: One-shot factual lookups or tiny edits where the full prompt already fits comfortably and needs no curation ritual.

When should I use this skill?

When agent sessions grow large, token cost or latency matters, or you need to curate skills, docs, and instructions before a substantive run.

What you get

You apply measurable context budgets, loading order, and disclosure patterns so each turn gets dense, relevant material instead of an expensive junk drawer.

  • A context loading and compression plan for the current agent task
  • Prioritized information sets sized to the active decision, not the whole project

By the numbers

  • Designed for routine operation within roughly 200k-token windows while maintaining domain-expert-level accuracy

Files

SKILL.mdMarkdownGitHub ↗

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 compressed

Best Practices

1. Measure before optimizing — instrument token usage per category (system prompt, conversation history, tool outputs, knowledge) before applying compression techniques. 2. Reserve output headroom — always allocate 15-20% of the context window for the model's response; running the window to capacity guarantees truncation. 3. Prefer structured over narrative — JSON, YAML, and tabular formats carry higher information density per token than prose descriptions. 4. Apply progressive disclosure — start with summaries and load detail on demand; most agent turns need only a fraction of available context. 5. Implement context reclamation — after each tool call, evaluate whether the full tool output is still needed or can be replaced with a summary. 6. Separate hot and cold context — keep frequently referenced items (system instructions, current task) in every turn; archive infrequently accessed items behind retrieval. 7. Version your context schemas — as prompts and knowledge bases evolve, track which context configuration produced which quality outcomes. 8. Test at the margins — validate agent behavior at 50%, 80%, and 95% context utilization to understand degradation curves.

Platform Compatibility

FeatureClaude CodeCursorCodexGemini 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

Related skills

How it compares

Use instead of pasting whole repos or skill folders into chat without a loading strategy or density pass.

FAQ

Who is context-engineering for?

Developers using Claude Code, Cursor, or Codex who treat agents as daily dev tools and need stable quality inside large context windows.

When should I use context-engineering?

Before long implementation runs, when stacking multiple skills, when costs spike, or during Build agent-tooling setup—and again in Ship review or Operate iteration whenever context has grown messy.

Is context-engineering safe to install?

It is instructional metadata about prompt and context design; review the Security Audits panel on this Prism page before enabling any third-party skill in your agent.

Skill Developmentagentsautomationllm

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.