编程

Self-Refine Reflection

试用

Systematically review and iteratively refine your response for logic, accuracy, completeness, conciseness, actionability, and consistency before delivering.

它能做什么

An AI agent skill for systematic self-reflection and iterative output refinement. Based on Madaan et al. (2023), Shinn et al. (2023), and Andrew Ng's Reflection design pattern.

技能文档

Self-Refine Reflection Skill

An AI agent skill for systematic self-reflection and iterative output refinement. Based on Madaan et al. (2023), Shinn et al. (2023), and Andrew Ng's Reflection design pattern.

Platform Auto-Detection

At skill load time, detect your runtime environment and adjust capabilities:

CapabilityHow to CheckFallback
File systemCan you read references/reflection-templates.md?Use the inline templates below instead
Persistent memoryCan you write to memory/?Store reflection notes in conversation context only
Long contextIs your context window > 32K tokens?Cap at Level 2 (skip adversarial review)
Tool accessCan you call external tools?Use mental verification only

Detection rules:

  • If you can read this file's references/ directory → full mode (all levels + memory)
  • If you can read files but not write → full levels, in-conversation memory only
  • If you cannot read files at all → use inline templates (copied below), cap at Level 2
  • If context is limited (< 8K usable) → default to Level 1, max Level 2

This means every platform gets the best possible experience automatically — no manual configuration needed.

Inline Reflection Templates (for environments without file access)

If you cannot read references/reflection-templates.md, use these directly:

Level 1 Internal Prompt

Review drafted response: (1) Did I answer everything? (2) Logic gaps? (3) Can I cut 20%? (4) User can act on this? Fix → Deliver.

Level 2 Internal Prompt

For each dimension (Logic / Facts / Completeness / Conciseness / Actionability / Consistency):
  - Quote exact sentences with issues
  - Rate: Critical / Minor / Pass
Fix ALL Critical. Fix Minor if straightforward. Re-read once. Deliver.

Level 3 Internal Prompt

Round 1: Level 2 review.
Round 2: "If a domain expert attacked this, what would they target?" Fix valid attacks.
Round 3: Did fixes introduce new issues? If stable → deliver. If not → fix and deliver.

When to Activate

Activate when you are about to deliver a final response to the user, after you've gathered all information and formed your answer. Reflection happens before delivery, not instead of work.

Core Loop: GENERATE → CRITIQUE → REFINE → CHECK

1. GENERATE  — Produce your initial response as normal
2. CRITIQUE  — Apply the reflection framework (depth-dependent)
3. REFINE    — Fix every issue found in CRITIQUE
4. CHECK     — If issues remain AND within budget, loop to step 2
              — If clear OR budget exhausted, deliver

Source: Madaan et al., "Self-Refine: Iterative Refinement with Self-Feedback" (2023) — the same LLM acts as generator, critic, and refiner.


Reflection Dimensions

Every critique examines the response across these dimensions. Not all apply to every response — skip irrelevant ones silently.

#DimensionWhat to CheckSignal Words
1Logical CompletenessDoes the reasoning chain have gaps? Are conclusions supported by premises?"therefore" without prior evidence, jumps in logic
2Factual AccuracyAre there unverified assertions? Claims that could be wrong?Specific numbers, dates, names, "everyone knows..."
3Response CompletenessDid I address every part of the user's question? Are there sub-questions I ignored?Multiple questions in user message, implicit needs
4ConcisenessIs there redundancy? Can paragraphs be merged? Are there filler phrases?"It's important to note that", "In conclusion", repeated points
5ActionabilityCan the user act on this immediately? Or do they need to ask follow-ups?Vague advice without steps, missing specifics
6Internal ConsistencyDo any parts of my response contradict each other?Conflicting recommendations, contradictory statements

Reflection Depth Levels

The depth is determined by task complexity, not user preference. The agent auto-selects.

Level 0: Quick Scan (Skip formal reflection)

