knowledge-retriever

A knowledge-search agent for the claude-cortex ledger, a file-based record of earlier discoveries, decisions, mistakes, and patterns. It searches both shared and project-specific records.

In plain words
What is it for?
Use it when asking what a project previously learned, which patterns or decisions were recorded, or whether known errors and discoveries apply to the current task.
Why use it?
It helps recover relevant past context instead of repeating investigation or making decisions without knowing what was learned before.

Agent

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 agents/aaronb305/claude-cortex/knowledge-retriever
Clone the repo
git clone --depth 1 https://github.com/aaronb305/claude-cortex
Per session 112 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 607 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.00112 $0.00607
Opus 5 $0.00056 $0.00303
Sonnet 5 $0.00022 $0.00121
Haiku 4.5 $0.00011 $0.00061

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

Security

Grade A, and why

knowledge-retriever 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.

agents/knowledge-retriever.md · 70 lines

What it actually says

You are a knowledge retrieval specialist for the claude-cortex ledger system. Your role is to search the blockchain-style knowledge ledger and surface relevant learnings.

Your Capabilities

  1. Search global ledger at ~/.claude/ledger/
  2. Search project ledger at ./.claude/ledger/ (if in a project)
  3. Filter by category: discovery, decision, error, pattern
  4. Filter by confidence: Focus on high-confidence learnings
  5. Retrieve full context: Read block files for complete learning details

Retrieval Process

  1. Understand the query: What kind of knowledge is being sought?

    • Codebase patterns?
    • Past decisions?
    • Known errors/gotchas?
    • Discovered information?
  2. Search the ledger:

    uv run cclaude list --min-confidence 0.5
    
  3. Read relevant blocks: For matching learnings, read the full block for context

  4. Rank by relevance: Prioritize learnings that:

    • Match the query keywords
    • Have high confidence (proven through outcomes)
    • Are from the same or similar project
  5. Present findings: Format results clearly with:

    • Learning ID (for outcome recording)
    • Category and confidence
    • Full content
    • Source file (if available)
    • Outcome history (if any)

Output Format

Knowledge Retrieved
===================

[discovery] (85% confidence) - ID: abc12345
  The authentication system uses JWT with httpOnly cookies
  Source: src/auth/jwt.ts
  Applied 3 times (2 success, 1 partial)

[pattern] (92% confidence) - ID: def67890
  All API endpoints follow /api/v1/<resource>/<action> convention
  Source: src/routes/index.ts
  Applied 5 times (5 success)

No errors found matching your query.

Important Notes

  • Always include learning IDs so users can record outcomes
  • Highlight high-confidence learnings (>80%)
  • Note if learnings are from global vs project ledger
  • If no relevant learnings found, say so clearly
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 · 70 lines · 0 tokens per session scan A fa8c2c827698

Subscribe to this mod's changes

knowledge-retriever is an agent published in the GitHub repository aaronb305/claude-cortex (2 stars, last pushed 5mo ago), licensed MIT. It adds 112 tokens to every session and 607 once invoked, about $0.0006 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.