From rune
Use when spawning 4+ agents, when "Prompt is too long" errors appear, when sessions exceed 50 messages, or when context feels degraded. Prevents overflow before agent summoning, compresses long sessions, and offloads verbose content to filesystem. Keywords: context overflow, prompt too long, glyph budget, compression, long session. <example> Context: About to launch 4 review agents user: "Review this PR with multiple agents" assistant: "I'll use context-weaving to enforce Glyph Budgets and plan agent orchestration" </example> <example> Context: Long coding session user: "Context is getting long, I'm losing track" assistant: "Loading context-weaving for session compression" </example>
npx claudepluginhub vinhnxv/rune --plugin runeThis skill is limited to using the following tools:
Unified context management combining overflow prevention, compression strategies, and filesystem offloading into a single skill. Prevents both context overflow (too many tokens from agent returns) and context rot (attention degradation in long sessions).
Manages context window in long Claude Code sessions: detects limits via tool counts, triggers smart compaction, preserves critical state, injects dev/research/review behavioral modes.
Manages context window health in long Claude sessions: monitors triggers, assesses states, compresses stale content for subagents, recommends fresh starts to prevent degradation.
Persists task state across context compaction using TaskCreate/Update/List/Get. For long tasks, agent coordination, and workflows nearing limits.
Share bugs, ideas, or general feedback.
Unified context management combining overflow prevention, compression strategies, and filesystem offloading into a single skill. Prevents both context overflow (too many tokens from agent returns) and context rot (attention degradation in long sessions).
Control what returns to the Tarnished context, not what agents produce.
Agents can write unlimited detail to files. The overflow comes from what they return to the caller. This skill ensures returns are minimal (file path + 1-sentence summary).
| Layer | Problem | Solution | When |
|---|---|---|---|
| Overflow Prevention | Agent returns flood lead context | Glyph Budget: file-only output | Before any Rune multi-agent command |
| Inter-Agent Output Compression | Ash file outputs too verbose for Runebinder | Phase 5.0 Pre-Aggregate: marker-based extraction | Before aggregation (threshold-gated) |
| Context Rot | Attention degrades in long contexts | Instruction anchoring, re-anchoring signals | Always (in prompts) |
| Compression | Session grows beyond 50+ messages | Anchored iterative summarization | During long sessions |
| Filesystem Offloading | Tool outputs consume 83.9% of context | Write outputs to files, read on demand | During any workflow |
| Compaction Recovery | Auto-compaction truncates earlier context | PreCompact checkpoint + SessionStart recovery | During long arc/arc-batch sessions |
| Runtime Context Monitoring | Context exhaustion during active workflows | Statusline bridge + PostToolUse warnings | Any session with monitoring enabled |
| Condition | Action |
|---|---|
| Any Rune multi-agent command | Agent Teams + Glyph Budget + inscription (loaded automatically) |
| Custom multi-agent orchestration (3+ agents) | Agent Teams + Glyph Budget + inscription |
BEFORE summoning agents, complete the 8-step checklist: Count & Estimate → Choose Strategy → Plan Output Dir → Verify Protocol Injection → Post-Completion Validation → Revision Checkpoint → Fallback Strategies → Verification Planning.
See pre-summon-checklist.md for the full checklist with templates.
The Glyph Budget is one half of context overflow prevention — it controls what returns to the orchestrator. The other half is IPC token cost accounting, which controls what goes into agent spawn prompts. Bloated spawn prompts displace reasoning capacity: every token of inlined content (file bodies, plan text, criteria YAML) is a token the agent cannot use for analysis. Apply the Reference Don't Inline principle — pass file paths, not file contents — to keep spawn prompts under 500 tokens. See spec-continuity.md § 8.7 for the five IPC principles.
Inject this text into EVERY agent prompt when summoning in a multi-agent workflow:
GLYPH BUDGET PROTOCOL:
- Write ALL detailed findings to: {output-directory}/{agent-name}.md
- Return to caller ONLY: the output file path + 1-sentence summary (max 50 words)
- DO NOT include full analysis, code examples, or detailed recommendations in return message
Example return:
"Findings written to {output-directory}/{agent-name}.md. Found 2 P1 issues (SQL injection, missing auth) and 4 P2 issues across 3 files."
After all agents complete, summon the Runebinder to process raw files:
| Raw files | Action |
|---|---|
| 1-3 files | Read directly |
| 4+ files | Summon Runebinder agent |
| 10+ files | MUST summon Runebinder (never read all directly) |
After aggregation, read ONLY the TOME.md file. Do NOT also read raw files.
| Probe | Check | If Failed |
|---|---|---|
| Circuit Breaker | ALL output files missing? | Systemic failure — abort |
| Inscription Validation | All expected files exist and > 100 bytes? | Report gaps |
| Agent Count | Does TOME.md mention all summoned agents? | Read missing agent's raw file |
| P1 Completeness | Are P1 findings specific (file path + line)? | Spot-check one raw file |
| Truthbinding Spot-Check | Verify Rune Traces in 1-2 P1 findings per agent | Compare against actual source |
| Component | Tokens | Notes |
|---|---|---|
| CLAUDE.md + rules + MCP tools | ~30k | Fixed, always present |
| Each agent return (without budget) | 3-5k | The overflow source |
| Each agent return (with budget) | ~100-200 | File path + 50-word summary |
| TOME.md (aggregated) | ~1k | Replaces reading all raw files |
| Context window | Full | Claude's per-session limit |
Problem: Ash output files are verbose — 15-25% is non-finding overhead (Self-Review Log, Unverified Observations, boilerplate). When 5-8 Ashes produce 100-270 lines each, combined size exceeds 30KB, causing Runebinder stalling.
Solution: Phase 5.0 (Pre-Aggregate) extracts structured findings from Ash outputs before Runebinder ingestion. Deterministic marker-based extraction — no LLM call.
Trigger: Combined Ash output size >= review.pre_aggregate.threshold_bytes (default 25KB)
Mechanism:
{output_dir}/condensed/Expected reduction: 40-60% byte savings (non-finding sections + trace truncation)
Config:
review:
pre_aggregate:
enabled: true # Master toggle (default: true)
threshold_bytes: 25000 # Auto-trigger threshold (default: 25KB)
preserve_priorities: [P1, P2] # Full preservation priorities
truncate_trace_lines: 3 # Max Rune Trace lines for P3
nit_summary_only: true # 1-line summaries for N findings
See roundtable-circle/references/pre-aggregate.md for the extraction algorithm.
Context rot occurs when the model's attention degrades on important instructions placed in the middle of long contexts (Lost-in-Middle effect). This is different from overflow — it happens even within token limits.
Instruction Anchoring: Duplicate critical rules at BEGINNING and END of prompts.
# ANCHOR — TRUTHBINDING PROTOCOL
[critical rules here]
## TASK
[main instructions]
# RE-ANCHOR — TRUTHBINDING REMINDER
[repeat critical rules]
Read Ordering: Source files FIRST, agent references LAST. Keeps review criteria fresh near output generation.
Re-anchoring Signals: After every 5 files reviewed, re-check evidence rules.
Context Budget per Teammate:
| Message Count | Action |
|---|---|
| < 30 | No compression needed |
| 30-49 | Optional — available if needed |
| 50-69 | Trigger compression |
| >= 70 | Force compression |
Identify truncation point → Extract key info (files, tests, decisions, errors) → Merge into existing summary → Write to tmp/scratch/session-{timestamp}.md → Continue. See context-compression.md for session summary format and quality verification dimensions.
Tool outputs consume up to 83.9% of context. Offload large outputs to files.
| Output Size | Action |
|---|---|
| < 10 lines | Keep inline |
| 10-50 lines | Consider offloading |
| > 50 lines | MUST offload to file |
1. Write output to tmp/{workflow}/{descriptive-name}.md
2. Reference: "Output written to {path}. Key finding: {1-sentence summary}"
3. Read file only when needed for next step
Claude's auto-compaction fires during long sessions (especially /rune:arc with 43 phases), truncating earlier context. This can cause the Tarnished to lose awareness of active teams, task state, workflow phase, and arc checkpoint — leading to orphaned teams, duplicated work, or pipeline restarts.
Two hooks form a checkpoint/recovery pair:
PreCompact (scripts/pre-compact-checkpoint.sh) — Fires before compaction (manual or auto). Captures a snapshot of:
tmp/.rune-compact-checkpoint.jsonSessionStart:compact (scripts/session-compact-recovery.sh) — Fires when session resumes after compaction. Re-injects the saved checkpoint as additionalContext so the Tarnished can resume seamlessly. Includes a correlation guard that verifies the team still exists before injection. One-time use — deletes the checkpoint file after injection to prevent stale state.
After compaction recovery, the Tarnished reconciles three sources:
| Source | Contains | Priority |
|---|---|---|
| Team config.json | Team name, members, creation time | Authoritative for team existence |
| Task list | Task status, assignments, dependencies | Authoritative for work state |
| Arc checkpoint | Phase, artifacts, SHA-256 hashes | Authoritative for pipeline progress |
When arc-batch is active, the Stop hook writes structured summary files between iterations to tmp/arc-batch/summaries/iteration-{N}.md. These summaries are captured in the pre-compact checkpoint (arc_batch_state field) and referenced in compact recovery context. Summary files are on disk (not in context), so they survive compaction and are available for Read() after recovery.
The compact recovery message includes batch iteration number, total plans, and the path to the latest summary file — giving the Tarnished immediate awareness of batch progress after compaction.
Edge case: During arc-batch, teams are created and destroyed per phase. Compaction may hit between phases when no team is active. The pre-compact hook captures batch state even without an active team, writing a minimal checkpoint. The recovery hook handles teamless checkpoints by injecting batch context directly without the team correlation guard.
This layer automates what Rule #5 ("On compaction or session resume: re-read team config, task list, and inscription contract") previously required manually. The PreCompact hook captures state proactively, and the SessionStart:compact hook re-injects it — ensuring Rule #5 compliance even when compaction truncates the original context.
Even with overflow prevention and compression, a session can creep toward context exhaustion during long workflows without visible feedback. By the time the model notices degraded output quality, significant context has already been lost.
/tmp/rune-ctx-{session_id}.json. Runs as a color-coded statusline with git branch and active workflow detection. The bridge file is the producer half of a producer/consumer pattern.PostToolUse hook (scripts/rune-context-monitor.sh) that reads the bridge file and injects agent-visible warnings when context usage crosses thresholds. Non-blocking (exits 0). Only injects when the bridge file is fresh (staleness guard: 5 minutes). The monitor is the consumer half of the pattern.session_budget frontmatter field in plan files that caps simultaneous agent spawning (max_concurrent_agents). Validated silently by strive/arc worker orchestration to prevent context saturation from large teams.Enable in .rune/talisman.yml:
context_monitor:
enabled: true # Master toggle for context monitoring
warning_threshold: 35 # Warn when remaining% <= this (default: 35)
critical_threshold: 25 # Critical stop when remaining% <= this (default: 25)
stale_seconds: 60 # Bridge file max age before ignoring (default: 60)
debounce_calls: 5 # Tool uses between repeated warnings (default: 5)
workflows: [review, audit, work, mend, arc, devise] # Which workflows emit warnings
| Level | Context Remaining | Injected Message |
|---|---|---|
| WARNING | ≤ 35% | "Context at {pct}% remaining. Consider compacting or reducing agent scope." |
| CRITICAL | ≤ 25% | "Context CRITICAL at {pct}% remaining. Compact now or risk truncation." |
/tmp/ bridge file. No shared memory — pure filesystem.session_id with config_dir + owner_pid ownership fields.on-session-stop.sh scans /tmp/rune-ctx-*.json and removes files matching the current session's ownership markers.A PostToolUse:SendMessage hook (scripts/enforce-glyph-budget.sh) reinforces the Glyph Budget Protocol at the infrastructure layer. When any teammate sends a SendMessage call exceeding the word budget, the hook injects an advisory context message.
Threshold: 300 words (configurable via RUNE_GLYPH_BUDGET environment variable or talisman context_weaving.glyph_budget.word_limit).
Behavior: Advisory-only — PostToolUse cannot block. The advisory informs the orchestrator for corrective action on future messages.
Guard: Only active when Rune workflow state files exist in tmp/ (detection via explicit file path checks — not globs).
# talisman.yml schema (optional config)
context_weaving:
glyph_budget:
enabled: true # Toggle enforcement
word_limit: 300 # Max words before advisory
enforcement: advisory # advisory | warning | block (future)
The guard-context-critical.sh PreToolUse hook now implements a 3-tier context degradation system that provides graduated responses as context approaches exhaustion:
| Tier | Remaining % | Action | Block? |
|---|---|---|---|
| Caution | 35–40% | Advisory: compress messages, prefer file output | No |
| Warning | 25–35% | Workflow-specific degradation suggestions | No |
| Critical | ≤25% | Hard DENY for TeamCreate/Agent (except Explore/Plan) | Yes |
Injects additionalContext with general compression suggestions. No block. Applies to all TeamCreate/Agent calls.
Detects active workflow from state files (with session ownership check) and injects workflow-specific degradation suggestions:
| Workflow | Suggestion |
|---|---|
| review/appraise/audit | Reduce team to 3-4 Ashes |
| work/strive | Complete current task, skip optional tasks |
| arc | Skip optional phases, proceed to ship |
| devise/plan | Skip forge enrichment |
| unknown | Reduce scope, prefer file-based output |
Hard DENY for TeamCreate and Agent tool calls. Explore/Plan agents remain exempt (read-only, minimal context cost). Escape hatches: /rune:rest, talisman disable flag, or Explore/Plan agent types.
rune-orchestration (architectural patterns, inscription protocol)