| name | chat-experience-capture |
| description | Analyze the current conversation at the end of a task, convert reusable lessons into directly executable project rules or system rules, ask which rule lines should be saved, and persist the confirmed rules into the correct rule files. Use when the user wants to复盘对话、沉淀经验、整理可复用做法、保存踩坑记录、归档工作流经验, especially near the end of a conversation or task. |
Chat Experience Capture
Overview
Use this skill at the end of a conversation to convert transient chat history into durable rules.
Do not output abstract experience cards when a concrete rule can be written.
Workflow
1. Review the full conversation
Read the current conversation and identify only experience that can help in future work.
Prefer these experience types:
- Reusable workflows
- Stable debugging steps
- Proven command sequences
- Decision heuristics
- Gotchas and failure patterns
- Prompt patterns that produced strong results
- Conventions the user repeatedly prefers
Ignore these items:
- One-off status updates
- Trivial facts with no reuse value
- Private secrets, tokens, cookies, keys, or credentials
- Personal data that is not necessary for future work
- Temporary project state that will quickly go stale
2. Produce candidate rule lines
List candidate rules before saving anything unless the user explicitly asks to save automatically.
Each candidate must already be written as a rule line that can be saved with little or no editing.
Do not lead with 标题 or 类型 unless the user explicitly asks for metadata.
Prefer this shape:
维度: 项目规则 or 系统规则
规则草案: the exact line to save
理由: one short sentence
建议保存: yes or no
Keep the list concise. Merge duplicates.
Prefer imperative, concrete, operational wording.
For 项目规则, prefer the sentence pattern 在<场景>时,先/必须/不要<动作> whenever possible.
For 系统规则, prefer the sentence pattern Before/When <scenario>, <do or avoid something>.
Good:
项目规则:在 jwc 服务器连接数据库前,先读取 /www/wwwroot/evaluation_server/.env 中的 DB_HOST、DB_PORT、POSTGRES_DB、DB_SCHEMA,并按 schema=evaluation 查询。
项目规则:在服务器执行线上 SQL 前,先确认目标表位于 evaluation schema,而不是默认 public schema。
系统规则:Before modifying production data, perform a read-only check first and reduce the change to a single idempotent transaction.
Bad:
线上数据库来源先查 .env 和监听端口
生产环境修库优先走最小写入原则
3. Ask what to save
After listing candidates, ask the user which numbered rule lines should be saved.
Use a concise prompt such as:
可保存的规则草案如上。请回复要保存的编号,例如“1,3,4”,或回复“全部保存”。
If the user already gave clear save intent such as 都保存, 自动保存推荐项, or 全部归档, skip the question and save immediately.
4. Classify and save confirmed items
Do not save confirmed items into a generic experience bank.
Save them in two dimensions only:
项目规则: save to the current project's AGENTS.md
系统规则: save to all three files and keep them byte-identical
~/.claude/CLAUDE.md
~/.codex/AGENTS.md
~/.config/opencode/AGENTS.md
Before writing, scan target files for obvious duplicates with the same meaning. Update or skip duplicates instead of blindly appending.
When the candidate is ambiguous, prefer asking the user whether it belongs to 项目规则 or 系统规则 before saving.
Use this classification:
项目规则: preferences, conventions, workflow constraints, or instructions that are only valid for the current repository or project
系统规则: stable cross-project operating rules that should apply to future work everywhere
5. Persist in rule format
Rewrite saved items as concise, directly executable rules.
Prefer rules that contain:
- trigger or scenario
- required or forbidden action
- concrete target when the conversation provides one
For 系统规则, always follow these format constraints:
- one rule per line
- start with
-
- write in English
- use imperative mood
- do not indent
For 项目规则, preserve the existing style of the target AGENTS.md. If the file already uses Chinese rules, keep Chinese. If it already uses one-rule-per-line format, follow it.
Do not append timestamps, titles, narrative fields, or analysis blocks into rule files.
Examples:
- Run the conversation-capture skill at the end of substantial tasks to extract reusable rules.
- 必须中文回复用户
Write 项目规则 in Chinese by default unless the target file clearly uses another language.
Prefer 项目规则 that can be pasted directly into AGENTS.md without rewriting.
If a candidate cannot be written as a direct rule line, refine it before presenting it.
Write 系统规则 in English unless the user explicitly requests otherwise and the system rule files already follow another convention.
Extraction Rules
Prefer extracting rules at the level of actionability.
Aim for rules that another agent can execute immediately without reading the original conversation.
When the conversation contains concrete paths, hosts, commands, schemas, service names, or entrypoints, preserve them in the rule if they are stable and project-specific.
Good examples:
遇到 Next.js dev lock 时,先杀掉遗留 dev 进程,再删除 .next/dev/lock,再重启
为重复执行的终局复盘任务创建 skill,比把流程写进单次对话更可复用
当一个技能需要用户确认保存项时,先列候选编号,再让用户选择,避免误存噪音
只在当前仓库有效的偏好写入项目 AGENTS.md,跨项目稳定规则写入三份系统规则文件
在当前项目的生产库执行 SQL 前,先确认表位于 evaluation schema,而不是默认 public schema
When a server lacks project dependencies, use an isolated tool directory instead of installing packages into the production app directory
在 jwc 服务器连接 evaluation 项目数据库前,先从 /www/wwwroot/evaluation_server/.env 提取数据库变量,再按 schema=evaluation 查询
Avoid vague entries:
今天修了一个 bug
这个方案不错
用户喜欢这样
线上数据库来源先查 .env 和监听端口
服务器缺少项目依赖时优先使用隔离工具目录
Convert vague entries into executable rules before presenting them.
If two candidates overlap, keep the more executable one and drop the more abstract one.
Preferred Output Format
Prefer grouping candidates by dimension:
项目规则:
1. 在 jwc 服务器连接数据库前,先读取 /www/wwwroot/evaluation_server/.env 中的数据库变量,并按 schema=evaluation 查询。
理由:这个项目线上 PostgreSQL 表不在 public schema,直接查默认 schema 会误判。
2. 在 evaluation 项目线上修 RBAC 前,先只读检查 evaluation."Resource" 和 evaluation."RolePermission",确认缺的是资源还是授权关系。
理由:先确认缺失层级可以把写入范围收窄到最小。
系统规则:
3. Before modifying production data, perform a read-only check first and reduce the change to a single idempotent transaction.
理由:This lowers production risk and makes rollback boundaries clear.
If the user asks for "具体可执行项", skip metadata like 标题 and 类型 entirely and output only grouped rule lines plus brief reasons.
Response Shape
When invoked, respond in this order:
- A short line stating that you are reviewing the conversation for saveable rules.
- Grouped candidates under
项目规则 and 系统规则.
- A direct save question if save intent is not already explicit.
- After confirmation, a short save result with the target files and item count.
File Editing Guidance
Use apply_patch for file edits when possible.
When updating system rules, keep ~/.claude/CLAUDE.md, ~/.codex/AGENTS.md, and ~/.config/opencode/AGENTS.md byte-identical.
After every rule update, audit the touched rule files for invalid references, conflicting rules, duplicated rules, and outdated instructions.