Codex

reflection-injection

Inject relevant past reflections into agent context at iteration start so agents learn from prior mistakes without repeating them

104 stars

Best use case

reflection-injection is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

It is a strong fit for teams already working in Codex.

Inject relevant past reflections into agent context at iteration start so agents learn from prior mistakes without repeating them

Teams using reflection-injection 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

$curl -o ~/.claude/skills/reflection-injection/SKILL.md --create-dirs "https://raw.githubusercontent.com/jmagly/aiwg/main/.agents/skills/reflection-injection/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/reflection-injection/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How reflection-injection Compares

Feature / Agentreflection-injectionStandard Approach
Platform SupportCodexLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Inject relevant past reflections into agent context at iteration start so agents learn from prior mistakes without repeating them

Which AI agents support this skill?

This skill is designed for Codex.

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.

Related Guides

SKILL.md Source

# reflection-injection

Automatically inject relevant past reflections into agent context when starting new iterations or retrying after failures.

## Triggers


Alternate expressions and non-obvious activations (primary phrases are matched automatically from the skill description):

- "inject reflection" → explicit reflection injection shorthand
- "add metacognition" → metacognitive step insertion

## Purpose

This skill implements the Reflexion episodic memory injection pattern. Before each iteration, it loads relevant past reflections and injects them into the agent's context, enabling learning from past mistakes without repeating them.

## Behavior

When triggered, this skill:

1. **Load reflection history**:
   - Read `.aiwg/ralph/reflections/loops/` for current loop reflections
   - Read `.aiwg/ralph/reflections/patterns/` for cross-loop patterns
   - Apply sliding window: k=5 most recent reflections

2. **Filter for relevance**:
   - Match reflections by task type similarity
   - Match by error type if retrying after failure
   - Match by file/module if working on specific code

3. **Format for injection**:
   - Convert reflections to natural language summary
   - Use @$AIWG_ROOT/agentic/code/addons/ralph/templates/self-reflection-prompt.md template
   - Prepend to agent context

4. **Track usage**:
   - Record which reflections were injected
   - Track whether injected reflections led to success
   - Update pattern effectiveness scores

## Activation Conditions

```yaml
activation:
  always_active_for:
    - ralph-loop-orchestrator
    - ralph-verifier

  triggered_by:
    - ralph_iteration_start
    - agent_retry_after_failure
    - explicit_user_request

  skip_when:
    - no_reflection_history: true
    - first_iteration_of_first_loop: true
```

## Integration

This skill uses:
- `project-awareness`: Context for relevance filtering
- Agent Loop Orchestrator: Provides iteration state
- Reflection memory at `.aiwg/ralph/reflections/`

## References

- @$AIWG_ROOT/agentic/code/addons/ralph/schemas/reflection-memory.json - Schema
- @$AIWG_ROOT/agentic/code/addons/ralph/docs/reflection-memory-guide.md - Guide
- @$AIWG_ROOT/agentic/code/addons/ralph/templates/self-reflection-prompt.md - Prompt template
- @.aiwg/research/findings/REF-021-reflexion.md - Research foundation

Related Skills

aiwg-orchestrate

104
from jmagly/aiwg

Route structured artifact work to AIWG workflows via MCP with zero parent context cost

venv-manager

104
from jmagly/aiwg

Create, manage, and validate Python virtual environments. Use for project isolation and dependency management.

pytest-runner

104
from jmagly/aiwg

Execute Python tests with pytest, supporting fixtures, markers, coverage, and parallel execution. Use for Python test automation.

vitest-runner

104
from jmagly/aiwg

Execute JavaScript/TypeScript tests with Vitest, supporting coverage, watch mode, and parallel execution. Use for JS/TS test automation.

eslint-checker

104
from jmagly/aiwg

Run ESLint for JavaScript/TypeScript code quality and style enforcement. Use for static analysis and auto-fixing.

repo-analyzer

104
from jmagly/aiwg

Analyze GitHub repositories for structure, documentation, dependencies, and contribution patterns. Use for codebase understanding and health assessment.

pr-reviewer

104
from jmagly/aiwg

Review GitHub pull requests for code quality, security, and best practices. Use for automated PR feedback and approval workflows.

YouTube Acquisition

104
from jmagly/aiwg

yt-dlp patterns for acquiring content from YouTube and video platforms

Quality Filtering

104
from jmagly/aiwg

Accept/reject logic and quality scoring heuristics for media content

Provenance Tracking

104
from jmagly/aiwg

W3C PROV-O patterns for tracking media derivation chains and production history

Metadata Tagging

104
from jmagly/aiwg

opustags and ffmpeg patterns for applying metadata to audio and video files

Audio Extraction

104
from jmagly/aiwg

ffmpeg patterns for extracting audio from video files and transcoding between formats