extract-rules

extract-rules is a command for Claude Code from design-and-deliver/claude-code-autoconfig. It costs 0 tokens per session (2,916 once invoked), scanned B, original, MIT.

A command that scans Claude configuration and memory files and proposes organized rules for .claude/rules/. These rules tell the coding agent how a project should be handled.

In plain words
What is it for?
Use it to discover possible rules across project configuration, nested folders, .claude files, and memory, then review the proposed rules and any cleanup.
Why use it?
It helps turn scattered instructions in files such as CLAUDE.md and agent notes into a clearer, central rule set, while checking for uncommitted Git changes first.

Command for Claude Code

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 commands/design-and-deliver/claude-code-autoconfig/extract-rules
Clone the repo
git clone --depth 1 https://github.com/design-and-deliver/claude-code-autoconfig

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 extract-rules

README.md
[![agentmods](https://agentmods.dev/badge/commands/design-and-deliver/claude-code-autoconfig/extract-rules.svg)](https://agentmods.dev/commands/design-and-deliver/claude-code-autoconfig/extract-rules)
Your own site
<a href="https://agentmods.dev/commands/design-and-deliver/claude-code-autoconfig/extract-rules"><img src="https://agentmods.dev/badge/commands/design-and-deliver/claude-code-autoconfig/extract-rules.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 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,916 The whole file, excluding the scripts and references it only reads on demand.
Security scan B 1 finding. 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.00000 $0.02916
Opus 5 $0.00000 $0.01458
Sonnet 5 $0.00000 $0.00583
Haiku 4.5 $0.00000 $0.00292

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

Security

Grade B, and why

extract-rules scanned grade B with 1 finding 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 5d 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.

Reads agent configuration directoriesmediumAgent snooping

.claude/, .codex/, .gemini/ hold keys, settings and other credentials a mod has no legitimate need for.

5. Auto memory files — memory often contains misplaced imperatives that should be promoted to rules. To find the memory directory, list `~/.claude/projects/` and fuzzy-match against the current project path. The director
.claude/commands/extract-rules.md · 261 lines

How it starts

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

Extract Rules

Scan all Claude configuration artifacts and propose structured rules for .claude/rules/.

Step 0: Git safety check

Before doing anything else, check for uncommitted changes:

git status --porcelain

If there are uncommitted changes, show this warning and wait for confirmation:

Warning: This command will modify files (extract rules from sources and optionally clean up originals). You have uncommitted changes.

Commit your work before proceeding, or type "continue" to proceed anyway.

If the working tree is clean, proceed silently.

Step 1: Discover sources

Scan these locations for .md files containing potential rules. Skip any that don't exist — not all projects have all of these:

  1. CLAUDE.md (project root)
  2. CLAUDE.local.md (project root, if present)
  3. All .md files in .claude/ recursively (feedback, commands, etc.) — excluding .claude/rules/ and .claude/commands/extract-rules.md
  4. Any nested CLAUDE.md files in subdirectories (e.g., src/CLAUDE.md)
  5. Auto memory files — memory often contains misplaced imperatives that should be promoted to rules. To find the memory directory, list ~/.claude/projects/ and fuzzy-match against the current project path. The directory name encodes the path with dashes replacing separators, but encoding varies by platform and may not be consistent for paths with spaces, special characters, or deep nesting. Discovery strategy: list all directories under ~/.claude/projects/, then find the one whose name best matches the current working directory (check if the directory name contains key path segments like the project folder name). Read MEMORY.md in that directory, then each .md file it links to. If no match is found or the memory directory can't be read, skip this source silently.

Read the full file on GitHub · 261 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. 5d ago First seen · 261 lines · 0 tokens per session scan B 6ea40c27884d

Subscribe to this mod's changes

extract-rules is a command published in the GitHub repository design-and-deliver/claude-code-autoconfig (2 stars, last pushed yesterday), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 2,916 tokens. A static security scan graded it B with 1 finding (reads agent configuration directories). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.