learning-loop

Rules for a learning system that stores verified code-fix patterns in a playbook for later investigation.

In plain words
What is it for?
Use them when recalling playbook entries, analyzing code, validating fixes, running tests, and recording newly confirmed patterns.
Why use it?
They prevent remembered patterns from being treated as proof, which could cause stale or incorrect fixes to be applied blindly.

Cursor rule

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/whitequeen306/code-cortex-loop/learning-loop
Clone the repo
git clone --depth 1 https://github.com/whitequeen306/code-cortex-loop
Per session 18 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 2,443 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 $0.00018 $0.02443
Opus 5 $0.00009 $0.01222
Sonnet 5 $0.00004 $0.00489
Haiku 4.5 $0.00002 $0.00244

Measured yesterday against content hash c03d5d43c3f4, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

learning-loop 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 yesterday.

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.

rules/learning-loop.mdc · 221 lines

How it starts

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

Learning Loop (CodeCortexLoop v2.2)

Purpose

CodeCortexLoop learns from Direct fixes via a playbook (.cortexloop/playbook.json). Before analysis, query relevant entries; after Direct fixes, reflect and record new patterns.

Anti-hallucination goal: memory is recall (where to look), not authority (what to conclude). Self-reinforcing echo chambers are blocked by verified-outcome confidence, two tiers, external oracles, diversity requirements, and time decay.

Core principles

Recall, not authority

Playbook hits tell the agent where to investigate first, not what the answer is:

  • Re-derive every fix from current code context
  • Re-verify with tests and refactor-safety rules
  • Never paste a stored fix method as a diff or blind patch

Suggestions, not mandatory

Playbook hits do not:

  • Skip any analysis pass
  • Override suppressions or scope rules
  • Force a fix without understanding context

Hits must be verified

When applying a playbook-suggested fix:

  1. Follow rules/refactor-safety.mdc
  2. Run tests after the change group
  3. Re-verify with analysis if in Direct mode

Bad or stale memory must never cause silent breakage. If a pattern does not fit, ignore it and record --outcome=rejected.

Negative signals must be recorded

If a suggested fix fails tests, is reverted, or is judged inapplicable, run playbook.mjs feedback with --outcome=failed or --outcome=rejected. Do not leave failed memories at high confidence.

Two tiers

Tier Meaning Query behavior
candidate Unconfirmed hypothesis Hidden by default; shown only with --include-candidates, labeled as guesses — do NOT apply
verified Trusted recall Shown by default in Step 0.5
quarantined Failed / too low confidence Never shown in query; pruned with --drop-quarantined

Promotion to verified requires ALL of:

  • confidence >= 0.7
  • verifiedCount >= 2
  • distinctContexts >= 2 (diverse evidence, not one file repeated)

Read the full file on GitHub · 221 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. yesterday First seen · 221 lines · 18 tokens per session scan A c03d5d43c3f4

Subscribe to this mod's changes

learning-loop is a cursor rule published in the GitHub repository whitequeen306/code-cortex-loop (15 stars, last pushed 1mo ago), licensed MIT. It adds 18 tokens to every session and 2,443 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-30.