Reflection injection

From jmagly/aiwg · View interactive version

Reflection injection is an AI agent skill from the GitHub repository jmagly/aiwg. Inject relevant past reflections into agent context at iteration start so agents learn from prior mistakes without repeating them

How to use this skill

Skill file

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):

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:
  1. Filter for relevance:
  1. Format for injection:
  1. Track usage:

Activation Conditions

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:

References

Storage Routing (#934, #967)

This skill's persistence flows through resolveStorage('reflections'). On the default fs backend reflections live at .aiwg/reflections/. To redirect into Obsidian, Logseq, Fortemi, or another backend without changing this skill, configure roots.reflections or backends.reflections in .aiwg/storage.config (#934).

When this skill needs to read/write reflections from a Bash step, prefer the storage-routed CLI:

aiwg reflections list --prefix sessions/
aiwg reflections get sessions/2026-04-28.md
echo "# reflection" | aiwg reflections put sessions/2026-04-28.md
echo '{"event":"reflect","summary":"..."}' | aiwg reflections append-log sessions/log.jsonl

The legacy direct-fs paths continue to work on the default fs backend — byte-identical to what the adapter writes — but only the adapter route honors storage.config redirection.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.