agentleFS
CodeCaroSCodeCaroS/MythOs_Aegis/.agents/skills/context-budget/SKILL.md

context-budget

Skill0 starsChanged 3 months agoApache-2.0View on GitHub

Plans and enforces the context window as a budget: what an agent loads, what it keeps, what it writes down, and when it hands over. Use for long agent sessions, large repositories, repeated codebase re-reading, token cost complaints, multi-session work, project memory files, and handover before context overflow.

54 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use agent-payment-x402, openclaw-persona-forge 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.
  • TironFoxSkill

    agent-payment-x402

    Add x402 payment execution to AI agents — per-task budgets, spending controls, and non-custodial wallets via MCP tools. Use when agents need to pay for APIs, services, or other agents.

    Also in 6 projects that use this

  • TironFoxSkill

    openclaw-persona-forge

    为 OpenClaw AI Agent 锻造完整的龙虾灵魂方案。根据用户偏好或随机抽卡, 输出身份定位、灵魂描述(SOUL.md)、角色化底线规则、名字和头像生图提示词。 如当前环境提供已审核的生图 skill,可自动生成统一风格头像图片。 当用户需要创建、设计或定制 OpenClaw 龙虾灵魂时使用。 不适用于:微调已有 SOUL.md、非 OpenClaw 平台的角色设计、纯工具型无性格 Agent。 触发词:龙虾灵魂、虾魂、OpenClaw 灵魂、养虾灵魂、龙虾角色、龙虾定位、 龙虾剧本杀角色、龙虾游戏角色、龙虾 NPC、龙虾性格、龙虾背景故事、 lobster soul、lobster character、抽卡、随机龙虾、龙虾 SOUL、gacha。

    Also in 5 projects that use this

  • loulanyueSkill

    nuxt4-patterns

    Nuxt 4 app patterns for hydration safety, performance, route rules, lazy loading, and SSR-safe data fetching with useFetch and useAsyncData.

    Also in 9 projects that use this

  • renepfSkill

    orch-pipeline

    Shared orchestration engine for the orch-* skill family. Defines the gated Research-Plan-TDD-Review-Commit pipeline, the size classifier, the agent map, and the two human gates that the orch-* operation skills delegate to. Not usually invoked directly.

    Also in 4 projects that use this

  • Exploration-labsSkill

    token-budget-advisor

    Proactive token budget assessment and task chunking strategy. Use this skill when queries involve multiple large file uploads, requests for comprehensive multi-document analysis, complex multi-step workflows with heavy research (10+ tool calls), phrases like "complete analysis", "full audit", "thorough review", "deep dive", or tasks combining extensive research with large output artifacts. This skill helps assess token consumption risk early and recommend chunking strategies before beginning work.

    Also in 11 projects that use this

  • loulanyueSkill

    santa-method

    Multi-agent adversarial verification with convergence loop. Two independent review agents must both pass before output ships.

    Also in 8 projects that use this

The file

Show its rules and text

We split this skill into the rules it gives an agent

16 rules. 0 are common, 16 are distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 50 edited versions we read keep these.

  • 16

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Treat the context window as a finite budget with an explicit allocation, not as a place where files accumulate until quality collapses.

    line 54
  2. Distinctive:

    Re-reading: Every new session rediscovers the same repository facts.

    line 61
  3. Distinctive:

    Before loading anything, record:

    line 94
  4. Distinctive:

    Never let the working set grow past the files actually being changed.

    line 109
  5. Distinctive:

    Search before reading. Read ranges before reading files.

    line 125
  6. Distinctive:

    Never re-read a file already in context unless it changed.

    line 126
  7. Distinctive:

    Prefer structured extraction (one pass producing a table) over many small reads.

    line 128
  8. Distinctive:

    Write repository facts once into a durable file that every session loads.

    line 132
  9. Distinctive:

    Not derivable from a single cheap command

    line 137
  10. Distinctive:

    When the repository exceeds what any session can hold:

    line 158
  11. Distinctive:

    Verify the index instead of trusting it: a stale index is worse than none, because it produces confident wrong file paths.

    line 165
  12. Distinctive:

    Never hand over a summary that drops a decision.

    line 195
  13. Distinctive:

    Before claiming a context plan works, verify:

    line 213
  14. Distinctive:

    Every claim in project memory is checked against the current repository

    line 216
  15. Distinctive:

    No dropped evidence contained an unrecorded decision

    line 218
  16. Distinctive:

    Never claim a file was loaded, indexed, or verified when it was not.

    line 220

“Common” is measured: kept by at least 6 in 10 of the 50 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Context Budget

Purpose

Treat the context window as a finite budget with an explicit allocation, not as a place where files accumulate until quality collapses.

For checkpoint/rollback safety around irreversible actions during a session, also see shepherd.

