recursive-context-pruning-token-budgeting

Optimizes AI agent performance by pruning redundant context, managing token usage, and enforcing ultra-concise, direct-to-value responses.

5 stars

Best use case

recursive-context-pruning-token-budgeting is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Optimizes AI agent performance by pruning redundant context, managing token usage, and enforcing ultra-concise, direct-to-value responses.

Teams using recursive-context-pruning-token-budgeting should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/recursive-context-pruning-token-budgeting/SKILL.md --create-dirs "https://raw.githubusercontent.com/FrancoStino/opencode-skills-collection/main/bundled-skills/recursive-context-pruning-token-budgeting/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/recursive-context-pruning-token-budgeting/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How recursive-context-pruning-token-budgeting Compares

Feature / Agentrecursive-context-pruning-token-budgetingStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Optimizes AI agent performance by pruning redundant context, managing token usage, and enforcing ultra-concise, direct-to-value responses.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# Recursive Context Pruning & Token Budgeting

## Overview

This skill implements a "Gatekeeper" logic to prevent context window bloat and unnecessary token expenditure. It ensures the agent only processes relevant data shards and adheres to an Atomic Precision protocol—delivering functional answers with zero conversational filler. By recursively summarizing state and stripping "bridge phrases," it maximizes the longevity and speed of long-running development workflows.

## When to Use This Skill

- Use when building multi-step agents to prevent repetition and "memory drift" in long conversations.
- Use when working with large document sets or codebases to avoid dumping entire files into the prompt.
- Use when you need purely functional output (code/logic) without "Sure! Here is your..." intros.

## How It Works

### Step 1: Metadata Sharding

Scan the available data for headers, summaries, and key indicators. Create a "map" of the context rather than injecting the full source. Never pull the entire file into the prompt unless a specific, narrowed fragment is requested.

### Step 2: Token Budget Allocation

Calculate a "Safe Response Limit" based on the current context window. Allocate 30% for current logic processing, 20% for immediate output, and 50% for a future context buffer.

### Step 3: Atomic Output Filtering

Strip all "Bridge Phrases" (e.g., "I've updated the code," "Based on your request," "Sure"). Start the response immediately with the solution or the code block.

### Step 4: Ambiguity Check

Before executing Step 3, scan for missing critical variables (e.g., specific file names or environment types). If the prompt is too ambiguous, bypass the atomic output and generate exactly one concise question to resolve the blocker.

### Step 5: Abstractive Compression

Summarize the current turn into a "compressed state string" (e.g., `[Project: Feasify | State: Auth-Fixed | Remaining-Tasks: 2]`) to discard redundant conversational data before the next prompt.

## Examples

### Example 1: Filtered Code Output (No Filler)

```text
User: "Update the Firebase config to use environment variables."
```

```javascript
const firebaseConfig = {
  apiKey: process.env.VITE_FIREBASE_API_KEY,
  authDomain: process.env.VITE_FIREBASE_AUTH_DOMAIN,
  projectId: process.env.VITE_FIREBASE_PROJECT_ID
};
```

### Example 2: Essential Clarification

```text
User: "Deploy the function."
```

```text
"Specify environment: production or staging?"
```

## Best Practices

- ✅ **Direct Start:** Place the code or answer at the very first character of the response.
- ✅ **Summarize-as-you-go:** Turn 10 pages of discussion into 5 bullet points for the next turn.
- ✅ **Omit Signatures:** Never end with "Let me know if you need more help."
- ❌ **No Bridge Phrases:** Avoid "Here is the code," "Sure," or "I can help with that."
- ❌ **No Guessing:** If input is missing, ask immediately rather than wasting tokens on a generic guess.

## Limitations

- This skill does not replace environment-specific validation, testing, or expert review.
- Extreme brevity can occasionally hide important nuances; use concise inline comments (`// crucial step`) for critical notes.

## Security & Safety Notes

- Never prune safety headers, environment-specific security constraints, or system-level instructions during the compression stage.
- Maintain original system instructions at the "Root" of the context to prevent context-loss-based jailbreaks.

## Common Pitfalls

- **Problem:** The response is so brief it lacks the context needed for implementation.
  **Solution:** Use concise inline code comments instead of separate paragraphs of text.

- **Problem:** The agent loses the overarching goal due to over-compression.
  **Solution:** Always pin the "Primary Objective" to the top of every pruned prompt.

## Related Skills

- `@atomic-precision-response` - Specifically for removing conversational filler.
- `@context-sharding` - For managing large-scale documentation mapping.

Related Skills

vercel-cli-with-tokens

5
from FrancoStino/opencode-skills-collection

Deploy and manage projects on Vercel using token-based authentication. Use when working with Vercel CLI using access tokens rather than interactive login — e.g. "deploy to vercel", "set up vercel", "add environment variables to vercel".

ui-tokens

5
from FrancoStino/opencode-skills-collection

List, add, and update StyleSeed design tokens while keeping JSON sources, CSS variables, and dark-mode values in sync.

tokenwise

5
from FrancoStino/opencode-skills-collection

Measurement-driven model router for Claude Code. Routes Haiku/Sonnet/Opus per task class, logs every routed task with real $ numbers, and A/B tests cheaper tiers before you trust the savings.

product-marketing-context

5
from FrancoStino/opencode-skills-collection

Create or update a reusable product marketing context document with positioning, audience, ICP, use cases, and messaging. Use at the start of a project to avoid repeating core marketing context across tasks.

hig-project-context

5
from FrancoStino/opencode-skills-collection

Create or update a shared Apple design context document that other HIG skills use to tailor guidance.

filesystem-context

5
from FrancoStino/opencode-skills-collection

Use for file-based context management, dynamic context discovery, and reducing context window bloat. Offload context to files for just-in-time loading.

ddd-context-mapping

5
from FrancoStino/opencode-skills-collection

Map relationships between bounded contexts and define integration contracts using DDD context mapping patterns.

context7-auto-research

5
from FrancoStino/opencode-skills-collection

Automatically fetch latest library/framework documentation for Claude Code via Context7 API. Use when you need up-to-date documentation for libraries and frameworks or asking about React, Next.js, Prisma, or any other popular library.

context-window-management

5
from FrancoStino/opencode-skills-collection

Strategies for managing LLM context windows including summarization, trimming, routing, and avoiding context rot

context-optimization

5
from FrancoStino/opencode-skills-collection

Context optimization extends the effective capacity of limited context windows through strategic compression, masking, caching, and partitioning. The goal is not to magically increase context windows but to make better use of available capacity.

context-manager

5
from FrancoStino/opencode-skills-collection

Elite AI context engineering specialist mastering dynamic context management, vector databases, knowledge graphs, and intelligent memory systems.

context-management-context-save

5
from FrancoStino/opencode-skills-collection

Use when working with context management context save