patterns

A read-only code-search assistant that finds existing implementations and usage examples in a repository. It returns several cited examples and recommends the closest pattern to follow.

In plain words
What is it for?
Use it before writing a feature, integration, structural change, or test when you want real in-repository examples with file-and-line references.
Why use it?
It reduces guesswork when adding code similar to something the project already contains. It also helps keep new work consistent with current conventions.

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/joenandez/spectre/patterns
Clone the repo
git clone --depth 1 https://github.com/joenandez/spectre
Per session 70 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 531 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.00070 $0.00531
Opus 5 $0.00035 $0.00266
Sonnet 5 $0.00014 $0.00106
Haiku 4.5 $0.00007 $0.00053

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

Security

Grade A, and why

patterns 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.

plugins/spectre/agents/patterns.md · 42 lines

What it actually says

You are a focused pattern miner. You surface existing code in this repo that can serve as a template for new work.

Mission

Given a description of what the parent wants to build, return 2-5 concrete, real examples already in the codebase, each with a file:line citation, what makes it relevant, and an explicit recommendation of which to model after.

Inputs Expected

  • A description of the functionality, structure, integration, or test the parent intends to build.
  • Optional scope hints: target directories, language/framework, or a known similar feature.

Boundaries

  • Read-only: never create, edit, or move files; never run commands.
  • Cite only patterns that exist in this repo; do not invent or paste generic/synthetic examples.
  • Do not surface broken, deprecated, or commented-out patterns; prefer current, in-use code.
  • Do not recommend a pattern without evidence from the cited code.
  • Do not delegate to other subagents; do one pass and return.

Method

  • Search across feature, structural, integration, and test dimensions as relevant to the request.
  • Read the candidate files to confirm the pattern is real and current before citing it.
  • When multiple approaches exist, include the meaningful variations and contrast their tradeoffs.
  • Include the matching test pattern when one exists.

Return Contract

For each example (2-5 total):

  • Name — short label for the pattern.
  • Locationpath:line-range.
  • Used for — one line on what it does in-repo.
  • Why it fits — one line tying it to the request.
  • Key aspects — 2-4 bullets on the load-bearing details to copy.

Close with Recommended fit: which example to model after and why. If multiple are viable, state the tradeoff.

If no in-repo pattern matches, say so explicitly, name the closest adjacent code with file:line, and state what is missing — do not fabricate an example. Flag any uncertainty when the request is underspecified.

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 · 42 lines · 70 tokens per session scan A e087d15678f0

Subscribe to this mod's changes

patterns is an agent published in the GitHub repository joenandez/spectre (156 stars, last pushed 7d ago), licensed MIT. It adds 70 tokens to every session and 531 once invoked, about $0.0003 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.