Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx skills add alivirgo/Major-AI-Skills --skill context-pruning-directivegit clone --depth 1 https://github.com/alivirgo/Major-AI-SkillsWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/skills/alivirgo/major-ai-skills/context-pruning-directive)<a href="https://agentmods.dev/skills/alivirgo/major-ai-skills/context-pruning-directive"><img src="https://agentmods.dev/badge/skills/alivirgo/major-ai-skills/context-pruning-directive/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/skills/alivirgo/major-ai-skills/context-pruning-directive"><img src="https://agentmods.dev/badge/skills/alivirgo/major-ai-skills/context-pruning-directive.svg" alt="Reviewed on agentmods" width="80" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00026 | $0.01251 |
| Opus 5 | $0.00013 | $0.00626 |
| Sonnet 5 | $0.00005 | $0.00250 |
| Haiku 4.5 | $0.00003 | $0.00125 |
Grade A, and why
context-pruning-directive scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured today.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 119 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Dynamic Context Pruning (Sliding Memory Compactor)
Overview
In long-running autonomous agent sessions, every new message appends the entire historical transcript to the input array. If an agent executes 40 tool calls (reading files, executing bash commands, running test suites), historical tool outputs accumulate in the context window.
This unpruned history causes Quadratic Token Growth ($O(N^2)$): a 5,000-token file read at Turn 2 is needlessly re-sent on Turns 3 through 50, consuming 240,000 redundant input tokens and causing "Lost-in-the-Middle" Attention Degradation.
The Dynamic Context Pruning Protocol actively sanitizes historical turns: replacing stale, completed tool outputs with compact 1-line tombstone summaries and maintaining a high-density rolling memory buffer.
Unpruned Quadratic Accumulation vs. Dynamic Context Pruning
┌─────────────────────────────────────────────────────────────┐
│ Context Growth Dynamics │
│ │
│ Unpruned Transcript ($O(N^2)$ Quadratic Explosion): │
│ • Turn 2: Reads 800-line file (4,000 tokens) │
│ • Turn 3..50: 4,000 tokens re-sent on every turn │
│ ↳ Total Waste: 4,000 tokens $\times$ 48 turns = 192,000 tokens! │
│ ↳ Latency increases from 1.2s to 18.5s per turn │
│ │
│ Dynamic Context Pruning ($O(N)$ Linear Bounded Memory): │
│ • Turn 2: Reads 800-line file $\rightarrow$ Edits target lines │
│ • Turn 3: Old read pruned $\rightarrow$ `[Read: auth.ts (lines 40-50)]`│
│ ↳ Context remains strictly bounded $< 6,000$ tokens │
│ ↳ 78% Cost Reduction, Stable Sub-second Latency │
└─────────────────────────────────────────────────────────────┘
The 3-Tier Context Pruning Strategy
┌───────────────────────────────────────────────────────────────────────────┐
│ 1. EPHEMERAL TOOL PRUNING: Compress old tool outputs older than 2 turns │
│ `cat package.json` (300 lines) $\rightarrow$ `[Tool Output: package.json verified]`│
│ │
│ 2. SLIDING CONVERSATION WINDOW: Keep only last $K=6$ turns verbatim │
│ │
│ 3. MILESTONE STATE CONDENSATION: Summarize completed phases into 3 bullets│
└───────────────────────────────────────────────────────────────────────────┘
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- today Changed · -14 tokens per session eae98d2450f7
- 6d ago First seen · 119 lines · 40 tokens per session scan A 5d3a09c87f3b
context-pruning-directive is a skill published in the GitHub repository alivirgo/Major-AI-Skills (1 stars, last pushed today), licensed MIT. It adds 26 tokens to every session and 1,251 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-05.
Other skills, from other repositories
agent-memory-mcp-v2
Agent Memory Skill workflow skill. Use this skill when the user needs A hybrid memory system that provides persistent, searchable knowledge management for AI agents (Architecture, Patterns, Decisions) and the operator should preserve the upstream workflow, copied support files, and provenance before merging or handing…
geminiignore-finops
Configure and optimize .geminiignore files for AI context window efficiency and token cost reduction (FinOps).
agent-memory-mcp
A hybrid memory system that provides persistent, searchable knowledge management for AI agents (Architecture, Patterns, Decisions).
agent-memory-systems
Memory is the cornerstone of intelligent agents. Without it, every interaction starts from zero. This skill covers the architecture of agent memory: short-term (context window), long-term (vector s...
agent-memory-systems-v2
Agent Memory Systems workflow skill. Use this skill when the user needs "Memory is the cornerstone of intelligent agents. Without it, every and the operator should preserve the upstream workflow, copied support files, and provenance before merging or handing off.
agent-memory-systems
Agent Memory Systems workflow skill. Use this skill when the user needs "Memory is the cornerstone of intelligent agents. Without it, every and the operator should preserve the upstream workflow, copied support files, and provenance before merging or handing off.