Communitygithub.com

ck — 上下文守护者

为 Claude Code 提供持久化、按项目存储的记忆。自动加载项目上下文,跟踪 Git 活动会话,并写入原生内存,避免每次重新解释项目细节。

ck — 上下文守护者 是什么?

Context Keeper (ck) 是一个专门为 Claude Code 设计的 AI 助手技能,旨在解决 AI 会话间项目上下文丢失的问题。它通过在 `~/.claude/ck/` 下维护一个结构化的 JSON 数据目录(包括 `projects.json` 和每个项目的上下文文件),实现了跨会话的持久化记忆。每次会话启动时,一个 SessionStart 钩子会自动注入约 100 token 的紧凑项目摘要,并检测未保存的会话或 Git 变更。用户可以通过 `/ck:init`、`/ck:save`、`/ck:resume`、`/ck:info`、`/ck:list`、`/ck:forget` 和 `/ck:migrate` 等命令管理项目上下文,这些命令都运行确定性的 Node.js 脚本,确保行为在不同模型版本间一致。该技能特别适合那些需要 AI 记住项目目标、技术栈、已做决策和下一步计划的大型或复杂项目,无需在每次新会话中重新解释。

兼容平台✓Claude Code~Codex CLI~Cursor
npx skills add https://github.com/affaan-m/everything-claude-code/tree/main/skills/ck

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

ck — 上下文守护者 是做什么的?

你是上下文守护者助手。当用户调用任何 /ck:* 命令时,运行相应的 Node.js 脚本,并将其标准输出原样呈现给用户。脚本位于:~/.claude/skills/ck/commands/(将 ~ 替换为 $HOME)。


数据布局

~/.claude/ck/
├── projects.json              ← 路径 → {名称, contextDir, 最后更新}
└── contexts/<名称>/
    ├── context.json           ← 权威来源(结构化 JSON,v2)
    └── CONTEXT.md             ← 自动生成的视图 — 请勿手动编辑

命令

/ck:init — 注册项目

node "$HOME/.claude/skills/ck/commands/init.mjs"

该脚本输出带有自动检测信息的 JSON。将其呈现为确认草稿:

以下是我找到的信息 — 请确认或编辑:
项目:     <名称>
描述:     <描述>
技术栈:   <技术栈>
目标:     <目标>
禁止项:   <约束条件 或 "无">
仓库:     <仓库 或 "无">

等待用户批准。应用任何修改。然后将确认后的 JSON 通过管道传递给 save.mjs --init:

echo '<确认后的 JSON>' | node "$HOME/.claude/skills/ck/commands/save.mjs" --init

确认后的 JSON 架构:{"name":"...","path":"...","description":"...","stack":["..."],"goal":"...","constraints":["..."],"repo":"..." }


/ck:save — 保存会话状态

这是唯一需要 LLM 分析的命令。 分析当前对话:

  • summary:一句话,最多 10 个词,总结完成了什么
  • leftOff:当前正在积极处理的内容(具体文件/功能/错误)
  • nextSteps:有序的具体下一步行动数组
  • decisions:本次会话中做出的决策数组,格式为 {what, why}
  • blockers:当前阻塞项数组(若无则空数组)
  • goal:仅当本次会话中目标发生变化时才更新的目标字符串,否则省略

向用户显示总结草稿:"会话:'<总结>' — 是否保存?(是 / 编辑)" 等待确认。然后通过管道传递给 save.mjs:

echo '<json>' | node "$HOME/.claude/skills/ck/commands/save.mjs"

JSON 架构(精确):{"summary":"...","leftOff":"...","nextSteps":["..."],"decisions":[{"what":"...","why":"..."}],"blockers":["..."]} 原样显示脚本的标准输出确认信息。


/ck:resume [名称|编号] — 完整简报

node "$HOME/.claude/skills/ck/commands/resume.mjs" [参数]

原样显示输出。然后询问:"是否从这里继续?或者有什么变化?" 如果用户报告有变化 → 立即运行 /ck:save。


/ck:info [名称|编号] — 快速快照

node "$HOME/.claude/skills/ck/commands/info.mjs" [参数]

原样显示输出。无后续问题。


/ck:list — 项目列表

node "$HOME/.claude/skills/ck/commands/list.mjs"

原样显示输出。如果用户回复数字或名称 → 运行 /ck:resume。


/ck:forget [名称|编号] — 删除项目

首先解析项目名称(如果需要,运行 /ck:list)。 询问:"这将永久删除 '<名称>' 的上下文。是否确认?(是/否)" 如果确认:

node "$HOME/.claude/skills/ck/commands/forget.mjs" [名称]

原样显示确认信息。


/ck:migrate — 将 v1 数据转换为 v2

node "$HOME/.claude/skills/ck/commands/migrate.mjs"

首先执行试运行:

node "$HOME/.claude/skills/ck/commands/migrate.mjs" --dry-run

原样显示输出。将所有 v1 的 CONTEXT.md + meta.json 文件迁移为 v2 的 context.json。 原始文件备份为 meta.json.v1-backup — 不会删除任何内容。


SessionStart 钩子

