brewcode/skills/convention/SKILL.md
Extracts etalon classes, patterns, architecture into convention docs. Triggers: extract conventions, etalon classes.
npx skillsauth add kochetkov-ma/claude-brewcode brewcode:conventionInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Arguments: $ARGUMENTS
| Mode | Invocation | Phases | Prerequisites |
|------|-----------|--------|---------------|
| full (default) | /brewcode:convention | P0-P8 | None |
| conventions | /brewcode:convention conventions | P0-P7 | None |
| rules | /brewcode:convention rules | P0, P7, P7.5, P8 | .claude/convention/ exists |
| paths | /brewcode:convention paths src/a,src/b | P0-P7 scoped | None |
Parse $ARGUMENTS for mode keyword. Default = full. For paths mode: split comma-separated paths after keyword.
EXECUTE using Bash tool:
bash "${CLAUDE_SKILL_DIR}/scripts/convention.sh" detect-stack && echo "---DETECT-OK---" || echo "---DETECT-FAILED---"
Output: JSON {"stacks":[...],"primary":"...","build_file":"...","modules":[...]}.
| Primary Stack | Active Layers | |---------------|-------------| | java, kotlin | L1-L14, T1-T6 (all) | | typescript | L1-L6, L8, L10-L11, L13-L14, T1-T3, T5-T6 | | python | L1-L2, L4-L6, L8, L10, L13-L14, T1-T3, T5-T6 | | rust | L1-L2, L4-L6, L8, L10-L11, T5 | | go | L1-L2, L4-L6, L8, L10, T5 | | Multi-stack | Union of all detected | | other/unknown | All main layers (L1-L14), all test layers (T1-T6) — agent determines relevance per layer |
EXECUTE using Bash tool:
bash "${CLAUDE_SKILL_DIR}/scripts/convention.sh" scan && echo "---SCAN-OK---" || echo "---SCAN-FAILED---"
Output: JSON with source_dirs, file_counts, modules, total_files.
If
total_files> 1000: warn user, suggestpathsmode.
EXECUTE using Bash tool:
bash "${CLAUDE_SKILL_DIR}/scripts/convention.sh" setup && echo "---SETUP-OK---" || echo "---SETUP-FAILED---"
STOP if FAILED -- cannot proceed without output directory.
EXECUTE using Bash tool:
bash "${CLAUDE_SKILL_DIR}/scripts/convention.sh" validate && echo "---VALID---" || echo "---INVALID---"
If
rulesmode +INVALID-- exit: "Run/brewcode:convention conventionsfirst."
Read references/analysis-layers.md. Filter layers by detected stack from P0. For paths mode: further filter by specified paths — match layer file patterns against provided paths. Build ACTIVE_LAYERS for P2.
Before spawning agents, check for project team agents:
.claude/teams/ exists — read team.md for agent roster with domainsSpawn ALL agents in a SINGLE message. Skip agents for inactive layers (filtered in P1).
| # | Agent | Layers | Focus | |---|-------|--------|-------| | 1 | architect | L1-L3 | Build config, dependency management, code generation | | 2 | architect | L4 | @UtilityClass, static helpers, shared converters | | 3 | architect | L5+L14 | REST endpoints, security, config, caching | | 4 | architect | L6+L9 | DI patterns, @Transactional, domain services | | 5 | architect | L7 | Feign clients, external API integrations | | 6 | architect | L8 | JOOQ DSL, raw SQL, mappers, query patterns | | 7 | architect | L10+L11 | Records, @Value @Builder, naming conventions | | 8 | architect | L12+L13 | DDL scripts, config files, templates | | 9 | tester | T1-T4 | Test data, base classes, helpers, ExpectedData | | 10 | tester | T5-T6 | BDD style, assertion patterns, @ParameterizedTest |
Per-agent prompt template:
Analyze {LAYERS} in the project.
Stack: {DETECTED_STACK}
Layer definitions:
{LAYER_CRITERIA_FROM_ANALYSIS_LAYERS_MD}
Use grepai_search FIRST for file discovery, then Glob/Grep for verification.
For paths mode, scope analysis to: {SCOPED_PATHS}
Output format:
## Etalon Candidates
| Class | Path | Why Etalon | Score (1-10) |
## Naming Conventions
| Pattern | Example | Frequency |
## Directory Rules
| Rule | Path Pattern |
## Patterns (code snippets, max 3, 5-15 lines each)
### Pattern Name
` ```code```
Why: explanation
## Anti-Patterns
| Class | Problem | Fix |
After all P2 agents complete, spawn 1 architect agent with combined results.
Prompt:
Receive analysis from 10 layer-analysis agents. Select 1-2 etalons per layer based on:
- Highest score from candidates
- Most complete pattern coverage
- Best naming convention adherence
- Fewest anti-patterns
If same class appears as etalon for multiple layers, assign to most relevant layer.
Input: {ALL_10_AGENT_OUTPUTS}
Output:
## Final Etalon Summary
| Layer | Etalon Class | Path | Score | Role |
## Conflict Resolutions
| Class | Claimed By | Assigned To | Reason |
## Coverage Gaps
| Layer | Issue | Recommendation |
Read references/conventions-guide.md for templates. Spawn 3 developer agents in ONE message.
| # | Document | Target |
|---|----------|--------|
| 1 | .claude/convention/reference-patterns.md | ~300 lines -- main code layers (L4-L11, L14): etalons, patterns, anti-patterns, quick reference |
| 2 | .claude/convention/testing-conventions.md | ~150 lines -- test layers (T1-T6): test etalons, patterns, assertion conventions |
| 3 | .claude/convention/project-architecture.md | ~200 lines -- build layers (L1-L3, L12-L13): build, deps, codegen, migrations, structure |
Per-agent prompt:
Generate {DOCUMENT_NAME} following the template from conventions-guide.
Target structure: {TEMPLATE_FROM_CONVENTIONS_GUIDE}
Etalon selection: {P3_ETALON_SUMMARY}
Layer analyses: {RELEVANT_P2_OUTPUTS}
Stack: {DETECTED_STACK}
Write to: .claude/convention/{filename}.md
Structure: organized by layer -- each with Etalon Classes table, Patterns (5-15 lines each, max 3/layer), Anti-Patterns table, Quick Reference table at end.
Target: ~{LINE_COUNT} lines.
IF text-optimizer agent is available (brewtools installed):
Spawn 3 text-optimizer agents in ONE message (medium mode):
Task(subagent_type="text-optimizer", prompt="FIRST: Read $BT_PLUGIN_ROOT/skills/text-optimize/references/rules-review.md. THEN optimize .claude/convention/reference-patterns.md using medium mode. Output report with metrics.")
Task(subagent_type="text-optimizer", prompt="FIRST: Read $BT_PLUGIN_ROOT/skills/text-optimize/references/rules-review.md. THEN optimize .claude/convention/testing-conventions.md using medium mode. Output report with metrics.")
Task(subagent_type="text-optimizer", prompt="FIRST: Read $BT_PLUGIN_ROOT/skills/text-optimize/references/rules-review.md. THEN optimize .claude/convention/project-architecture.md using medium mode. Output report with metrics.")
ELSE (brewtools not installed -- fallback):
Read ${CLAUDE_SKILL_DIR}/../convention/references/text-optimize-fallback.md for compact rules. Apply rules manually to all 3 generated documents.
Present summary:
## Convention Documents Generated
| Document | Lines | Key Etalons (top 5) |
|----------|-------|---------------------|
| reference-patterns.md | {N} | {class1}, {class2}, ... |
| testing-conventions.md | {N} | {class1}, {class2}, ... |
| project-architecture.md | {N} | {file1}, {file2}, ... |
AskUserQuestion options:
Read references/rules-guide.md for interactive flow.
| Source Section | Rule Type | |---------------|-----------| | Anti-Patterns tables | avoid | | Patterns sections | best-practice | | Naming Conventions | best-practice | | Constraints | avoid |
Read existing .claude/rules/*.md files.
| Similarity | Action | |------------|--------| | >70% | Skip (already covered) | | 40-70% | Merge into existing entry | | <40% | New rule candidate |
Present 5-7 rules per batch via AskUserQuestion:
## Rules Batch {N}/{TOTAL}
| # | Type | Rule | Target File |
|---|------|------|-------------|
| 1 | avoid | ... | {prefix}-avoid.md |
| 2 | bp | ... | {prefix}-best-practice.md |
Options: Accept all | Select by number | Skip batch | Stop
Spawn bc-rules-organizer per references/rules-guide.md Section 4. Pass {ACCEPTED_RULES_JSON} from interactive batching.
AskUserQuestion: "Update project CLAUDE.md with etalon summary table + convention references?"
If yes:
CLAUDE.md## Reference Patterns & Etalon Classes section## Reference Patterns & Etalon Classes
> **Full doc**: `.claude/convention/reference-patterns.md` (lazy-load when writing new code)
| When writing... | Copy from (etalon) |
|-----------------|---------------------|
| {role} | `{ClassName}` -- {key traits} |
### DTO Evolution (prefer top)
1. **{preferred}** -- PREFER for new code
2. **{established}** -- OK for complex entities
3. **{legacy}** -- AVOID
## Convention Analysis Complete
| Document | Path | Lines | Key Etalons |
|----------|------|-------|-------------|
| reference-patterns.md | `.claude/convention/reference-patterns.md` | {N} | {list} |
| testing-conventions.md | `.claude/convention/testing-conventions.md` | {N} | {list} |
| project-architecture.md | `.claude/convention/project-architecture.md` | {N} | {list} |
| When writing... | Copy from... |
|-----------------|-------------|
| {condensed top etalons} | {class} |
| Metric | Value |
|--------|-------|
| Rules extracted | {X} |
| Rules applied | {Y} |
| Duplicates skipped | {Z} |
Next Steps: Review `.claude/convention/` | `/brewcode:convention rules` to re-extract later | `/brewcode:convention paths src/new-module` for new modules
| Condition | Action |
|-----------|--------|
| No source files found | Exit: "No source files found for {STACK}" |
| rules mode without .claude/convention/ | Exit: "Run /brewcode:convention conventions first" |
| >1000 source files | Warn user, suggest paths mode |
| Unknown stack | Continue with generic analysis (no stack-specific layers) |
| Agent timeout | Log warning, continue with available results |
| grepai unavailable | Fall back to Glob + Grep for file discovery |
| Convention doc generation fails | Retry once, then present partial results |
development
Publish HTML, markdown, text, any file, or a multi-file site to brewpage.app — free hosting with no sign-up. Paste text, share a file, upload a site, or host a temporary page and get an instant public URL to share a link. Asks namespace and password, returns the public URL. Triggers: publish, publish HTML, share link, share a link, share a file, upload to brewpage, host page, host a temporary page, host a website, free hosting, paste text, instant public URL, no sign-up, brewpage, publish site, upload site, upload directory, deploy site, сделай публичную ссылку, опубликуй.
tools
Toggles terse-output mode to cut preamble and filler. Triggers: think-short, be terse, think shorter.
devops
Publish content to brewpage.app — text, markdown, JSON, file, or multi-file site. Asks namespace and password, returns public URL. Triggers: publish, share link, upload to brewpage, host page, brewpage, publish site, upload site, upload directory, deploy site, сделай публичную ссылку, опубликуй.
data-ai
Generate AI images via OpenRouter, Z.ai, Imagen 4, DALL-E 3, anti-slop. Triggers: generate image, AI image, og image.