PLUGIN brewcode / Agents

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

FieldValue
Modelhaiku: pinned, cheap file reorganization
ToolsRead, Write, Edit, Glob, Grep, Bash
Write accessBriefed .claude/rules/ files plus its checkpoint/report directory
maxTurns60: anti-loop stop, not a budget
InvocationMain-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

  1. Analyze and extract

    Reads the source fully, groups rules by scope, classifies each as avoid or best practice, checks existing rules first.

  2. Optimize and dedup

    Prose becomes tables; a 3-check protocol drops near-duplicates. CLAUDE.md is a dedup baseline only, never a source.

  3. Write

    Scaffold with rules.sh create or create-specialized; rules.sh validate must pass after every write.

  4. Checkpoint and report

    Appends each finished file to .claude/reports/YYYYMMDD-HHMMSS_rules-organizer/report.md; the calling skill then runs brewtools: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.

FrontmatterLoads
No pathsAt session start, like project CLAUDE.md
With pathsLazily, 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 #
CheckScopeAction
1. Within-fileSame target file>70% similarity skip; 40-70% merge
2. Cross-file antonymPaired avoid/best-practice fileKeep the avoid entry, delete the best-practice one
3. CLAUDE.mdProject CLAUDE.mdAlready documented: skip; "CLAUDE.md" is a forbidden Source value
PatternExampleContent
Globalavoid.md, best-practice.mdNo paths:
Path-scoped pair{prefix}-avoid.md, {prefix}-best-practice.mdPrefixes: test, sql, api, security, kotlin, java, react
Domain-specificbq-core.md, logging.mdMixed 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.

rules skill

Interactive extraction, accepted batches and main-caller optimization.

Convention Setup

Establish coding, testing and architecture patterns before creating teams.

Brewcode overview

All brewcode skills and agents in one place.

GitHub source

Agent definition, table formats, and dedup protocol in full.

Update: /brewtools:plugin-update, /reload-plugins, then /brewcode:setup-status upgrade - FAQ