位于 ~/.claude/skills/ck/hooks/session-start.mjs 的钩子必须在 ~/.claude/settings.json 中注册,以便在会话启动时自动加载项目上下文:

{
  "hooks": {
    "SessionStart": [
      { "hooks": [{ "type": "command", "command": "node \"~/.claude/skills/ck/hooks/session-start.mjs\"" }] }
    ]
  }
}

该钩子每次会话注入约 100 token(紧凑的 5 行摘要)。它还会检测未保存的会话、自上次保存以来的 Git 活动以及目标与 CLAUDE.md 不匹配的情况。


规则

  • 在 Bash 调用中始终将 ~ 展开为 $HOME。
  • 命令不区分大小写:/CK:SAVE、/ck:save、/Ck:Save 都有效。
  • 如果脚本退出码为 1,则将其标准输出作为错误消息显示。
  • 切勿直接编辑 context.json 或 CONTEXT.md — 始终使用脚本。
  • 如果 projects.json 格式错误,告知用户并提供将其重置为 {} 的选项。

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

accessibility

Design, implement, and audit inclusive digital products using WCAG 2.2 Level AA. Use when building or auditing UI that must meet WCAG 2.2 Level AA, or when reviewing a change for keyboard, contrast, or screen-reader support.

affaan-m/claude-api

Anthropic Claude API patterns for Python and TypeScript. Covers Messages API, streaming, tool use, vision, extended thinking, batches, prompt caching, and Claude Agent SDK. Use when building applications with the Claude API or Anthropic SDKs.

affaan-m/everything-claude-code

End-to-end marketing campaign planning and execution. Covers audience research, positioning, campaign angle definition, landing page copy, email sequences, social posts, ad copy, short-form video scripts, and content calendars. Use as the orchestration layer for multi-channel product launches. Use when planning or executing a multi-channel product launch, or producing landing page, email, social, or ad copy.

affaan-m/everything-claude-code

Development conventions and patterns for everything-claude-code. JavaScript project with conventional commits.

affaan-m/everything-claude-code-conventions

Development conventions and patterns for everything-claude-code. JavaScript project with conventional commits.

affaan-m/frontend-design

Create distinctive, production-grade frontend interfaces with high design quality. Use when the user asks to build web components, pages, or applications and the visual direction matters as much as the code quality.

affaan-m/gget

gget CLI and Python workflow for quick genomic database queries, sequence lookup, BLAST-style searches, enrichment checks, and reproducible bioinformatics evidence logs.

affaan-m/literature-review

Systematic literature-review workflow for academic, biomedical, technical, and scientific topics, including search planning, source screening, synthesis, citation checks, and evidence logging.

affaan-m/motion-ui

Production-ready UI motion system for React/Next.js. Use when implementing animations, transitions, or motion patterns.

affaan-m/project-guidelines-example

Example project-specific skill template based on a real production application.

affaan-m/pubmed-database

Direct PubMed and NCBI E-utilities search workflows for biomedical literature, MeSH queries, PMID lookup, citation retrieval, and API-backed literature monitoring.

affaan-m/scholar-evaluation

Structured scholarly-work evaluation for papers, proposals, literature reviews, methods sections, evidence quality, citation support, and research-writing feedback.

affaan-m/uspto-database

USPTO patent and trademark data workflow for official record lookup, PatentSearch queries, TSDR checks, assignment data, and reproducible IP research logs.

agent-architecture-audit

Full-stack diagnostic for agent and LLM applications. Audits the 12-layer agent stack for wrapper regression, memory pollution, tool discipline failures, hidden repair loops, and rendering corruption. Produces severity-ranked findings with code-first fixes. Essential for developers building agent applications, autonomous loops, or any LLM-powered feature. Use when an agent or LLM feature misbehaves and the failing layer is unknown, or before shipping an agent stack.

agent-eval

Head-to-head comparison of coding agents (Claude Code, Aider, Codex, etc.) on custom tasks with pass rate, cost, time, and consistency metrics. Use when choosing between coding agents, or when a change to an agent setup needs measured pass rate, cost, and time rather than an impression.

agent-harness-construction

Design and optimize AI agent action spaces, tool definitions, and observation formatting for higher completion rates. Use when defining or revising an agent

agentic-engineering

Operate as an agentic engineer using eval-first execution, decomposition, and cost-aware model routing. Use when planning or executing engineering work that agents will carry out end to end.

agentic-os

Build persistent multi-agent operating systems on Claude Code. Covers kernel architecture, specialist agents, slash commands, file-based memory, scheduled automation, and state management without external databases. Use when building a persistent multi-agent system on Claude Code with its own memory, commands, and scheduling.

agent-introspection-debugging

Structured self-debugging workflow for AI agent failures using capture, diagnosis, contained recovery, and introspection reports. Use when an agent run fails and you need a reproducible diagnosis instead of a retry.

agent-payment-x402

Add x402 payment execution to AI agents with per-task budgets, spending controls, and non-custodial wallets. Supports Base through agentwallet-sdk and X Layer through OKX Payments / OKX Agent Payments Protocol. Use when an agent must pay for something itself and needs per-task budgets, spending controls, and a non-custodial wallet.

相关技能