Command Palette

Search for a command to run...

Назад к скиллам
скилл № 34725

context-management

Proactive context window management via token monitoring, intelligent extraction, and selective rehydration. Use when approaching token limits or needing to…

БесплатноЗапускает вложенные скрипты
rysweetот rysweet★ 77 звёзд на GitHub

Установить context-management в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Об этом скилле

Context Management Skill

Purpose

This skill enables proactive management of Claude Code's context window through intelligent token monitoring, context extraction, and selective rehydration. Instead of reactive recovery after compaction, this skill helps users preserve essential context before hitting limits and restore it efficiently when needed.

When to Use This Skill

  • Token monitoring: Check current usage and get recommendations
  • Approaching limits: Create snapshots at 70-85% usage
  • After compaction: Restore essential context without full conversation
  • Long sessions: Preserve key decisions and state proactively
  • Complex tasks: Keep requirements and progress accessible
  • Context switching: Save state when pausing work
  • Team handoffs: Package context for others to continue

Quick Start

Check Token Status

User: Check my current token usage

I'll use the context_manager tool to check status:

from context_manager import check_context_status

status = check_context_status(current_tokens=<current_count>)
# Returns: ContextStatus with usage percentage and recommendations

Create a Snapshot

User: Create a context snapshot named "auth-implementation"

I'll use the context_manager tool to create a snapshot:

from context_manager import create_context_snapshot

snapshot = create_context_snapshot(
    conversation_data=<conversation_history>,
    name="auth-implementation"
)
# Returns: ContextSnapshot with snapshot_id, file_path, and token_count

Restore Context

User: Restore context from snapshot <snapshot_id> at essential level

I'll use the context_manager tool to rehydrate:

from context_manager import rehydrate_from_snapshot

context = rehydrate_from_snapshot(
    snapshot_id="20251116_143522",
    level="essential"  # or "standard" or "comprehensive"
)
# Returns: Formatted context text ready to process

List Snapshots

User: List my context snapshots

I'll use the context_manager tool to list snapshots:

from context_manager import list_context_snapshots

snapshots = list_context_snapshots()
# Returns: List of snapshot metadata dicts

Detail Levels

When rehydrating context, choose the appropriate detail level:

  • Essential (smallest): Requirements + current state only (~250 tokens)
  • Standard (balanced): + key decisions + open items (~800 tokens)
  • Comprehensive (complete): + full decisions + tools used + metadata (~1,250 tokens)

Start with essential and upgrade if more context is needed.

Actions

Action: status

Check current token usage and get recommendations.

Usage:

from context_manager import check_context_status

status = check_context_status(current_tokens=750000)
print(f"Usage: {status.percentage}%")
print(f"Status: {status.threshold_status}")
print(f"Recommendation: {status.recommendation}")

Returns:

  • ContextStatus object with usage details
  • threshold_status: 'ok', 'consider', 'recommended', or 'urgent'
  • recommendation: Human-readable action suggestion

Action: snapshot

Create intelligent context snapshot.

Usage:

from context_manager import create_context_snapshot

snapshot = create_context_snapshot(
    conversation_data=messages,
    name="feature-name"  # Optional
)
print(f"Snapshot ID: {snapshot.snapshot_id}")
print(f"Token count: {snapshot.token_count}")
print(f"Saved to: {snapshot.file_path}")

Returns:

  • ContextSnapshot object with metadata
  • Snapshot saved to ~/.amplihack/.claude/runtime/context-snapshots/

Action: rehydrate

Restore context from snapshot at specified detail level.

Usage:

from context_manager import rehydrate_from_snapshot

context = rehydrate_from_snapshot(
    snapshot_id="20251116_143522",
    level="standard"  # essential, standard, or comprehensive
)
print(context)  # Display restored context

Returns:

  • Formatted markdown text with restored context
  • Ready to process and continue work

Action: list

List all available context snapshots.

Usage:

from context_manager import list_context_snapshots

snapshots = list_context_snapshots()
for snapshot in snapshots:
    print(f"{snapshot['id']}: {snapshot['name']} ({snapshot['size']})")

Returns:

  • List of snapshot metadata dicts
  • Includes: id, name, timestamp, size, token_count

Proactive Usage Workflow

Step 1: Monitor Token Usage

Periodically check status during long sessions:

status = check_context_status(current_tokens=current)

if status.threshold_status == 'consider':
    # Usage at 70%+ - consider creating snapshot
    print("Consider creating a snapshot soon")
elif status.threshold_status == 'recommended':
    # Usage at 85%+ - snapshot recommended
    create_context_snapshot(messages, name='current-work')
elif status.threshold_status == 'urgent':
    # Usage at 95%+ - create snapsho
Полный SKILL.md на GitHub

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

  • QUICK_START.md
  • README.md
  • __init__.py
  • automation.py
  • context_extractor.py
  • context_rehydrator.py
  • core.py
  • examples/basic_usage.md
  • examples/proactive_workflow.md
  • examples/rehydration_levels.md
  • models.py
  • orchestrator.py
  • test_full_automation_flow.py
  • test_model_aware_thresholds.py
  • test_performance.py
  • test_real_hook_integration.py
  • test_with_real_transcript.py
  • token_monitor.py

FAQ

Что делает скилл context-management?

Proactive context window management via token monitoring, intelligent extraction, and selective rehydration. Use when approaching token limits or needing to preserve essential context. Complements /transcripts and PreCompact hook with proactive optimization.

Как установить скилл context-management?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл context-management запускает скрипты?

Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.

Похожие скиллы

Сравнить context-management с