moai-foundation-context

Manages token budgets, session state persistence, and multi-agent context handoffs for Claude Code workflows.

2|Updated May 27, 2026
One-click install
npx skills add https://github.com/yekinya/moai-novel --skill moai-foundation-context-yekinya
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: moai-foundation-context
Source: https://github.com/yekinya/moai-novel/tree/main/moai-novel/.claude/skills/moai-foundation-context
Command: npx skills add https://github.com/yekinya/moai-novel --skill moai-foundation-context-yekinya

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Long-running Claude Code sessions degrade as the 200K token context window fills, causing lost progress on /clear, failed agent handoffs, and degraded reasoning in the final portion of the context window. ## Core Features & Use Cases - Token Budget Management: Allocates and monitors the 200K token window with warning thresholds at 75% and critical compression triggers at 85%. - Session State Persistence: Snapshots six state layers (active context, session history, project state, user preferences) so work resumes after interruptions or /clear commands. - 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 SPEC-First workflow, execute /moai:1-plan, run a mandatory /clear to reclaim 45-50K tokens, then hand off to implementation agents while preserving the SPEC ID and next steps. ## Quick Start Ask the agent 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 Claude Code context window token limit?

Track usage against the 200K token budget with warning at 75% and critical compression at 85%. Execute /clear at strategic checkpoints such as after SPEC creation, and reload only Tier 1 files like CLAUDE.md afterward.

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

Persist the session ID, current SPEC ID, phase, and completed steps to a state snapshot before clearing. After /clear, reload CLAUDE.md and the active SPEC file to resume work without losing progress.

When should I run /clear during a long Claude Code session?

Run /clear after /moai:1-plan completion, when context exceeds 150K tokens, when conversations pass 50 messages, before major phase transitions, and during model switches between Haiku and Sonnet.

How do multi-agent handoffs work without losing context?

Create a handoff package containing only the SPEC ID, current phase, next step, and key artifact references. Validate agent compatibility, checksum integrity, and a minimum 30K available token buffer before transfer.

Why does Claude Code performance degrade near the context limit?

Reasoning quality degrades in the final 20% of the context window, roughly above 160K tokens. Avoid this zone by clearing aggressively and keeping a 55K token emergency reserve for recovery operations.

What are the limitations of progressive context summarization?

Summarization compresses conversation to about 30% of original size but loses fine detail, so original content must be archived for recovery. It is unsuitable when exact code or decision wording must be preserved verbatim.