spec-rule-miner

spec-rule-miner is a skill for Claude Code, Codex from ronronner02/codepilot-agent. It costs 118 tokens per session (2,020 once invoked), scanned A, original, MIT.

A tool for finding coding conventions already used in a software repository and turning them into instructions for AI coding agents.

In plain words
What is it for?
Use it to create or update AGENTS.md, CLAUDE.md, Cursor, or Qoder rules based on evidence from the codebase.
Why use it?
It helps generated code match the project’s existing habits instead of introducing unrelated styles or patterns.

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/ronronner02/codepilot-agent/spec-rule-miner
Any agent
npx skills add ronronner02/codepilot-agent --skill spec-rule-miner
Clone the repo
git clone --depth 1 https://github.com/ronronner02/codepilot-agent

Made for: Claude Code, Codex.

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 spec-rule-miner

README.md
[![agentmods](https://agentmods.dev/badge/skills/ronronner02/codepilot-agent/spec-rule-miner.svg)](https://agentmods.dev/skills/ronronner02/codepilot-agent/spec-rule-miner)
Your own site
<a href="https://agentmods.dev/skills/ronronner02/codepilot-agent/spec-rule-miner"><img src="https://agentmods.dev/badge/skills/ronronner02/codepilot-agent/spec-rule-miner.svg" alt="Measured on agentmods" height="20"></a>
Per session 118 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,020 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.00118 $0.02020
Opus 5 $0.00059 $0.01010
Sonnet 5 $0.00024 $0.00404
Haiku 4.5 $0.00012 $0.00202

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

Security

Grade A, and why

spec-rule-miner 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.

.claude/skills/spec-rule-miner/SKILL.md · 74 lines

How it starts

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

Spec Rule Miner

Purpose

spec-rule-miner 从目标仓库的真实代码中提炼项目级 AI 编码规则,把完整规则写入独立规则文件,并让 AGENTS.md / CLAUDE.md 这类 host 入口文件引用该文件。它是 standalone skill,不是 spec-* public workflow。

核心产物是 <=1000 words 的项目规则块,规则必须来自当前目标仓库证据,而不是语言默认、个人偏好或通用最佳实践。

When To Use

  • 使用本 skill:用户要“分析项目风格”“学习代码规范”“生成项目规则”“挖掘编码习惯”“让 AI 像团队一样写代码”,或明确要生成 AGENTS.md/CLAUDE.md 引用入口、Cursor/Qoder 规则文件。

When Not To Use

  • 不使用本 skill:用户要审查当前 diff、修复代码、重构、调试、写 lint/format 配置、生成通用语言规范,或治理 confirmed team policy。
  • 近邻路由:confirmed team policy governance 已退役,不再提供专用入口;代码质量评审走 spec-code-review;实际实现或修复走 spec-work;创建或修改 spec-first source skill 走 spec-write-skill

Inputs

  • target_repo:必须是一个明确的本地目标仓库。
  • 当前仓库的人写源码、测试、配置和已有 agent rule 文件。
  • 用户指定的输出目标;未指定时使用默认目标。

Outputs

  • rules_block:写入独立规则文件的纯规则正文,使用 spec-rule-miner-start / spec-rule-miner-end markers。
  • evidence_summary:每个规则组的代表性文件路径和样本限制;不写入规则文件,除非用户明确要求。
  • target_files:默认独立规则文件、入口 pointer 文件与用户指定输出文件,说明 pointer 还是 inline。
  • limitations:小样本、大仓库/多包抽样、混合语言、生成代码占比高、历史例外、冲突模式跳过、图候选未回源、refresh no-op、headless 默认写入等限制。

Hard Boundaries

  • 只读目标仓库代码;不要修改业务源码、测试、构建配置或 formatter/linter 配置。
  • Host-projected copies are outside this skill's rule targets;具体禁区见 Write Targets。宿主投影过期时从 source 运行 spec-first init 修复。
  • 写入独立规则文件和引用入口前必须 preview 规则正文和目标文件;交互可用时等待用户确认。只有用户明确要求直接写入,或宿主/调用参数明确证明当前运行是 headless/non-interactive,才使用默认目标;普通聊天里用户暂未回复不能算 headless。默认写入必须在 closeout 记录 headless_default_write、目标文件和限制。
  • 不覆盖用户已有规则。读取目标文件后,只替换 spec-rule-miner markers 内的旧块;无 markers 时追加;疑似旧版无 marker 输出时先询问替换还是追加。
  • 非首次执行必须先重新取证并生成 candidate rules block,再与现有 canonical marked block / pointer 对比;无实质变化时不重写文件,closeout 记录 refresh_noop、采样范围和限制;有变化时 preview diff 后只替换 marker 内内容。
  • 每条规则必须有当前仓库证据:默认至少 2 个文件支撑;小仓库样本不足时降级说明 sample-size;不确定或 50/50 分裂的模式不写成规则。
  • 不泄露敏感信息:密钥、内部 URL、私有包名、账号、生产路径、安全实现细节只用于判断,不进入规则正文。

Workflow

  1. 明确 target_repo。父级多仓工作区必须先锁定一个目标仓库;不清楚时只问一个问题。
  2. 盘点仓库形态:根目录、主要语言、源码目录、测试目录、配置文件、包/应用边界、生成物/依赖目录和已有 agent rule 文件;多包 workspace 必须识别具体子项目范围。
  3. 过滤读取范围:跳过依赖、构建产物、锁文件、minified 文件、二进制、vendored/generated 代码;大仓库或多包仓库使用分层抽样并在 preview 和 closeout 中披露样本包、未覆盖子项目和适用范围。
  4. 读取并记录证据。抽取前先读 Pattern Categories,用其中类别组织证据;大仓库可按其中 capability-class 边界使用 code-graph / project-graph 候选缩小阅读范围,但规则证据必须回到当前源码;配置已强制的 formatter/linter 规则只记录为“已由工具处理”,不要重复写入 AI 规则。
  5. 合成规则:按 frequency x deviation from defaults 排序,保留高频且偏离默认的做法;多包规则必须区分跨包通用模式、包级专属模式和历史例外,旧项目反例只能写成“新增代码优先”或“不扩大例外”;除非证据在适用范围内压倒性一致,不使用全仓库绝对措辞。必须包含至少一个 hidden association 和至少一个 anti-pattern,除非证据明确不存在,并在 preview 限制中说明。规则正文可以包含适用范围和例外边界,这不算挖掘过程元说明。
  6. Preview:展示将写入独立规则文件的规则块、入口引用文件、word count、采样/证据限制、适用包范围、历史例外、refresh diff/no-op 判断,以及每个规则组的代表性 source refs。规则正文不要包含挖掘过程元说明。
  7. 写入前读 Write Targets,按目标文件的 marker、frontmatter、pointer/inline 规则执行。默认把完整规则写入 docs/ai/project-rules.md,并让 AGENTS.mdCLAUDE.md 指向该文件。
  8. 收尾输出:列出写入文件、规则字数、是否采样、未写入的近邻工具文件、需要用户手动检查的限制;如果没有写文件,说明 preview-only 状态;如果因 headless 走默认写入,必须说明 headless_default_write 的证据来源。

Read the full file on GitHub · 74 lines

Files

What ships with it

2 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

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 · 74 lines · 118 tokens per session scan A 01b5af41925d

Subscribe to this mod's changes

spec-rule-miner is a skill published in the GitHub repository ronronner02/codepilot-agent (0 stars, last pushed 3d ago), licensed MIT. It adds 118 tokens to every session and 2,020 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.

Related

Other skills, from other repositories

agent-orchestration

Agent orchestration patterns for agentic loops, multi-agent coordination, alternative frameworks, and multi-scenario workflows. Use when building autonomous agent loops, coordinating multiple agents, evaluating CrewAI/AutoGen/Swarm, or orchestrating complex multi-step scenarios.

yonatangross/orchestkit · 56 tokens

generate-ai-rules

Generate AI assistant configuration files for a repository — CLAUDE.md, AGENTS.md, and Cursor rules (.cursor/rules/.mdc) — from codebase analysis. Use whenever the user wants to create or update CLAUDE.md, AGENTS.md, agent rules, Cursor rules, AI coding assistant configuration, or "onboard AI tools" to a project, even…

divar-ir/ai-doc-gen · 91 tokens

generate-readme

Generate or refresh a comprehensive, professional README.md for a repository, with architecture overview, mermaid and optional C4 diagrams, repository structure, dependencies, and API documentation. Use whenever the user asks to create, write, update, improve, or regenerate a README, project documentation, or a…

divar-ir/ai-doc-gen · 83 tokens

analyze-codebase

Run a multi-agent deep analysis of a codebase, producing AI-readable analysis documents in .ai/docs/ covering structure, dependencies, data flow, request flow, and APIs. Use whenever the user asks to analyze a repository, generate codebase analysis, understand an unfamiliar codebase in depth, or before generating…

divar-ir/ai-doc-gen · 113 tokens

langgraph-orchestration

Build or modify LangGraph StateGraph agents in vpeetla-ai repos: typed state, nodes, conditional edges, MemorySaver, interruptbefore HITL. Use when adding orchestrators, coding loops, or multi-agent graphs.

vpeetla-ai/multi-agent-system-pattern · 52 tokens

aegis-gateway

Integrate AegisAI gateway before tool side effects (notify, publish, deploy). Use when adding Slack/Telegram/WhatsApp notify, content publish, or any irreversible external action in VAP, AegisLoop, or ai-content-factory.

vpeetla-ai/multi-agent-system-pattern · 58 tokens