Communitygithub.com

CM - CASS 记忆系统

AI 编码代理的程序性记忆系统。三层认知架构,包含置信度衰减、反模式学习、跨代理知识转移和创伤保护安全系统。基于 Bun/TypeScript 的 CLI 工具。

CM - CASS 记忆系统 是什么?

CM (CASS Memory System) 是一个专为 AI 编码代理设计的程序性记忆系统,旨在解决会话记忆丢失、代理间知识孤立和原始日志缺乏结构化的问题。它采用三层认知架构:情节记忆(CASS)存储来自所有代理的原始会话日志;工作记忆(Diary)生成结构化的会话摘要;程序记忆(Playbook)则提炼出经过置信度跟踪和衰减的规则。该系统支持跨代理学习,一个代理(如 Cursor)发现的模式可以自动被另一个代理(如 Claude Code)使用。此外,它还具有置信度衰减机制(90 天半衰期)、反模式学习(自动将有害规则转化为警告)和 Trauma Guard 安全系统(阻止危险操作,如 `rm -rf /`),并提供 MCP 服务器以便集成到各种 AI 代理中。

兼容平台✓Claude Code✓Codex CLI✓Cursor✓Gemini CLI
npx skills add https://github.com/bg-szy/TOP-SKILLS/tree/HEAD/skills/marketplace/cm

在你喜欢的 AI 中提问

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

文档

CM - CASS 记忆系统 是做什么的?

专为 AI 编码代理设计的程序性记忆。将零散的会话转换为持久的、跨代理的记忆。采用三层认知架构,模拟人类专业技能的发展过程。

为什么存在

AI 编码代理积累了宝贵的知识,但这些知识通常:

  • 困在会话中 - 会话结束时上下文丢失
  • 特定于代理 - Claude 不知道 Cursor 学到了什么
  • 非结构化 - 原始日志不是可操作的指导
  • 容易崩溃 - 简单的摘要会丢失关键细节

这个月你已经在不同的代理中解决了三次认证 bug。每次你都得从头开始。

CM 通过跨代理学习解决了这个问题:在 Cursor 中发现的模式可以立即被 Claude Code 使用。


三层认知架构

┌─────────────────────────────────────────────────────────────────────┐
│                    情节记忆 (cass)                                  │
│   来自所有代理的原始会话日志 — “基本事实”                            │
│   Claude Code │ Codex │ Cursor │ Aider │ PI │ Gemini │ ChatGPT │ ...│
└───────────────────────────┬─────────────────────────────────────────┘
                            │ cass search
                            ▼
┌─────────────────────────────────────────────────────────────────────┐
│                    工作记忆 (Diary)                                  │
│   结构化的会话摘要:成就、决策等。                                    │
└───────────────────────────┬─────────────────────────────────────────┘
                            │ reflect + curate(自动化)
                            ▼
┌─────────────────────────────────────────────────────────────────────┐
│                    程序记忆 (Playbook)                               │
│   经过置信度跟踪和衰减提炼的规则                                      │
└─────────────────────────────────────────────────────────────────────┘

每个代理的会话都会输入到共享记忆库。在 Cursor 中发现的模式自动在下一次会话中帮助 Claude Code。


你需要的一个命令

cm context "<你的任务>" --json

在开始任何非平凡任务之前运行此命令。 返回:

  • relevantBullets - 根据任务相关性评分的 Playbook 规则
  • antiPatterns - 已经引起过问题的内容
  • historySnippets - 过去的会话(你自己的和其他代理的)
  • suggestedCassQueries - 更深入的调查搜索

按来源过滤历史记录

historySnippets[].origin.kind 是 "local" 或 "remote"。远程命中包括 origin.host:

{
  "historySnippets": [
    {
      "source_path": "~/.claude/sessions/session-001.jsonl",
      "origin": { "kind": "local" }
    },
    {
      "source_path": "/home/user/.codex/sessions/session.jsonl",
      "origin": { "kind": "remote", "host": "workstation" }
    }
  ]
}

置信度衰减系统

规则不是永生的。如果没有重新验证,置信度会衰减:

机制效果
90 天半衰期每 90 天在没有反馈的情况下置信度减半
4 倍有害乘数一次错误相当于四次成功的影响
成熟度递进candidate → established → proven

分数衰减可视化

初始分数:10.0(今天10次有用的标记)

