AgentStack
Browse Sign in
Browse Why AgentStack Sell Docs
Sign in
SKILL verified MIT Self-run

Context Budget Discipline

skill-redtropig-harness-anchor-context-budget-discipline · by Redtropig

Use when sessions run long, adding subagents, fetching large files, or planning context-heavy work. SELECT/WRITE/COMPRESS/ISOLATE discipline.

No reviews yet
0 installs
14 views
0.0% view→install

Install

$ agentstack add skill-redtropig-harness-anchor-context-budget-discipline

✓ scanned · ✓ verified, works with Claude Code, Cursor, and more.

Security review

✓ Passed

No issues found. Passed automated security review. · v0.1.0 How review works →

  • Prompt-injection patterns
  • Secret / credential exfiltration
  • Dangerous shell & filesystem operations
  • Untrusted network calls
  • Known-malicious package signatures

What it can access

  • Network access No
  • Filesystem access No
  • Shell / process execution No
  • Environment & secrets No
  • Dynamic code execution No

From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.

View the full security report →

Verified badge

Passed review? Show it. Paste this badge into your README, it links to the public security report.

AgentStack Verified badge Links to your public security report.
[![AgentStack Verified](https://agentstack.voostack.com/badges/verified.svg)](https://agentstack.voostack.com/security/report/skill-redtropig-harness-anchor-context-budget-discipline)

Reliability & compatibility

Security review passed
0 installs to date
no reviews yet
9d ago

Declared compatibility

Claude CodeClaude Desktop

Compatibility is declared by the source manifest. End-to-end runtime verification is coming, see below.

Preview Execution monitoring

We're building live execution health for every listing: tool-call success rate, median latency, uptime, and last-checked timestamps, measured, not self-reported. It isn't live yet, so we don't show numbers we can't stand behind.

How agent discovery & health will work →
Are you the author of Context Budget Discipline? Claim this listing to set pricing, connect Stripe payouts, and keep 70% of every sale.
Sign up to claim

About

Context Budget Discipline

Context is a finite resource. Every token competes for the model's attention. The "lost-in-the-middle" phenomenon is real — content buried in 50% of the window position is least attended.

This skill applies four operations to keep the budget sane.

The Four Operations

SELECT     load context just-in-time, not all-at-once
WRITE      persist to disk; let the filesystem remember, not chat
COMPRESS   summarize older turns when window fills
ISOLATE    delegate so child work doesn't pollute parent context

SELECT — pull, don't push

Default behaviour: don't preemptively load files. Wait until they're needed.

  • ❌ "Let me read all 30 .cpp files to understand the project."
  • ✅ "I'll consult PROJECT-TOC.md first, then read only the 2 files the task touches."

WRITE — disk is cheap, context is expensive

Anything reusable across turns should live on disk:

  • Active feature → feature_list.json
  • Decisions / rationale → progress.md or docs/decisions/
  • "What I just did" → session-handoff.md

Anti-pattern: re-explaining the same plan/decision in every reply.

COMPRESS — summarize old turns when window pressure rises

When context usage > 70% of model window, mid-session compaction can help. But per Anthropic Nov 2025:

> "Compaction preserves continuity, but doesn't give the agent a clean slate. Context anxiety can still persist."

Flush before you compress. Before compaction/reset — or when the PostToolUse watermark fires (T1 "Context is filling" = flush now; T2 "Context is heavily filled" = wrap up via /session-end + fresh session) — write chat-only durable memory to disk first: golden-rule stubs (capturing-golden-rules), feature status, a milestone progress.md entry. After a compaction, do NOT backfill memory from the summary: reconstruct from on-disk evidence (git diff, test output, progress.md) and state uncertainty where evidence is missing.

If compaction isn't enough → use /session-end to write a rich handoff, then suggest the user start a fresh context (context reset > compaction for long runs).

ISOLATE — child work doesn't bleed up

Subagents (/verify, cpp-build-doctor, etc.) run in fresh context. They:

  • Don't inherit conversational baggage
  • Return a fixed-structure result (diagnosis / evidence / recommendation)
  • Don't dump their working notes into your context

If you delegate a noisy task, ask for a SUMMARY back, not a transcript.

Token Budget Reference

| Tier | Budget | Source | |---|---|---| | Tier 1 (always loaded) | ~3000 tokens cap; measured at v0.10.0: generic ≈1160 t, C/C++ ≈1580 t | SessionStart hook injection (hard-capped 12000 chars, meta-skill injected slimmed; ${CLAUDE_PLUGIN_ROOT}/scripts/measure-context.sh re-measures both baselines) | | System prompt + tools | Model-defined | Outside your control | | Working context | Most of remaining window | Your edits + reads accumulate here |

State-file budgets

Hot state files carry fixed budgets. The SessionStart banner warns (warn-only) when one is exceeded; /session-end offers deterministic archival via state-archive.mjs.

| File | Hot window | Sentinel | |---|---|---| | progress.md | newest 20 sections | 64KB | | feature_list.json | live features + 10 newest pass | 32KB | | golden-rules.md | prune — never archived | 8KB | | AGENTS.md | keep it a map (~80 lines) | 8KB | | session-handoff.md | overwritten each session | 4KB |

Archives (progress-archive.md, feature_archive.json) are grep-only — never load whole.

When to invoke this skill

  • A session has been going for >2 hours
  • You notice your replies summarizing already-discussed content (you're losing focus)
  • About to read a large file (>500 lines) — ask: do I need ALL of it?
  • About to dispatch a subagent — confirm it returns summary, not log
  • Context monitor / Claude Code warns about token usage

Practical moves

When budget pressure rises:

  1. Stop and write handoff. Run /session-end if features are in flight.
  2. Hard-truncate reads. Prefer head -50, grep -A 5, line range in Read tool — over reading whole files.
  3. Drop tool definitions. If you have many MCP tools loaded and none are relevant to current work, that's overhead — but you can't control this from inside the session.
  4. Consider context reset. A fresh session with rich handoff often outperforms continuing a stale one.

Calibrated estimates

You can roughly estimate context use by:

  • 1 token ≈ 4 chars (English) or 1-2 chars (Chinese)
  • A 200-line code file ≈ 1500-2500 tokens
  • A medium SKILL.md ≈ 1000-2000 tokens
  • Your own multi-paragraph replies ≈ 200-500 tokens each

When the user asks "how much room do we have?", be honest about the estimate.

Looking up context engineering research

For specific patterns (e.g., compaction algorithms, attention windowing, RAG indexing strategies) — invoke the docs-lookup skill. Pattern names evolve fast in this area; don't rely on memory.

Typical entry query: context engineering 2026 or llm.

Related

  • using-harness-anchor — Tier 1 injection budget reference
  • feature-state-keeper — what to write to disk
  • project-indexing — TOC as compressed file index

Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

Install and usage instructions live in the source repository linked above.

Reviews

No reviews yet, be the first.

Versions

  • v0.1.0 Imported from the upstream source.