Install
openclaw skills install @posthuman/context-budgetMeasure and safely reduce always-loaded agent instruction context in characters and tokens.
openclaw skills install @posthuman/context-budgetAlways-loaded files such as AGENTS.md, MEMORY.md, SOUL.md, USER.md,
IDENTITY.md, and SECURITY.md are injected into an agent's prompt. Their
cost recurs on every turn. Measure that cost before changing instructions, then
reduce it without weakening authority, safety, or meaning.
Use this skill when runtime logs report bootstrap truncation, per-turn context cost is high, policies appear in several files, or a persistent rule is being added.
Runtime truncation limits are expressed in characters; model cost is paid in tokens. Optimising one does not guarantee improvement in the other.
Do not abbreviate words as a token-saving technique. In the measured nine-pair
sample in references/method.md, no abbreviation saved a token and three cost
more. Remove duplication and unnecessary text instead.
Measure before editing. Character-only estimation is the safe default:
scripts/context-budget.py --workspace <path> --sections
For exact token counts, explicitly select a trusted loopback tokenizer for that run:
scripts/context-budget.py --workspace <path> --sections \
--tokenizer-url http://127.0.0.1:<port>/tokenize \
--tokenizer-model <model>
Tokenization sends complete selected-file contents to that local process. The script rejects non-loopback endpoints, inherited endpoint settings, path traversal, and symlinked inputs. Confirm that the tokenizer does not retain requests. Without a working endpoint the report marks token counts as estimates.
Map authority before moving text. Classify every rule by identity, safety, privacy, secrets, tool authority, approval, delivery, and task specificity. Keep always-on authority and safety rules in their required precedence layer. Move only task-specific material whose on-demand loader and trigger are verified. Relocation changes delivery context and can change behaviour even when wording is unchanged.
Deduplicate across files. Keep each rule in its canonical home and leave a pointer only where the pointer is guaranteed to load the rule before it is needed. Preserve every unique condition and exception.
Give each file one job. Separate operating rules, temperament, identity, audience preferences, memory, and security policy. Resolve conflicts before editing.
Compress remaining prose. Merge sections that answer the same question, turn repeated-prefix lists into tables, and remove connective text while preserving conditions.
Verify syntax and semantics. Use distinctive markers only as a missing- text check. Also review every moved or rewritten rule for meaning, precedence, and availability. Run regressions for direct injection, quoted/forwarded injection, secret exfiltration, unauthorized external delivery, destructive requests, and a legitimate authorized operation.
Re-measure and report both units. Treat estimates as estimates and record the tokenizer model when exact counts are used.
--show-content reveals those
values; use it only with explicit intent, keep output local, and redact before
sharing.A pass is complete only when all hold: