claude-code-plugin-ref…
Explain plugin, skill, command, agent, and hook mechanics used here. Use when authoring or debugging plugins. Do not use for ops;…
Manages context overflow by handing off to a fresh subagent at 80% usage. Use when context pressure is critical and work must continue uninterrupted.
Claude Code
$ npx -y skills add athola/claude-night-market --skill clear-context --agent claude-code
Codex
$ npx skills add athola/claude-night-market --skill clear-context -a codex -y
Cursor
$ npx skills add athola/claude-night-market --skill clear-context -a cursor -y
Gemini CLI
$ npx skills add athola/claude-night-market --skill clear-context -a gemini-cli -y
GitHub Copilot
$ npx skills add athola/claude-night-market --skill clear-context -a github-copilot -y
OpenCode
$ npx skills add athola/claude-night-market --skill clear-context -a opencode -y
Windsurf
$ npx skills add athola/claude-night-market --skill clear-context -a windsurf -y
name: clear-context description: Manages context overflow by handing off to a fresh subagent at 80% usage. Use when context pressure is critical and work must continue uninterrupted. alwaysApply: false category: conservation token_budget: 200 progressive_loading: true role: library
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)
try partial summarization via the message selector. This compresses older context while preserving recent work, often sufficient to relieve pressure without a full handoff.
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| Level | Threshold | Action | |-------|-----------|--------| | WARNING | 40% | Monitor, plan optimization | | CRITICAL | 50% | Prepare for handoff | | EMERGENCY | 80% | **Execute auto-clear now** |
**Configuration** (environment variables):
Before triggering auto-clear, gather:
**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.
**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 Progress 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"]A continuation agent inherits only what `session-state.md` says. If the draft is ambiguous, the new agent starts from corrupted task state. Before spawning, gate the handoff on the belief-clarity check (the `belief-clarity` module of `Skill(conserve:context-optimization)`), which asks two anchor questions against the draft state:
1. **Progress probe**: what is the current task progress: what is done, and what state is the task in now? 2. **Gap probe**: what information is still needed to finish: a bounded list of concrete open items, not generic categories.
Gate logic:
probe's answer to `session-state.md` as explicit `Current state:` and `Still needed:` bullets, then re-score. Re-score at most twice
A plugin marketplace for Claude Code. Install only the plugins you need to run git workflows, code review, spec-driven development, and autonomous agents from inside your Claude Code session.
Explain plugin, skill, command, agent, and hook mechanics used here. Use when authoring or debugging plugins. Do not use for ops;…
States load-bearing decisions, invariants, and weak points. Use when judging a design change. Do not use for gating; use…
Rebuild the dev environment: uv, Python tiers, pins, traps. Use when onboarding or toolchain breaks. Do not use for daily…
Classify, gate, and review changes. Use when landing a PR, releasing, or amending rules. Do not use for failure triage; use…
Search and record project memory (Discussions, journal, ADRs). Use before re-investigating anything. Do not use for settled…
Bind loop 'done' to unfakeable gates. Use to harden egregore/herald loops or promote completion_integrity. Not for QA gates; use…
You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or…
Ask which skill or flow fits your situation. A router over the skills in this repo.