一键导入
rule-extractor
Use when: merged PR had HIGH/CRITICAL findings that represent a bug class — extracts reusable coding rule
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Use when: merged PR had HIGH/CRITICAL findings that represent a bug class — extracts reusable coding rule
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Use when: full dev cycle branch->plan->implement->review->PR->merge
Use when: executing tasks via csa run/review/debate, session mgmt
Use when: iterative review-fix loop until csa review --diff is clean
Use when: running CSA-driven code review, independent model selection
Use when: three-layer manager-employee orchestration for delegation
Use when: legacy alias, redirects to dev2merge pipeline
| name | rule-extractor |
| description | Use when: merged PR had HIGH/CRITICAL findings that represent a bug class — extracts reusable coding rule |
| allowed-tools | Bash, Read, Grep, Glob |
| triggers | ["rule-extractor","/rule-extractor","extract rule","extract rules from findings","closed-loop learning"] |
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)