reflexion
Invoked by develop when iteration feedback requires a retry, not directly by users. Prevents repeating the same mistakes across attempts. Also relevant when: 'why did this fail again', 'same error twice', 'what should I do differently', 'keep making the same mistake'.
Best use case
reflexion is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Invoked by develop when iteration feedback requires a retry, not directly by users. Prevents repeating the same mistakes across attempts. Also relevant when: 'why did this fail again', 'same error twice', 'what should I do differently', 'keep making the same mistake'.
Teams using reflexion should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/reflexion/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How reflexion Compares
| Feature / Agent | reflexion | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Invoked by develop when iteration feedback requires a retry, not directly by users. Prevents repeating the same mistakes across attempts. Also relevant when: 'why did this fail again', 'same error twice', 'what should I do differently', 'keep making the same mistake'.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# Reflexion
<ROLE>
Learning Specialist for iterative development. When validation fails, you analyze what went wrong, extract lessons, store them for future reference, and guide the next attempt. Your reputation depends on ensuring the same mistake never happens twice. Failure is data; repeated failure is negligence.
</ROLE>
## Reasoning Schema
<analysis>Before analysis: feature name, stage, iteration number, feedback items, previous patterns.</analysis>
<reflection>After analysis: root causes identified, reflections stored, patterns checked, retry guidance generated.</reflection>
## Invariant Principles
1. **Every Failure Teaches**: ITERATE verdicts contain actionable information.
2. **Patterns Over Instances**: Single failures are learning; repeated failures are patterns.
3. **Root Cause Focus**: Symptoms are feedback; causes are lessons.
4. **Knowledge Accumulates**: Reflections persist across iterations and features.
5. **Guidance Prevents Repetition**: Next attempt must address previous failure.
## Inputs / Outputs
| Input | Required | Description |
|-------|----------|-------------|
| `feature_name` | Yes | Feature that received ITERATE verdict |
| `feedback` | Yes | List of feedback items from roundtable |
| `stage` | Yes | Stage where iteration occurred |
| `iteration_number` | Yes | Current iteration count |
| Output | Type | Description |
|--------|------|-------------|
| `reflection_record` | Database | Stored in forged.db reflections table |
| `root_cause_analysis` | Inline | What went wrong and why |
| `retry_guidance` | Inline | Specific guidance for next attempt |
---
## Phase Sequence
### Steps 1-3: Full Analysis Pipeline
**Dispatch subagent** with command: `reflexion-analyze`
The subagent executes the complete analysis pipeline:
1. **Parse Feedback** - Extract structured fields from each feedback item
2. **Categorize Root Cause** - Map failures to root cause categories (Incomplete Analysis, Misunderstanding, Technical Gap, Scope Creep, Quality Shortcut, Integration Blind Spot)
3. **Root Cause Questions** - Answer expected vs actual, why deviation occurred, what would have prevented it
4. **Store Reflections** - Write to forged.db with PENDING status
5. **Generate Retry Guidance** - Produce specific correction guidance for the re-invoked skill
---
## Pattern Detection
| Pattern | Threshold | Alert |
|---------|-----------|-------|
| Same failure, same feature | 2 iterations | "Root cause not addressed" |
| Same failure, different features | 3 features | "Systemic pattern" |
| Same validator, different failures | 3 failures | "Validator focus area needs attention" |
---
## Integration with Develop Workflow
**Trigger**: `forge_iteration_return` with ITERATE verdict
**Flow**: Roundtable ITERATE -> `forge_iteration_return` -> reflexion skill -> analyze + store + check patterns + generate guidance -> return to develop orchestrator -> re-select and re-invoke skill
---
## Escalation
After 3 iterations on same stage with same root cause: mark ESCALATED, report attempts made, recommend human intervention.
---
## Example
<example>
Feedback: Hermit flags "No input validation on API endpoint"
1. Parse: source=Hermit, severity=blocking, stage=IMPLEMENT
2. Categorize: Quality Shortcut (missing validation)
3. Root cause: Rushed implementation, skipped security checklist
4. Store reflection with status=PENDING
5. Pattern check: Hermit flagged validation 2x before -> alert
6. Generate guidance: "Add input validation to all endpoints before resubmit"
</example>
---
<FORBIDDEN>
- Ignoring feedback severity (blocking must block)
- Surface-level analysis (symptoms, not causes)
- Generic lessons ("be more careful")
- Skipping pattern detection
- Failing to store reflections in database
- Allowing 4+ iterations without escalation
</FORBIDDEN>
---
## Self-Check
- [ ] All feedback items analyzed for root cause
- [ ] Root causes categorized (not just described)
- [ ] Reflections stored with PENDING status
- [ ] Pattern check performed
- [ ] Retry guidance includes specific corrections
- [ ] Escalation evaluated if iteration >= 3
If ANY unchecked: complete before returning.
---
<FINAL_EMPHASIS>
Failure is information. The roundtable said ITERATE because something was wrong. Your job is to understand WHY, not just WHAT. Store the lesson. Check for patterns. Guide the retry. The same mistake twice is repetition, not learning.
</FINAL_EMPHASIS>Related Skills
writing-skills
Use when creating new skills, editing existing skills, or verifying skills work before deployment. Triggers: 'write a skill', 'new skill', 'create a skill', 'skill doesn't work', 'skill isn't firing', 'edit skill', 'skill quality'. NOT for: general prompt improvement (use instruction-engineering) or command creation (use writing-commands).
writing-plans
Use when you have a spec, design doc, or requirements and need a detailed implementation plan before coding. Triggers: 'write a plan', 'create implementation plan', 'plan this out', 'break this down into steps', 'convert design to tasks', 'implementation order'. Also invoked by develop during planning. NOT for: reviewing existing plans (use reviewing-impl-plans).
writing-commands
Use when creating new commands, editing existing commands, or reviewing command quality. Triggers: 'write command', 'new command', 'create a command', 'review command', 'fix command', 'command doesn't work', 'add a slash command'. NOT for: skill creation (use writing-skills).
verifying-hunches
Use when about to claim discovery during debugging. Triggers: "I found", "this is the issue", "I think I see", "looks like the problem", "that's why", "the bug is", "root cause", "culprit", "smoking gun", "aha", "got it", "here's what's happening", "the reason is", "causing the", "explains why", "mystery solved", "figured it out", "the fix is", "should fix", "this will fix". Also invoked by debugging, scientific-debugging, systematic-debugging before any root cause claim.
using-skills
System skill loaded at session start to initialize skill routing. Not invoked directly by users. Also useful when: 'which skill should I use', 'what skill handles this', 'wrong skill fired', 'skill didn't trigger'.
using-lsp-tools
Use when mcp-language-server tools are available and you need semantic code intelligence. Triggers: 'find definition', 'find references', 'who calls this', 'rename symbol', 'type hierarchy', 'go to definition', 'where is this used', 'where is this defined', 'what type is this'. Provides navigation, refactoring, and type analysis via LSP.
using-git-worktrees
Use when starting feature work that needs isolation from current workspace, or setting up parallel development tracks. Triggers: 'worktree', 'separate branch', 'isolate this work', 'don't mess up current work', 'work on two things at once', 'parallel workstreams', 'new branch for this', 'keep my current work safe'.
tooling-discovery
Use when looking for available tools, MCP servers, or CLI utilities for a task. Triggers: 'what tools do I have', 'is there an MCP for this', 'what's available', 'find a tool for', 'discover tooling', 'what CLI tools exist'. NOT for: documenting existing tools (use documenting-tools).
testing-strategy
Test selection strategy and scope guidance. Triggers: 'which tests should I run', 'test tiers', 'test marks', 'slow tests', 'integration vs unit', 'cross-module regression', 'test scope', 'what should I run', 'select tests', 'test batching'. NOT for: writing tests (use test-driven-development) or fixing broken tests (use fixing-tests).
test-driven-development
Use when user explicitly requests test-driven development. Triggers: 'TDD', 'write tests first', 'red green refactor', 'test-first', 'start with the test'. Also invoked by develop and executing-plans for implementation tasks. NOT for: full feature work (use develop, which includes TDD internally).
tarot-mode
Use when session returns mode.type='tarot', user says '/tarot', or requests roundtable dialogue with archetypes. Triggers: '/tarot', 'use tarot mode', 'roundtable with archetypes', 'tarot personas'. Session-level mode, not task-level.
smart-reading
Behavioral protocol for reading files or command output of unknown size. Loaded automatically for all file reading operations. Also triggered by: 'this file is huge', 'output was cut off', 'large file', 'how should I read this', 'truncated output', 'missing data from file'.