agentleFS
troskatertroskater/flowdeck-claude/skills/context-budget/SKILL.md

context-budget

Skill0 starsChanged 23 days agoMITView on GitHub

Optimize token usage and context window discipline. Reduce costs and improve response quality through smart context management.

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

We split this skill into the rules it gives an agent

9 rules. 0 are common, 6 are distinctive, and 3 are very specific to this project.

  • 0

    Common

    Most of the 50 edited versions we read keep these.

  • 6

    Distinctive

    This author's own choices. Worth a look.

  • 3

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Treat context window as a finite resource.

    line 11
  2. Distinctive:

    Treat 80% of the window as your practical maximum.

    line 46
  3. Distinctive:

    Not every task needs the strongest model.

    line 83
  4. Distinctive:

    Do not escalate a cheap task to an expensive model.

    line 100
  5. Very specific:

    Use /flowdeck:fd-checkpoint after a batch of edits, then /flowdeck:fd-resume to continue.

    line 144
  6. Very specific:

    Use stages array to gate loading

    line 185
  7. Distinctive:

    Keep rules under 150 lines when possible

    line 187
  8. Very specific:

    Use the blast-radius procedure in fd-codenav to find natural split points — it reveals which dependents are independent

    line 215
  9. Distinctive:

    Run this monthly or when context feels heavy:

    line 219

“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

<fd> is this project's FlowDeck directory, the one fd-state path prints (~/.fd-plan/<project>/, or <project>/.fd-plan/ when the storage setting is project).

Context Budget Skill

Treat context window as a finite resource. Every token loaded — files, rules, tool outputs, conversation history — consumes budget. Optimizing context improves speed, cuts costs, and prevents mid-session truncation.

When to Activate

Activate when:

  • A session exceeds 50K tokens or feels sluggish
  • You are about to load large files, MCP tools, or heavy rulesets
  • You want to audit and slim down your FlowDeck setup
  • You are designing new skills, agents, or workflows

Core Principles

  • Load less, get more — context quality beats context quantity
  • Measure before optimizing — know your current burn rate
  • Batch over chat — accumulate work, run checks once
  • Right-size the model — light tasks do not need the strongest model

Why Context Budget Matters

FactorImpact
Context window limitHard cap — exceed it and early conversation is lost
Cost per tokenMore context = more input tokens = higher bill
Response latencyLarge context increases time-to-first-token
Attention degradationModels perform worse on content near the middle of long context

Hard Limits (Examples)

ModelContext Window
Claude 3.5 Haiku200K tokens
Claude 3.5 Sonnet200K tokens
GPT-4o128K tokens
GPT-4o mini128K tokens

Treat 80% of the window as your practical maximum. Beyond that, truncation risk rises sharply.

Skill Size Audit

Oversized skills waste context on every activation. Audit yours regularly.

Thresholds

MetricWarningCritical
Lines per SKILL.md> 300> 400
Words in description> 25> 30
Files loaded per task> 5> 10
Rules active at once> 8> 12

How to Audit

# Count lines in all skills
find src/skills -name "SKILL.md" -exec wc -l {} + | sort -n

# Flag skills over 300 lines
find src/skills -name "SKILL.md" -exec sh -c 'lines=$(wc -l < "$1"); [ "$lines" -gt 300 ] && echo "$lines $1"' _ {} \;

# Check description word counts
grep -r "^description:" src/skills/ | awk '{print NF, $0}' | sort -n

Remediation

  • Split oversized skills — extract sub-topics into separate skills
  • Shorten descriptions — under 25 words is ideal; under 30 is required
  • Use stage-gated rules — load heavy rules only in execute or verify stages
  • Defer heavy context — load <fd>/architecture.md only when needed

Model Routing Strategy

Not every task needs the strongest model. Route by complexity.

Task TypeExampleModel Tier
Simple editFix typo, rename variableFast / Small
Code reviewLint, style checkFast / Small
ResearchLook up API docsFast / Small
Feature implementationMulti-file changeStrong / Large
DebugRoot cause analysisStrong / Large
Architecture designNew module designStrong / Large

Routing by cost

  • cheap: structural lookups, listings and summaries go to the read-only Explore subagent (or a forked skill with model: haiku, like fd-map)
  • standard: implementation and test work stays in the main conversation
  • expensive: design decisions, debugging and security review run on the strongest model

Do not escalate a cheap task to an expensive model.

Prefer CLI Tools Over MCPs

MCP servers add context overhead: schema discovery, tool definitions, and response envelopes. Native CLI tools are leaner.

Use CaseHeavy MCPLean Alternative
Git operationsGitHub MCPgit, gh CLI
AWS queriesAWS MCPaws CLI
Kubernetes checksK8s MCPkubectl
File searchFile-system MCPfind, rg
Database queryDB MCPpsql, mysql CLI

