hiroro-work/claude-plugins/extract-rules
Claude Code and agent skill by hiroro-work/claude-plugins
- community
- ext:[{"type":"config","description":"Configuration overrides"}]
Checking that the SKILL.md file is still in the repository.
Extract project-specific coding rules and domain knowledge from existing codebase, generating markdown documentation for AI agents. Use when onboarding a new project, after code review discussions about coding style, or when coding conventions need documenting. Also consider running after sessions where coding preferences were discussed or corrected (--from-conversation), or after PRs with significant review feedback (--from-pr).
Install
npx vskill@latest install hiroro-work/claude-plugins/extract-rulesSemi-extensibleMentions customization, but needs skill-specific knowledge. Read the extensible skills standard
SKILL.md
Extract Rules
Analyzes existing codebase to identify what Claude would get wrong without project-specific guidance, extracting coding rules and domain knowledge as structured markdown documentation for AI agents.
Usage
Change-origin flags: a change-based extraction is scoped only by --from-conversation or --from-pr. This skill accepts no diff-base / commit-sha origin argument such as --base-commit <sha>; passing one is unsupported.
Configuration
Settings file: extract-rules.local.md (YAML frontmatter only, no markdown body)
- Project-level:
.claude/extract-rules.local.md(takes precedence) - User-level:
~/.claude/extract-rules.local.md
| Setting | Default | Description | |
|---|---|---|---|
target_dirs | ["."] | Analysis target directories | |
exclude_dirs | [".git", ".claude"] | Exclude directories (in addition to .gitignore) | |
exclude_patterns | [] | Exclude file patterns (e.g., *.generated.ts, *.d.ts) | |
output_dir | .claude/rules | Output directory for rule files (.md and .local.md) | |
examples_output_dir | .claude/rules-extras | Output directory for .examples.md files. Defaults to a sibling directory outside .claude/rules/** so examples are not auto-loaded into context on session start. Set to output_dir (or any path under output_dir) to opt examples back into auto-load | |
staging_output_dir | .claude/rules-staging | Output directory for 1st-observation project-level patterns staged by incremental modes. Defaults to a sibling directory outside .claude/rules/** so staged candidates are not auto-loaded into context on session start. Set to output_dir (or any path under output_dir) to opt staging back into auto-load. Staging gating and the promote path: references/conversation-mode.md § Step C5 and § Mode interaction summary. Also holds lint-candidates.md (references/audit-pass.md § Lint candidate writes) | |
language | ja | Report language (e.g., ja) | |
split_output | true | Separate Principles (.md) and patterns (.local.md) | |
resolve_references | true | Resolve file references during restructure | |
compaction_threshold | 40000 | Char count threshold for --compact mode (file is compacted if char count exceeds this). Set to a very large number (e.g. 99999999) to opt out of compaction. The default 40000 matches Claude Code's per-file warning threshold (40k chars, observed in Claude Code 2.1.x) — firing the gate exactly at the warning matches the user's visible signal that the file needs attention (buffer 0). | |
min_cluster_size | 3 | Minimum related-bullet cluster size for --compact mode's consolidation detection. The subagent emits consolidation_proposals only when a cluster has at least this many related bullets. Set to a very large number (e.g. 99999999) to disable consolidation while keeping compaction |
Output Structure
Three output directories are involved: output_dir for rule files (.md / .local.md), examples_output_dir for .examples.md files, and staging_output_dir for staged 1st-observation project-level patterns and lint candidates from incremental modes. The paths: frontmatter on rule files is a human-facing category-scope hint; the auto-load boundary is determined by directory placement only.
Default (split_output: true):
Principles (portable across projects) and Project-specific patterns (local) are separated by default.
Hybrid mode (split_output: false): no <name>.local.md — each <name>.md carries both ## Principles and ## Project-specific patterns. The other two directories are unchanged.
Layered frameworks (Rails, Django, Spring, etc.): When a framework has distinct architectural layers, generate layer-specific files:
<framework>.md— Cross-layer rules (nopaths:or broad scope)<framework>-<layer>.md— Layer-specific rules with scopedpaths:(e.g.,app/models/**)- In split mode, both cross-layer and layer-specific files get
.local.mdcounterparts
Integration libraries (Inertia, Pundit, Devise, Turbo, etc.): When integration libraries are detected alongside a layered framework:
integrations/<framework>-<integration>.md— Integration-specific rules- Separated from layer files into dedicated
integrations/directory - In split mode, integration files also get
.local.mdcounterparts
Format switching: Run --restructure after changing split_output setting to switch between split and hybrid formats.
Dispatch authorization
This skill's procedure dispatches subagents, so invoking the skill is the request to use that mechanism: an ambient instruction allowing subagent dispatch only when the user asked for it — a permission-shaped restriction — is already satisfied by this invocation. Do not ask the user to re-confirm the dispatch, and do not silently substitute inline execution for a dispatch this procedure specifies. Only two things justify that substitution: technical availability (the dispatch tool is not present and callable on the current tool surface), and an explicit contract term from the caller bounding this skill to its own thread. A permission-shaped restriction is neither.
Processing Flow
Mode Detection
Check arguments to determine mode:
- No arguments → Full Extraction Mode (Step 1-7)
--update→ Update Mode (Step U1-U6)--restructure→ Restructure Mode (Step R1-R5)--from-conversation [session-id]→ Conversation Extraction Mode (Step C1-C5)--compact [<paths>]→ Compaction Mode (Step CP1-CP5)--realign [<paths>]→ Realign Mode (Step RA1-RA5)--from-pr <number|owner/repo#number|range> [...]→ PR Review Extraction Mode (Step P1-P5)--apply-conversation-candidates <path>→ Conversation Candidate Apply Mode (Step A1-A2)
Full Extraction Mode
Step 1: Load Settings
Search for extract-rules.local.md:
- Project-level:
.claude/extract-rules.local.md - User-level:
~/.claude/extract-rules.local.md
Priority:
- If both exist, use project-level only
- If only one exists, use that file
- If neither exists, use default settings
Extract settings (target_dirs, exclude_dirs, exclude_patterns, output_dir, examples_output_dir, staging_output_dir, language, split_output, resolve_references, compaction_threshold) from the config file. See Configuration section above for defaults.
`language` resolution: skill config → Claude Code settings (~/.claude/settings.json language field) → default ja. Write the report's prose in plain words, one claim per sentence, with no figure of speech translated word for word.
Load existing rule files (incremental modes; Full Extraction skips it): read <output_dir>/<name>.md, <output_dir>/<name>.local.md, and <examples_output_dir>/<name>.examples.md. When examples_output_dir does not exist yet (legacy projects that co-located examples under output_dir), use <output_dir>/<name>.examples.md instead. Also read <staging_output_dir>/project.staging.local.md when present — the staging-match branch needs it; skip silently when it does not exist.
Step 2: Detect Project Type
Detect project language and framework:
1. Detect languages by config files (package.json, tsconfig.json, pyproject.toml, go.mod, Cargo.toml, Gemfile, pom.xml, etc.) and file extensions (.ts/.tsx, .py, .go, .rb, etc.)
2. Detect frameworks by their config files (e.g., next.config.*, playwright.config.*) and dependencies in package manifests.
3. Detect architectural layers (for layered frameworks): If a framework has distinct layers with separate directories (e.g., Rails: app/models/, app/controllers/; Django: models.py, views.py), detect them for layer-specific rule files. Only split when corresponding directories actually exist.
4. Detect integration libraries (for layered frameworks): Read references/integration-criteria.md for detection rules and classification criteria.
Output: List of detected languages, frameworks, architectural layers, and integration libraries
Step 3: Collect Sample Files
Collect target files for analysis:
- Get git-tracked files using
git ls-files(respects.gitignore). If not a git repo, use Glob instead, with manual exclusions from settings. - Filter by
target_dirs,exclude_dirs,exclude_patterns, and detected language extensions - Sample 10-15 files per category, distributed across directories for representative coverage. Large projects (100+): prioritize directory diversity. Small projects (<10): analyze all files.
Step 4: Analyze by Category
Read references/extraction-criteria.md before proceeding to understand the classification criteria. The core question for every pattern is: "Would Claude produce something different without knowing this?" — extract only what fills the gap between Claude's general knowledge and this project's actual conventions.
For each detected language, framework, and integration library:
- Use Grep/Read to collect relevant code patterns
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/extract-rules/SKILL.md
Popularity
- Repository stars
- 26
- 7-day trend score
- 16
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 4 Apr 2026, 7 months ago.
Extension points
configConfiguration overrides
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/hiroro-work/claude-plugins/extract-rules)