Openclaw-superpowers context-budget-guard
Proactively monitors estimated token usage during long sessions and triggers context-window-management before overflow, not after. Use at the start of any session expected to last more than 30 minutes.
install
source · Clone the upstream repo
git clone https://github.com/ArchieIndian/openclaw-superpowers
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/ArchieIndian/openclaw-superpowers "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/openclaw-native/context-budget-guard" ~/.claude/skills/archieindian-openclaw-superpowers-context-budget-guard && rm -rf "$T"
OpenClaw · Install into ~/.openclaw/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/ArchieIndian/openclaw-superpowers "$T" && mkdir -p ~/.openclaw/skills && cp -r "$T/skills/openclaw-native/context-budget-guard" ~/.openclaw/skills/archieindian-openclaw-superpowers-context-budget-guard && rm -rf "$T"
manifest:
skills/openclaw-native/context-budget-guard/SKILL.mdsource content
Context Budget Guard
State file:
~/.openclaw/skill-state/context-budget-guard/state.yaml
Don't wait for the model to go incoherent. Act at 70%, not 95%.
When to Use
- At the start of any long-running session (>30 min expected)
- Before each major task step in a multi-hour workflow
- When
advances to a new stagelong-running-task-management
The Process
Step 1: Initialize (Session Start)
Write to state:
session_start timestamp, compaction_count: 0, status: monitoring, threshold_pct: 70.
Step 2: Check Budget (Before Each Major Step)
Estimate current context usage as a rough percentage:
- Low (<50%) — continue normally
- Medium (50–70%) — note in state, proceed with caution (avoid loading large files)
- High (>70%) — trigger
NOW, before continuingcontext-window-management
To estimate: count approximate tokens from recent messages, loaded file contents, and active task context.
Step 3: After Compaction
- Increment
in statecompaction_count - Write
,last_compacted_at
(passed fromstrategy_used
)context-window-management - Reset mental estimate to ~20% (post-compaction baseline)
Step 4: Session End
Update state:
status: idle, session_end timestamp.
Key Principles
- The 70% threshold is the trigger — earlier is always better than later
- Check budget BEFORE loading large files or running subagents, not after
- If in doubt: compact. A clean context costs less than a confused one.
- Works best paired with
— check budget at every checkpointlong-running-task-management