askill
context-integrity

context-integritySafety 95Repository

Detects and repairs context drift. Monitors hierarchy staleness, chain breaks, and context decay across compactions.

47 stars
1.2k downloads
Updated 2/21/2026

Package Files

Loading files...
SKILL.md

Context Integrity

Core principle: Detect loss. Repair state. Never work on stale context.

When to Use

  • Drift score warning appears in <hivemind> prompt
  • Post-compaction (context was just compressed)
  • Resuming work after a gap (hours/days between sessions)
  • Hierarchy feels wrong ("what was I doing?")
  • Multiple compactions in same conversation
  • Switching from one subagent's context back to main flow

Detect — Know When Context Is Broken

Automatic Detection (hooks do this for you)

The <hivemind> block in your system prompt already contains:

  • Drift score — drops below 50 = you're wandering
  • Turn count — 5+ turns without map_context = stale
  • Timestamp gaps — hours between hierarchy nodes = context likely lost
  • Post-compaction alert — context was just compressed
  • Failure flag — subagent reported failure, not yet acknowledged
  • Tool-hierarchy mismatch — writing files but no action declared

You don't need to detect these yourself. Read the <hivemind> block.

Manual Detection (when you suspect problems)

# Full hierarchy tree with cursor position
node bin/hivemind-tools.cjs state hierarchy

# Validate parent-child chain integrity
node bin/hivemind-tools.cjs validate chain

# Check all timestamps parse correctly
node bin/hivemind-tools.cjs validate stamps

# See gap between last activity and now
node bin/hivemind-tools.cjs state get metrics.turn_count

# Check if compaction happened
node bin/hivemind-tools.cjs state get compaction_count

Repair — Fix Broken Context

After Drift Warning

// 1. Check where you are
scan_hierarchy({})
// → Shows full tree with cursor marker

// 2. Update to re-engage
map_context({
  level: "action",    // or tactic if action is wrong too
  content: "What you're actually doing right now",
  status: "active"
})
// → Resets turn count, boosts drift score

After Compaction

// 1. Refresh context from persistent stores
think_back({})
// → Shows: tree position + anchors + chain analysis + session plan

// 2. Check what mems survived
recall_mems({ shelf: "decisions" })
recall_mems({ shelf: "cycle-intel" })
// → Key decisions and subagent intelligence from before compaction

// 3. Re-declare if trajectory feels wrong
// Only if think_back shows misalignment
map_context({
  level: "tactic",
  content: "Continuing: [what think_back showed as active]"
})

After Session Gap (Hours/Days)

# 1. What session was active?
node bin/hivemind-tools.cjs session active

# 2. What's the full tree?
node bin/hivemind-tools.cjs state hierarchy

# 3. Trace the last session's work
node bin/hivemind-tools.cjs session trace <stamp>

# 4. What mems exist?
recall_mems({})
recall_mems({ query: "decisions" })

Then start a new session:

declare_intent({
  mode: "plan_driven",
  focus: "Continuing: [what trace showed]",
  reason: "Resuming after gap — checked trace + mems"
})

After Chaos (User Changed Mind Multiple Times)

// 1. See the FULL tree — shows every pivot as a node
scan_hierarchy({})

// 2. Save an anchor at the stable point
save_anchor({
  type: "decision",
  content: "After 3 pivots, settling on: [X]. Reasons: [Y].",
  tags: ["pivot-resolution"]
})

// 3. Prune completed/abandoned branches
hierarchy_manage({ action: "prune" })

// 4. Re-set trajectory clearly
map_context({
  level: "trajectory",
  content: "Final direction: [X]",
  status: "active"
})

Survive — Patterns for Long-Haul Sessions

The Anchor Pattern (Compaction-Proof Decisions)

Before making any significant decision:

save_anchor({
  type: "decision",
  content: "Chose JWT over session tokens because: stateless, scales horizontally",
  tags: ["auth", "architecture"]
})

This survives compaction. think_back will show it.

The Mem Pattern (Session-Proof Knowledge)

When you learn something that future sessions need:

save_mem({
  shelf: "architecture",
  content: "Auth uses jose library for JWT, passport was abandoned at turn 15",
  tags: ["auth", "jwt", "jose"]
})

This survives session boundaries. recall_mems from any future session.

The Checkpoint Pattern (Drift-Proof Progress)

Every 3-5 meaningful actions:

map_context({
  level: "action",
  content: "Completed: X, Y, Z. Next: W.",
  status: "active"
})

This resets drift counter. Keeps the tree current.

Red Flags

ThoughtReality
"I remember what I was doing"After compaction you're guessing. Use think_back.
"The context is fine"Check the <hivemind> block. If drift > 50, it's not fine.
"I'll recover context later"Later = after more drift. Recover NOW.
"Compaction didn't lose anything important"Prove it. recall_mems + think_back.

Install

Download ZIP
Requires askill CLI v1.0+

AI Quality Score

77/100Analyzed 2/24/2026

High-quality technical reference skill for HiveMind plugin context management. Comprehensive coverage of drift detection, repair strategies, and survival patterns with clear triggers and actionable commands. Tightly coupled to the specific plugin (internal CLI paths, custom functions), limiting broader reusability. Well-structured with tables, code examples, and clear section headers. Includes bonus elements like tags and dedicated folder location.

95
90
45
75
80

Metadata

Licenseunknown
Version2.6.0
Updated2/21/2026
Publishershynlee04

Tags

observabilitypromptingsecurity