90天后(半衰期):   5.0
180天后:            2.5
270天后:            1.25
365天后:            0.78

有效分数公式

effectiveScore = decayedHelpful - (4 × decayedHarmful)

// 其中衰减系数 = 0.5 ^ (daysSinceFeedback / 90)

成熟度状态机

  ┌──────────┐       ┌─────────────┐    ┌────────┐
  │ candidate│──────▶│ established │───▶│ proven │
  └──────────┘       └─────────────┘    └────────┘
       │                   │                  │
       │                   │ (有害 >25%)    │
       │                   ▼                  │
       │             ┌─────────────┐          │
       └────────────▶│ deprecated  │◀─────────┘
                     └─────────────┘

转换规则:

转换标准
candidate → established3+ 次有用,有害率 <25%
established → proven10+ 次有用,有害率 <10%
any → deprecated有害率 >25% 或显式废弃

反模式学习

坏规则不只是删除。它们会变成警告:

"缓存认证令牌以提高性能"
    ↓ (3次有害标记)
"陷阱:不要在没有过期验证的情况下缓存认证令牌"

当一个规则被多次标记为有害(>50% 有害率且 3+ 次标记)时,它会自动被反转为反模式。


ACE 管道(规则创建方式)

Generator → Reflector → Validator → Curator
阶段角色使用 LLM?
Generator任务前上下文水合(cm context)否
Reflector从会话中提取模式(cm reflect)是
Validator针对 cass 历史进行证据门控是
Curator确定性增量合并否

关键: Curator 不使用 LLM,以防止因迭代漂移导致的上下文崩溃。LLM 提出模式;确定性逻辑管理它们。

科学验证

在规则加入你的 Playbook 之前,它会针对 cass 历史进行验证:

提议规则:"总是在认证调试前检查令牌过期"
    ↓
证据门控:搜索 cass 中应用此规则的会话
    ↓
结果:找到 5 个会话,4 个成功结果 → 接受

没有历史证据的规则会被标记为候选,直到被证明。


命令参考

上下文检索(主要工作流)

# 主要命令 - 在非平凡任务前运行
cm context "实现用户认证" --json

# 为节省 token 预算限制结果
cm context "修复 bug" --json --limit 5 --no-history

# 使用工作空间过滤器
cm context "重构" --json --workspace /path/to/project

# 自文档化解释
cm quickstart --json

# 系统健康检查
cm doctor --json
cm doctor --fix  # 自动修复问题

# 查找相似规则
cm similar "错误处理最佳实践"

Playbook 管理

cm playbook list                              # 所有规则
cm playbook get b-8f3a2c                      # 规则详情
cm playbook add "总是先运行测试"              # 添加规则
cm playbook add --file rules.json             # 从文件批量添加
cm playbook add --file rules.json --session /path/session.jsonl  # 跟踪来源
cm playbook remove b-xyz --reason "已过时"    # 移除
cm playbook export > backup.yaml              # 导出
cm playbook import shared.yaml                # 导入
cm playbook bootstrap react                   # 将启动器应用到现有规则

cm top 10                                     # 最有效的规则
cm stale --days 60                            # 没有最近反馈的规则
cm why b-8f3a2c                               # 规则来源
cm stats --json                               # Playbook 健康指标

学习与反馈

# 手动反馈
cm mark b-8f3a2c --helpful
cm mark b-xyz789 --harmful --reason "导致回归"
cm undo b-xyz789                              # 撤销反馈

# 会话结果(位置参数:状态,规则)
cm outcome success b-8f3a2c,b-def456
cm outcome failure b-x7k9p1 --summary "认证方法失败"
cm outcome-apply                              # 应用到 Playbook

# 反思(通常是自动化的)
cm reflect --days 7 --json
cm reflect --session /path/to/session.jsonl   # 单个会话
cm reflect --workspace /path/to/project       # 项目特定

# 验证
cm validate "总是在解引用前检查 null"

# 审计会话中的规则
cm audit --days 30

# 永久废弃
cm forget b-xyz789 --reason "已被更好的模式取代"

入职(代理原生)

使用你现有的代理实现零成本的 Playbook 构建:

cm onboard status                             # 检查进度
cm onboard gaps                               # 类别缺口
cm onboard sample --fill-gaps                 # 优先处理的会话
cm onboard sample --agent claude --days 14    # 按代理/时间过滤
cm onboard sample --workspace /path/project   # 按工作空间过滤
cm onboard sample --include-processed         # 重新分析会话
cm onboard read /path/session.jsonl --template  # 丰富上下文
cm onboard mark-done /path/session.jsonl      # 标记为已处理
cm onboard reset                              # 重新开始