Three failure modes this skill prevents:

  1. Re-reading. Every new session rediscovers the same repository facts.
  2. Silent overflow. The session degrades or truncates mid-task and loses decisions.
  3. Undocumented state. Work cannot continue because the reasoning lived only in chat.

Core Principle

Load the smallest set of facts that makes the next action correct.
Write down anything a successor would otherwise have to rediscover.
Hand over before the window forces the decision.

Compression is not the goal. Retrievability is.


Activation Triggers

Apply this skill when:

  • A session spans more than a few tasks or is expected to resume later
  • The repository is too large to read exhaustively
  • The same files are read repeatedly across sessions
  • Token cost, latency, or answer quality is degrading
  • Work must be handed to another agent, another session, or a human
  • A project memory, AGENTS.md, or equivalent context file is being written

Workflow

Phase 1: Inventory the Budget

Before loading anything, record:

SlotContentRough sizeRefreshable?
InstructionsSystem prompt, skills, rulesfixedno
Project memoryDurable repo factssmallyes
Task stateCurrent goal, decisions, open questionssmallyes
Working setFiles being editedmediumyes
EvidenceCommand output, search resultsvolatileyes

Rules:

  • Instructions and project memory must stay small enough to survive every turn.
  • Evidence is the first thing discarded, so it must be summarized into task state before it is dropped.
  • Never let the working set grow past the files actually being changed.

Phase 2: Define the Load Policy

For each information need, choose the cheapest sufficient source:

NeedPreferred sourceAvoid
Where does X liveSymbol or path searchReading directories
What does X doSignature plus call sitesWhole-file read
How is X usedGrep for usages, bounded outputRecursive reads
Why is X this wayDecision record, commit messageGuessing from code
Full detailRead only the relevant rangeRead entire file

Required behavior:

  • Search before reading. Read ranges before reading files. Read files before reading trees.
  • Never re-read a file already in context unless it changed.
  • Cap command output; quote the shortest decisive lines.
  • Prefer structured extraction (one pass producing a table) over many small reads.

Phase 3: Build Durable Project Memory

Write repository facts once into a durable file that every session loads.

A project memory entry earns its place only if it is:

  • Stable across sessions
  • Not derivable from a single cheap command
  • Load-bearing for future decisions

Include:

  • Entry points, build, test, and lint commands
  • Directory map with one line per meaningful area
  • Non-obvious conventions and their reason
  • Architectural decisions and rejected alternatives
  • Known traps: flaky tests, generated files, forbidden edits

Exclude:

  • Anything the code, README, or git history already states plainly
  • Facts that expire quickly (branch names, in-flight work)
  • Long code excerpts

Convert relative dates to absolute dates before writing.

Phase 4: Retrieval Routing

When the repository exceeds what any session can hold:

  1. Maintain an index keyed by symbol, path, and concept.
  2. Route each question to the smallest index slice that answers it.
  3. Return locations plus evidence lines, not whole files.
  4. Refresh index entries when the underlying file changes, not on a timer.

Verify the index instead of trusting it: a stale index is worse than none, because it produces confident wrong file paths. Confirm any location before editing it.

Phase 5: Handover Before Overflow

Trigger a handover when any of the following is true:

  • The window is roughly two thirds consumed
  • Evidence is being dropped faster than it is summarized
  • The task will clearly not finish in the current session

A handover package contains, in this order:

## Goal
One sentence: what done looks like.

## State
What now works, verified how.

## Decisions
Each decision, its reason, and the rejected alternative.

## Open questions
Each question and who or what can answer it.

## Next action
One concrete step, with the exact file or command.

Never hand over a summary that drops a decision. A decision without its reason will be re-litigated and reversed.


Anti-Patterns

  • Loading the whole repository "for context" before knowing the task
  • Summarizing chat history instead of recording decisions
  • Memory files that restate the README
  • Index built once and never invalidated
  • Treating a truncated session as a finished one
  • Optimizing token count while increasing the number of round trips

Verification

Before claiming a context plan works, verify:

  • A fresh session can reach the first correct action using only the durable files
  • Every claim in project memory is checked against the current repository
  • The handover note names one next action, not a list of intentions
  • No dropped evidence contained an unrecorded decision

Never claim a file was loaded, indexed, or verified when it was not.


Required Final Output

## Context Budget Result
Status: PLANNED | APPLIED | HANDOVER

### Budget allocation
- ...

### Load policy changes
- ...

### Durable memory written
- ...

### Dropped or deferred
- ...

### Next action
- ...

Shared output profile

Compose the plan profile from output-templates. Lead with the allocation and the load policy, then durable memory, dropped context, and the next action. Preserve stricter domain rules above, omit empty components, and never fill a component with invented evidence.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.