compact-now

GitHub

处理上下文压缩的 Skill,在触发时保存关键状态快照至 Vault,调用原生 compact 清理上下文后恢复,避免重复读取历史。

plugins/chrono-vault/skills/compact-now/SKILL.md mtarcure/claude-vibe-squad

Trigger Scenarios

用户输入 /compact-now 或相关短语 检测到上下文压力并获用户确认

Install

npx skills add mtarcure/claude-vibe-squad --skill compact-now -g -y
More Options

Non-standard path

npx skills add https://github.com/mtarcure/claude-vibe-squad/tree/main/plugins/chrono-vault/skills/compact-now -g -y

Use without installing

npx skills use mtarcure/claude-vibe-squad@compact-now

指定 Agent (Claude Code)

npx skills add mtarcure/claude-vibe-squad --skill compact-now -a claude-code -g -y

安装 repo 全部 skill

npx skills add mtarcure/claude-vibe-squad --all -g -y

预览 repo 内 skill

npx skills add mtarcure/claude-vibe-squad --list

SKILL.md

Frontmatter
{
    "name": "compact-now",
    "type": "skill",
    "description": "Operator-triggered proactive compaction — Chrono externalizes load-bearing state (active decisions, open tasks, next action) to a snapshot + a durable Vault learning note before invoking Claude Code's native \/compact, then resumes from the snapshot. Use when the operator says \"\/compact-now\" \/ \"compact now\" or when Chrono has flagged context pressure against shared\/lifecycle.md rule 8."
}

/compact-now

Chrono-side proactive compaction. The operator triggers via slash phrase. Chrono:

  1. Reads the live board partition via chrono_state.registry.registry_view() and confirms no live work is in flight. Whether context pressure warrants compacting is Chrono's judgment against shared/lifecycle.md § 8 — there is no predicate to call, and no token counter to call it with (shared/lifecycle.md § 9: pressure is inferred from proxy signals only).
  2. If blockers exist (live dispatches), surfaces them to the operator and asks whether to proceed anyway — likewise for any unclassified registry status, which the partition cannot vouch for.
  3. Externalizes load-bearing state to the Vault via the current record("learning", {...}) writer — captures active decisions (authority), open tasks, pending approvals, and the next action.
  4. Snapshots the same state to _state/chrono/compaction/<session>.json via chrono_state.compaction.snapshot().
  5. Invokes Claude Code's native /compact.
  6. After compact, reads the snapshot via chrono_state.compaction.recover() and re-anchors on the next operator turn — never bulk-re-reading conversation history.

When to invoke

  • Operator types /compact-now (explicit)
  • Operator types compact now / please compact / let's compact in prose (intent-recognition)
  • After Chrono has flagged context pressure against shared/lifecycle.md § 8 and the operator nudges affirmatively

When NOT to invoke

  • Live dispatches running (registry_view()["live"] non-empty) — surface blockers first
  • Mid-task (Chrono still processing) — wait for a task boundary
  • Below the shared/lifecycle.md § 8 threshold — no benefit, just cost

Implementation

Chrono runs this skill inline (not a subagent dispatch), operator-triggered. It uses the chrono_state helpers (in scripts/python/chrono_state/) and Chrono's existing chrono-vault MCP access. A PreCompact hook is OPTIONAL and only fires if .claude/settings.json declares one — do not depend on it; externalize eagerly here.

# Chrono inline (not dispatched)
import json, sys
sys.path.insert(0, "scripts/python")
from chrono_state.compaction import snapshot                   # noqa: E402
from chrono_state.registry import registry_view                # noqa: E402
from chrono_state.decisions import active_decisions            # noqa: E402

# ONE classification pass over the LIVE registry (_state/active-tasks.json).
# registry_view() is the current API for this gate. The dead bounded-registry helper
# load_active() was removed; it read _state/tasks/active.json, which the live board
# does not feed. registry_view() partitions by the real vocabulary in
# registry.LIVE_STATUSES / DEFERRED_STATUSES; never hand-write status literals here,
# or the gate filters on a status the board does not emit and passes vacuously.
board = registry_view()

# Live work is a hard blocker and IS mechanical -- the board knows it, so ask the
# board. Whether context pressure warrants compacting at all is Chrono's judgment
# against shared/lifecycle.md rule 8; there is no predicate for it and no token
# counter to feed one (rule 9: proxy signals only).
blockers = [t["id"] for t in board["live"]]
if blockers:
    surface_to_operator(f"Blockers: {blockers}. Proceed anyway?")
    if not operator_confirms:
        return
# An unclassified status is owed work the partition cannot see — surface it loudly
# rather than compacting over it (same contract as the resume capsule).
if board["unclassified"]:
    surface_to_operator(f"UNKNOWN registry statuses: {board['unclassified']}. Proceed anyway?")

state = {
    "next_action": next_action,
    "active_decisions": active_decisions(),   # AUTHORITY — not Vault evidence
    "active_tasks": board["live"],
    "deferred_tasks": board["deferred"],      # owed work; stalled, not executing
    "latest_turn": latest_operator_turn,
    "pending_approvals": pending_approvals,
}

