self-refinement

A feedback process that turns repeated corrections into lasting rules or skill updates. It reviews what went wrong, finds the root cause, and suggests how to prevent the same mistake later.

In plain words
What is it for?
Use it after correcting the assistant, or run the /reflect command, to identify missing guidance, knowledge gaps, skipped process steps, or faulty reasoning patterns.
Why use it?
It reduces the chance that the same error will appear again in a future conversation or task.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/davidyichengwei/agentic-engineering-framework/self-refinement
Any agent
npx skills add davidYichengWei/agentic-engineering-framework --skill self-refinement
Clone the repo
git clone --depth 1 https://github.com/davidYichengWei/agentic-engineering-framework

Made for: Claude Code, Codex.

Per session 55 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,318 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00055 $0.01318
Opus 5 $0.00028 $0.00659
Sonnet 5 $0.00011 $0.00264
Haiku 4.5 $0.00006 $0.00132

Measured 2d ago against content hash 0d1bc1efb983, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

self-refinement scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/self-refinement/SKILL.md · 142 lines

How it starts

The opening of the file, as written. The whole thing — 142 lines — stays where its author put it; the contents beside it link to each section on GitHub.

经验沉淀 (Self-Refinement)

核心定位

从错误中构建反馈闭环:将非结构化的错误经验转化为结构化的持久化上下文(Rules/Skills),防止同类错误在新会话中重复发生。

原理:LLM 没有跨会话的持久记忆——会话 A 中被纠正的错误,在会话 B 中会以相同概率再次发生。唯一的解法是将错误经验外化为持久化的上下文。


触发模式

模式一:自动触发

触发条件:AI 在协作过程中被用户纠正(用户否定了 AI 的输出并给出了正确方向)。

行为

  1. 先完成当前纠正——不打断用户当前的任务流
  2. 纠正完成后,在回复末尾简要评估是否需要沉淀经验
  3. 如果需要,输出轻量建议(不超过 3 条)

输出格式

---
💡 **经验沉淀建议**

刚才的纠正揭示了一个可沉淀的模式:

- **错误模式**:[简述 AI 犯的错]
- **根因**:[规范缺失 / 知识缺失 / 流程遗漏 / 模式错误]
- **建议**:[更新 Rule/Skill 的具体操作]

是否需要我执行?(回复"沉淀"执行,或忽略继续当前工作)

设计原则

  • 不打断:建议附在回复末尾,不影响正常工作流
  • 轻量化:仅简述,不展开长篇分析
  • 建议优先:不自主执行,等用户确认

模式二:手动触发(/reflect)

触发条件:用户通过 /reflect Command 主动发起。

行为

  1. 回顾当前对话历史
  2. 识别所有被纠正的错误模式
  3. 对每个错误执行完整的诊断闭环
  4. 输出结构化的沉淀建议

核心闭环

无论自动还是手动触发,共享同一个核心流程:

Step 1: 识别错误模式

回顾对话中 AI 被纠正的场景,提取:

  • 错误输出:AI 说了什么/做了什么
  • 正确方向:用户期望什么
  • 差距:AI 为什么偏离

Step 2: 诊断根因

根因类别 定义 典型表现
规范缺失 现有 Rules/Skills 中没有覆盖该场景 AI 不知道项目的特定约定
知识缺失 AI 缺少项目特定的领域知识 AI 对某个模块的行为/限制不了解
流程遗漏 Workflow Skill 中缺少关键步骤或检查点 AI 跳过了应有的验证步骤
模式错误 AI 应用了错误的思维模式 AI 用类比代替第一性原理推导

Step 3: 检索现有知识

搜索现有 Skills 和 Rules:

  • 是否已有相关规则?→ 需要补充/修改
  • 完全没有相关规则?→ 需要新建

Step 4: 生成建议

每条建议包含:

### 建议 N: [简短标题]

- **根因**:[规范缺失 / 知识缺失 / 流程遗漏 / 模式错误]
- **目标文件**:`[Rules/Skills 文件路径]`
- **操作**:[新建 / 在 X 位置添加 / 修改 Y 内容]
- **具体内容**:

[要添加或修改的具体文本]

建议数量:≤ 3 条。多于 3 条时,按影响范围排序取 Top 3。

Step 5: 用户确认

以上是本次经验沉淀建议,请选择:
- **全部执行** → 我将依次执行所有建议
- **选择执行** → 告诉我执行哪几条(如"执行 1 和 3")
- **跳过** → 不执行任何建议

Step 6: 执行更新

用户确认后,更新现有文件或创建新文件,并写入对应的 Rules/Skills 更新内容。


强制规则

规则 说明
建议优先 不自主执行任何 Rules/Skills 修改,必须经用户确认
不打断 自动触发时,建议附在回复末尾,不打断当前工作流
轻量化 自动触发时,建议控制在 3 条以内,每条不超过 5 行
可追溯 每条建议明确标注根因类别和目标文件
不重复 执行前检索现有 Rules/Skills,避免重复添加相似规则

反模式

❌ 错误做法 ✅ 正确做法
被纠正后立即修改 Rules/Skills 先完成当前任务,再提建议
输出冗长分析 / 建议过于宽泛 每条建议 ≤ 5 行,具体到文件和内容
自主执行变更 / 打断工作流 等用户确认;附在回复末尾

Read the full file on GitHub · 142 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 142 lines · 55 tokens per session scan A 0d1bc1efb983

Subscribe to this mod's changes

self-refinement is a skill published in the GitHub repository davidYichengWei/agentic-engineering-framework (159 stars, last pushed 5mo ago), licensed MIT. It adds 55 tokens to every session and 1,318 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

systematic-debugging

Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes.

obra/superpowers · 21 tokens

brainstorming

You MUST use this before any creative work - creating features, building components, adding functionality, or modifying behavior. Explores user intent, requirements and design before implementation.

obra/superpowers · 37 tokens

chat-pet-sprite-creation

Use when creating or changing VS Code chat pet sprite art, sprite sheets, state animations, eye treatments, Stable/Insiders variants, or pet transitions under src/vs/workbench/contrib/chat/browser/widget/media/chatPet.

microsoft/vscode · 53 tokens

cpu-profile-analysis

Analyze V8/Chrome CPU profiles (.cpuprofile) and DevTools trace files (Trace-.json). Use when: profiling performance, investigating slow functions, comparing code paths, finding bottlenecks, analyzing timeToRequest, understanding call trees from sampling profiler data, analyzing layout/paint/rendering, investigating…

microsoft/vscode · 71 tokens

agent-host-chat-contributions

Build and review cross-cutting agent-host chat behavior through lifecycle contributions. Use when adding turn lifecycle side effects, prompt or context injection, restored-history transformation, protocol-action observation, or when reviewing changes that add code to AgentSideEffects or AgentService.

microsoft/vscode · 56 tokens

auto-perf-optimize

Run agent-driven VS Code performance or memory investigations. Use when asked to launch Code OSS, automate a VS Code scenario, run the Chat memory smoke runner, capture renderer heap snapshots, take workflow screenshots, compare run summaries, or drive a repeatable scenario before heap-snapshot analysis.

microsoft/vscode · 62 tokens