moai-foundation-context

Manages token budgets, session state persistence, and multi-agent context handoffs.

Updated Jun 18, 2026
One-click install
npx skills add https://github.com/h102-log/pdfrag --skill moai-foundation-context-h102-log
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: moai-foundation-context
Source: https://github.com/h102-log/pdfrag/tree/main/.claude/skills/moai-foundation-context
Command: npx skills add https://github.com/h102-log/pdfrag --skill moai-foundation-context-h102-log

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Long-running Claude Code sessions hit the 200K token context window limit, causing degraded performance, lost work after interruptions, and wasteful token usage during multi-agent workflows. ## Core Features & Use Cases - Token Budget Management: Monitors usage against a 200K budget with warning (75%), critical (85%), and emergency (95%) thresholds, triggering compression or /clear actions. - Session State Persistence: Saves session snapshots across six state layers so interrupted workflows resume in under 5 seconds without losing SPEC progress. - Multi-Agent Handoff Protocols: Transfers minimal, validated context packages between agents with compatibility checks, checksums, and a 30K token safety buffer. - Use Case: During a Plan-Run-Sync workflow, execute /clear after planning to save 45-50K tokens, then hand off a compressed context package from the spec-builder agent to the implementation agent. ## Quick Start Ask the assistant to monitor token usage and prepare a session checkpoint before clearing context for the current SPEC workflow.

Frequently Asked Questions about moai-foundation-context

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I manage the 200K token context window in Claude Code?▼

Track usage against a 200K budget with thresholds at 60% (monitor), 75% (warning), and 85% (critical). Execute /clear at strategic checkpoints such as after SPEC creation, and reload only Tier 1 and Tier 2 files afterward.

How to preserve session state across /clear in Claude Code?▼

Persist the session ID and a state snapshot before clearing, covering work state, SPEC progress, and user context. After /clear, reload CLAUDE.md and the current SPEC file, then restore the snapshot to resume work.

When should I execute /clear during a workflow?▼

Clear after /moai:1-plan completion, when context exceeds 150K tokens, after 50 messages, before phase transitions, and during model switches. Post-plan clearing typically saves 45-50K tokens.

How do multi-agent handoffs work without losing context?▼

Create a handoff package containing session context, task context, and recovery info with a checksum. Validate agent compatibility and ensure at least 30K available tokens before transfer; compress context if the budget is low.

What are the limitations of aggressive context clearing?▼

Clearing without persisting the session ID first makes workflows unrecoverable, since session IDs are the only reliable resumption mechanism. Always create a checkpoint and save state before any /clear operation.