Agent skill

Self-Refinement from Corrections

by davidYichengWei in davidYichengWei/agentic-engineering-framework

Turns mistakes you correct into proposed updates to persistent Rules and Skills so the same error does not recur in later sessions, triggered automatically or with /reflect.

MITAuto-check passedAgent Workflows

SKILL.md written in Chinese; this summary is our English description.

Install Self-Refinement from Corrections

skills CLI
$ npx skills add davidYichengWei/agentic-engineering-framework --skill self-refinement -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install davidYichengWei/agentic-engineering-framework self-refinement --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/davidYichengWei/agentic-engineering-framework.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/self-refinement .claude/skills/self-refinement && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
self-refinement
GitHub stars
158
Token cost
~575 tokens
SKILL.md length
153 words
Files
2
Skills in repo
14
Repo updated
First seen
Licence
MIT

At a glance

Turns mistakes you correct into proposed updates to persistent Rules and Skills so the same error does not recur in later sessions, triggered automatically or with /reflect.

  • Works in 6 steps: 识别错误模式 → 诊断根因 → 检索现有知识 → …
  • The agent repeats a mistake you already corrected in an earlier session
  • SKILL.md covers 核心定位, 触发模式, 核心闭环 and 强制规则, plus 2 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

A model keeps no memory across sessions, so a mistake corrected in one session can reappear in the next. This skill moves the lesson into persistent context. It triggers in two ways: automatically when you correct the agent in a pattern-like way, in which case it finishes the current correction first and then appends at most three lightweight suggestions to the end of its reply, or manually with `/reflect`, which reviews the whole conversation for corrected mistake patterns.

Each case follows one loop. The agent identifies the wrong output, the intended direction and the gap, diagnoses the root cause as a missing rule, missing knowledge, a skipped workflow step or a wrong thinking pattern, searches existing Rules and Skills to decide between amending and creating, and writes a suggestion naming the cause and target file. Nothing is changed without your confirmation; you can accept all suggestions or pick some. A reference file holds typical examples.

When your agent uses it

  • The agent repeats a mistake you already corrected in an earlier session
  • Reviewing a conversation to capture lessons as rules or skill updates
  • Deciding whether a correction belongs in a Rule, a Skill or project knowledge

Example prompts

  • “/reflect and propose rules from the corrections I made today”
  • “You keep ignoring our naming convention, so write down which rule is missing.”
  • “Review this session and tell me which corrections should become persistent rules.”

Requirements

  • A project with Rules or Skills files the agent can update

Workflow steps

6 steps, taken from the step headings in SKILL.md.

  1. 识别错误模式
  2. 诊断根因
  3. 检索现有知识
  4. 生成建议
  5. 用户确认
  6. 执行更新

What it can do on your machine

Read from SKILL.md and the folder at commit 1f7ac0f. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are markdown).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Self-Refinement from Corrections loads about 575 tokens when it runs. Until then it costs about 24 tokens; SKILL.md has 153 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~24
When it runs · the whole SKILL.md, loaded when a task matches
~575

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from davidYichengWei/agentic-engineering-framework at commit 1f7ac0f, republished under its MIT licence (© davidYichengWei). 153 words, ~575 tokens.

