Token导航 LogoToken导航

Agent Skill · 开发

context-management(上下文管理)

context-management 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要围绕仓库状态、代码变更或协作事项进行整理时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

context-management 是开发类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为权限未标注;许可证为 MIT,第三方扫描有未通过项,按安装量在开发类的 21,746 个 Skill 里排第 8,629。

总安装 3,065周安装 129GitHub Stars 55下载 1,073核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
MIT

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:context-management(上下文管理)
来源仓库:https://github.com/rysweet/amplihack
仓库路径:skills/context-management
安装命令:
npx skills add https://github.com/rysweet/amplihack --skill context-management
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。不同来源提供的安装方式可能略有差异;本站展示可直接复制的安装命令,安装前请核对来源页面。

skills.shnpx skills
npx skills add https://github.com/rysweet/amplihack --skill context-management

这个 Skill 是做什么的

开发类 Skill 面向写代码、改代码和排查问题,一般会读写仓库文件,部分还会执行构建或测试命令。

用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息。适合围绕仓库状态、代码变更或协作事项进行整理。可结合来源仓库和原始 README 核验具体用法。安装前建议确认权限范围、维护状态及是否触发联网或文件读写。

安装命令:npx skills add https://github.com/rysweet/amplihack --skill context-management

来源仓库内路径:skills/context-management

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/rysweet/amplihack --skill context-management;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    权限没有明确标注,第一次使用时只给一个无关紧要的任务,观察它到底读了哪些文件和网络。

常见问题

6 条

context-management 怎么安装?

在终端执行 npx skills add https://github.com/rysweet/amplihack --skill context-management。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

context-management 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

context-management 需要什么权限?

权限级别没有明确标注。第一次使用时建议只给无关紧要的任务,观察它实际读写了哪些内容。

context-management 是免费的吗?

来源标注的许可证是 MIT。本站不代收任何费用,也不托管安装包;能否商用、要不要署名,以许可证原文为准。

context-management 用的人多吗?

公开数据是累计安装 3,065 次,近一周安装 129 次,下载 1,073 次,GitHub 55 星。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

context-management 安全吗?

第三方扫描有未通过项,风险较高。除非你确认过源码,否则不建议直接安装到常用环境。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。
  • 3 个目录同时收录,说明这个 Skill 流传比较广。
  • 许可证明确为 MIT,商用和分发边界好判断。

先想清楚的地方

  • 第三方扫描存在提醒项或未通过项,需要人工逐条确认。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理开发类任务、又不想每次都手写提示词的人。

不太适合

  • 需要厂商级技术支持和 SLA 的生产系统。

开发类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
skill-vetter

技能审查员 · OpenClaw

8,779,018986操作浏览器MIT-0通过
ontology

本体论 · OpenClaw

6,636,960576只读MIT-0通过
entra-app-registration

内部应用程序注册 · Codex、Claude

6,631,872764接触敏感数据未明确通过
entra-app-registration

内部应用程序注册 · Codex、Claude

3,757,680201接触敏感数据未明确通过
nano-banana-pro

纳米香蕉专业版 · OpenClaw

3,526,898364接触敏感数据MIT-0有提醒
context-management

上下文管理 · 本页

3,06555权限未标注MIT未通过

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

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.

Version 3.0 Enhancements:

  • Predictive Budget Monitoring: Estimate when capacity thresholds will be reached
  • Context Health Indicators: Visual indicators for statusline integration
  • Priority-Based Retention: Keep requirements and decisions, archive verbose logs
  • Burn Rate Tracking: Monitor token consumption velocity for early warnings

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
  • Predictive planning: Get early warnings before capacity is reached
  • Session health: Monitor context health for sustained productivity

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 Features (v3.0)

Predictive Budget Monitoring

Instead of just checking current usage, predict when thresholds will be reached:

# The system tracks token burn rate over time
# When checking status, you get predictive insights

status = check_context_status(current_tokens=500000)

# Status includes predictions (when automation is running):
# - Estimated tool uses until 70% threshold
# - Time estimate based on current burn rate
# - Early warning before you hit capacity

# Example output interpretation:
# "At current rate, you'll hit 70% in ~15 tool uses"
# "Consider creating a checkpoint before your next major operation"

How Prediction Works:

The automation tracks:

  1. Token count at each check interval
  2. Number of tool uses between checks
  3. Average tokens consumed per tool use
  4. Time elapsed between checks

From this data, it estimates:

  • Tools remaining until threshold
  • Approximate time until threshold
  • Whether current task will complete before limit

Context Health Indicators

Visual indicators for session health, suitable for statusline integration:

