07-reflect-retry

07-reflect-retry is a cursor rule for Cursor from AG-Dmitry/composer-enhanced. It costs 35 tokens per session (591 once invoked), scanned A, original, MIT.

A bounded retry procedure for fixing a confirmed bug or failed check. It requires finding the cause before editing and stops after a set number of attempts.

In plain words
What is it for?
Use it after tests or review checks fail to diagnose the problem, apply a small fix, record important decisions, and escalate when progress stalls.
Why use it?
It prevents repeated guess-and-check changes that create new problems or hide the original issue.

Cursor rule for Cursor

Written for Cursor: a Cursor rule (.mdc). Also seen: mentions subagents.

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 rules/ag-dmitry/composer-enhanced/07-reflect-retry
Clone the repo
git clone --depth 1 https://github.com/AG-Dmitry/composer-enhanced

Made for: Cursor.

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 07-reflect-retry

README.md
[![agentmods](https://agentmods.dev/badge/rules/ag-dmitry/composer-enhanced/07-reflect-retry.svg)](https://agentmods.dev/rules/ag-dmitry/composer-enhanced/07-reflect-retry)
Your own site
<a href="https://agentmods.dev/rules/ag-dmitry/composer-enhanced/07-reflect-retry"><img src="https://agentmods.dev/badge/rules/ag-dmitry/composer-enhanced/07-reflect-retry.svg" alt="Measured on agentmods" height="20"></a>
Per session 35 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 591 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.00035 $0.00591
Opus 5 $0.00017 $0.00296
Sonnet 5 $0.00007 $0.00118
Haiku 4.5 $0.00003 $0.00059

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

Security

Grade A, and why

07-reflect-retry 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.

agent-protocols/07-reflect-retry.mdc · 59 lines

How it starts

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

Phase 7 — Reflect & Retry

You arrive here when the red-team found a confirmed bug or a verification gate failed. The danger now is the doom loop: a cheap model patches blindly, breaks something else, and digs deeper into a wrong approach. This protocol bounds and grounds the loop.

Iteration counter

Count one iteration per failed verify-and-fix cycle. Track it in the Iteration log of the task-memory file. The cap is 5.

Every iteration

  1. Diagnose the root cause before editing. Read the actual error/test output. State, in one or two sentences, why it failed. No fix until you can name the cause. A fix without a diagnosis is a guess.

  2. Check your decision log. Does the fix contradict a design decision from phase 3? If so, either keep the decision and fix within it, or add a new dated decision-log entry explaining the reversal. Never silently flip-flop.

  3. Re-ground against the code. If memory and the code disagree, the code wins. Re-read the relevant file (use the git drift check — see working-memory.mdc).

  4. Apply the minimal fix, then return to 05-red-team.mdc and 06-verify.mdc.

Iteration-3 checkpoint (mandatory)

If you reach iteration 3 without converging, stop patching. The local approach is probably wrong. Do one of:

Record which you chose and why in the decision log.

Iteration-5 cap (hard stop)

If you reach iteration 5 still failing, stop. Do not keep burning tokens or mutating code. Surface a structured blocker to the user containing:

  • What you were trying to do and the success criteria.
  • What you tried each iteration (from the iteration log).
  • The exact current failure (pasted output).
  • Your best hypothesis for the root cause.
  • The specific decision or information you need from the user to proceed.

Read the full file on GitHub · 59 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 · 59 lines · 35 tokens per session scan A cfa96a3bed03

Subscribe to this mod's changes

07-reflect-retry is a cursor rule published in the GitHub repository AG-Dmitry/composer-enhanced (3 stars, last pushed 2mo ago), licensed MIT. It adds 35 tokens to every session and 591 once invoked, about $0.0002 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.