Token导航 LogoToken导航

Agent Skill · AI 工具

clear-context(清晰的背景)

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

clear-context 是AI 工具类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为接触敏感数据;许可证为 MIT,第三方扫描有未通过项,按安装量在AI 工具类的 2,536 个 Skill 里排第 1,380。

总安装 783周安装 32GitHub Stars 264下载 251核验 2026-05-01

安装说明

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

安装方式

通过对话安装

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

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

命令行安装

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

skills.shnpx skills
npx skills add https://github.com/athola/claude-night-market --skill clear-context

这个 Skill 是做什么的

AI 工具类 Skill 用来扩展助手本身的能力,例如接模型、接检索、接外部服务。

在上下文压力达到阈值时保存会话状态并委托给新子代理,实现工作流无缝延续。适用于大型多链任务或长时间运行流程中防止上下文溢出导致中断。支持主动触发或阈值监控两种模式,自动管理会话快照与恢复机制。包含钩子机制可能执行系统命令,安装前务必审查权限与运行环境。

clear-context 属于AI 工具类 Skill,可作为该场景下的辅助能力补充。

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

上手步骤

4 步
  1. 1

    确认自己的宿主工具

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

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/athola/claude-night-market --skill clear-conte…;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

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

  4. 4

    按最小权限试用

    它需要接触敏感数据,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

clear-context 怎么安装?

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

clear-context 支持哪些 AI 工具?

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

clear-context 需要什么权限?

权限级别是接触敏感数据。该 Skill 可能接触密钥、Token、环境变量或敏感配置,应进入高风险复核队列,默认不自动发布。

clear-context 是免费的吗?

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

clear-context 用的人多吗?

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

clear-context 安全吗?

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

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

值得选的地方

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

先想清楚的地方

  • 需要接触敏感数据,装到常用环境前要先评估影响面。
  • 第三方扫描存在提醒项或未通过项,需要人工逐条确认。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

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

不太适合

  • 环境里有大量密钥、凭证,不方便给第三方 Skill 读取的人。
  • 需要厂商级技术支持和 SLA 的生产系统。

AI 工具类 Skill 对比

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

执行计划 · Codex、Claude

1,515,336173,110只读MIT通过
verification-before-completion

完成前的验证 · Codex、Claude

1,319,472173,121权限未标注MIT通过
subagent-driven-development

子 Agent 驱动开发 · Codex、Claude

1,312,416173,138只读MIT通过
copy-editing

复制编辑 · Codex、Claude

1,209,57625,632只读MIT通过
paywall-upgrade-cro

付费专区升级 cro · Codex、Claude

1,030,17625,617只读MIT通过
clear-context

清晰的背景 · 本页

783264接触敏感数据MIT未通过

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

SKILL.md 原文

Table of Contents

Clear Context Skill

Quick Start

When context pressure reaches critical levels (80%+), invoke this skill to:

  1. Save current session state
  2. Delegate continuation to a fresh subagent
  3. Continue work without manual intervention
Skill(conserve:clear-context)

When To Use

  • Proactively: Before starting large multi-chained tasks
  • Reactively: When context warning indicates 80%+ usage
  • Automatically: Integrated into long-running workflows

When NOT To Use

  • Context usage is under 50% - continue working normally
  • Mid-critical-operation where handoff would lose state
  • Consider "Summarize from here" first (Claude Code 2.1.32+): Before full auto-clear, try partial summarization via the message selector. This compresses older context while preserving recent work — often sufficient to relieve pressure without a full handoff.

The Auto-Clear Pattern

Since /clear requires user action, we achieve automatic context clearing without interruption through subagent delegation:

Main Agent (high context)
    ↓
    Saves state to .claude/session-state.md
    ↓
    Spawns continuation subagent (fresh context)
    ↓
    Subagent reads state, continues work

Thresholds

LevelThresholdAction
WARNING40%Monitor, plan optimization
CRITICAL50%Prepare for handoff
EMERGENCY80%Execute auto-clear now

Configuration (environment variables):

  • CONSERVE_EMERGENCY_THRESHOLD: Override 80% default (e.g., 0.75 for 75%)
  • CONSERVE_SESSION_STATE_PATH: Override .claude/session-state.md default

Auto-Clear Workflow

Step 1: Assess Current State

Before triggering auto-clear, gather:

  • Current task/goal description
  • Progress made so far
  • Key decisions and rationale
  • Files being actively worked on
  • Open TodoWrite items

Step 1.5: Finalize Task List Before Handoff

