AgentSkillsCN

context

上下文窗口管理。适用于以下场景: - 用户询问“上下文窗口”、“上下文的使用方式”、“上下文的上限”; - 用户提到“上下文即将耗尽”、“上下文已满”; - 用户希望“精简上下文”、“清除上下文”、“优化上下文”; - 当上下文逐渐饱和,亟需加以管理时。

SKILL.md
--- frontmatter
name: context
description: |
  Context window management. Use when:
  - User asks about "context window", "context usage", "context limit"
  - User mentions "running out of context", "context full"
  - User wants to "compact", "clear context", "optimize context"
  - Context is getting full and needs management

Context Window Management

Monitor and manage Claude Code context window usage.

Check Context Usage

Run /context in Claude Code to see current usage.

Context Thresholds

LevelUsageAction
Notice70%Consider handoff at next stopping point
Warning80%Create handoff, prepare to compact
Critical90%Create handoff NOW, then compact

Managing Context

Create Handoff Before Compacting

code
/create-handoff

This saves:

  • Current task state
  • Key decisions made
  • Files modified
  • Next steps

Compact Context

code
/compact

Reduces context by summarizing earlier conversation.

Resume After Compact

code
/resume-handoff

Restores context from handoff file.

Tips for Reducing Context

  1. Use context: fork - Skills that fork don't bloat main context
  2. Delegate exploration - Let agents handle research
  3. Clean summaries - Agents return summaries, not raw output
  4. Avoid large file reads - Use TLDR for token-efficient analysis

When Context is Full

  1. Don't panic - Your work isn't lost
  2. Create handoff - Save current state
  3. Compact - Let Claude summarize
  4. Resume - Pick up where you left off

Automatic Protection

The setup includes:

  • Warning at 70%, 80%, 90% thresholds
  • Auto-handoff before compaction (PreCompact hook)
  • Session start recalls relevant learnings

Output

Report:

  • Current usage: X% of context
  • Recommendation: Action to take
  • Next steps: What to do