IndicatorMeaningUsage %Recommended Action
[CTX:OK]Healthy0-30%Continue normally
[CTX:WATCH]Monitor30-50%Plan checkpoint
[CTX:WARN]Warning50-70%Create snapshot soon
[CTX:CRITICAL]Critical70%+Snapshot immediately

Statusline Integration Example:

# In your statusline script, check context health:
# The automation state file contains health status

# Example statusline addition:
if [ -f ".claude/runtime/context-automation-state.json" ]; then
    LAST_PCT=$(jq -r '.last_percentage // 0' .claude/runtime/context-automation-state.json)
    if [ "$LAST_PCT" -lt 30 ]; then
        echo "[CTX:OK]"
    elif [ "$LAST_PCT" -lt 50 ]; then
        echo "[CTX:WATCH]"
    elif [ "$LAST_PCT" -lt 70 ]; then
        echo "[CTX:WARN]"
    else
        echo "[CTX:CRITICAL]"
    fi
fi

Priority-Based Context Retention

When creating snapshots, the system prioritizes content by importance:

High Priority (Always Retained):

  • Original user requirements (first user message)
  • Key architectural decisions
  • Current implementation state
  • Open items and blockers

Medium Priority (Retained in Standard+):

  • Tool usage history
  • Decision rationales
  • Questions and clarifications

Low Priority (Only in Comprehensive):

  • Verbose output logs
  • Intermediate steps
  • Debugging information

Usage Pattern:

# Create snapshot with priority awareness
snapshot = create_context_snapshot(
    conversation_data=messages,
    name='feature-checkpoint'
)

# Essential level (~200 tokens): Only high priority content
# Standard level (~800 tokens): High + medium priority
# Comprehensive level (~1250 tokens): Everything

# Start minimal, upgrade as needed:
context = rehydrate_from_snapshot(snapshot_id, level='essential')

Burn Rate Tracking

Monitor how fast you're consuming context:

# The automation tracks consumption velocity
# Adaptive checking frequency based on burn rate:

# Low burn rate (< 1K tokens/tool): Check every 50 tools
# Medium burn rate (1-5K tokens/tool): Check every 10 tools
# High burn rate (> 5K tokens/tool): Check every 3 tools
# Critical zone (70%+): Check every tool

# This means:
# - Normal development: Minimal overhead (checks rarely)
# - Large file operations: Increased monitoring
# - Approaching limits: Continuous monitoring

Burn Rate Thresholds:

Burn RateRisk LevelMonitoring Frequency
< 1K/toolLowEvery 50 tools
1-5K/toolMediumEvery 10 tools
> 5K/toolHighEvery 3 tools
Any at 70%+CriticalEvery tool

Auto-Summarization Triggers

The system automatically creates snapshots before limits are hit:

# Automatic snapshot triggers (already implemented):
# - 30% usage: First checkpoint created
# - 40% usage: Second checkpoint created
# - 50% usage: Third checkpoint created (for 1M models)

# For smaller context windows (< 800K):
# - 55% usage: First checkpoint
# - 70% usage: Second checkpoint
# - 85% usage: Urgent checkpoint

# After compaction detected (30% token drop):
# - Automatically rehydrates from most recent snapshot
# - Uses smart level selection based on previous usage

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 snapshot immediately
    create_context_snapshot(messages, name='urgent-backup')

Step 2: Create Snapshot at Threshold

When 70-85% threshold reached, create a named snapshot:

snapshot = create_context_snapshot(
    conversation_data=messages,
    name='descriptive-name'
)
# Save snapshot ID for later rehydration

Step 3: Continue Working

After snapshot creation:

  • Continue conversation naturally
  • Let Claude Code compact if needed
  • Use /transcripts for full history if desired
  • PreCompact hook saves everything automatically

Step 4: Rehydrate After Compaction

After compaction, restore essential context:

# Start minimal
context = rehydrate_from_snapshot(
    snapshot_id='20251116_143522',
    level='essential'
)

# If more context needed, upgrade to standard
context = rehydrate_from_snapshot(
    snapshot_id='20251116_143522',
    level='standard'
)

# For complete context, use comprehensive
context = rehydrate_from_snapshot(
    snapshot_id='20251116_143522',
    level='comprehensive'
)

Integration with Existing Systems

vs. PreCompact Hook

PreCompact Hook (automatic safety net):

  • Triggered by Claude Code before compaction
  • Saves complete conversation transcript
  • Automatic, no user action needed
  • Full conversation export to markdown

Context Skill (proactive optimization):

  • Triggered by user when monitoring indicates
  • Saves intelligent context extraction
  • User-initiated, deliberate choice
  • Essential context only, not full dump

