agentleFS
jthiruveedulajthiruveedula/agentkit/skills/context-budget/SKILL.md

context-budget

Skill0 starsChanged 2 months agoMITView on GitHub

Pause long Claude Code sessions at a token budget: write a checkpoint, ask for /compact or /clear, auto-reinject on resume. Use when the user wants session token monitoring, a context budget, or pause/resume on long runs.

69 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use orch-pipeline, agent-payment-x402 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.
  • 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 5 projects that use this

  • 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 8 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 7 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 12 projects that use this

  • renepfSkill

    config-gc

    Garbage collection for your Claude Code configuration. Periodically scans ~/.claude (skills, memory, hooks, permissions, MCP servers, caches) for redundant, stale, orphaned, or low-value items, then walks the user through a confirm-each-deletion cleanup. Use when the user says "clean up my config", "config GC", "too many skills", "audit my setup", "my .claude is bloated", or asks for a periodic config review.

    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 13 projects that use this

  • +2 more from renepf

The file

We split this skill into the rules it gives an agent

1 rule. 0 are common, 1 is distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 64 edited versions we read keep these.

  • 1

    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:

    Every turn re-reads the whole context, so cost grows with session length.

    line 10

“Common” is measured: kept by at least 6 in 10 of the 64 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

Every turn re-reads the whole context, so cost grows with session length. This skill turns that into a pause/resume loop.

Procedure

  1. Install the hooks once (idempotent; keeps one .bak of settings and replaces the file atomically): python3 scripts/install_hooks.py — adds budget_hook.py check on UserPromptSubmit and PostToolUse, and budget_hook.py resume on SessionStart for compact|clear|resume. --uninstall removes them.
  2. Set the budget (optional): AGENTKIT_BUDGET_TOKENS (default 200000) and AGENTKIT_BUDGET_STEP (default 50000, re-warn interval) in the env block of settings (an invalid value warns on stderr and uses the default). Pick a budget below autoCompactWindow so your checkpoint beats the generic auto-compaction summary. State and checkpoints live in AGENTKIT_DATA_DIR (default ~/.agentkit; AGENTKIT_HOME is still read as a fallback, but install.sh uses that name for the repo clone).
  3. When the pause notice arrives, finish the current step — don't abandon a half-applied edit — then write the checkpoint to the path the notice names, using the context-compressor template (Goal, Decisions with reasons, State, Open threads / Next action; under 60 lines). Lint it with ../context-compressor/scripts/checkpoint.py lint <path> (relative to this SKILL.md).
  4. Ask the user to /compact (same task continues) or /clear (next task). On the next session start of either kind the checkpoint is injected back as context, so work resumes without re-deriving state.
  5. Check manually any time: python3 scripts/budget_hook.py status <transcript.jsonl> prints the current context tokens; python3 scripts/budget_hook.py path prints this directory's checkpoint path.

Reference

  • reference/design.md — hook events, state file, failure-mode rules.

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.