Important: Before saving state or spawning a continuation agent, reconcile the task list:

  1. Review all tasks via TaskList
  2. Mark completed tasks as completed via TaskUpdate — do NOT leave done work as in_progress
  3. Record existing task IDs — collect all task IDs (pending and in_progress) to pass in the session state so the continuation agent references them instead of creating duplicates
  4. Include task IDs in session state under the existing_task_ids field (see Step 2)

This prevents the continuation agent from creating duplicate tasks.

Step 2: Save Session State

Important: If .claude/session-state.md already exists, always Read it first before writing (Claude Code requires reading existing files before overwriting). Create the .claude/ directory if it doesn't exist.

Write to .claude/session-state.md (or $CONSERVE_SESSION_STATE_PATH):

# Session State Checkpoint
state_version: 1
Generated: [timestamp]
Reason: Context threshold exceeded (80%+)

## Execution Mode

**Mode**: [unattended | interactive | dangerous]
**Auto-Continue**: [true | false]
**Source Command**: [do-issue | execute-plan | etc.]
**Remaining Tasks**: [list of pending items]

> **Important**: If `auto_continue: true` or mode is `dangerous`/`unattended`,
> the continuation agent should not pause for user confirmation.
> Continue executing all remaining tasks until completion.

## Current Task
[What we're trying to accomplish]

## Progress Summary
[What's been done so far]

## Key Decisions
- Decision 1: [rationale]
- Decision 2: [rationale]

## Active Files
- path/to/file1.py - [status]
- path/to/file2.md - [status]

## Pending TodoWrite Items
- [ ] Item 1
- [ ] Item 2

## Existing Task IDs
[List task IDs from TaskList so the continuation agent can reference them
instead of creating duplicates. Example:]
- Task #1: "Implement feature X" (in_progress)
- Task #2: "Write tests for feature X" (pending)

## Continuation Instructions
[Specific next steps for the continuation agent]

Execution Mode Detection:

Before writing state, detect the execution mode:

# Detect execution mode from environment/context
execution_mode = {
    "mode": "interactive",  # default
    "auto_continue": False,
    "source_command": None,
    "remaining_tasks": [],
    "dangerous_mode": False
}

# Check for dangerous/unattended mode indicators
if os.environ.get("CLAUDE_DANGEROUS_MODE") == "1":
    execution_mode["mode"] = "dangerous"
    execution_mode["auto_continue"] = True
    execution_mode["dangerous_mode"] = True
elif os.environ.get("CLAUDE_UNATTENDED") == "1":
    execution_mode["mode"] = "unattended"
    execution_mode["auto_continue"] = True

# Inherit from parent session state if exists
if parent_state and parent_state.get("execution_mode"):
    execution_mode = parent_state["execution_mode"]

Step 3: Spawn Continuation Agent

Use the Task tool to delegate. Important: Include execution mode in the task prompt:

Task: Continue the work from session checkpoint

Instructions:
1. Read .claude/session-state.md for full context
2. Check the "Execution Mode" section FIRST
3. If `auto_continue: true` or mode is `dangerous`/`unattended`:
   - DO NOT pause for user confirmation
   - Continue executing ALL remaining tasks until completion
   - Only stop on actual errors or when all work is done
4. **TASK LIST**: Do NOT create new tasks via TaskCreate. The parent agent
   already created the task list. Use TaskList to see existing tasks, and
   TaskUpdate to mark them in_progress/completed. Check the "Existing Task IDs"
   section in the session state for the authoritative list.
5. Verify understanding of current task and progress
6. Continue from where the previous agent left off
7. If you also approach 80% context, repeat this handoff process
   - PRESERVE the execution mode when creating your own checkpoint

The session state file contains all necessary context to continue without interruption.

**Execution mode inheritance**: Always inherit and propagate the execution
mode from the session state. If the parent was in dangerous/unattended mode,
you are also in that mode. Do not ask the user for confirmation.

**Task deduplication**: Do not create duplicate tasks. The parent has already
populated the task list. Use TaskUpdate on existing task IDs only.

For batch/multi-issue workflows (e.g., /do-issue 42 43 44):

Task: Continue batch processing from session checkpoint

Instructions:
1. Read .claude/session-state.md for full context
2. EXECUTION MODE: This is a batch operation with auto_continue=true
3. Process ALL remaining tasks in the queue:
   - Remaining: [issue #43, issue #44]
4. DO NOT stop between tasks - continue until all are complete
5. If you hit 80% context, hand off with the same execution mode
6. Only pause for:
   - Actual errors requiring human judgment
   - Completion of ALL tasks

This is an unattended batch operation. Continue without user prompts.

Task Tool Details:

  • Spawns subagent with fresh 1M context window
  • Up to 10 parallel agents supported
  • ~20k token overhead per subagent

Step 3 Fallback: Graceful Wrap-Up

If Task tool is unavailable (permissions, context restrictions):

  1. Complete current in-progress work (finish edits, commits)
  2. Summarize remaining tasks in your response
  3. Let auto-compact handle continuation - Claude Code compresses context automatically
  4. Manual continuation options:

- claude --continue to resume session - New session + /catchup to understand changes - Read .claude/session-state.md for saved context

Fixed in 2.1.63: /clear now properly resets cached skills. Previously, stale skill content could persist into the new conversation. The /clear + /catchup pattern is now fully reliable.
Fixed in 2.1.72: /clear now only clears foreground tasks. Background agent and bash tasks continue running. Previously, /clear would kill all tasks including background ones, which was problematic for long-running background agents that should survive context resets.

Integration with Existing Hooks

This skill works with context_warning.py hook:

  1. Hook fires on PreToolUse
  2. At 80%+ threshold, hook injects emergency guidance
  3. Guidance recommends invoking this skill
  4. Skill executes auto-clear workflow

Module Loading

For detailed session state format and examples:

  • See modules/session-state.md for checkpoint format and handoff patterns
  • See modules/session-state-schema.md for versioned schema and migration logic

Self-Monitoring Pattern

For workflows that might exceed context, add periodic checks:

# Pseudocode for context-aware workflow
def long_running_task():
    for step in task_steps:
        execute_step(step)

        # Check context after each major step
        if estimate_context_usage() > 0.80:
            invoke_skill("conserve:clear-context")
            return  # Continuation agent takes over

Context Measurement Methods

Precise (Headless/Batch)

For accurate token breakdown in automation:

claude -p "/context" --verbose --output-format json

See /conserve:optimize-context for full headless documentation.

Fast Estimation (Real-time Hooks)

For hooks where speed matters, use heuristics:

  1. JSONL file size: ~800KB ≈ 100% context (used by context_warning hook)
  2. Turn count: ~5-10K tokens per complex turn
  3. Tool invocations: Heavy tool use = faster growth

Example: Brainstorm with Auto-Clear

## Brainstorm Session with Context Management

1. Before starting, note current context level
2. Set checkpoint after each brainstorm phase:
   - Problem definition checkpoint
   - Constraints checkpoint
   - Approaches checkpoint
   - Selection checkpoint

3. If context exceeds 80% at any checkpoint:
   - Save brainstorm state
   - Delegate to continuation agent
   - Agent continues from checkpoint

Best Practices

  1. Checkpoint Frequently: During long tasks, save state at natural breakpoints
  2. Clear Instructions: Continuation agent needs specific, actionable guidance
  3. Verify Handoff: Ensure state file is written before spawning subagent
  4. Monitor Recursion: Continuation agents can also hit limits - design for chaining

Troubleshooting

Continuation agent doesn't have full context

  • Ensure session-state.md is comprehensive
  • Include all relevant file paths
  • Document implicit assumptions

Subagent fails to continue properly

  • Check that state file path is correct
  • Verify file permissions
  • Add more specific continuation instructions

Context threshold not detected

  • CLAUDE_CONTEXT_USAGE may not be set
  • The context_warning hook uses fallback estimation from session file size
  • Manual invocation always works

Hook Integration

This skill is triggered automatically by the context_warning hook (hooks/context_warning.py):

  • 40% usage: WARNING - plan optimization soon
  • 50% usage: CRITICAL - immediate optimization required
  • 80% usage: EMERGENCY - this skill should be invoked immediately

The hook monitors context via:

  1. CLAUDE_CONTEXT_USAGE environment variable (when available)
  2. Fallback: estimates from session JSONL file size (~800KB = 100%)

Configure thresholds via environment:

  • CONSERVE_EMERGENCY_THRESHOLD: Override 80% default (e.g., "0.75")
  • CONSERVE_CONTEXT_ESTIMATION: Set to "0" to disable fallback
  • CONSERVE_CONTEXT_WINDOW_BYTES: Override 800000 byte estimate

平台分布

Claude Code

28.07%
按下载量换算70

OpenCode

26.82%
按下载量换算67

Cursor

17.78%
按下载量换算45

Codex

13.56%
按下载量换算34

Antigravity

9.12%
按下载量换算23

Gemini CLI

3.39%
按下载量换算9

安全审计

Gen Agent Trust Hub

未通过

Socket

通过

Snyk

通过

权限和风险

接触敏感数据

该 Skill 可能接触密钥、Token、环境变量或敏感配置,应进入高风险复核队列,默认不自动发布。

安装前确认

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

继续浏览同类 Skills