Relationship: Complementary, not competing. Hook = safety net, Skill = optimization.

vs. /transcripts Command

/transcripts (reactive restoration):

  • Restores full conversation after compaction
  • Complete history, all messages
  • Used when you need everything back
  • Reactive recovery tool

Context Skill (proactive preservation):

  • Preserves essential context before compaction
  • Selective rehydration, not full history
  • Used when you want efficient context
  • Proactive optimization tool

Relationship: Transcripts for full recovery, skill for efficient management.

Storage Locations

  • Snapshots: ~/.amplihack/.claude/runtime/context-snapshots/ (JSON)
  • Transcripts: ~/.amplihack/.claude/runtime/logs/<session_id>/CONVERSATION_TRANSCRIPT.md
  • No conflicts: Different directories, different purposes

Automatic Management

Context management runs automatically via the post_tool_use hook:

  • Monitors token usage every Nth tool use (adaptive frequency)
  • Creates snapshots at thresholds (30%, 40%, 50% for 1M models)
  • Detects compaction (token drop > 30%)
  • Auto-rehydrates after compaction at appropriate level

This happens transparently without user intervention.

Implementation

All context management functionality is provided by:

  • Tool: ~/.amplihack/.claude/tools/amplihack/context_manager.py
  • Hook Integration: ~/.amplihack/.claude/tools/amplihack/context_automation_hook.py
  • Hook System: ~/.amplihack/.claude/tools/amplihack/hooks/tool_registry.py

See tool documentation for complete API reference and implementation details.

Common Patterns

Pattern 1: Preventive Snapshotting

Check before long operation and create snapshot if needed:

status = check_context_status(current_tokens=current)
if status.threshold_status in ['recommended', 'urgent']:
    create_context_snapshot(messages, name='before-refactoring')

Pattern 2: Context Switching

Save state when pausing work on one feature to start another:

# Pausing work on Feature A
create_context_snapshot(messages, name='feature-a-paused')

# [... work on Feature B ...]

# Resume Feature A later
context = rehydrate_from_snapshot('feature-a-snapshot-id', level='standard')

Pattern 3: Team Handoff

Create comprehensive snapshot for teammate:

snapshot = create_context_snapshot(
    messages,
    name='handoff-to-alice-api-work'
)
# Share snapshot ID with teammate
# Alice can rehydrate and continue work

Philosophy Alignment

Ruthless Simplicity

  • Four single-purpose components in one tool
  • On-demand invocation, no background processes
  • Standard library only, no external dependencies
  • Clear public API with convenience functions

Single Responsibility

  • ContextManager coordinates all operations
  • Token monitoring, extraction, rehydration in one place
  • No duplicate code or scattered logic

Zero-BS Implementation

  • No stubs or placeholders
  • All functions work completely
  • Real token estimation, not fake
  • Actual file operations, not simulated

Trust in Emergence

  • User decides when to snapshot, not automatic (unless via hook)
  • User chooses detail level, not system
  • Proactive choice empowers the user

Tips for Effective Context Management

  1. Monitor regularly: Check status at natural breakpoints
  2. Snapshot strategically: At 70-85% or before long operations
  3. Start minimal: Use essential level first, upgrade if needed
  4. Name descriptively: Use clear snapshot names for later reference
  5. List periodically: Review and clean old snapshots
  6. Combine tools: Use with /transcripts for full recovery option
  7. Trust emergence: Don't over-snapshot, let context flow naturally

Resources

  • Tool: ~/.amplihack/.claude/tools/amplihack/context_manager.py
  • Hook: ~/.amplihack/.claude/tools/amplihack/context_automation_hook.py
  • Philosophy: ~/.amplihack/.claude/context/PHILOSOPHY.md
  • Patterns: ~/.amplihack/.claude/context/PATTERNS.md

Remember

This skill provides proactive context management through a clean, reusable tool. The tool can be called from skills, commands, and hooks. It complements existing tools (PreCompact hook, /transcripts) rather than replacing them. Use it to maintain clean, efficient context throughout long sessions.

Key Takeaway: Business logic lives in context_manager.py, this skill just tells you how to use it.

平台分布

Claude Code

25.76%
按下载量换算276

OpenCode

24.3%
按下载量换算261

Antigravity

17.91%
按下载量换算192

Gemini CLI

11.08%
按下载量换算119

windsurf

7.94%
按下载量换算85

Cursor

2.97%
按下载量换算32

安全审计

Gen Agent Trust Hub

未通过

Socket

通过

Snyk

通过

权限和风险

权限未标注

当前来源未能明确判断权限范围,默认进入异常复核队列。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在提醒或未通过项,安装前请自行复核。

继续浏览同类 Skills