Reflect
Turn one session's friction into every future session's head start. Reflect
reviews what actually happened — corrections, retries, rediscovered facts,
wasted tokens — and converts it into small, concrete improvements that
compound: rules, skills, commands, scripts, delegation, and leaner context.
Designed to be hands-off: run it at the end of a session or on a schedule,
and it applies safe improvements itself, queues risky ones as proposals, and
tracks everything in .reflect/ so the next run builds on the last.
Inputs
Accept any of these; with no argument, reflect on the current conversation
and working directory:
- The current visible session (default).
- A path to a session transcript (JSONL or plain text).
- A pasted transcript or log excerpt.
- A scope hint like "last 3 sessions" or "this week" when state exists.
For JSONL transcripts, build a neutral inventory first instead of reading the
raw file:
python3 scripts/session_inventory.py <transcript.jsonl>
(Resolve scripts/ relative to this skill's directory.) The inventory shows
turns, tool-call frequency, errors/retries, and the largest tool outputs —
use it to target which raw evidence to read. Never keyword-scan a whole
transcript.
State: the .reflect/ folder
Cross-session memory lives in a .reflect/ directory:
- In a git project:
.reflect/ at the repo root (commit it — it is shared
team memory — unless the project prefers it ignored).
- Outside a project:
~/.reflect/ for cross-project patterns.
Files (create on first run; formats in reference/state-format.md):
observations.md — tentative patterns seen once or twice, not yet worth a
rule. Promote after repeated sightings; prune when stale.
applied.md — ledger of every improvement applied or proposed: date,
lane, target file, status (applied / proposed / verified / pruned).
Read both files before analyzing so you promote repeat observations instead
of re-deriving them, and never re-apply something already logged.
Workflow
- Inventory. Establish scope. Run the inventory script for JSONL input;
for the live session, review it directly. Read
.reflect/ state.
- Find signals. Look for: repeated user corrections; wrong first
assumptions; facts about the environment rediscovered by trial and error;
the same multi-step sequence performed manually more than once; fragile or
noisy commands; verbose tool output dominating context; work a smaller
model could have done; missing validation before "done" claims.
- Classify into lanes. Assign each signal to one improvement lane (see
below and
reference/improvement-taxonomy.md). One signal, one lane, one
smallest-possible change.
- Gate. Keep a candidate only if it is evidence-backed (cite the moment
in the session), durable (still true in 3 months), non-duplicate (check
the target file and
applied.md), and actionable (imperative and
testable, not vague encouragement). Single sightings of a maybe-pattern
go to observations.md, not into rules.
- Apply or propose. Apply low-risk improvements directly (see Autonomy
below). Record risky ones as
proposed in applied.md with a ready-to-
apply diff or file body. If the user asked for analysis only, propose
everything.
- Log and report. Append to
applied.md, update observations.md,
then report using the Output format.
Improvement lanes
Full guidance with worked examples: reference/improvement-taxonomy.md.
- Agent rules — additions to the project's
AGENTS.md or CLAUDE.md
(follow whichever the repo already uses; offer to create AGENTS.md if
neither exists). For conventions, commands, and constraints the agent
should never rediscover.
- Skills — create or edit a skill when a workflow has enough steps or
judgment to deserve its own trigger. Prefer updating an existing skill
over creating a near-duplicate, and check the ecosystem
(
npx skills find <keywords>) before authoring from scratch.
- Slash commands — when the user keeps typing variants of the same
request, create a command file so it becomes one keystroke of intent.
- Deterministic scripts — when the agent repeats fragile parsing,
scoring, checking, or formatting by hand, encode it as a small script and
add a rule or skill line naming when to run it.
- Sub-agent delegation — when bounded, verifiable work ran in the main
thread, recommend routing it to a sub-agent — ideally a smaller, cheaper
model (Haiku-class / mini-class) — so the main thread orchestrates
instead of executes.
- Context-bloat reduction — when a tool's verbose output dominated
context, wrap it: quieter flags, output-to-file plus targeted reads, a
filtering wrapper script, or a hook that trims known-noisy tools.
- Observation — real but unproven pattern: log it to
observations.md
with a sighting count.
- No action — one-off, already documented, or too speculative. Say so
explicitly; a confident no-change call is a valid outcome.
Autonomy boundaries
Hands-off means safe-by-default, not unlimited:
- Apply directly: additive edits to
AGENTS.md/CLAUDE.md; new skill,
command, or script files; edits to files reflect itself created earlier
(check applied.md); all .reflect/ state.
- Propose only: rewriting or deleting content reflect did not create;
changes to hooks, settings, permissions, or CI; anything touching secrets,
deploy, or external services; large restructures.
- Never: delete user content, edit outside the project (except
~/.reflect/), or store secrets/credentials/personal message text in any
state file or report.
Output format
## Reflection
**Applied**
| Lane | Change | Target | Evidence |
| --- | --- | --- | --- |
**Proposed** (ready to apply on approval)
| Lane | Change | Target | Why gated |
| --- | --- | --- | --- |
**Observations logged** — n new, n promoted, n pruned
**No-change calls**
- <signal considered and rejected, with reason>
Every row cites evidence from the session. If nothing cleared the gate,
report that plainly — an empty reflection that keeps state clean beats a
noisy one that clutters it.
Companions
reflect-feedback — audits applied.md: are past improvements actually
firing, or dead weight? Run weekly or every ~10 sessions.
reflect-memory — lifecycle for accumulated state and rules: dedupe,
merge, expire, resolve contradictions. Run monthly or when files feel
bloated.
reflect-skills — scans local session logs across many sessions for
recurring failure patterns and manages the skill portfolio: install,
create, fix, or remove skills. Use it when the evidence spans sessions
rather than living in this one.
1---2name: reflect3description: Review a work session, transcript, or tool-call log and compound the learnings into durable improvements: agent rules (AGENTS.md/CLAUDE.md), new or updated skills, slash commands, deterministic scripts, sub-agent delegation, and context-bloat reduction. Use when the user says "reflect", at the end of a work session, on a schedule, or when asked how to make the agent faster, cheaper, or more reliable in this project. Do not use for ordinary code review unless the requested output is agent/process improvement.4---56# Reflect78Turn one session's friction into every future session's head start. Reflect9reviews what actually happened — corrections, retries, rediscovered facts,10wasted tokens — and converts it into small, concrete improvements that11compound: rules, skills, commands, scripts, delegation, and leaner context.1213Designed to be hands-off: run it at the end of a session or on a schedule,14and it applies safe improvements itself, queues risky ones as proposals, and15tracks everything in `.reflect/` so the next run builds on the last.1617## Inputs1819Accept any of these; with no argument, reflect on the current conversation20and working directory:2122- The current visible session (default).23- A path to a session transcript (JSONL or plain text).24- A pasted transcript or log excerpt.25- A scope hint like "last 3 sessions" or "this week" when state exists.2627For JSONL transcripts, build a neutral inventory first instead of reading the28raw file:2930```bash31python3 scripts/session_inventory.py <transcript.jsonl>32```3334(Resolve `scripts/` relative to this skill's directory.) The inventory shows35turns, tool-call frequency, errors/retries, and the largest tool outputs —36use it to target which raw evidence to read. Never keyword-scan a whole37transcript.3839## State: the `.reflect/` folder4041Cross-session memory lives in a `.reflect/` directory:4243- In a git project: `.reflect/` at the repo root (commit it — it is shared44 team memory — unless the project prefers it ignored).45- Outside a project: `~/.reflect/` for cross-project patterns.4647Files (create on first run; formats in `reference/state-format.md`):4849- `observations.md` — tentative patterns seen once or twice, not yet worth a50 rule. Promote after repeated sightings; prune when stale.51- `applied.md` — ledger of every improvement applied or proposed: date,52 lane, target file, status (`applied` / `proposed` / `verified` / `pruned`).5354Read both files before analyzing so you promote repeat observations instead55of re-deriving them, and never re-apply something already logged.5657## Workflow58591. **Inventory.** Establish scope. Run the inventory script for JSONL input;60 for the live session, review it directly. Read `.reflect/` state.612. **Find signals.** Look for: repeated user corrections; wrong first62 assumptions; facts about the environment rediscovered by trial and error;63 the same multi-step sequence performed manually more than once; fragile or64 noisy commands; verbose tool output dominating context; work a smaller65 model could have done; missing validation before "done" claims.663. **Classify into lanes.** Assign each signal to one improvement lane (see67 below and `reference/improvement-taxonomy.md`). One signal, one lane, one68 smallest-possible change.694. **Gate.** Keep a candidate only if it is evidence-backed (cite the moment70 in the session), durable (still true in 3 months), non-duplicate (check71 the target file and `applied.md`), and actionable (imperative and72 testable, not vague encouragement). Single sightings of a maybe-pattern73 go to `observations.md`, not into rules.745. **Apply or propose.** Apply low-risk improvements directly (see Autonomy75 below). Record risky ones as `proposed` in `applied.md` with a ready-to-76 apply diff or file body. If the user asked for analysis only, propose77 everything.786. **Log and report.** Append to `applied.md`, update `observations.md`,79 then report using the Output format.8081## Improvement lanes8283Full guidance with worked examples: `reference/improvement-taxonomy.md`.84851. **Agent rules** — additions to the project's `AGENTS.md` or `CLAUDE.md`86 (follow whichever the repo already uses; offer to create `AGENTS.md` if87 neither exists). For conventions, commands, and constraints the agent88 should never rediscover.892. **Skills** — create or edit a skill when a workflow has enough steps or90 judgment to deserve its own trigger. Prefer updating an existing skill91 over creating a near-duplicate, and check the ecosystem92 (`npx skills find <keywords>`) before authoring from scratch.933. **Slash commands** — when the user keeps typing variants of the same94 request, create a command file so it becomes one keystroke of intent.954. **Deterministic scripts** — when the agent repeats fragile parsing,96 scoring, checking, or formatting by hand, encode it as a small script and97 add a rule or skill line naming when to run it.985. **Sub-agent delegation** — when bounded, verifiable work ran in the main99 thread, recommend routing it to a sub-agent — ideally a smaller, cheaper100 model (Haiku-class / mini-class) — so the main thread orchestrates101 instead of executes.1026. **Context-bloat reduction** — when a tool's verbose output dominated103 context, wrap it: quieter flags, output-to-file plus targeted reads, a104 filtering wrapper script, or a hook that trims known-noisy tools.1057. **Observation** — real but unproven pattern: log it to `observations.md`106 with a sighting count.1078. **No action** — one-off, already documented, or too speculative. Say so108 explicitly; a confident no-change call is a valid outcome.109110## Autonomy boundaries111112Hands-off means safe-by-default, not unlimited:113114- **Apply directly:** additive edits to `AGENTS.md`/`CLAUDE.md`; new skill,115 command, or script files; edits to files reflect itself created earlier116 (check `applied.md`); all `.reflect/` state.117- **Propose only:** rewriting or deleting content reflect did not create;118 changes to hooks, settings, permissions, or CI; anything touching secrets,119 deploy, or external services; large restructures.120- **Never:** delete user content, edit outside the project (except121 `~/.reflect/`), or store secrets/credentials/personal message text in any122 state file or report.123124## Output format125126```markdown127## Reflection128129**Applied**130| Lane | Change | Target | Evidence |131| --- | --- | --- | --- |132133**Proposed** (ready to apply on approval)134| Lane | Change | Target | Why gated |135| --- | --- | --- | --- |136137**Observations logged** — n new, n promoted, n pruned138139**No-change calls**140- <signal considered and rejected, with reason>141```142143Every row cites evidence from the session. If nothing cleared the gate,144report that plainly — an empty reflection that keeps state clean beats a145noisy one that clutters it.146147## Companions148149- `reflect-feedback` — audits `applied.md`: are past improvements actually150 firing, or dead weight? Run weekly or every ~10 sessions.151- `reflect-memory` — lifecycle for accumulated state and rules: dedupe,152 merge, expire, resolve contradictions. Run monthly or when files feel153 bloated.154- `reflect-skills` — scans local session logs across many sessions for155 recurring failure patterns and manages the skill portfolio: install,156 create, fix, or remove skills. Use it when the evidence spans sessions157 rather than living in this one.