1
---
2
name: skill-master
3
description: Discover codebase patterns and auto-generate SKILL files for .claude/skills/. Use when analyzing project for missing skills, creating new skills from codebase patterns, or syncing skills with project structure.
4
version: 1.0.0
5
---
6
7
# Skill Master
8
9
## Overview
10
11
Analyze codebase to discover patterns and generate/update SKILL files in `.claude/skills/`. Supports multi-platform projects with stack-specific pattern detection.
12
13
**Capabilities:**
14
- Scan codebase for architectural patterns (ViewModel, Repository, Room, etc.)
15
- Compare detected patterns with existing skills
16
- Auto-generate SKILL files with real code examples
17
- Version tracking and smart updates
18
19
## How the AI discovers and uses this skill
20
21
This skill triggers when user:
22
- Asks to analyze project for missing skills
23
- Requests skill generation from codebase patterns
24
- Wants to sync or update existing skills
25
- Mentions "skill discovery", "generate skills", or "skill-sync"
26
27
**Detection signals:**
28
- `.claude/skills/` directory presence
29
- Project structure matching known patterns
30
- Build/config files indicating platform (see references)
31
32
## Modes
33
34
### Discover Mode
35
36
Analyze codebase and report missing skills.
37
38
**Steps:**
39
1. Detect platform via build/config files (see references)
40
2. Scan source roots for pattern indicators
41
3. Compare detected patterns with existing `.claude/skills/`
42
4. Output gap analysis report
43
44
**Output format:**
45
```
46
Detected Patterns: {count}
47
| Pattern | Files Found | Example Location |
48
|---------|-------------|------------------|
49
| {name} | {count} | {path} |
50
51
Existing Skills: {count}
52
Missing Skills: {count}
53
- {skill-name}: {pattern}, {file-count} files found
54
```
55
56
### Generate Mode
57
58
Create SKILL files from detected patterns.
59
60
**Steps:**
61
1. Run discovery to identify missing skills
62
2. For each missing skill:
63
- Find 2-3 representative source files
64
- Extract: imports, annotations, class structure, conventions
65
- Extract rules from `.ruler/*.md` if present
66
3. Generate SKILL.md using template structure
67
4. Add version and source marker
68
69
**Generated SKILL structure:**
70
```yaml
71
---
72
name: {pattern-name}
73
description: {Generated description with trigger keywords}
74
version: 1.0.0
75
---
76
77
# {Title}
78
79
## Overview
80
{Brief description from pattern analysis}
81
82
## File Structure
83
{Extracted from codebase}
84
85
## Implementation Pattern
86
{Real code examples - anonymized}
87
88
## Rules
89
### Do
90
{From .ruler/*.md + codebase conventions}
91
92
### Don't
93
{Anti-patterns found}
94
95
## File Location
96
{Actual paths from codebase}
97
```
98
99
## Create Strategy
100
101
When target SKILL file does not exist:
102
1. Generate new file using template
103
2. Set `version: 1.0.0` in frontmatter
104
3. Include all mandatory sections
105
4. Add source marker at end (see Marker Format)
106
107
## Update Strategy
108
109
**Marker check:** Look for `<!-- Generated by skill-master command` at file end.
110
111
**If marker present (subsequent run):**
112
- Smart merge: preserve custom content, add missing sections
113
- Increment version: major (breaking) / minor (feature) / patch (fix)
114
- Update source list in marker
115
116
**If marker absent (first run on existing file):**
117
- Backup: `SKILL.md` → `SKILL.md.bak`
118
- Use backup as source, extract relevant content
119
- Generate fresh file with marker
120
- Set `version: 1.0.0`
121
122
## Marker Format
123
124
Place at END of generated SKILL.md:
125
126
```html
127
<!-- Generated by skill-master command
128
Version: {version}
129
Sources:
130
- path/to/source1.kt
131
- path/to/source2.md
132
- .ruler/rule-file.md
133
Last updated: {YYYY-MM-DD}
134
-->
135
```
136
137
## Platform References
138
139
Read relevant reference when platform detected:
140
141
| Platform | Detection Files | Reference |
142
|----------|-----------------|-----------|
143
| Android/Gradle | `build.gradle`, `settings.gradle` | `references/android.md` |
144
| iOS/Xcode | `*.xcodeproj`, `Package.swift` | `references/ios.md` |
145
| React (web) | `package.json` + react | `references/react-web.md` |
146
| React Native | `package.json` + react-native | `references/react-native.md` |
147
| Flutter/Dart | `pubspec.yaml` | `references/flutter.md` |
148
| Node.js | `package.json` | `references/node.md` |
149
| Python | `pyproject.toml`, `requirements.txt` | `references/python.md` |
150
| Java/JVM | `pom.xml`, `build.gradle` | `references/java.md` |
151
| .NET/C# | `*.csproj`, `*.sln` | `references/dotnet.md` |
152
| Go | `go.mod` | `references/go.md` |
153
| Rust | `Cargo.toml` | `references/rust.md` |
154
| PHP | `composer.json` | `references/php.md` |
155
| Ruby | `Gemfile` | `references/ruby.md` |
156
| Elixir | `mix.exs` | `references/elixir.md` |
157
| C/C++ | `CMakeLists.txt`, `Makefile` | `references/cpp.md` |
158
| Unknown | - | `references/generic.md` |
159
160
If multiple platforms detected, read multiple references.
161
162
## Rules
163
164
### Do
165
- Only extract patterns verified in codebase
166
- Use real code examples (anonymize business logic)
167
- Include trigger keywords in description
168
- Keep SKILL.md under 500 lines
169
- Reference external files for detailed content
170
- Preserve custom sections during updates
171
- Always backup before first modification
172
173
### Don't
174
- Include secrets, tokens, or credentials
175
- Include business-specific logic details
176
- Generate placeholders without real content
177
- Overwrite user customizations without backup
178
- Create deep reference chains (max 1 level)
179
- Write outside `.claude/skills/`
180
181
## Content Extraction Rules
182
183
**From codebase:**
184
- Extract: class structures, annotations, import patterns, file locations, naming conventions
185
- Never: hardcoded values, secrets, API keys, PII
186
187
**From .ruler/*.md (if present):**
188
- Extract: Do/Don't rules, architecture constraints, dependency rules
189
190
## Output Report
191
192
After generation, print:
193
```
194
SKILL GENERATION REPORT
195
196
Skills Generated: {count}
197
198
{skill-name} [CREATED | UPDATED | BACKED_UP+CREATED]
199
├── Analyzed: {file-count} source files
200
├── Sources: {list of source files}
201
├── Rules from: {.ruler files if any}
202
└── Output: .claude/skills/{skill-name}/SKILL.md ({line-count} lines)
203
204
Validation:
205
✓ YAML frontmatter valid
206
✓ Description includes trigger keywords
207
✓ Content under 500 lines
208
✓ Has required sections
209
```
210
211
## Safety Constraints
212
213
- Never write outside `.claude/skills/`
214
- Never delete content without backup
215
- Always backup before first-time modification
216
- Preserve user customizations
217
- Deterministic: same input → same output
218