kb-pattern-extractor

kb-pattern-extractor is an agent for coding agents from rp1-run/rp1. It costs 21 tokens per session (2,656 once invoked), scanned A, original, Apache-2.0.

An analysis agent that extracts observable implementation patterns from a preselected set of source files and records them for a codebase knowledge base. It updates existing pattern documentation using the supplied evidence.

In plain words
What is it for?
Use it to document coding idioms, compare new evidence with an existing patterns.md file, and produce a compact implementation-pattern reference.
Why use it?
It gives coding agents a concise record of how a project is built, reducing repeated inspection of the same conventions. It also keeps documented patterns tied to actual files and changes.

Agent

Part of the rp1-base plugin — 20 skills, 17 agents, 1 hook shipped together

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/rp1-run/rp1/kb-pattern-extractor
Clone the repo
git clone --depth 1 https://github.com/rp1-run/rp1

Or install rp1-base, the plugin that ships this one along with the rest of its 20 skills, 17 agents, 1 hook.

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 kb-pattern-extractor

README.md
[![agentmods](https://agentmods.dev/badge/agents/rp1-run/rp1/kb-pattern-extractor.svg)](https://agentmods.dev/agents/rp1-run/rp1/kb-pattern-extractor)
Your own site
<a href="https://agentmods.dev/agents/rp1-run/rp1/kb-pattern-extractor"><img src="https://agentmods.dev/badge/agents/rp1-run/rp1/kb-pattern-extractor.svg" alt="Measured on agentmods" height="20"></a>
Per session 21 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,656 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.00021 $0.02656
Opus 5 $0.00010 $0.01328
Sonnet 5 $0.00004 $0.00531
Haiku 4.5 $0.00002 $0.00266

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

Security

Grade A, and why

kb-pattern-extractor 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 4d 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/base/agents/kb-pattern-extractor.md · 356 lines

How it starts

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

KB Pattern Extractor - Implementation Idiom Mapping

You are PatternExtractor-GPT, a specialized agent that extracts implementation patterns and coding idioms from codebases. You receive a pre-filtered list of source files and extract "how things are done" conventions.

CRITICAL: You do NOT scan files. You receive a curated list and focus on extracting observable patterns with evidence. Output MUST be ≤150 lines when rendered.

<codebase_root> $1 </codebase_root>

<pattern_files_json> $2 </pattern_files_json>

<repo_type> $3 </repo_type>

<file_diffs> $5 </file_diffs>

<feature_context> $6 </feature_context>

1. Load Existing KB Context (If Available)

Check for existing patterns.md:

  • Check if {KB_ROOT}/patterns.md exists
  • If exists, read to understand current pattern documentation
  • Use as baseline for refinement in INCREMENTAL mode

§BAYES

Existing patterns.md = prior. New files/diffs/feature notes = evidence. Output = posterior. Bayesian update includes revising old hypotheses and creating new ones when evidence does not fit the old map.

  • Revise; do not rewrite.
  • Keep prior claims that still fit the evidence.
  • Tighten when evidence sharpens.
  • Rewrite/remove only on contradiction.
  • Add only with strong evidence.
  • Silence in changed files != deletion signal.
  • Local evidence -> local edits. Broad rewrites need broad evidence.

Anti-bias:

  • Read the prior first, but treat it as hypotheses, not truth.
  • For each major claim: confirmed | refined | contradicted | untested.
  • Seek disconfirming evidence before preserving a major claim.
  • Preserve untested claims unless evidence disproves them.

MUST NOT:

  • keep a claim only because it already exists
  • delete a claim only because new evidence is silent
  • replace a specific prior claim with weaker generic wording

Preserve knowledge mass. Correct it; do not reset it.

§DISCOVERY

The prior is incomplete.

  • Do not limit exploration to patterns already named in the prior.
  • Actively search for new conventions, idioms, workarounds, boundaries, and recurring structures.
  • Treat the prior as a starting map, not a closed set.
  • If evidence points to a material area the prior does not model: investigate it, then add it if supported.
  • Missing prior coverage != unimportant.
  • After reconciling existing claims, perform one explicit novelty scan for material knowledge absent from the prior.

Read the full file on GitHub · 356 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. 4d ago First seen · 356 lines · 21 tokens per session scan A 667d32c445f9

Subscribe to this mod's changes

kb-pattern-extractor is an agent published in the GitHub repository rp1-run/rp1 (38 stars, last pushed 28d ago), licensed Apache-2.0. It adds 21 tokens to every session and 2,656 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.

Related

Other agents, from other repositories

python-architect

Expert on Python design patterns, modularization, and scalable architecture for the APM CLI codebase. Activate when creating new modules, refactoring class hierarchies, or making cross-cutting architectural decisions.

microsoft/apm · 45 tokens

doc-writer

APM documentation writer. Use this agent for creating, editing, or restructuring any documentation in docs/src/content/docs/. Activate whenever the task involves writing user-facing prose, adding guide pages, updating reference docs, or consolidating duplicate content across the doc site.

microsoft/apm · 51 tokens

cdo

APM Chief Documentation Officer. Use this agent as the synthesizer and final arbiter for any multi-persona docs panel -- holds the 3-promise narrative (consume / produce / govern), the chapter-start and chapter-end bridges, the TOC integrity, and the persona ramps (consumer / producer / enterprise). Activate to…

microsoft/apm · 95 tokens

algorithmic-patterns

Load this reference when the PR diff touches code outside the transport/cache layer -- i.e. when the change introduces or modifies loops, data structures, lookup patterns, or module-level imports.

microsoft/apm · 0 tokens

apm-expert

Expert on APM (Agent Package Manager). Helps users install, configure, author, and troubleshoot APM packages, dependencies, compilation, MCP servers, and governance policies.

microsoft/apm · 39 tokens

test-coverage-expert

Test-coverage expert paired with the DevX UX lens. Activate when reviewing PRs that change CLI surface (commands, flags, help text), error wording, exit codes, install/init/run flows, lockfile behavior, auth resolution, hooks, marketplace, or any contract a user can observe -- even when the user does not say "tests"…

microsoft/apm · 151 tokens