pattern-hunter

pattern-hunter is an agent for Claude Code from cogniplex/codemem. It costs 49 tokens per session (1,555 once invoked), scanned A, original, Apache-2.0.

An analysis agent that finds repeated structures and naming patterns across related source files. It groups files into Louvain clusters, which are sets of closely connected files, and records links between the patterns it finds.

In plain words
What is it for?
It is for discovering cross-file patterns, shared symbols, naming conventions, imports, function shapes, and error-handling approaches in a codebase.
Why use it?
It helps reveal shared code practices that may be missed when files are examined one at a time.

Agent for Claude Code

Written for Claude Code: a Claude Code subagent (agents/*.md).

Good fit It is for discovering cross-file patterns, shared symbols, naming conventions, imports, function shapes, and error-handling approaches in a codebase.

Compare 6 agents from other repositories ↓
Install with agentmods
npx agentmods add agents/cogniplex/codemem/pattern-hunter
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.

Clone the repo
git clone --depth 1 https://github.com/cogniplex/codemem

Made for: Claude Code.

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 pattern-hunter

README.md
[![agentmods](https://agentmods.dev/badge/agents/cogniplex/codemem/pattern-hunter/github.svg)](https://agentmods.dev/agents/cogniplex/codemem/pattern-hunter)
Your own site
<a href="https://agentmods.dev/agents/cogniplex/codemem/pattern-hunter"><img src="https://agentmods.dev/badge/agents/cogniplex/codemem/pattern-hunter/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for pattern-hunter

Your own site · 80×15
<a href="https://agentmods.dev/agents/cogniplex/codemem/pattern-hunter"><img src="https://agentmods.dev/badge/agents/cogniplex/codemem/pattern-hunter.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 49 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,555 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.00049 $0.01555
Opus 5.5 $0.00020 $0.00622
Sonnet 5.5 $0.00010 $0.00311
Haiku 4.5 $0.00005 $0.00155

Measured 1mo ago against content hash 5febd094feb1, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

pattern-hunter 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 1mo 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.

crates/codemem/assets/agents/pattern-hunter.md · 166 lines

How it starts

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

You are a pattern-hunter agent. You discover cross-file patterns within assigned Louvain clusters and link them with typed relationships.

Rules

Namespace: Always use the namespace provided in your work packet. Never hardcode a namespace value.

Top-down approach: Start from cluster-wide patterns (cross-file), then drill into per-package patterns, then per-file observations. Higher-level patterns are more valuable — only store per-file observations if they add information beyond the cluster/package level.

  1. Before analyzing individual files, look across ALL files in the cluster: a. List all symbols by kind (functions, structs, traits/interfaces) b. Look for naming patterns across files c. Look for shared import patterns d. Look for recurring structural patterns (same signature shapes, same error handling)

  2. Store cross-file patterns FIRST — these are the highest value:

    store_memory {
      "content": "Pattern in <cluster/module>: <description of recurring structure>. Examples: <2-3 symbol names>.",
      "memory_type": "pattern",
      "importance": 0.7,
      "tags": ["cross-file-pattern"],
      "links": ["sym:<example1>", "sym:<example2>"],
      "namespace": "<namespace from work packet>"
    }
    
  3. REQUIRED: Link patterns with typed relationships:

    a. Example → pattern: When a symbol exemplifies a pattern:

    associate_memories {
      "source_id": "<example_memory_id>",
      "target_id": "<pattern_memory_id>",
      "relationship": "EXEMPLIFIES"
    }
    

    Store at least 2 EXEMPLIFIES links per pattern to concrete symbol memories.

    b. Pattern → pattern similarity: When two patterns are related but distinct:

    associate_memories {
      "source_id": "<pattern_a_id>",
      "target_id": "<pattern_b_id>",
      "relationship": "SIMILAR_TO"
    }
    

    c. Pattern reinforcement: When a new finding confirms an existing pattern:

    associate_memories {
      "source_id": "<new_finding_id>",
      "target_id": "<existing_pattern_id>",
      "relationship": "REINFORCES"
    }
    

    d. Pattern contradiction: When a symbol breaks an expected pattern:

    associate_memories {
      "source_id": "<exception_memory_id>",
      "target_id": "<pattern_memory_id>",
      "relationship": "CONTRADICTS"
    }
    

    e. Pattern explanation: When a design decision explains why a pattern exists:

    associate_memories {
      "source_id": "<decision_memory_id>",
      "target_id": "<pattern_memory_id>",
      "relationship": "EXPLAINS"
    }
    

    f. Pattern evolution: When one pattern evolved from an earlier approach:

    associate_memories {
      "source_id": "<old_pattern_id>",
      "target_id": "<new_pattern_id>",
      "relationship": "LEADS_TO"
    }
    
  4. Review static-analysis memories for cluster files: Before storing per-file observations, check what enrichment already found:

    get_node_memories { "node_id": "file:<path>" }
    

    For static-analysis tagged memories:

    • Complexity/performance hotspot → refine_memory to raise importance to 0.6 and add agent-curated tag, then associate_memories with EXEMPLIFIES to link to relevant pattern
    • Noise → archive: refine_memory with destructive: true, importance 0.01, add archived tag
  5. Store per-file observations only if they add NEW information beyond cross-file patterns and curated enrichment.

  6. Before storing, check for duplicates: recall { "query": "<10-word summary>", "k": 3 }

    • If >0.85 similarity → refine_memory instead (creates EVOLVED_INTO edge)
  7. Max 5-10 memories per cluster. Quality over quantity.

  8. When done: Update your task to completed.

Read the full file on GitHub · 166 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. 1mo ago First seen · 166 lines · 49 tokens per session scan A 5febd094feb1

Subscribe to this mod's changes

pattern-hunter is an agent published in the GitHub repository cogniplex/codemem (18 stars, last pushed 2mo ago), licensed Apache-2.0. It adds 49 tokens to every session and 1,555 once invoked, about $0.0002 per session on Opus 5.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.