context-folding

Create token-budgeted branches for isolated sub-task execution.

Updated Jan 7, 2026
One-click install
npx skills add https://github.com/fyrsmithlabs/marketplace --skill context-folding
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: context-folding
Source: https://github.com/fyrsmithlabs/marketplace/tree/main/plugins/fs-dev/skills/context-folding
Command: npx skills add https://github.com/fyrsmithlabs/marketplace --skill context-folding

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Context folding addresses context bloat by creating isolated computation branches for complex sub-tasks, each with its own token budget and automatic cleanup on return.

Core Features & Use Cases

  • Isolated branching: Create a dedicated context branch for a sub-task to prevent leakage into the main context.
  • Budgeted execution: Each branch carries a token budget and timeout, with real-time status checks.
  • Safe orchestration: Supports parallel or dependent task workflows with clear return values and memory records.
  • Real-world use: Analyzing a large codebase with multiple agents while protecting the main session state.

Quick Start

  1. Create an isolated branch: branch_create(session_id: "main", description: "Analyze auth module (sub-task)", budget: 4096)
  2. Do work inside the branch, then check status: branch_status("br_abc123")
  3. Return results: branch_return(branch_id: "br_abc123", message: "Analysis complete", return_value: { "results": [] })

Frequently Asked Questions about context-folding

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I prevent context bleed when running multi-agent tasks?

To prevent context bleed during multi-agent tasks, you create isolated computation branches with dedicated token budgets using branch_create. This isolates sub-task execution, performs the work, and returns structured data to the parent session via branch_return.

What is context folding for multi-file codebase analysis?

Context folding is a task-orchestration technique that creates token-budgeted branches to isolate complex sub-tasks like multi-file codebase analysis. It prevents context bloat by automatically cleaning up branches upon return, preserving the main session state.

How do I manage token budgets for parallel agent coordination?

You manage token budgets for parallel agent coordination by assigning a specific budget and timeout to each isolated branch during creation. You can then monitor real-time execution status using branch_status before returning the final results.

Can I execute dependent sub-tasks while protecting the main session state?

Yes, you can execute dependent sub-tasks while protecting the main session state. The context folding mechanism supports both parallel and dependent workflows, ensuring each branch operates independently with clear return values and memory records.

Does context folding require external dependencies to isolate branches?

No, context folding does not require external dependencies to isolate branches. It implements branch creation, status checks, and returns natively, with optional contextd integration available for advanced multi-agent orchestration workflows.

What are the limitations of using token-budgeted branches for exploratory tasks?

Limitations of using token-budgeted branches include strict execution ceilings defined by the assigned budget and timeout. If exploratory tasks exceed these limits, the branch cannot complete, requiring careful budget allocation for complex analyses.