关于 cass-memory
cass-memory 是面向编码 Agent 的命令行系统,可从编码会话中构建个人实践手册。它会提供相关规则和过往示例,并通过反馈与结果记录帮助维护规则。
主要功能
- 01按任务提供上下文和历史示例
- 02从近期会话提取模式
- 03管理实践手册规则
- 04反馈规则是否有帮助
- 05记录会话结果并查看统计
适用场景
- 01开始任务前获取相关编码指南
- 02从近期工作中提取可复用模式
- 03审查并清理过时规则
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ johnlindquist/ claude --skill cass-memory安装后在 Claude Code 中输入/cass-memory确认已加载。
详细介绍
CASS Memory - 上下文学习系统
构建并使用一套从你的会话中学习到的编码模式个人手册。
前置条件
cm 命令行应可用(属于 cass-memory 系统)。
初始化:
cm init
# Or with a starter playbook
cm init --starter typescript
cm init --starter react
cm init --starter python
cm init --starter go
命令行参考
获取某项任务的上下文
# THE main command - get relevant rules before starting work
cm context "Description of your task" --json
返回内容:
- 你的手册中的相关规则
- 需要避免的反模式
- 类似过往工作的历史片段
反思(提取模式)
# Run reflection on recent sessions
cm reflect --json
# Specify lookback period
cm reflect --days 7 --json
cm reflect --days 30 --json
手册管理
# List all rules
cm playbook list --json
# Get specific rule details
cm playbook get b-8f3a2c --json
# Add a new rule
cm playbook add "Always use optional chaining for nested object access" --json
对规则的反馈
# Mark rule as helpful
cm mark b-8f3a2c --helpful --json
cm mark b-8f3a2c --helpful --reason "Prevented null error" --json
# Mark rule as harmful
cm mark b-8f3a2c --harmful --json
cm mark b-8f3a2c --harmful --reason "Caused false positive" --json
记录会话结果
# Record success
cm outcome --status success --json
cm outcome --status success --rules "b-8f3a2c,b-4d2e1f" --json
# Record failure
cm outcome --status failure --text "Build failed due to type error" --json
# Mixed results
cm outcome --status mixed --text "Partial completion" --json
统计
# Get playbook stats
cm stats --json
顶级规则
# Show most effective rules
cm top --json
cm top 5 --json
cm top 20 --json
健康检查
# Check system health
cm doctor --json
# Auto-fix issues
cm doctor --fix --json
查找过时规则
# Rules without recent feedback
cm stale --json
cm stale --days 30 --json
cm stale --days 60 --json
验证规则
# Validate a proposed rule against history
cm validate "Proposed rule text" --json
解释规则来源
# Show evidence and reasoning for a rule
cm why b-8f3a2c --json
使用统计
cm usage --json
入门手册
# List available starters
cm starters --json
工作流模式
会话开始
# Get context before starting a task
cm context "Implement user authentication with JWT" --json
工作过程中
当某条规则有帮助时:
cm mark b-8f3a2c --helpful --json
当某条规则导致误入歧途时:
cm mark b-8f3a2c --harmful --reason "Not applicable to this framework" --json
会话结束
# Record outcome
cm outcome --status success --rules "b-8f3a2c,b-4d2e1f" --json
定期维护
# Weekly: Run reflection to extract new patterns
cm reflect --days 7 --json
# Monthly: Review stale rules
cm stale --days 30 --json
# Check system health
cm doctor --json
构建你的手册
# Manually add a pattern you've learned
cm playbook add "Use React.memo() for components receiving complex objects as props" --json
# After adding, use it in context queries
cm context "Create a list component with filtering" --json
规则生命周期
- 创建 - 规则来自反思或手动添加
- 使用 - 规则在上下文查询中出现
- 反馈 - 根据经验标记为有帮助/有害
- 演化 - 高反馈的规则上升,低反馈的规则变得过时
- 淘汰 - 过时规则会被审查并清除
最佳实践
- 始终先获取上下文 - 在开始工作前运行
cm context "task" - 提供反馈 - 将规则标记为有帮助/有害
- 记录结果 - 跟踪会话成功/失败
- 定期运行反思 - 每周反思可提取新模式
- 审查过时规则 - 不要让旧规则不断累积
- 手动添加规则 - 当你学到重要内容时
集成技巧
任务前上下文
在任何重要的编码任务之前:
CONTEXT=$(cm context "Your task description" --json)
# Use context to inform your approach
会话后记录
在编码会话结束时:
cm outcome --status success --text "Completed feature X" --json
评论
支持 Markdown