When MCPs Are Worth It

  • Complex multi-step operations (e.g., create PR + add reviewers + set labels)
  • Operations requiring authentication tokens you do not have locally
  • Structured data return that CLI would require parsing

Accumulator + Batch Pattern

Chatty sessions burn context fast. Accumulate edits, then run checks once.

Anti-Pattern: Chatty Loop

Edit file A → run test → fix error → edit file B → run test → fix error → edit file C → run test

Each test run consumes output tokens. Three runs = 3x test output in context.

Preferred: Batch + Single Check

Edit file A
Edit file B
Edit file C
Run tests once
Fix all errors

In FlowDeck

Use /flowdeck:fd-checkpoint after a batch of edits, then /flowdeck:fd-resume to continue. This preserves your work without carrying full error output forward indefinitely.

Strategic Context Clearing

Long sessions accumulate noise: failed attempts, dead-ends, large tool outputs. Clear context before it degrades quality.

When to Checkpoint

SignalAction
Session > 1 hour/flowdeck:fd-checkpoint
Tokens > 50K/flowdeck:fd-checkpoint
Multiple failed attempts/flowdeck:fd-checkpoint and reassess
Task complete, new task next/flowdeck:fd-checkpoint

Resume Pattern

1. `/flowdeck:fd-checkpoint` — save current state to STATE.md
2. Start fresh session
3. `/flowdeck:fd-resume` — load checkpoint.json, STATE.md, plan.md, active context
4. Continue with clean context

This is cheaper than carrying 80K tokens of conversation history.

Rule Loading Optimization

FlowDeck uses stage-gated rules. Only rules matching the current stage are loaded.

StageTypical Rules Loaded
discussBehavioral, lightweight
planPlanning, architecture
executeCoding standards, language patterns, security
verifyTesting, security, linting
fix-bugDebug, testing

Keep Rules Focused

  • One concern per rule file
  • Use stages array to gate loading
  • Set always_on: false for heavy rules
  • Keep rules under 150 lines when possible

Audit with:

# Find rules loaded in every stage (always_on = true)
grep -r "always_on: true" src/rules/

# Find oversized rules
find src/rules -name "*.md" -exec sh -c 'lines=$(wc -l < "$1"); [ "$lines" -gt 200 ] && echo "$lines $1"' _ {} \;

Code Modularity Benefits

Smaller files = less context per task. A 400-line file forces the model to hold the entire file in working memory. Four 100-line files let the model focus on one at a time.

File SizeContext Impact
< 200 linesMinimal — load on demand
200-400 linesModerate — acceptable for core files
400-800 linesHeavy — consider splitting
> 800 linesCritical — split immediately

Splitting Guidance

  • One responsibility per file
  • Extract utilities to utils/ or helpers/
  • Extract types to types.ts
  • Use the blast-radius procedure in fd-codenav to find natural split points — it reveals which dependents are independent

Self-Audit Checklist

Run this monthly or when context feels heavy:

Skills

  • No SKILL.md exceeds 400 lines
  • No skill description exceeds 30 words
  • Unused skills removed from .claude/skills/

Rules

  • No rule file exceeds 200 lines
  • Heavy rules are stage-gated (always_on: false)
  • No redundant rules (same topic, different files)

Workflows

  • Tasks are batched before verification runs
  • /flowdeck:fd-checkpoint used at natural boundaries
  • Model routing respects task complexity

Codebase

  • No source file exceeds 800 lines
  • Core modules are under 400 lines
  • Large files have clear split candidates via the fd-codenav blast-radius procedure

Session Hygiene

  • MCP tools used only when CLI is insufficient
  • Large outputs (logs, diffs) are summarized, not pasted raw
  • Failed attempts are checkpointed, not retried endlessly

Quick Wins

  1. Truncate diffs — git diff | head -50 instead of full diff
  2. Summarize logs — tail -20 instead of full log file
  3. Use LSP document symbols — find symbols without reading entire files
  4. Load rules on demand — load-rules instead of pre-loading everything
  5. Split before you grow — when a file hits 400 lines, plan the split

Related Skills

  • plan-task — break work into right-sized chunks
  • performance-profiling — measure before optimizing
  • context-load — load only the context you need

References

  • /flowdeck:fd-checkpoint — save session state, clear context
  • /flowdeck:fd-resume — restore from checkpoint
  • load-rules — stage-gated rule loading
  • LSP document symbols — symbol search without full-file reads
  • the fd-codenav blast-radius procedure — find split points in large files
  • LSP references and call hierarchy — a symbol's callers and callees

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.