reflect

reflect is a command for Claude Code, Codex from PGHH84/claude-layered-learning. It costs 22 tokens per session (1,964 once invoked), scanned A, original, MIT.

A command that examines diary entries from previous coding sessions and finds patterns, contradictions, and repeated mistakes. It can propose lasting updates to project or global instructions.

In plain words
What is it for?
Use it to review recent or filtered diary entries, identify recurring problems, and apply approved changes to a repository's CLAUDE.md or shared project instructions.
Why use it?
Useful lessons can remain buried in old notes, while instructions can become inconsistent or outdated. This command helps turn repeated observations into maintained guidance.

Command for Claude CodeCodex

Written for Claude Code and Codex: PreCompact hook event, but also reads ~/.codex or $CODEX_HOME. Also seen: reads .claude/ paths; mentions CLAUDE.md; mentions AGENTS.md.

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/pghh84/claude-layered-learning/reflect
Clone the repo
git clone --depth 1 https://github.com/PGHH84/claude-layered-learning

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for reflect

README.md
[![agentmods](https://agentmods.dev/badge/commands/pghh84/claude-layered-learning/reflect.svg)](https://agentmods.dev/commands/pghh84/claude-layered-learning/reflect)
Your own site
<a href="https://agentmods.dev/commands/pghh84/claude-layered-learning/reflect"><img src="https://agentmods.dev/badge/commands/pghh84/claude-layered-learning/reflect.svg" alt="Measured on agentmods" height="20"></a>
Per session 22 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,964 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00022 $0.01964
Opus 5 $0.00011 $0.00982
Sonnet 5 $0.00004 $0.00393
Haiku 4.5 $0.00002 $0.00196

Measured 6d ago against content hash 202ca9608eb5, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

reflect scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 6d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

commands/reflect.md · 250 lines

How it starts

The opening of the file, as written. The whole thing — 250 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Reflect on Diary Entries and Synthesize Insights

Analyze accumulated diary entries to identify recurring patterns across sessions and projects, then route durable learnings to the canonical local or global instruction source.

/reflect:

  • reads diary entries and supporting memory
  • identifies repeated patterns, rule violations, contradictions, and one-off observations
  • proposes durable promotions to repo CLAUDE.md or ~/.agents/global/PROJECT.md
  • applies approved durable promotions in the same reflection flow

Parameters

The user can provide:

  • Date range: "from YYYY-MM-DD to YYYY-MM-DD" or "last N days"
  • Entry count: "last N entries" (for example "last 10 entries")
  • Project filter: "for project [project-path]"
  • Pattern filter: "related to [keyword]"

Default: analyze all unprocessed diary entries.

Runtime Paths

  • diary input: ~/.claude/memory/diary/
  • reflections: ~/.claude/memory/reflections/
  • processed index: ~/.claude/memory/reflections/processed.log
  • project memory: ~/.claude/projects/<slug>/memory/MEMORY.md
  • project operating guidance source: repo CLAUDE.md
  • global operating guidance source: ~/.agents/global/PROJECT.md
  • generated global mirrors: ~/.claude/CLAUDE.md, ~/.codex/AGENTS.md

Path-To-Slug Transform

Use this exact transform so /reflect, /diary, wrap-up, and the PreCompact hook agree on project identity:

  1. If inside a git repository, resolve the canonical project root with git rev-parse --show-toplevel.
  2. If that repo root contains /.worktrees/, strip the /.worktrees/<name> suffix and use the parent repo path as the canonical project root.
  3. Otherwise, if not inside a git repository, use the canonical absolute working directory.
  4. Resolve symlinks before deriving the slug.
  5. Replace every / in the canonical absolute path with -.

Processing Workflow

  1. Resolve the filter set and project slug mapping using the shared path-derived slug rule.
  2. Load matching diary entries from ~/.claude/memory/diary/.
  3. Skip entries already listed in processed.log unless the user explicitly requests reprocessing.
  4. Read supporting context relevant to the filtered corpus:
    • recent reflections
    • ~/.claude/memory/reflections/processed.log
    • project ~/.claude/projects/<slug>/memory/MEMORY.md when project context is relevant
    • repo CLAUDE.md when project operating-guidance candidates are being considered
    • canonical global ~/.agents/global/PROJECT.md when evaluating global promotion candidates
  5. Group repeated patterns, explicit rule violations, contradictions, and one-off observations.
  6. Carry forward recent one-off observations from prior reflections when the same signal reappears.
  7. Prioritize repeated violation of existing guidance over inventing a new rule.
  8. Route each repeated learning by scope and destination, strengthening weak existing guidance before proposing a brand-new durable rule.
  9. Write the reflection file to ~/.claude/memory/reflections/YYYY-MM-DD-reflection-N.md.
  10. Present proposed durable edits with destination, evidence, and confidence.
  11. If the user approves any durable edits, apply them in the same flow.
  12. If approved global canonical edits were applied, run ~/.agents/global/sync_global_instructions.sh.
  13. Update processed.log only after the user accepts the reflection pass as complete and any approved durable edits for that pass were applied.

Read the full file on GitHub · 250 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 6d ago First seen · 250 lines · 22 tokens per session scan A 202ca9608eb5

Subscribe to this mod's changes

reflect is a command published in the GitHub repository PGHH84/claude-layered-learning (2 stars, last pushed 5mo ago), licensed MIT. It adds 22 tokens to every session and 1,964 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.