commands/skill-create.md
Analyze your repository's git history to extract coding patterns and generate SKILL.md files that teach Claude your team's practices.
/skill-create # Analyze current repo
/skill-create --commits 100 # Analyze last 100 commits
/skill-create --output ./skills # Custom output; export-only unless configured
/skill-create --instincts # Also generate instincts for continuous-learning-v2
# Get recent commits with file changes
git log --oneline -n ${COMMITS:-200} --name-only --pretty=format:"%H|%s|%ad" --date=short
# Get commit frequency by file
git log --oneline -n 200 --name-only | grep -v "^$" | grep -v "^[a-f0-9]" | sort | uniq -c | sort -rn | head -20
# Get commit message patterns
git log --oneline -n 200 | cut -d' ' -f2- | head -50
Look for these pattern types:
| Pattern | Detection Method |
|---|---|
| Commit conventions | Regex on commit messages (feat:, fix:, chore:) |
| File co-changes | Files that always change together |
| Workflow sequences | Repeated file change patterns |
| Architecture | Folder structure and naming conventions |
| Testing patterns | Test file locations, naming, coverage |
Derive the default skill-name safely: lowercase the repository name, replace
runs of spaces, underscores, path separators, or other non-alphanumeric
characters with one hyphen, trim leading/trailing hyphens, then append
-patterns. For example, My Repo_API/Client becomes
my-repo-api-client-patterns. If normalization produces an empty slug, stop
and request an explicit safe name.
Set skill-name once; it defaults to the normalized {repo-name}-patterns, and
the same value must be used for the directory and frontmatter. Validate the
final skill-name, then write the generated skill to
<output-dir>/<skill-name>/SKILL.md. The default project root is
.claude/skills/; a global skill uses ~/.claude/skills/.
Discovery depends on the root, not only the filename. A custom --output is a
configured skill root only when the active harness is set up to discover it.
Otherwise, treat the result as an export-only artifact that must be installed
into a configured root before it can activate.
The directory form is required for discovery: Claude Code treats
<name>/SKILL.md as the skill entrypoint. Keep the directory name and
frontmatter name: identical.
Before writing, apply these guarded-write requirements:
skill-name as a lowercase hyphenated slug. Reject path separators
and path traversal. Resolve the target and confirm it stays inside the
selected approved skill root, or inside the explicitly approved export root
when --output is not configured for discovery.Output format:
---
name: {skill-name}
description: "Use when working in {repo-name}, especially before editing its common modules, placing tests, naming branches, or writing commits — conventions measured from git history"
metadata:
version: "1.0.0"
source: local-git-analysis
analyzed_commits: "{count}"
---
# {Repo Name} Patterns
## Commit Conventions
{detected commit message patterns}
## Code Architecture
{detected folder structure and organization}
## Workflows
{detected repeating file change patterns}
## Testing Patterns
{detected test conventions}
Make description: trigger-first rather than a generic summary. Lead with
Use when ... and name observable moments where the conventions apply, based
on the patterns actually found in the repository.
Verify discoverability or export status before replacing the target: write
the approved sanitized draft to a uniquely named temporary sibling beside the
target. Validate that candidate before it can replace
<output-dir>/<skill-name>/SKILL.md: its ----delimited frontmatter must parse
as valid YAML, its name: must match the intended final directory, and its
non-empty description: must begin with Use when. Confirm the output is a
configured skill root; for any other custom --output, label the artifact
export-only and do not report it as discoverable. Only after every structural
check passes may you atomically replace the target with the validated sibling.
If a check fails, report the specific failure, remove or quarantine only the
temporary sibling, leave any existing skill unchanged, and stop. To repair the
candidate, prepare a corrected draft without writing, show the full path, and
obtain fresh explicit approval. Do not report success until the temporary-write
validation and atomic replacement both complete.
For continuous-learning-v2 integration:
---
id: {repo}-commit-convention
trigger: "when writing a commit message"
confidence: 0.8
domain: git
source: local-repo-analysis
---
# Use Conventional Commits
## Action
Prefix commits with: feat:, fix:, chore:, docs:, test:, refactor:
## Evidence
- Analyzed {n} commits
- {percentage}% follow conventional commit format
For advanced features (10k+ commits, team sharing, auto-PRs), use the Skill Creator GitHub App:
/skill-creator analyze on any issue/instinct-import - Import generated instincts/instinct-status - View learned instincts/evolve - Cluster instincts into skills/agentsPart of Everything Claude Code