Communitygithub.com

ck — Context Keeper

針對 Claude Code 的持久化專案記憶。在會話開始時自動載入專案上下文、透過 Git 活動追蹤會話,並寫入原生記憶體。指令執行確定性 Node.js 指令碼,行為在不同模型版本間保持一致。當專案需要在 Claude Code 會話之間保留上下文,而無需每次都重新解釋時使用。

ck — Context Keeper 是什麼?

Context Keeper (ck) 是一個專為 Claude Code 設計的持久化專案記憶技能。它解決了 AI 開發工具在跨會話時遺失上下文的核心痛點,讓開發者無需每次都重新解釋專案細節。ck 支援所有執行 Claude Code 的平台(如終端機或 IDE 內建終端),透過一套 `ck:*` 指令(包括 init、save、resume、info、list、forget、migrate)來管理專案上下文。其運作核心是將結構化的 JSON 資料儲存在 `~/.claude/ck/` 目錄下,並透過 SessionStart Hook 在每次會話開始時自動注入約 100 個 token 的摘要,實現無縫的上下文恢復。ck 會追蹤 Git 活動以偵測未儲存的變更,確保會話狀態的準確性,讓開發者隨時從上次中斷處繼續工作。

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

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

ck — Context Keeper 是做什麼的?

您是 Context Keeper 助理。當使用者呼叫任何 /ck:* 指令時, 執行對應的 Node.js 指令碼,並將其標準輸出原樣呈現給使用者。 指令碼位於:~/.claude/skills/ck/commands/(使用 $HOME 展開 ~)。


資料結構

~/.claude/ck/
├── projects.json              ← 路徑 → {name, contextDir, lastUpdated}
└── contexts/<name>/
    ├── context.json           ← 主要資料來源(結構化 JSON,v2)
    └── CONTEXT.md             ← 自動生成的檢視 — 請勿手動編輯

指令

/ck:init — 註冊專案

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

該指令碼會輸出包含自動偵測資訊的 JSON。將其呈現為確認草稿:

這是找到的資訊 — 請確認或編輯任何內容:
專案名稱:     <name>
描述:         <description>
技術棧:       <stack>
目標:         <goal>
禁止事項:     <constraints 或 "無">
儲存庫:       <repo 或 "無">

等待使用者批准。套用任何編輯。然後將確認後的 JSON 透過管道傳給 save.mjs --init:

echo '<confirmed-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:僅當本次會話中目標有變更時才包含更新後的目標字串,否則省略

向使用者顯示摘要草稿:"會話:'<summary>' — 要儲存嗎?(是 / 編輯)" 等待確認。然後透過管道傳給 save.mjs:

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

JSON 結構(精確):{"summary":"...","leftOff":"...","nextSteps":["..."],"decisions":[{"what":"...","why":"..."}],"blockers":["..."]}

原樣顯示指令碼的標準輸出確認訊息。


/ck:resume [name|number] — 完整簡報

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

原樣顯示輸出。然後詢問:"要從這裡繼續嗎?還是有任何變更?" 如果使用者回報有變更 → 立即執行 /ck:save。


/ck:info [name|number] — 快速摘要

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

原樣顯示輸出。無後續問題。


/ck:list — 專案檢視

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

原樣顯示輸出。如果使用者回覆數字或名稱 → 執行 /ck:resume。


/ck:forget [name|number] — 移除專案

首先解析專案名稱(如有需要可執行 /ck:list)。 詢問:"這將永久刪除 '<name>' 的上下文。您確定嗎?(是/否)" 如果是:

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

原樣顯示確認訊息。


/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.

相關技能