Trauma Guard(安全系统)

cm trauma list                                # 活跃模式
cm trauma add "DROP TABLE" --description "批量删除" --severity critical
cm trauma heal t-abc --reason "有意的迁移"
cm trauma remove t-abc
cm trauma scan --days 30                      # 扫描创伤
cm trauma import shared-traumas.yaml

cm guard --install                            # Claude Code 钩子
cm guard --git                                # Git pre-commit 钩子
cm guard --install --git                      # 两者
cm guard --status                             # 检查安装状态

系统命令

cm init                                       # 初始化
cm init --starter typescript                  # 使用模板
cm init --force                               # 重新初始化(创建备份)
cm starters                                   # 列出模板
cm serve --port 3001                          # MCP 服务器
cm usage                                      # LLM 成本统计
cm privacy status                             # 隐私设置
cm privacy enable                             # 启用跨代理丰富
cm privacy disable                            # 禁用丰富
cm project --format agents.md                 # 导出用于 AGENTS.md

启动 Playbook

从一个空的 Playbook 开始很艰巨。启动器提供了精选的最佳实践:

cm starters                    # 列出可用启动器
cm init --starter typescript   # 使用启动器初始化
cm playbook bootstrap react    # 应用到现有的 Playbook

内置启动器

启动器重点规则数
general通用最佳实践5
typescriptTypeScript/Node.js 模式4
reactReact/Next.js 开发4
pythonPython/FastAPI/Django4
nodeNode.js/Express 服务4
rustRust 服务模式4

自定义启动器

在 ~/.cass-memory/starters/ 中创建 YAML 文件:

# ~/.cass-memory/starters/django.yaml
name: django
description: Django Web 框架最佳实践
bullets:
  - content: "始终使用 Django 的 ORM 进行数据库操作"
    category: database
    maturity: established
    tags: [django, orm]

内联反馈(在工作期间)

在代码注释中留下反馈。会在反思期间被解析:

// [cass: helpful b-8f3a2c] - 这条规则让我避免了浪费时间

// [cass: harmful b-x7k9p1] - 这个建议对我们的用例是错误的

代理协议

1. 开始:    cm context "<任务>" --json
2. 工作:     在遵循规则时引用规则 ID(例如,“遵循 b-8f3a2c...”)
3. 反馈:     当规则有帮助/有害时留下内联注释
4. 结束:     只需完成。学习会自动进行。

你不需要:

  • 运行 cm reflect(自动化会处理)
  • 手动运行 cm mark(使用内联注释)
  • 手动向 Playbook 添加规则

差距分析类别

类别关键词
debuggingerror, fix, bug, trace, stack
testingtest, mock, assert, expect, jest
architecturedesign, pattern, module, abstraction
workflowtask, CI/CD, deployment
documentationcomment, README, API doc
integrationAPI, HTTP, JSON, endpoint
collaborationreview, PR, team
gitbranch, merge, commit
securityauth, token, encrypt, permission
performanceoptimize, cache, profile

类别状态阈值:

状态规则数优先级
critical0 规则高
underrepresented1-2 规则中
adequate3-10 规则低
well-covered11+ 规则无

Trauma Guard:安全系统

“热炉”原则——从过去的事件中学习并防止再次发生。

工作原理

