Agent skill

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'.

Stars 5
Forks 2

Install this agent skill to your Project

npx add-skill https://github.com/axiomantic/spellbook/tree/main/skills/reflexion

SKILL.md

Reflexion

Reasoning Schema

Before analysis: feature name, stage, iteration number, feedback items, previous patterns.

After analysis: root causes identified, reflections stored, patterns checked, retry guidance generated.

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

  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"


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>

Expand your agent's capabilities with these related and highly-rated skills.

axiomantic/spellbook

spellbook-auditing

Meta-audit skill for spellbook development. Spawns parallel subagents to factcheck docs, optimize instructions, find token savings, and identify MCP candidates. Produces actionable report.

5 2
Explore
axiomantic/spellbook

documentation-updates

Use after modifying library skills, library commands, or agents to ensure CHANGELOG, README, and docs are updated

5 2
Explore
axiomantic/spellbook

project-encyclopedia

[DEPRECATED] Use project-level AGENTS.md files instead. Previously used for first-session codebase onboarding and persistent glossary creation.

5 2
Explore
axiomantic/spellbook

reviewing-impl-plans

Use when reviewing implementation plans before execution. Triggers: 'is this plan solid', 'review the plan', 'check before I start building', 'anything missing from this plan', 'will this plan work', 'audit the implementation plan'. NOT for: reviewing design documents (use reviewing-design-docs) or creating plans (use writing-plans).

5 2
Explore
axiomantic/spellbook

session-resume

Session resume protocol and session repairs handling. Loaded when spellbook_session_init returns resume_available: true, or when session_init returns a repairs array. Triggers: 'resume', 'continue', 'where were we', session resume, session repairs.

5 2
Explore
axiomantic/spellbook

brainstorming

Use when exploring design approaches, generating ideas, or making architectural decisions. Triggers: 'explore options', 'what are the tradeoffs', 'how should I approach', 'let's think through', 'sketch out an approach', 'I need ideas for', 'how would you structure', 'what are my options'. Also invoked by develop when design decisions are needed.

5 2
Explore

Didn't find tool you were looking for?

Be as detailed as possible for better results