
Brewcode:Rules
- 19 installs
- 29 repo stars
- Updated August 2, 2026
- kochetkov-ma/claude-brewcode
Helps with ai & agent building tasks.
About
brewcode:rules is a Claude Code skill for ai & agent building. It helps solo builders move faster with AI-assisted development.
- brewcode:rules
- AI & Agent Building
- AI-coding skill
Brewcode:Rules by the numbers
- 19 all-time installs (skills.sh)
- +1 installs in the week ending Aug 2, 2026 (Skillselion tracking)
- Ranked #10,587 of 16,546 AI & Agent Building skills by installs in the Skillselion catalog
- Data as of Aug 3, 2026 (Skillselion catalog sync)
npx skills add https://github.com/kochetkov-ma/claude-brewcode --skill brewcoderulesAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 19 |
|---|---|
| repo stars | ★ 29 |
| Last updated | August 2, 2026 |
| Repository | kochetkov-ma/claude-brewcode ↗ |
What it does
Helps with ai & agent building tasks.
Files
TARGET: Project.claude/rules/only. NEVER~/.claude/rules/
<instructions>
Mode Detection
Arguments: $ARGUMENTS
| Input | Mode |
|---|---|
list | List mode |
<path> <text> | Prompt mode |
<path-to-file> | File mode |
| (empty) | Session mode |
List Mode
EXECUTE and STOP:
bash "${CLAUDE_SKILL_DIR}/scripts/rules.sh" listFile / Prompt / Session Mode
Spawn bc-rules-organizer agent via Task tool.
Prepare Knowledge by Mode
| Mode | Preparation |
|---|---|
| file | Read KNOWLEDGE.jsonl; parse t:"❌" → avoid, t:"✅" → practice |
| prompt | Extract <path> (first arg), <prompt> (rest) |
| session | Extract 5 most impactful findings: errors, fixes, patterns. Format as ❌ or ✅ |
Agent Prompt Template
Update PROJECT .claude/rules/ — NEVER ~/.claude/rules/
Plugin templates: $BC_PLUGIN_ROOT/templates/rules/
Validation: bash "$BC_PLUGIN_ROOT/skills/rules/scripts/rules.sh" validate
Create missing: bash "$BC_PLUGIN_ROOT/skills/rules/scripts/rules.sh" create
Targets: avoid.md, best-practice.md, {prefix}-avoid.md, {prefix}-best-practice.md
MODE: {detected mode}
KNOWLEDGE: {prepared from table above}
DEDUP: 3-Check Protocol:
1. Within-file similarity (>70% skip, 40-70% merge)
2. Cross-file antonym (avoid↔best-practice — keep avoid only)
3. CLAUDE.md duplicate (skip if in CLAUDE.md; "CLAUDE.md" forbidden as Source)BC_PLUGIN_ROOT injected by pre-task.mjs hook.Fallback
Agent unavailable → error: bc-rules-organizer not available — install brewcode plugin
</instructions>
Output
Forward agent report to user as-is.
Error Handling
| Condition | Action |
|---|---|
| Agent unavailable | Error + install instructions |
| No knowledge found | "No new rules extracted" |
| Plugin not found | STOP + install instructions |
MIT License
Copyright (c) 2025-2026 Maxim Kochetkov (kochetkov-ma)
https://github.com/kochetkov-ma/claude-brewcode
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Rules
Extracts learnings, anti-patterns, and best practices from KNOWLEDGE files, arbitrary files, or the current conversation -- then organizes them into structured .claude/rules/ files that Claude Code loads automatically on every session.
Quick Start
/brewcode:rulesScans the current session for the 5 most impactful findings and writes them to your project rules.
Modes
| Mode | Trigger | What it does |
|---|---|---|
| Session | /brewcode:rules (no arguments) | Extracts top 5 findings from the current conversation, classifies each as avoid or best-practice, writes to rules |
| File | /brewcode:rules path/to/KNOWLEDGE.jsonl | Parses a KNOWLEDGE.jsonl file, maps entries by type: t:"X" to avoid, t:"V" to best-practice |
| Prompt | /brewcode:rules path/to/file "your instructions" | Reads the given file and applies your custom prompt to extract rules from it |
| List | /brewcode:rules list | Lists all rule files in .claude/rules/ with entry counts per file |
Examples
Good Usage
# After a debugging session -- capture what you learned
/brewcode:rules
# Import rules from a completed brewcode task's knowledge file
/brewcode:rules .claude/tasks/20260401_auth_task/KNOWLEDGE.jsonl
# Extract SQL-specific rules from a code review document
/brewcode:rules docs/sql-review.md "Extract SQL anti-patterns and best practices"
# Check what rule files exist and how many entries each has
/brewcode:rules listCommon Mistakes
# WRONG: Passing a directory instead of a file
/brewcode:rules .claude/tasks/
# FIX: Point to the specific KNOWLEDGE.jsonl inside the task directory
/brewcode:rules .claude/tasks/20260401_auth_task/KNOWLEDGE.jsonl
# WRONG: Using "list" with extra arguments
/brewcode:rules list some-filter
# FIX: "list" takes no arguments -- it always shows all rule files
/brewcode:rules list
# WRONG: Expecting global rules to be updated
# The skill ONLY writes to project .claude/rules/, never to ~/.claude/rules/Output
Rule files are created or updated in your project's .claude/rules/ directory:
| File | Content |
|---|---|
avoid.md | General anti-patterns (table format: #, Avoid, Instead, Why) |
best-practice.md | General best practices (table format: #, Practice, Context, Source) |
{prefix}-avoid.md | Domain-specific anti-patterns (e.g., sql-avoid.md, test-avoid.md) |
{prefix}-best-practice.md | Domain-specific practices (e.g., sql-best-practice.md) |
All files use a markdown table format validated by the built-in rules.sh validate script.
Deduplication
New entries go through a 3-check protocol before being added:
1. Within-file similarity -- entries >70% similar are skipped, 40-70% are merged 2. Cross-file antonym -- if an item appears in both avoid and best-practice, only the avoid entry is kept 3. CLAUDE.md duplicate -- entries already covered in CLAUDE.md are skipped
Tips
- Run
/brewcode:rulesat the end of any long debugging or implementation session to capture learnings before they are lost to compaction. - Use prompt mode with a code review doc or retrospective notes to bulk-import rules from external sources.
- After importing, run
/brewcode:rules listto verify entry counts and spot unbalanced files. - Domain-specific rule files (e.g.,
test-avoid.md) keep rules organized and reduce noise for unrelated tasks.
Documentation
Full docs: rules
#!/bin/bash
# Brewcode Rules Script
# Multi-function script for /brewcode:rules skill
# Usage: rules.sh <mode> [options]
#
# Modes:
# read <path> - Read knowledge file (first 100 lines)
# check - Check existing rules files (main + specialized)
# create - Create missing main rules from templates
# create-specialized <prefix> - Create specialized rules (e.g., test-avoid.md)
# list - List all rule files (*-avoid.md, *-best-practice.md)
# validate - Validate table structure
set -euo pipefail
MODE="${1:-check}"
ARG="${2:-}"
# Self-location: derive plugin root from script path
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
# Path: scripts/rules.sh -> skills/rules/scripts -> skills/rules -> skills -> PLUGIN_ROOT
PLUGIN_ROOT="$(dirname "$(dirname "$(dirname "$SCRIPT_DIR")")")"
PLUGIN_TEMPLATES="$PLUGIN_ROOT/templates"
# Validate plugin structure
validate_plugin() {
if [ ! -d "$PLUGIN_ROOT" ]; then
echo "X Plugin root not found: $PLUGIN_ROOT"
exit 1
fi
if [ ! -d "$PLUGIN_TEMPLATES" ]; then
echo "X Templates not found: $PLUGIN_TEMPLATES"
exit 1
fi
}
# Read knowledge file
read_knowledge() {
local path="$1"
if [ -z "$path" ]; then
echo "X Missing path argument"
echo "Usage: rules.sh read <path>"
exit 1
fi
if [ -f "$path" ]; then
head -100 "$path"
else
echo "X File not found: $path"
exit 1
fi
}
# Check existing rules files (main + specialized)
check_rules() {
echo "=== Check Rules Files ==="
echo "--- Main Files ---"
test -f .claude/rules/avoid.md && echo "V avoid.md exists" || echo "! avoid.md missing"
test -f .claude/rules/best-practice.md && echo "V best-practice.md exists" || echo "! best-practice.md missing"
echo "--- Specialized Files ---"
local specialized_avoid specialized_bp
specialized_avoid=$(find .claude/rules -maxdepth 1 -name "*-avoid.md" 2>/dev/null | grep -v "^.claude/rules/avoid.md$" || true)
specialized_bp=$(find .claude/rules -maxdepth 1 -name "*-best-practice.md" 2>/dev/null | grep -v "^.claude/rules/best-practice.md$" || true)
if [ -n "$specialized_avoid" ] || [ -n "$specialized_bp" ]; then
echo "$specialized_avoid" | while read -r f; do [ -n "$f" ] && echo "V $(basename "$f")"; done
echo "$specialized_bp" | while read -r f; do [ -n "$f" ] && echo "V $(basename "$f")"; done
else
echo " (none found)"
fi
}
# Create missing rules from templates
create_rules() {
echo "=== Create Rules ==="
validate_plugin
mkdir -p .claude/rules
if [ ! -f .claude/rules/avoid.md ]; then
cp "$PLUGIN_TEMPLATES/rules/avoid.md.template" .claude/rules/avoid.md
echo "V Created: .claude/rules/avoid.md"
else
echo ">> Preserved: .claude/rules/avoid.md (exists)"
fi
if [ ! -f .claude/rules/best-practice.md ]; then
cp "$PLUGIN_TEMPLATES/rules/best-practice.md.template" .claude/rules/best-practice.md
echo "V Created: .claude/rules/best-practice.md"
else
echo ">> Preserved: .claude/rules/best-practice.md (exists)"
fi
}
# Validate table structure (main + specialized)
validate_rules() {
echo "=== Validate Rules Structure ==="
ERRORS=0
# Validate main files
if [ -f .claude/rules/avoid.md ]; then
grep -q "^| #" .claude/rules/avoid.md && echo "V avoid.md valid structure" || { echo "X avoid.md invalid structure (missing table header)"; ERRORS=$((ERRORS+1)); }
else
echo "X avoid.md not found"
ERRORS=$((ERRORS+1))
fi
if [ -f .claude/rules/best-practice.md ]; then
grep -q "^| #" .claude/rules/best-practice.md && echo "V best-practice.md valid structure" || { echo "X best-practice.md invalid structure (missing table header)"; ERRORS=$((ERRORS+1)); }
else
echo "X best-practice.md not found"
ERRORS=$((ERRORS+1))
fi
# Validate specialized files
for f in .claude/rules/*-avoid.md .claude/rules/*-best-practice.md; do
[ -f "$f" ] || continue
# Skip main files
[ "$(basename "$f")" = "avoid.md" ] && continue
[ "$(basename "$f")" = "best-practice.md" ] && continue
if grep -q "^| #" "$f"; then
echo "V $(basename "$f") valid structure"
else
echo "X $(basename "$f") invalid structure (missing table header)"
ERRORS=$((ERRORS+1))
fi
done
exit $ERRORS
}
# List all rule files
list_rules() {
echo "=== Rule Files in .claude/rules/ ==="
mkdir -p .claude/rules
echo "--- Avoid Files ---"
local avoid_count=0
for f in .claude/rules/avoid.md .claude/rules/*-avoid.md; do
if [ -f "$f" ]; then
rows=$(grep -c "^|" "$f" 2>/dev/null || echo 0)
rows=$((rows - 2)) # Subtract header and separator
[ $rows -lt 0 ] && rows=0
echo " $(basename "$f") ($rows entries)"
avoid_count=$((avoid_count + 1))
fi
done
[ $avoid_count -eq 0 ] && echo " (none found)"
echo "--- Best Practice Files ---"
local bp_count=0
for f in .claude/rules/best-practice.md .claude/rules/*-best-practice.md; do
if [ -f "$f" ]; then
rows=$(grep -c "^|" "$f" 2>/dev/null || echo 0)
rows=$((rows - 2)) # Subtract header and separator
[ $rows -lt 0 ] && rows=0
echo " $(basename "$f") ($rows entries)"
bp_count=$((bp_count + 1))
fi
done
[ $bp_count -eq 0 ] && echo " (none found)"
echo "---"
echo "Total: $((avoid_count + bp_count)) rule files"
}
# Create specialized rules from template with prefix
create_specialized() {
local prefix="$1"
if [ -z "$prefix" ]; then
echo "X Missing prefix argument"
echo "Usage: rules.sh create-specialized <prefix>"
echo "Example: rules.sh create-specialized test"
exit 1
fi
echo "=== Create Specialized Rules: $prefix ==="
validate_plugin
mkdir -p .claude/rules
local avoid_file=".claude/rules/${prefix}-avoid.md"
local bp_file=".claude/rules/${prefix}-best-practice.md"
if [ ! -f "$avoid_file" ]; then
# Create from template with prefix substitution
sed "s/# Avoid/# ${prefix^} Avoid/" "$PLUGIN_TEMPLATES/rules/avoid.md.template" > "$avoid_file"
echo "V Created: $avoid_file"
else
echo ">> Preserved: $avoid_file (exists)"
fi
if [ ! -f "$bp_file" ]; then
sed "s/# Best Practices/# ${prefix^} Best Practices/" "$PLUGIN_TEMPLATES/rules/best-practice.md.template" > "$bp_file"
echo "V Created: $bp_file"
else
echo ">> Preserved: $bp_file (exists)"
fi
}
# Main dispatch
case "$MODE" in
read)
read_knowledge "$ARG"
;;
check)
check_rules
;;
create)
create_rules
;;
create-specialized)
create_specialized "$ARG"
;;
list)
list_rules
;;
validate)
validate_rules
;;
*)
echo "Usage: rules.sh <mode> [options]"
echo ""
echo "Modes:"
echo " read <path> - Read knowledge file (first 100 lines)"
echo " check - Check existing rules files (main + specialized)"
echo " create - Create missing main rules from templates"
echo " create-specialized <prefix> - Create specialized rules (e.g., test-avoid.md)"
echo " list - List all rule files"
echo " validate - Validate table structure"
exit 1
;;
esac