PLUGIN brewcode / Agents
On this page
Rules Organizer
Internal agent with no direct or automatic invocation. The main orchestrator spawns it with an accepted, bounded rule batch from rules or the rule-writing phase of convention-setup.
Quick reference
| Field | Value |
|---|---|
| Model | haiku: pinned, cheap file reorganization |
| Tools | Read, Write, Edit, Glob, Grep, Bash |
| Write access | Briefed .claude/rules/ files plus its checkpoint/report directory |
maxTurns | 60: anti-loop stop, not a budget |
| Invocation | Main-caller Agent spawn; no manual trigger |
Rules Organizer turns extracted rules (docs, code, session learnings) into .claude/rules/*.md files with correct paths: frontmatter: one file per logical scope, deduplicated against existing rules, formatted as numbered tables. Two table formats are authoritative (| # | Avoid | Instead | Why | and | # | Practice | Context | Source |), and a 20-row-per-file ceiling forces a split into {prefix}-avoid.md / {prefix}-best-practice.md.
Example
/brewcode:rules "extract logging and SQL conventions from docs/conventions.md"
The skill proposes rule candidates, you accept them in batches, then it spawns bc-rules-organizer once. Expected result: .claude/rules/logging.md and .claude/rules/sql-best-practice.md created or updated with paths: frontmatter, numbered tables, and a report with file and rule counts.
How it works
- Analyze and extract
Reads the source fully, groups rules by scope, classifies each as avoid or best practice, checks existing rules first.
- Optimize and dedup
Prose becomes tables; a 3-check protocol drops near-duplicates. CLAUDE.md is a dedup baseline only, never a source.
- Write
Scaffold with
rules.sh createorcreate-specialized;rules.sh validatemust pass after every write. - Checkpoint and report
Appends each finished file to
.claude/reports/YYYYMMDD-HHMMSS_rules-organizer/report.md; the calling skill then runsbrewtools:text-optimize.
It refuses anything beyond rule organization, writes to global rules or CLAUDE.md, and spawning optimizers (it has no Agent tool). A brief without CONTEXT or CONSUMER gets a stated assumption or a question back. Generic rules: scope guard. If it exhausts maxTurns, the files already written survive and main resumes it with SendMessage.
Rule-file frontmatter and loading #
paths: is the only field Claude Code reads for scoping (memory docs). rules.sh validate also requires doc_type, version, generated_by, last_updated. The agent never adds description: and does not use ! negation in paths.
---
paths:
- "src/components/**/*.tsx"
doc_type: llm
version: "6.1.4"
generated_by: "brewcode:rules"
last_updated: "2026-09-12"
---Quote the patterns and give them as an array; doc_type: llm is the one unquoted value. rules.sh create stamps doc_type, version, generated_by and last_updated on a new file; an edit refreshes only last_updated and version.
| Frontmatter | Loads |
|---|---|
No paths | At session start, like project CLAUDE.md |
With paths | Lazily, when Claude reads a matching file (rechecked through 2.1.296) |
Language and directory conventions get paths:; tool-choice policy (lsp-first, semble-first) and global anti-patterns do not.
Dedup protocol and file naming #
| Check | Scope | Action |
|---|---|---|
| 1. Within-file | Same target file | >70% similarity skip; 40-70% merge |
| 2. Cross-file antonym | Paired avoid/best-practice file | Keep the avoid entry, delete the best-practice one |
| 3. CLAUDE.md | Project CLAUDE.md | Already documented: skip; "CLAUDE.md" is a forbidden Source value |
| Pattern | Example | Content |
|---|---|---|
| Global | avoid.md, best-practice.md | No paths: |
| Path-scoped pair | {prefix}-avoid.md, {prefix}-best-practice.md | Prefixes: test, sql, api, security, kotlin, java, react |
| Domain-specific | bq-core.md, logging.md | Mixed tables under one paths: scope |
Editing an existing file only refreshes last_updated and version by hand. A new rule file starts from the closest well-built file in .claude/rules/*.md, additive, never a wholesale replacement.
Return contract #
Verdict first, at most 30 lines, path:line. One row per file (path, matched paths:, change) plus totals: new/updated, rule counts, dedup skipped/merged, optimizer run or skipped. The dedup ledger and rationale go to the checkpoint file; only the path comes back. /brewtools:agent-return-setup enforces ~2500 / ~6000 est-tokens when installed.
Related
rules skill
Convention Setup
Brewcode overview
GitHub source
Update: /brewtools:plugin-update, /reload-plugins, then /brewcode:setup-status upgrade - FAQ