Trigger: Simple factual lookups, greetings, trivial questions, single-sentence answers.

Action: Do nothing extra. Just respond. Cost: 0 additional tokens.

Examples: "What time is it?", "Thanks", simple formatting requests.

Level 1: Standard Review

Trigger: Medium-complexity tasks — explanations, how-to guides, code snippets, multi-paragraph responses.

Action: One pass through all 6 dimensions mentally. Fix issues. Deliver.

Budget: 1 refinement round. ~15-20% overhead on response tokens.

Internal process:

After drafting your response, ask yourself:
- Did I answer everything they asked?
- Any logical gaps or contradictions?
- Can I cut 20% of the words without losing meaning?
- Would the user know exactly what to do next?
Fix → Deliver.

Level 2: Deep Audit

Trigger: Complex tasks — technical architectures, multi-step plans, research summaries, anything with 5+ distinct claims.

Action: Explicit dimension-by-dimension review. One full refinement round with documented issues.

Budget: Up to 2 refinement rounds. ~30% overhead.

Internal process:

Draft response.
For each dimension (1-6):
  - Identify specific issues (quote the exact sentence)
  - Rate severity: Critical / Minor / Pass
If any Critical: refine entire response, then re-check
If only Minor: fix inline, deliver

Level 3: Adversarial Review

Trigger: High-stakes tasks — production code, security decisions, medical/legal adjacent, public-facing content, or user explicitly requests thorough review.

Action: Full audit PLUS an adversarial pass where you actively try to find the weakest point in your response.

Budget: Up to 3 refinement rounds. ~50% overhead.

Internal process:

Draft response.
Round 1: Standard dimension-by-dimension review.
Round 2: Adversarial pass — "If I wanted to prove this response wrong, 
         what would I attack?" Check those attack vectors.
Round 3 (if needed): Verify fixes from Round 2 didn't introduce new issues.

Convergence Rules

Based on the empirical finding from Madaan et al. that "most gains are in the initial iterations":

  1. Maximum 3 refinement rounds regardless of depth level.
  2. Stop early if no Critical or Minor issues found in a round.
  3. Stop early if the changes between rounds are purely stylistic (no substantive improvement).
  4. Diminishing returns rule: If Round N fixes fewer issues than Round N-1, stop after N.

Anti-pattern — DO NOT:

  • Refine forever trying to reach perfection
  • Make changes just to justify another round
  • Re-introduce previously fixed issues

Cost Control Strategy

DepthMax RoundsApprox. Token OverheadWhen to Use
Level 000%Simple Q&A
Level 11~15%Most conversations
Level 22~30%Complex technical
Level 33~50%High-stakes only

Principle: Reflection should cost less than the cost of delivering a wrong answer. For low-stakes responses, skip reflection entirely.


Trigger Conditions Summary

Auto-Trigger (always on)

  • Response exceeds 3 paragraphs → at least Level 1
  • Response makes 3+ factual claims → at least Level 1
  • Response includes code → at least Level 1 (check logic + actionability)

Skip Reflection

  • User is in a hurry (explicit: "quick", "brief", "just tell me")
  • Response is under 2 sentences
  • Pure social/chat exchange

User Manual Trigger

  • User says "think carefully", "double-check", "make sure this is right" → Level 2+
  • User says "this is important", "critical", "production" → Level 3
  • User says "reflect" or "self-refine" → Level 2+

Output Format

Reflection is internal — the user should not see the raw critique. However:

After refinement, you MAY append a subtle note:

Level 1: No note (keep it invisible). Level 2: Optionally: _(response refined via self-review)_ Level 3: Optionally: _(refined through [N]-round adversarial self-review)_

NEVER:

  • Show the actual critique/feedback text to the user
  • Make the note prominent or distracting
  • Add notes for Level 0 or Level 1 responses

Reflexion Memory (Cross-Session Learning)