会话历史                  创伤注册表                运行时防护
┌─────────────────┐         ┌─────────────────┐         ┌─────────────────┐
│ rm -rf /* (哎呦)│ ──────▶ │ 模式:rm -rf     │ ──────▶ │ 已阻止:此命令 │
│ “抱歉,我犯了   │  扫描   │ 严重度:致命     │  钩子   │ 匹配了一个创伤 │
│  一个错误...”   │         │ 会话:abc123     │         │ 模式           │
└─────────────────┘         └─────────────────┘         └─────────────────┘

内置的毁灭模式(20+)

类别示例
文件系统rm -rf /, rm -rf ~, 递归删除
数据库DROP DATABASE, TRUNCATE, DELETE FROM 没有 WHERE
Gitgit push --force 到 main/master, git reset --hard
基础设施terraform destroy -auto-approve, kubectl delete namespace
云服务aws s3 rm --recursive, 破坏性 CloudFormation

模式存储

范围位置目的
全局~/.cass-memory/traumas.jsonl个人模式
项目.cass/traumas.jsonl提交到仓库供团队使用

模式生命周期

  • 活跃: 阻止匹配的命令
  • 已治愈: 临时绕过(带有原因和时间戳)
  • 已删除: 移除(可以重新添加)

MCP 服务器

作为 MCP 服务器运行以便代理集成:

# 仅本地(推荐)
cm serve --port 3001

# 使用认证令牌(用于非回环)
MCP_HTTP_TOKEN="<随机数>" cm serve --host 0.0.0.0 --port 3001

暴露的工具

工具方法描述
contextget_context获取任务上下文(Playbook 规则、反模式、历史记录片段)
record_outcomerecord_outcome记录成果(成功、失败、部分成功)并关联规则
add_ruleadd_rule手动向 Playbook 添加规则
mark_feedbackmark_feedback提供关于规则的反馈(有用、有害)
trauma_healtrauma_heal治愈创伤模式(带原因)
trauma_scantrauma_scan扫描过去的会话以发现创伤
statsget_stats获取 Playbook 健康指标

Individual skills in this repo

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

bg-szy/TOP-SKILLS

Brand-first landing page designer — runs a brand-identity interview (colors, typography, shape language), then generates and iterates on a polished landing page via Stitch with deployment-ready HTML. Use when the user asks to create, design, or build a landing page, homepage, or marketing page and has no established visual direction. Skip when they have a design mockup, need a dashboard or app UI, are working at component level, building a multi-page app, or restyling with known design tokens — use frontend-design instead.

bg-szy/TOP-SKILLS

Fill out Microsoft Azure Landing Zone (ALZ) Accelerator checklists by interviewing the user, mapping their Azure subscriptions, integrating IP addressing documentation, and applying Microsoft Cloud Adoption Framework best practices. Produces a completed Excel checklist (.xlsx) ready for ALZ deployment. Use this skill whenever the user mentions Azure Landing Zone, ALZ checklist, landing zone accelerator, platform landing zone configuration, ALZ bootstrap, hub-and-spoke setup, Azure network topology planning, or wants to fill out any ALZ-related checklist or configuration file. Also trigger when the user uploads an Excel file that contains tabs like "Accelerator - Bootstrap", "Accelerator - Bicep", or "Accelerator - Terraform".

bg-szy/TOP-SKILLS

Compose a premium, animated landing page section by section in Next.js + Tailwind + Motion (Framer Motion) — built on a real design system, with editorial copy and motion that feels human-crafted, not template-generated. Use when building or rebuilding a landing page, marketing site, or hero/feature/pricing/CTA sections that need to look production-ready and bespoke from day one.

bg-szy/TOP-SKILLS

Write high-converting landing page copy using proven frameworks like PAS (Problem-Agitate-Solution), AIDA, and StoryBrand. Creates headlines, value propositions, CTAs, and full page sections optimized for conversion. Use when users need landing page copy, sales page content, or marketing website text.

bg-szy/TOP-SKILLS

Optimize landing pages for conversions, performance, and SEO. Use when improving landing pages, increasing conversions, or optimizing page performance.

bg-szy/TOP-SKILLS

Review investment portfolios for risk, diversification, fees. Asset allocation recommendations, tax-loss harvesting, rebalancing.

bg-szy/TOP-SKILLS

Beads Viewer - Graph-aware triage engine for Beads projects. Computes PageRank, betweenness, critical path, and cycles. Use --robot-* flags for AI agents.

bg-szy/TOP-SKILLS

CI red? Call us. Pipeline fire brigade deploys. Use when user mentions CI failures, build errors, test failures, or pipeline issues. Do NOT load for: local builds, standard implementation work, reviews, or setup.

bg-szy/TOP-SKILLS

Mandatory entry point: read this first for any request to make, create, edit, animate, or render a video, animation, or motion graphic, including a promo, explainer, captioned clip, title card, overlay, slideshow or interactive deck, Remotion port, or any HyperFrames HTML composition. Also use it to inspect, diagnose, validate, preview, publish, or batch-render an existing HyperFrames project. Inputs may be a website URL, GitHub PR, Figma design or URL, text or brief, existing footage, or music. It resumes project state, captures intent when applicable, selects and installs the owning workflow, and routes domain capabilities. HyperFrames is the default output framework unless the user explicitly chooses another framework for the deliverable or asks only to record a browser session.

bg-szy/TOP-SKILLS

Expert in building portfolios that actually land jobs and clients - not just showing work, but creating memorable experiences. Covers developer portfolios, designer portfolios, creative portfolios, and portfolios that convert visitors into opportunities.

bg-szy/TOP-SKILLS

Use when the user asks to "pre-launch check the landing page", "run a Quality-Score preflight", or "verify ad-to-page message match before launch"; produces an ad↔page continuity report — message-match gaps, above-the-fold check, page-speed read, form-friction count, mobile-render flags — as a pass/fix punch list. Not for redesigning or rewriting the page — use landing-optimizer; not for scoring the account or the RQS — use ad-account-auditor. 落地页体验预检/广告落地页一致性检查

bg-szy/TOP-SKILLS

Use when the user asks to "optimize our landing page for influencer traffic", "fix our promo-code landing page", or "improve conversion from a creator campaign"; produces a message-match audit, page-structure and social-proof recommendations, a promo-code/CTA conversion plan, and an A/B test roadmap. Not for measuring campaign results after launch — use performance-analyzer.

bg-szy/TOP-SKILLS

Audit a landing page, sales page or checkout page for conversion leaks and return a fix list ordered by expected revenue impact. Use when asked to review, critique or improve a landing page, sales page, opt-in page, product page or checkout flow, when conversion rate is low, when paid traffic is not converting, or when someone asks "why isn't this page converting" or wants a CRO / landing page review.

bg-szy/TOP-SKILLS

Landing page conversion optimization with layout rules, hero section design, and CTA psychology. Covers above-the-fold formula, social proof placement, mobile design, and F-pattern reading. Use for: startup landing pages, product pages, SaaS marketing, conversion optimization. Triggers: landing page, hero section, above the fold, conversion optimization, landing page design, cta button, hero image, landing page layout, saas landing page, product page design, conversion rate, landing page best practices

bg-szy/TOP-SKILLS

Create high-converting, visually distinctive landing pages. Use when building marketing pages, product launches, SaaS homepages, or any single-page conversion-focused website. Guides section-by-section composition with anti-AI-slop principles.

bg-szy/TOP-SKILLS

Landing page conversion optimization with layout rules, hero section design, and CTA psychology. Covers above-the-fold formula, social proof placement, mobile design, and F-pattern reading. Use for: startup landing pages, product pages, SaaS marketing, conversion optimization. Triggers: landing page, hero section, above the fold, conversion optimization, landing page design, cta button, hero image, landing page layout, saas landing page, product page design, conversion rate, landing page best practices

bg-szy/TOP-SKILLS

Account assets, equity and fund positions, P&L, cash flow records, account statements, margin ratios, buy-power estimates, order management, and DCA recurring investments via Longbridge (most require Trade permission). Frameworks: portfolio diagnosis, rebalancing, asset allocation, risk analysis (VaR/CVaR), performance attribution, and tax-loss harvesting. Triggers: "持仓", "账户", "盈亏", "资产", "对账单", "下单", "买入", "卖出", "撤单", "定投", "组合诊断", "再平衡", "资产配置", "风险分析", "绩效归因", "税损收割", "持倉", "賬戶", "盈虧", "對賬單", "下單", "買入", "賣出", "組合診斷", "再平衡", "稅損收割", "positions", "portfolio", "P&L", "order", "buy", "sell", "DCA", "statement", "risk analysis", "rebalancing", "tax harvesting", "我的风险", "持仓风险", "风险敞口", "資產", "資產配置", "風險分析", "績效歸因", "撤單

bg-szy/TOP-SKILLS

Auto-loaded context for Portfolio Buddy 2 development. Use for ANY task involving: React 19 development, TypeScript, portfolio analysis features, metrics calculations, trading strategy comparison, or working with the Portfolio Buddy 2 codebase. Contains tech stack, known issues, and architectural constraints.

bg-szy/TOP-SKILLS

Process video files with audio extraction, format conversion (mp4, webm), and Whisper transcription. Use when user mentions video conversion, audio extraction, transcription, mp4, webm, ffmpeg, or whisper transcription.

bg-szy/TOP-SKILLS

Using the Wonda CLI to generate images, videos, music, and audio from the terminal — plus LinkedIn, Reddit, and X/Twitter research and automation

相关技能