Download SKILL.mdSave it as .claude/skills/self-refinement/SKILL.md (or your agent's skills folder). This skill also uses 1 other file; get the full folder from GitHub.
name
self-refinement
description
将纠错经验沉淀为持久化的 Rules/Skills 更新,构建反馈闭环。当被用户纠正且错误具有模式性时自动触发,或通过 /reflect 命令手动触发回顾。

经验沉淀 (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: 生成建议

每条建议包含:

markdown
### 建议 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 行,具体到文件和内容
自主执行变更 / 打断工作流等用户确认;附在回复末尾

参考资料

© davidYichengWei, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 1 other file in skills/self-refinement of davidYichengWei/agentic-engineering-framework.

  • SKILL.md
  • reference/refinement-examples.md

Open the folder on GitHubat commit 1f7ac0f

Compare with similar skills

Self-Refinement from Corrections next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Self-Refinement from Corrections compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Self-Refinement from Corrections this skilldavidYichengWei/agentic-engineering-framework158—~575Automated safety check: PassMIT
Using Agent Skillsaddyosmani/agent-skills102k4 repos~2.4kAutomated safety check: PassMIT
Neat-Freak Knowledge CloseoutKKKKhazix/khazix-skills21k—~1.9kAutomated safety check: PassMIT
Task Observerrebelytics/one-skill-to-rule-them-all3.2k1 repos~12kAutomated safety check: PassCC-BY-4.0
SkillOpt Sleep Cyclemicrosoft/SkillOpt18k—~2.3kAutomated safety check: PassMIT
CLAUDE.md Improveranthropics/claude-plugins-official37k5 repos~1.5kAutomated safety check: PassApache-2.0

Similar skills

  • Using Agent Skills

    addyosmani/agent-skills

    Meta-skill for choosing which workflow skill fits the task at hand, plus always-on habits: surface assumptions, stop on confusion, push back, keep it simple and stay in scope.

    102k GitHub starsUsed in 4 repos~2.4k tokens
    Agent WorkflowsAuto-check passed
  • Neat-Freak Knowledge Closeout

    KKKKhazix/khazix-skills

    Brings project docs, agent rule files, authorized memory and leftover workspace files back in line with what the code and runtime actually do at the end of a work session.

    21k GitHub stars~1.9k tokensUpdated 6 days ago
    Agent WorkflowsAuto-check passed
  • Task Observer

    rebelytics/one-skill-to-rule-them-all

    Monitors task execution for skill improvement opportunities.

    3.2k GitHub starsUsed in 1 repo~12k tokens
    Agent WorkflowsAuto-check passed
  • SkillOpt Sleep Cycle

    microsoft/SkillOpt

    Official

    Runs an on-demand or nightly sleep cycle that reviews past Claude Code sessions and proposes validated updates to CLAUDE.md and skills.

    18k GitHub stars~2.3k tokensUpdated yesterday
    Agent WorkflowsAuto-check passed
  • CLAUDE.md Improver

    anthropics/claude-plugins-official

    Official

    Finds every CLAUDE.md file in a repository, scores each against quality criteria, shows a report, then makes targeted updates after you approve.

    37k GitHub starsUsed in 5 repos~1.5k tokens
    Agent WorkflowsAuto-check passed
  • Official

    Runs a nightly or on-demand sleep cycle for a local Codex agent: review past sessions, replay recurring tasks and stage validated skill and memory edits for adoption.

    18k GitHub stars~2.3k tokensUpdated yesterday
    Agent WorkflowsAuto-check passed

More from davidYichengWei/agentic-engineering-framework

All 14 skills in this repo
  • Architecture Design Principles

    davidYichengWei/agentic-engineering-framework

    Gives architecture design principles for system design discussions and code review: module boundaries, dependency direction, data ownership and interface rules, plus a checklist.

    158 GitHub stars~545 tokensUpdated 6 mo ago
    Auto-check passed
  • General Coding Best Practices

    davidYichengWei/agentic-engineering-framework

    A checklist of language-neutral rules for writing and reviewing code: naming, function design, control flow, resource safety, comments and logging.

    158 GitHub stars~631 tokensUpdated 6 mo ago
    Auto-check passed
  • Component Design Principles

    davidYichengWei/agentic-engineering-framework

    Chinese-language checklists for component-level design: class and module structure, public interfaces, data models, concurrency and error handling.

    158 GitHub stars~1k tokensUpdated 6 mo ago
    Auto-check passed
  • Skill Authoring Guide (Chinese)

    davidYichengWei/agentic-engineering-framework

    Chinese-language guide to writing and improving SKILL.md files: frontmatter rules, concise writing, progressive disclosure, common patterns and a pre-release checklist.

    158 GitHub stars~788 tokensUpdated 6 mo ago
    Auto-check passed
  • Root-Cause Troubleshooting

    davidYichengWei/agentic-engineering-framework

    Diagnoses compile errors, runtime exceptions, failing tests, pipeline failures and production alerts from code and logs, giving a root cause before any fix.

    158 GitHub stars~646 tokensUpdated 6 mo ago
    Auto-check passed
  • Workflow Code Generation

    davidYichengWei/agentic-engineering-framework

    代码文件修改的统一入口。当用户请求任何代码变更(新功能、优化、Bug 修复、重构)时必须首先调用此 skill。仅适用于代码文件(如 .cc/.cpp/.h/.go/.py 等),修改 .md 等非代码文件时不需要调用。它会评估复杂度、检查 spec.md、生成 tasks.md、并逐个任务执行。

    158 GitHub stars~733 tokensUpdated 6 mo ago
    Auto-check passed

Categories

Questions about Self-Refinement from Corrections

What does Self-Refinement from Corrections do?

Turns mistakes you correct into proposed updates to persistent Rules and Skills so the same error does not recur in later sessions, triggered automatically or with /reflect. A model keeps no memory across sessions, so a mistake corrected in one session can reappear in the next. This skill moves the lesson into persistent context.

When should I use Self-Refinement from Corrections?

Self-Refinement from Corrections fits situations like: the agent repeats a mistake you already corrected in an earlier session; reviewing a conversation to capture lessons as rules or skill updates; deciding whether a correction belongs in a Rule, a Skill or project knowledge.

How do I install Self-Refinement from Corrections in Claude Code?

Run `npx skills add davidYichengWei/agentic-engineering-framework --skill self-refinement -a claude-code`. Or copy the skill folder (skills/self-refinement in davidYichengWei/agentic-engineering-framework) into .claude/skills/self-refinement in your project. Claude Code loads it when a task matches its description.

How do I install Self-Refinement from Corrections in Codex?

Run `npx skills add davidYichengWei/agentic-engineering-framework --skill self-refinement -a codex`. Or copy the skill folder (skills/self-refinement in davidYichengWei/agentic-engineering-framework) into .agents/skills/self-refinement in your project. Codex loads it when a task matches its description.

Can I use Self-Refinement from Corrections in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add davidYichengWei/agentic-engineering-framework --skill self-refinement -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/self-refinement, .gemini/skills/self-refinement, .github/skills/self-refinement and .opencode/skills/self-refinement in your project.

What does Self-Refinement from Corrections need to run?

SKILL.md names no scripts, command-line tools or credentials: Self-Refinement from Corrections is instructions for the agent only. Our summary lists: A project with Rules or Skills files the agent can update.

Does Self-Refinement from Corrections access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Self-Refinement from Corrections safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Self-Refinement from Corrections use?

Self-Refinement from Corrections is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Self-Refinement from Corrections use?

About 575 tokens (SKILL.md is roughly 2.3k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Self-Refinement from Corrections?

Skills that share tags, products or a category with Self-Refinement from Corrections: Using Agent Skills (addyosmani/agent-skills, 102k stars), Neat-Freak Knowledge Closeout (KKKKhazix/khazix-skills, 21k stars), Task Observer (rebelytics/one-skill-to-rule-them-all, 3.2k stars) and SkillOpt Sleep Cycle (microsoft/SkillOpt, 18k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Self-Refinement from Corrections?

davidYichengWei (a GitHub user) maintains it in davidYichengWei/agentic-engineering-framework, which has 158 GitHub stars. The repository holds 14 skills in this directory. The repository was last updated on March 25, 2026.

Source: davidYichengWei/agentic-engineering-framework on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.