rules sonnet

Project scope only

Writes to project .claude/rules/ only — never ~/.claude/rules/.

Quick reference

FieldValue
Command/brewcode:rules
Input[list] | [<path>] | [<path> <prompt>]
Specialistbc-rules-organizer (Task)
List sourcerules.sh list (Bash)
Target dir.claude/rules/ (project only)

When to use

  • After fixing a bug: capture what went wrong and the correct pattern
  • After a code review: lock in the standards that were enforced
  • After a session with many learnings: extract the 5 most impactful findings
  • To inspect which rules already exist in the project
  • To import structured knowledge from a KNOWLEDGE.jsonl file

Examples

/brewcode:rules
/brewcode:rules what is the current state of our rules
/brewcode:rules capture what we learned fixing the auth bug
/brewcode:rules path/to/KNOWLEDGE.jsonl add new entries
/brewcode:rules list

How it works

  1. Input gate

    Reads $ARGUMENTS. If the first token is list, routes immediately to rules.sh list and exits. Otherwise continues to mode detection.

  2. Auto-mode select

    Announces Mode: <mode> (rules) — chosen because <evidence>. Defaults to status when arguments are empty or conversational; detects create, improve, or review from explicit cues. A .jsonl path or inline prompt is treated as a knowledge source passed to the organizer, not a separate mode.

  3. No-prompt menu

    When no arguments are given and mode cannot be inferred, sends a single AskUserQuestion with options in this order: Status (rules) (recommended), Status (all: agents+rules+skills), Create, Improve, Review, List (plain), Cancel.

  4. Dispatch

    Routes to bc-rules-organizer via the Task tool, passing the prepared knowledge block and mode. For list mode, runs rules.sh list directly via Bash instead.

  5. Real status

    Reports which files were created or updated (avoid.md, best-practice.md, or prefix variants). If bc-rules-organizer is unavailable, outputs: bc-rules-organizer not available — install brewcode plugin.

  6. Final output

    Prints a summary of rules added, merged, or skipped, grouped by target file. Skipped entries include the dedup reason (similarity %, cross-file antonym, or CLAUDE.md duplicate).

Modes

ModeTriggerExecution
status (default)Empty input or conversational status queryReports current rule files and coverage; delegates to bc-rules-organizer
listExplicit list argument onlyRuns rules.sh list directly — no agent spawned
createConversational cue or menu selectionCreates missing rule files from plugin templates; accepts KNOWLEDGE.jsonl or inline prompt as knowledge source
improveConversational cue or menu selectionRewrites weak or redundant entries for clarity; accepts KNOWLEDGE.jsonl or inline prompt as knowledge source
reviewConversational cue or menu selectionReads all rule files and reports coverage gaps
batchAuto fan-out flagProcesses multiple knowledge entries in one pass alongside the selected mode
Knowledge sources & dedup

Sources accepted:

  • KNOWLEDGE.jsonl path — parses each line; t:"❌" maps to avoid, t:"✅" maps to best-practice
  • File path + inline prompt — organizer reads the file and uses the prompt as instruction
  • Session learnings — the skill selects the 5 most impactful findings from the current conversation and formats them as ❌/✅ pairs

Output files: avoid.md, best-practice.md, {prefix}-avoid.md, {prefix}-best-practice.md — all inside .claude/rules/

3-Check dedup protocol:

  1. Within-file similarity: >70% match → skip; 40–70% match → merge into existing entry
  2. Cross-file antonym check: if the same pattern appears in both avoid and best-practice → keep the avoid entry only
  3. CLAUDE.md duplicate: if the content already appears in CLAUDE.md, skip entirely. The string "CLAUDE.md" is forbidden as a Source value in rule entries

Specialist: bc-rules-organizer — acts as organizer only (no separate creator agent). Spawned via the Task tool; the agent resolves paths via native ${CLAUDE_PLUGIN_ROOT} (substituted in its .md at Task spawn).

⚙️

agents

Sibling: manage agents
✏️

skills

Sibling: manage skills
🚀

brewcode

Plugin overview
🔗

GitHub source

SKILL.md

Updating plugins

Use /brewtools:plugin-update to check and update the brewcode plugin suite in one command. See the FAQ for details.