blueprint-plugin/skills/blueprint-derive-rules/SKILL.md
Derive Claude rules from git commit history. Use when extracting implicit decisions from commits or codifying code-style, testing, and API-design rules.
npx skillsauth add laurigates/claude-plugins blueprint-derive-rulesInstall 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.
Extract project decisions from git commit history and codify them as Claude rules. Newer commits override older decisions when conflicts exist.
Use case: Derive implicit project patterns from git history to establish consistent AI-assisted development guidelines.
Usage: /blueprint:derive-rules [--since DATE] [--scope SCOPE]
| Use this skill when... | Use alternative when... | |------------------------|-------------------------| | Want to extract implicit decisions from git history | Creating rules from requirements (use PRDs instead) | | Project has significant commit history | New project with little history | | Establishing project coding standards | Quick manual rule creation |
git rev-parse --git-dirfind docs/blueprint -maxdepth 1 -name 'manifest.json' -type fgit rev-list --count HEADgit log --format="%s"find .claude/rules -maxdepth 1 -name "*.md" -type ffind .claude/rules/blueprint -maxdepth 1 -name "*.md" -type fParse $ARGUMENTS:
--since DATE: Analyze commits from specific date (e.g., --since 2024-01-01)--scope SCOPE: Focus on specific area (e.g., --scope api, --scope testing)Execute the complete git-to-rules derivation workflow:
Read structure.generated_rules_path from docs/blueprint/manifest.json (default .claude/rules/):
RULES_DIR=$(jq -r '.structure.generated_rules_path // ".claude/rules/"' docs/blueprint/manifest.json)
mkdir -p "$RULES_DIR"
Use $RULES_DIR for all subsequent reads/writes and conflict checks. Hand-written files in the parent .claude/rules/ are intentionally invisible to this skill (issue #1043).
/blueprint:init first--since and --scope flags to determine analysis rangeUse parallel agents to analyze git history efficiently (see REFERENCE.md):
refactor: commits for code style patternsfix: commits for repeated issue typesfeat!: and BREAKING CHANGE: commits for architecture decisionschore: and build: commits for tooling decisionsConsolidate findings by domain (code-style, testing, api-design, etc.), chronologically (newest first), and by frequency (most common wins).
When multiple commits address the same topic:
git log --format="%H|%ai|%s" | grep "{topic}"feat!: trumps regular commits$RULES_DIRFor each decision, generate rule file using template from REFERENCE.md. Write each file to $RULES_DIR/<filename>.md (the configured structure.generated_rules_path):
Extract source commit, date, type
Determine confidence level (High/Medium/Low based on commit frequency and clarity)
Generate actionable rule statement
Include code examples from commit diffs
Reference any superseded earlier decisions
REQUIRED: scope every generated rule via paths: frontmatter unless the rule genuinely applies everywhere. Rules without paths: load on every session and pollute context for unrelated work. Pick paths: from the source signal:
| Signal | Source | paths: value |
|---|---|---|
| Rule body cites a specific file via "patterns extracted from <path>" | Step 3 / 4 conflict resolution | Glob over that file's directory: <dir>/**/*.<ext> |
| Rule was derived from chore(deps) / build: commits | Tooling-decision agent | Lockfiles + manifests: package.json, pyproject.toml, Cargo.toml, go.mod, *.lock, biome.json, etc. |
| Rule references a language (refactor: + JS-only code blocks) | Code-style agent | Language Glob: **/*.{js,jsx,ts,tsx}, **/*.py, **/*.rs |
| Rule is about tests | Test-strategy agent | **/*.{test,spec}.*, tests/**/*, test/**/* |
| Rule is about API endpoints | API-design agent | src/{api,routes}/**/*, **/*controller*, **/*handler* |
| Rule is about documentation | Docs agent | docs/**, **/*.md |
| Rule restates global project context (already in CLAUDE.md) | any | Do not emit — that's CLAUDE.md's job; abort the rule |
| Rule genuinely applies to every file (e.g. universal error-handling philosophy, security mindset) | Rare | Omit paths: deliberately and note "global rule" in the rule body |
Default to scoping. The auto-derived starting point: take every code block in the rule body, collect the file extensions / directory roots they reference, and emit those as paths:. Verify the resulting glob set actually matches files in the working tree before writing — an empty match list means the inferred scope is wrong; re-derive.
Generate separate rule files by category (see REFERENCE.md for canonical filenames and default paths: per category):
code-style.md, testing-standards.md, api-conventions.md, error-handling.md, dependencies.md, security-practices.mdCheck for conflicts with existing rules only under $RULES_DIR (never the parent .claude/rules/, which may contain hand-authored content unrelated to blueprint):
Update the task registry entry in docs/blueprint/manifest.json:
jq --arg now "$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
--arg sha "$(git rev-parse HEAD 2>/dev/null)" \
--argjson processed "${COMMITS_ANALYZED:-0}" \
--argjson created "${RULES_DERIVED:-0}" \
'.task_registry["derive-rules"].last_completed_at = $now |
.task_registry["derive-rules"].last_result = "success" |
.task_registry["derive-rules"].context.commits_analyzed_up_to = $sha |
.task_registry["derive-rules"].stats.runs_total = ((.task_registry["derive-rules"].stats.runs_total // 0) + 1) |
.task_registry["derive-rules"].stats.items_processed = $processed |
.task_registry["derive-rules"].stats.items_created = $created' \
docs/blueprint/manifest.json > tmp.json && mv tmp.json docs/blueprint/manifest.json
docs/blueprint/manifest.json with derived rules metadata: timestamp, commits analyzed, rules generated, source commits| Context | Command |
|---------|---------|
| Check git status | git rev-parse --git-dir 2>/dev/null && echo "YES" \|\| echo "NO" |
| Count total commits | git rev-list --count HEAD 2>/dev/null \|\| echo "0" |
| Conventional commits % | git log --format="%s" \| grep -c "^(feat\|fix\|refactor)" \|\| echo 0 |
| Extract decision commits | git log --format="%H\|%s\|%b" \| grep -E "(always\|never\|must\|prefer)" |
| Fast derivation | Use parallel agents (Explore) for multi-domain analysis |
For git analysis patterns, rule templates, conflict resolution, and detailed procedures, see REFERENCE.md.
testing
Verify accumulated bug claims at upstream HEAD and dedup against trackers before filing issues. Use when filing upstream reports from backlogs, audit docs, or git-history findings.
documentation
Gate outward-bound text (upstream issues, docs, PR bodies) through isolated haiku fresh-reader critique before publishing. Use when an artifact must survive a reader with zero project context.
tools
Suggest improvements to SKILL.md content, descriptions, or tool config from eval results. Use when raising pass rates, fixing triggering, or iterating on a skill after evaluation.
tools
deadbranch CLI for stale-branch cleanup — dry-run preview, TUI or non-interactive delete, protects main/develop/WIP. Use when asked to clean up branches, prune branches, or remove stale branches.