cortex-learn

A tool for finding repeated routing decisions in Cortex's log and proposing reusable shortcuts for its cortex.md configuration. Cortex appears to be a system that routes tasks according to stored rules.

In plain words
What is it for?
Use it to inspect routing patterns, tune Cortex defaults, and create candidate Decision Shortcuts after a pattern appears at least three times.
Why use it?
It helps turn repeated manual choices into documented defaults, while leaving a person to approve, change, or reject each proposal.

Skill for Claude CodeCodex

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 skills/amitvijapur/cortex/cortex-learn
Any agent
npx skills add amitvijapur/cortex --skill cortex-learn
Clone the repo
git clone --depth 1 https://github.com/amitvijapur/cortex

Made for: Claude Code, Codex.

Per session 45 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 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.00045 $0.00443
Opus 5 $0.00023 $0.00221
Sonnet 5 $0.00009 $0.00089
Haiku 4.5 $0.00005 $0.00044

Measured 2d ago against content hash 7a20b56cd527, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

cortex-learn 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 2d 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.

skills/cortex-learn/SKILL.md · 51 lines

What it actually says

/cortex-learn

Run pattern detection on ~/.claude/cortex-log.jsonl. Surface groups of routing decisions that repeated ≥3 times as candidate Decision Shortcuts for cortex.md.

When to invoke

  • User types /cortex-learn explicitly
  • User asks "what patterns is cortex seeing"
  • User asks "are there routes I should codify"
  • User says "tune cortex based on usage"
  • Session-start check (via cortex learn --check) surfaced a pending pattern

What to do

Step 1 — Run pattern detection

python3 ~/.claude/bin/cortex learn

Optional:

  • --threshold N — change minimum count (default 3)
  • --check — terse one-liner for session-start use (no review flow)
  • --no-proposals — skip writing markdown proposal files

Step 2 — Review the proposals

For each detected pattern, the tool writes a markdown proposal file with frontmatter status pending. The user should:

  1. Read each proposal
  2. Decide: approve, modify, or reject
  3. Edit the proposal frontmatter to reflect the decision
  4. If approved: add the candidate shortcut to cortex.md → Decision Shortcuts table
  5. If rejected: write a one-line reason in the Notes section

Step 3 — Update cortex.md (only if approved)

Take the candidate shortcut row and merge it into the Decision Shortcuts table in cortex.md. Don't overwrite existing rows that already cover the same case.

Do NOT

  • Do not auto-apply patterns to cortex.md — Amit must approve each one
  • Do not delete proposal files even after approval; they're the audit trail
  • Do not skip the --no-proposals flag if the user explicitly asks for stats only
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. 2d ago First seen · 51 lines · 45 tokens per session scan A 7a20b56cd527

Subscribe to this mod's changes

cortex-learn is a skill published in the GitHub repository amitvijapur/cortex (5 stars, last pushed 3d ago), licensed MIT. It adds 45 tokens to every session and 443 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.