Skip to content

reflect

reflect is session-local metacognition for Claude Code: the deliberate opposite of cross-session memory.

Core trick

Detects repeated reverts within a tool-call window, then has Claude read back tool history and diffs to inject a guidance note into the next turn.

Tags

Description

reflect is session-local metacognition for Claude Code: the deliberate opposite of cross-session memory. Long /loop sessions drift; I watched it happen in my own multi-hour runs, hour two, the model repeating the same misjudgment. When suggestions get reverted 3+ times within 10 tool calls (weighted threshold, not single fail-retry), Opus 4.7 reads back recent tool history, active rules, and the rolled-back diff, infers why the user kept pushing back, not what failed, and injects structured guidance into the next turn: pattern, signal, adjustment, confidence. I'd previously shipped a static-rules version (stetkeep on npm). reflect is the dynamic recalibration layer static rules can't reach. Single-shot. Prompt-cached (3-layer: 1h + 5m + ephemeral, measured 95.9% warm cache hit). No persistence, no telemetry, by design. MIT-licensed, published as @chanjoongx/reflect. Failure modes characterized: cold-start refusal, false-trigger flagging, abstention on ambiguous prompts. Built solo over 6 days: npm package, Claude Code plugin, localhost viewer, dogfooded on the build itself.
chanjoongx/reflect★ 00 forksTypeScriptMITCreated Apr 22, 2026 · last push Apr 29, 2026

README excerpt

<div align="center">

# reflect

### *A session-local metacognition harness for long-running Claude Code work.*

**When your suggestions get reverted 3+ times within 10 tool calls, Opus 4.7 reads back recent tool calls + active rules + rolled-back diff, reasons about *why*, and injects guidance into the next turn.**

[![License: MIT](https://img.shields.io/badge/License-MIT-A78BFA.svg)](https://opensource.org/licenses/MIT)
[![Built for](https://img.shields.io/badge/Built%20for-Claude%20Code-D4A27F)](https://claude.com/claude-code)
[![Powered by](https://img.shields.io/badge/Powered%20by-Opus%204.7-5FE5D4)](https://www.anthropic.com/claude/opus)
[![Hackathon](https://img.shields.io/badge/Built%20with-Opus%204.7%20Hackathon-7AB7FC)](https://cerebralvalley.ai/e/built-with-4-7-hackathon)

</div>

---

## What is reflect?

You let Claude Code run for hours in auto mode. It does great work — and somewhere around hour two, it starts repeating the same misjudgment. You revert. It tries again. You revert.

reflect catches that cluster. When ≥3 revert signals appear within 10 tool calls (weighted threshold: 3 hard reverts = 3.0, or 2 hard + 1 utterance = 2.5, crosses the 2.4 cutoff), reflect hands recent history to Opus 4.7 and gets back one structured reflection — `pattern`, `signal`, `adjustment`, `confidence` — written to `.reflect/session-guidance.md`. Your next turn reads it via path-scoped rule injection and adjusts.

Session-local. No persistence. No team sync. No telemetry. The

Team