Inspired by Shinn et al. (2023) — Reflexion stores verbal self-reflections in persistent memory for future tasks.

When to use: After completing a Level 2 or Level 3 reflection where you discovered a significant pattern in your own errors (e.g., "I tend to forget edge cases in X", "I consistently over-explain Y").

How to use: Write a brief note to memory/ capturing the pattern:

Self-reflection: When writing about [topic], I tend to [pattern]. 
Fix: [specific behavior change]. 
Date: [today].

This creates a growing corpus of self-corrections that improve future responses.


Relationship to Other Reflection Techniques

This skill synthesizes multiple academic approaches:

TechniqueSourceWhat We Borrow
Self-RefineMadaan et al. 2023Core GENERATE→CRITIQUE→REFINE loop
ReflexionShinn et al. 2023Persistent memory of self-reflections
Chain-of-VerificationDhuliawala et al. 2023Verification questions for factual claims (Level 2-3)
Self-CalibrationKadavath et al. 2022Confidence assessment of own outputs
Andrew Ng's ReflectionNg 2024Design pattern: agent critiques and improves its own output iteratively
CRITICGou et al. 2023Tool-interactive critiquing (use tools to verify when possible)

Quick Reference Card

REFLECT? ──→ Simple/trivial? ──→ NO → Just respond
    │
    YES
    │
    ├─ Medium complexity → LEVEL 1 (1 round, mental check)
    ├─ Complex / multi-claim → LEVEL 2 (2 rounds, explicit review)
    └─ High-stakes / user requested → LEVEL 3 (3 rounds, adversarial)
    
For each round:
  1. Check 6 dimensions
  2. Fix all issues
  3. Converged? → Deliver
  4. Budget left? → Next round
  5. Budget exhausted → Deliver current version

相关技能

诊断生产力系统反复失效的根因,给出最小干预——容量测算、瓶颈定位、可靠的本地记录。

作者 Iván854 次安装69 星标

在本地磁盘以分类纯 Markdown 文件保存需要长期留存的事实,与智能体内置记忆并存。

作者 Iván555 次安装18 星标

以 AI 机器人身份加入视频会议,提供语音、虚拟形象与屏幕共享四种模式。

作者 johnpatternai21 次安装8 星标

把自然语言描述转为结构化 JSON,并由 mcp-diagram-generator MCP 服务生成 Draw.io、Mermaid 或 Excalidraw 图表文件。

作者 nssa.io1.0k 次安装47 星标

通过一个命令行工具完成多链加密货币交易、钱包管理与 AI 市场分析。

作者 lowesyang162 次安装109 星标

thomaszhou22 的更多技能

浏览全部技能

Use when the user asks to create, improve, fix, or audit a README.md file, score their README, document an open source project, or set up new project docs. Provides 8-dimension 0-100 quality scoring, 5-type template matrix (Library, CLI, App, Skill, Data), and pre-publish checklist. Do NOT use for API docs, wikis, inline code comments, or general technical writing.

作者 thomaszhou225 次安装1 星标

Transform vague user requests into precise, high-quality prompts by matching against a curated library of 2000+ proven prompt templates from multiple GitHub...

作者 thomaszhou2216 次安装

Automatically detects runtime capabilities to self-compose tailored multi-step reasoning structures for complex, multi-module problem solving and analysis ta...

作者 thomaszhou2212 次安装

Diagnose, fix, and prevent agent skill trigger failures. Use when a skill doesn't activate, when skills trigger incorrectly, when troubleshooting "skill not...

作者 thomaszhou224 次安装

Diagnose, fix, and prevent agent skill trigger failures. Use when a skill doesn't activate, when skills trigger incorrectly, when troubleshooting "skill not...

作者 thomaszhou224 次安装

Use when the user asks to optimize, improve, or rewrite a prompt, or when a vague request needs to be turned into a precise instruction. Two engines: 3300+ t...

作者 thomaszhou223 次安装