# 1) Durable Vault note via the CURRENT API — record(note_type, fields), NOT the stale
#    record_finding(role=, canonical_name=, ...) signature. fields require title/body/
#    target/attack_class; unknown fields are rejected.
mcp__chrono_vault__record("learning", {
    "title": f"compact-now externalization ({session_id})",
    "body": json.dumps(state, indent=2),
    "target": "chrono-orchestrator",
    "attack_class": "session-continuity",
    "keywords": ["compaction", "resume", "chrono"],
    "source_task": current_task_id,
})

# 2) Atomic snapshot to _state/chrono/compaction/<session>.json
snapshot(session_id, state)

# 3) Invoke Claude Code's native /compact
trigger_native_compact()

# 4) After compact: recover ONLY from the snapshot, never bulk-re-read history.
#    from chrono_state.compaction import recover; recover(session_id)

Cross-references

  • Snapshot helpers: scripts/python/chrono_state/compaction.py (snapshot, recover). The threshold policy is prose, not code: shared/lifecycle.md § 8.
  • Decision authority (separate from Vault): scripts/python/chrono_state/decisions.py
  • Live board partition: scripts/python/chrono_state/registry.py (registry_view — live / deferred / unclassified; LIVE_STATUSES is the only status vocabulary. The dead bounded-file helper load_active() was removed; registry_view() is the correct API for this blocker gate.)
  • Resume capsule generator: scripts/python/chrono_state/resume.py
  • Vault writer API: record(note_type, fields) — see plugins/chrono-vault/README.md
  • Resume canary (acceptance proof): scripts/python/tests/test_resume_canary.py
  • PreCompact hook: OPTIONAL; only if .claude/settings.json declares one

Version History

  • d5262e2 Current 2026-09-11 11:52

Same Skill Collection

.agents/skills/accessible-media-authoring/SKILL.md
.agents/skills/agent-prompt-engineering/SKILL.md
.agents/skills/agentic-safety-audit/SKILL.md
.agents/skills/audio-event-map-authoring/SKILL.md
.agents/skills/auto-scaffold/SKILL.md
.agents/skills/claim-verification/SKILL.md
.agents/skills/code-reachability-audit/SKILL.md
.agents/skills/code-review-loop/SKILL.md
.agents/skills/color-theory/SKILL.md
.agents/skills/conversation-design/SKILL.md
.agents/skills/copy-refinement/SKILL.md
.agents/skills/cross-file-relationship-synthesis/SKILL.md
.agents/skills/dependency-cycle-audit/SKILL.md
.agents/skills/dependency-health-triage/SKILL.md
.agents/skills/detection-as-code/SKILL.md
.agents/skills/diff-aware-semgrep-scan/SKILL.md
.agents/skills/differential-review/SKILL.md
.agents/skills/dimensional-analysis-check/SKILL.md
.agents/skills/dual-level-retrieval/SKILL.md
.agents/skills/figma-implement-design/SKILL.md
.agents/skills/forensic-timeline-authoring/SKILL.md
.agents/skills/game-design-fundamentals/SKILL.md
.agents/skills/game-mechanics-balancing/SKILL.md
.agents/skills/head-tail/SKILL.md
.agents/skills/incident-response-runbook/SKILL.md
.agents/skills/interactive-audio-design/SKILL.md
.agents/skills/interface-ambiguity-check/SKILL.md
.agents/skills/keyword-clustering/SKILL.md
.agents/skills/knowledge-base-integration/SKILL.md
.agents/skills/layered-analysis-loop/SKILL.md
.agents/skills/level-design-patterns/SKILL.md
.agents/skills/locale-adaptation/SKILL.md
.agents/skills/narrative-structure/SKILL.md
.agents/skills/platform-compliance/SKILL.md
.agents/skills/player-engagement-psychology/SKILL.md
.agents/skills/requirements-elicitation/SKILL.md
.agents/skills/rule6-rights-gate/SKILL.md
.agents/skills/rule8-truth-gate/SKILL.md
.agents/skills/sandbox-provision-discipline/SKILL.md
.agents/skills/scope-decomposition/SKILL.md
.agents/skills/scope-estimation/SKILL.md
.agents/skills/security-ownership-map/SKILL.md
.agents/skills/security-threat-model/SKILL.md
.agents/skills/semgrep-rule-author/SKILL.md
.agents/skills/skill-description-trigger-authoring/SKILL.md
.agents/skills/sound-design-principles/SKILL.md
.agents/skills/structured-data-authoring/SKILL.md
.agents/skills/supply-chain-audit/SKILL.md
.agents/skills/take-over-resume/SKILL.md
.agents/skills/technical-seo-audit/SKILL.md

Metadata

Files
0
Version
d5262e2
Hash
57bd8897
Indexed
2026-09-11 11:52

trang chủ - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-09-15 17:35
浙ICP备14020137号-1 $bản đồ khách truy cập$