patterns/rule-extractor/skills/rule-extractor/SKILL.md
Use when: merged PR had HIGH/CRITICAL findings that represent a bug class — extracts reusable coding rule
npx skillsauth add ryderfreeman4logos/cli-sub-agent rule-extractorInstall 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.
Transform verified HIGH/CRITICAL review findings into reusable coding rules. When pr-bot identifies a structural bug class, this skill extracts the lesson into a rule file so the bug class goes extinct — agents see the rule at write-time and avoid the anti-pattern entirely.
Post-merge extraction (Option 2) ensures rules come from the FINAL fix state, not intermediate review iterations.
This skill activates as a post-merge step in pr-bot when:
The orchestrator invokes this skill via:
csa plan run --sa-mode true patterns/rule-extractor/workflow.toml
When operating under SA mode, ALL csa invocations MUST include --sa-mode true.
Collect findings: Read merged PR's review artifacts. Parse findings.toml
from review session output directory (or PR comments as fallback). Emits
CSA_VAR:FINDING_DESCRIPTION, CSA_VAR:FINDING_SEVERITY, CSA_VAR:FINDING_FILE
for the first HIGH/CRITICAL finding. One finding per invocation.
Classify each finding (bash step): Dispatch LLM classifier via csa run
to determine BUG_CLASS vs ISOLATED_MISTAKE. Emits
CSA_VAR:HAS_BUG_CLASS_FINDINGS=yes when bug classes found. Only bug classes proceed.
Deduplicate against existing rules: Search project-local rules
(docs/rules-proposed/). Use keyword grep + semantic LLM comparison
with actual matched file content (both in a single bash block). Emits
CSA_VAR:SHOULD_DRAFT and CSA_VAR:DEDUPE_RESULT.
Generate rule draft (bash, dispatches csa run): Structure mirrors rust/017-concurrent-file-primitives.md.
Captures draft between RULE_DRAFT_START/END markers into DRAFT_FILE.
Emits CSA_VAR:DRAFT_FILE and CSA_VAR:STEP4_SESSION_ID:
Include frontmatter for traceability:
---
source: pr-bot-finding
pr: "#<PR_NUM>"
severity: HIGH|CRITICAL
extracted-at: <ISO-8601>
finding-ids: [<IDs>]
---
Propose via PR: NEVER auto-commit. Reads draft from DRAFT_FILE (Step 4).
Create branch chore/rules-propose-<shortsha>-<bug-class-slug>, commit rule file, push, open PR.
Human review is mandatory before merge.
On rule-proposal PR merge, update relevant AGENTS.md with one compact line:
NNN|bug-class-slug|one-line summary
All four must pass before a finding enters the pipeline:
Two-layer dedup prevents rule proliferation:
docs/rules-proposed/<lang>/ (project-local, fork-only per rule 030)development
Use when running a non-blocking CSA background code health scan that uses csa health and csa tokuin estimate to propose refactoring GitHub issues for files over token or complexity thresholds.
data-ai
Recover main-agent context after `/clear`, `/compact`, or lost local thread state by using `csa recall` against recorded Claude main sessions.
tools
Use when: review found 2+ independent findings in different files, fix phase can parallelize RECON
documentation
Split monolith project documentation (CLAUDE.md, etc.) into condensed summary + reference detail files following AGENTS.md pattern