This is a prescription reference system that captures reusable programming patterns, library APIs, and operational techniques as searchable markdown files. It forces you to actually grep the codebase before writing anything down, so tricks stay grounded in real project code instead of floating abstractions. Three types: pattern for design approaches, library for framework usage and gotchas, technique for commands and tooling recipes. The workflow is structured around user prompts like "record this trick" but honestly the best part is Phase 2, where it refuses to skip code investigation even when you're lazy about it. Updates existing tricks instead of piling up duplicates. If you've ever lost track of "how we do Prisma transactions here" or "that jq incantation for nested JSON," this keeps those answers in one place with actual file paths attached.
npx -y skills add liuzhengdongfortest/codestable --skill cs-trick --agent claude-codeInstalls into .claude/skills of the current project.
开始任何判断或动作前,先读取 .codestable/attention.md;缺失则视为骨架不完整,提示先补齐或运行 cs-onboard,不要回退到外部 AI 入口文件。
cs-trick 是面向问题的处方性参考库,回答:要做 X,经过验证的正确做法是什么? 不需要触发事件,任何时候发现值得沉淀的模式或用法都可以直接写。
典型内容:某个设计模式在这个项目的标准写法 / 某个库的核心 API 用法 + 已知坑 / 某类操作的命令配方。
共享路径与命名约定看
.codestable/reference/shared-conventions.md。产物写入.codestable/compound/,命名YYYY-MM-DD-trick-{slug}.md,frontmatter 带doc_type: trick。
frontmatter 的 type 字段:
| 类型 | 适用情境 | 示例 |
|---|---|---|
pattern | 设计模式 / 架构模式 / 编程惯用法 | "用 Repository 模式隔离数据访问层"、"用 Builder 构造复杂配置" |
library | 某个库 / 框架的用法 / 配置方式 / 常见坑 | "Prisma 事务的正确写法"、"Pinia store 的 action 错误处理" |
technique | 具体操作技巧 / 工具用法 / 命令配方 | "用 jq 从 JSON 提取嵌套字段"、"git bisect 定位引入 bug 的提交" |
查询用途:查"代码该怎么组织"→ pattern;"库 / 框架某 API 怎么用"→ library;"这类操作怎么做"→ technique。分不清选最接近的,type 不影响搜索可用性。
frontmatter / 正文模板 / 长示例见同目录 reference.md。流程约束:
type 只允许 pattern / library / technique最多两个问题:
typetopic用户描述已清楚就跳过直接进 Phase 1.5。
按 shared-conventions.md §6 第 5/6 条:
--query 查一遍 topic,命中相近时把候选列给用户更新流程:读旧文档 → 和用户对齐改哪几节 → 跳过 Phase 2 完整代码调查(被改的节涉及的代码要重读确认未失效)→ 起草 diff 给用户 review → 写回 + updated: YYYY-MM-DD。
技巧通过代码体现——用户不贴代码不等于不需要看代码。AI 必须主动调查代码仓。
为什么必做:没看代码就写出的"技巧"会停留在抽象层面,下次有人按这条找代码会找不到对应的真实例子,反而失去信心。
library 类找 import 和调用处;pattern 类找结构性代码(接口定义 / 类继承 / 组合);technique 类找操作步骤对应的脚本或配置补充:用户附带文件 → 仍要搜一遍代码仓确认有没有其他使用点;搜索结果为空 → 可继续但必须在文档注明;找到的代码和用户描述矛盾 → 主动跟用户确认。
结合 Phase 2 找到的代码提问——不问用户已经能在代码看到的东西:
用户说"没什么"或"跳过"就跳过,宁缺节也不用空话填充。
AI 一次性起草完整文档(YAML frontmatter + 正文)。示例代码优先用 Phase 2 找到的真实项目代码(可精简),别凭空编写。展示给用户。
compound/YYYY-MM-DD-trick-{slug}.md,frontmatter 带 doc_type: trickupdated: YYYY-MM-DDshared-conventions.md §6 第 5 条处理写完若发现一两行"每次 CodeStable 技能启动都该知道"的项目硬约束,提示用户用 cs-note 追加到 .codestable/attention.md。不要自作主张改 attention,也不要写外部 AI 入口。
完整语法见
.codestable/reference/tools.md。
# 按类型 + 框架筛选
python .codestable/tools/search-yaml.py --dir .codestable/compound --filter doc_type=trick --filter type=library --filter framework~={库名}
# 按技术栈浏览
python .codestable/tools/search-yaml.py --dir .codestable/compound --filter doc_type=trick --filter language=typescript --filter status=active
# 归档后查重叠
python .codestable/tools/search-yaml.py --dir .codestable/compound --filter doc_type=trick --query "{关键词}" --json
归档类共享规则见
shared-conventions.md第 6 节。本技能特有:
doc_type: trickjuliusbrussee/caveman
mattpocock/skills
shadcn/improve
obra/superpowers
forrestchang/andrej-karpathy-skills
vercel-labs/skills