AIFCC
記事一覧へ
claude-setupskillsSKILL.mdClaude Codeprompt-engineering

完璧なスキルの解剖学——100の優良事例からリバースエンジニアリングした6つのパターン

darkzodchi@zodchiii
773👁 282,000
## 完璧なスキルの解剖学——100の優良事例からリバースエンジニアリングした6つのパターン ほとんどのスキルは機能しません。機能するものは同じ6つのパターンに従っています。 実際に毎日使われているスキルの実例を交えながら、それぞれを解説します。 読み終わる頃には、なぜカスタムスキルが発動しないのか、どう直せばいいのかが正確にわかるはずです。 始める前に:AIとvibe codingに関する日々のノートをTelegramチャンネルで共有しています:https://t.me/zodchixquant ## 30秒でおさらい スキルとは、上部にYAML frontmatterがあり、その下に指示が続くMarkdownファイルです。 `~/.claude/skills/skill-name/SKILL.md` に配置します。コンテキストがdescriptionと一致すると自動でロードされるか、`/skill-name` で手動で呼び出せます。 ``` ~/.claude/skills/ ├── commit/SKILL.md → /commit ├── code-review/SKILL.md → /code-review └── deploy/ ├── SKILL.md → /deploy └── scripts/helper.sh ``` アーキテクチャは以上です。難しいのはSKILL.mdの中に何を書くかです。 ## パターン1:descriptionは「いつ使うか」を伝える、「何をするか」だけでなく これが最も重要なフィールドです。Claudeはどのスキルをロードするかを決める前に、すべての利用可能なスキルのdescriptionをスキャンします。descriptionがスキルの機能しか伝えていなければ、Claudeはいつ使うべきかを判断できません。 悪いdescription: ``` description: Code review tool ``` 良いdescription: ``` description: Review code for bugs, security issues, and maintainability. Use when reviewing pull requests, checking code quality, analyzing diffs, or when user mentions "review", "PR", "code quality", or "best practices". ``` 良い方はClaudeに伝えています:スキルが何をするか+いつトリガーするか+どのキーワードを聞くべきか。 50文字未満のdescriptionを持つスキルは、適切なトリガーコンテキストを持つスキルと比べて3〜5倍発動頻度が低くなります。最初の250文字でユースケースを前面に出してください——Claudeのコンテキストバジェットに含まれるのはそこまでだからです。 ## パターン2:会話的でなく、指示的に書く スキルは指示であり、チャットではありません。命令形の動詞を使います。 会話的(弱い): ``` コードをレビューしていただけますか?バグがないか確認してみてください。 ``` 指示的(強い): ``` 現在のdiffをレビューする。以下を確認すること: 1. セキュリティの脆弱性(OWASP Top 10) 2. パフォーマンスの問題(N+1クエリ、ブロッキングコール) 3. コードスタイル違反 深刻度評価付きのチェックリストとして出力する。 ``` Claudeは質問や丁寧なリクエストよりも、命令形の指示の方がはるかに確実に従います。 Anthropicの公式リポジトリのスキルを見れば、同じパターンがわかります:直接的な動詞・番号付きのステップ・明示的な出力フォーマット。 ## パターン3:出力フォーマットを明示する ほとんどのカスタムスキルが失敗するのはここです。何をするかはClaudeに伝えても、出力がどうあるべきかは伝えていません。Claudeは毎回フォーマットを作り上げ、結果は一貫しません。 出力フォーマットなし: ``` これらの変更のコミットメッセージを生成してください。 ``` 得られるもの:1行のこともあれば、段落のこともあれば、プレフィックスありのこともなしのこともあります。 出力フォーマットあり: ``` 以下の正確なフォーマットでコミットメッセージを生成する: type(scope): short description - 変更内容の箇条書き - 変更理由の箇条書き Typeは次のいずれか:feat, fix, refactor, docs, test, chore。 Scopeは影響を受けたモジュール名。 Short descriptionは50文字以内、現在形、小文字。 ``` 毎回同じ出力構造が得られます。スキルが再利用可能になります。 ## パターン4:「まず読む」ステップを含める 優れたスキルはClaudeがあなたのプロジェクトを知っていると仮定しません。まず確認するよう指示します。 awesome-claude-skillsリポジトリの `/test` スキルを見てください。「テストを書く」ではなく、こうします: ``` テストを書く前に: 1. ターゲットファイルを読み、関数のシグネチャと型を理解する 2. 既存のテストディレクトリを見つけ、既存テスト1〜2件を読む 3. テストフレームワーク(Jest、Vitest、Pytestなど)を特定する 4. インポートスタイルとアサーションパターンを確認する その後、以下をカバーするテストを生成する: - ハッピーパス - エッジケース(空、null、ゼロ、最大値) - エラーケース - 非同期動作(該当する場合) 既存テストのインポートスタイルとパターンに完全に合わせること。 テストを書いた後に実行する。終わる前に失敗を修正する。 ``` 「まず読む」ステップが、あなたのプロジェクトに合ったコードを生成するスキルと、リンターを壊す汎用コードを生成するスキルを分けるものです。 ## パターン5:スキルが「しないこと」を定義する 直感に反しますが強力です。優れたスキルはスコープ外を明示的にリストアップします。 Anthropicの公式PDFスキルより: ``` ## Out of Scope このスキルは以下を行いません: - スキャンされたPDFの処理(代わりにOCRスキルを使用) - PDFのゼロから作成(document-generationスキルを使用) - パスワードで保護されたファイルの処理 ``` なぜ重要か:ユーザーがスキルでできないことを頼んだとき、Claudeは試みて失敗しません。 別のスキルを選ぶか、確認を求めます。壊れた出力が減り、正しいルーティングが増えます。 このパターンは高品質スキルの70%に見られ、低品質スキルにはほとんど見られません。 ## パターン6:500行以内に収める すべてのスキルは呼び出されるとClaudeのコンテキストにロードされます。2000行のスキルは何も始める前に5000以上のトークンを消費します。 スキルが長くなるほど、Claudeが途中でフォーカスを失い、最後の方の指示を無視し始める可能性が高まります。 Anthropicの公式スキル(frontend-design、code-review、security-guidance)はすべて300行以内です。最もインストール数の多いコミュニティスキル(Superpowers、Context7、mcp-builder)も同様にタイトです。 スキルが長くなるなら、分割します。プログレッシブディスクロージャーパターンを使います: ``` SKILL.md(200行以内、常にロード) ├── ADVANCED_PATTERNS.md(必要なときだけロード) ├── REFERENCE.md(参照されたときだけロード) └── EXAMPLES.md(Claudeが例を必要とするときだけロード) ``` SKILL.md内で他のファイルを参照します: ``` 複雑なフォーム入力については [FORMS.md](FORMS.md) を参照 完全なAPIリファレンスは [REFERENCE.md](REFERENCE.md) を参照 さらなる例は [EXAMPLES.md](EXAMPLES.md) を参照 ``` Claudeはタスクが実際に必要とするときだけサポートファイルをロードします。 ## 実例:/commitスキルの解剖 6つのパターン全てに従った `/commit` スキルです。これが「良い」とはどういうことかです: ``` --- name: commit description: Create structured git commits from current changes. Use when user says "commit", "save changes", "commit this", or after finishing a feature. Breaks changes into logical units with clear messages. --- Create commits from current git state. ## Process 1. Run `git status` and `git diff` to see all changes 2. Group related changes into logical units (one feature = one commit) 3. For each unit, generate a commit message in this format: type(scope): short description - What changed - Why it changed (if not obvious) 4. Stage and commit each unit separately using `git add` then `git commit` 5. Show summary: "Created N commits: [list of titles]" ## Rules - Type must be: feat, fix, refactor, docs, test, chore - Description is under 50 characters, lowercase, present tense - Bullets are concise, no fluff - Never combine unrelated changes in one commit ## Out of Scope - Pushing to remote (use /push or git push manually) - Creating PRs (use /pr skill) - Merging branches ``` 注目点: - descriptionはClaudeに「いつ」を伝えている - 指示は命令形(命令形の動詞、番号付きステップ) - 出力フォーマットが明示的(コミットメッセージの構造) - 「まず読む」ステップが組み込まれている(git status、git diff) - スコープ外が定義されている - 合計長:50行以内 このスキルはすべてのプロジェクトで、すべての言語で、毎回機能します。 ## スキルを殺すもの 機能しないスキルはこれらの失敗パターンを共有しています: **DESCRIPTIONの失敗:** - 50文字未満 - 視点が不一致(「I help」vs「You can use this」) - トリガーキーワードなし - ユースケースコンテキストなし **CONTENTの失敗:** - 命令形でなく会話的 - 出力フォーマットが未指定 - 「まず読む」ステップなし - スコープ外セクションなし - 1000行超 **DESIGNの失敗:** - 1つのスキルで5つのことをしようとしている - 1つのプロジェクトの固有情報にハードコードされている - スキル自体にバージョン管理がない - 最初の作成後に更新されていない カスタムスキルがこれらのボックスを3つ以上チェックしているなら、おそらく発動していないか、悪い出力を生成しています。 ## 既存スキルの修正方法 最も弱いスキル(Claudeが決して発動しないもの)を開きます。このチェックリストを実行します: 1. Description:少なくとも3つのトリガーキーワードがあるか? 2. Description:最初の250文字でユースケースがあるか? 3. 指示:番号付きステップで命令形動詞になっているか? 4. 出力:フォーマットが明示的に指定されているか? 5. プロジェクト認識:既存ファイルをまず読むようClaudeに伝えているか? 6. スコープ:スキルが「しないこと」がリストアップされているか? 7. 長さ:SKILL.mdは500行以内か? 失敗したものを修正します。手動で呼び出さずに、スキルが処理すべきことをClaudeに尋ねてテストします。 Claudeが正しいスキルを選んだなら、descriptionは機能しています。別のスキルを選ぶか何も選ばないなら、descriptionにもっとトリガーコンテキストが必要です。 ## 複利効果 悪いスキルはClaudeを遅くし(何もせずコンテキストを消費)、一貫しない出力を生成し(フォーマットなし)、誤ったルーティングをします(曖昧なdescription)。 良いスキルは逆方向に複利します。 よく書かれたスキルはそれぞれ、Claudeがどんなタスクにも適切なものを選ぶ能力を高めます。スキルはコレクションではなく、システムになります。 6か月間これをやってきた人のskillsフォルダは、始めたばかりの人のものとまったく異なって見えます。 同じClaude、まったく異なる出力品質。
原文を表示 / Show original
The Anatomy of a Perfect Skill: Reverse-Engineered from 100 Best Examples Most skills don't work. The ones that do follow the same 6 patterns. I'll walk through each one with real examples from skills people actually use daily. By the end you'll know exactly why your custom skills don't fire and how to fix them. Before we dive in, I share daily notes on AI & vibe coding in my Telegram channel: https://t.me/zodchixquant ## The 30-second refresher A skill is a markdown file with YAML frontmatter at the top and instructions below. You put it in ~/.claude/skills/skill-name/SKILL.md. Claude loads it automatically when context matches the description, or you invoke it manually with /skill-name. ``` ~/.claude/skills/ ├── commit/SKILL.md → /commit ├── code-review/SKILL.md → /code-review └── deploy/ ├── SKILL.md → /deploy └── scripts/helper.sh ``` That's the whole architecture. The hard part is what goes inside SKILL.md. ## Pattern 1: Description tells Claude WHEN, not just WHAT This is the single most important field. Claude scans descriptions of all available skills before deciding which to load. If your description only says what the skill does, Claude won't know when to use it. Bad description: ``` description: Code review tool ``` Good description: ``` description: Review code for bugs, security issues, and maintainability. Use when reviewing pull requests, checking code quality, analyzing diffs, or when user mentions "review", "PR", "code quality", or "best practices". ``` The good one tells Claude: what the skill does + when to trigger it + which keywords to listen for. Skills with descriptions under 50 characters get invoked 3-5x less often than skills with proper trigger context. Front-load the use case in the first 250 characters because that's all that gets included in Claude's context budget. ## Pattern 2: Be directive, not conversational Skills are instructions, not chat. Use imperative verbs. Conversational (weak): ``` Could you please review the code? Maybe check if there are any bugs? ``` Directive (strong): ``` Review the current diff. Check for: 1. Security vulnerabilities (OWASP Top 10) 2. Performance issues (N+1 queries, blocking calls) 3. Code style violations Output as a checklist with severity ratings. ``` Claude follows imperative instructions much more reliably than questions or polite requests. Look at any skill from the official Anthropic repository, and you'll see the same pattern: direct verbs, numbered steps, explicit output formats. ## Pattern 3: Specify the output format This is where most custom skills fail. They tell Claude what to do but not what the output should look like. Claude makes up a format every time and the results are inconsistent. Without output format: ``` Generate a commit message for these changes. ``` You get: sometimes one line, sometimes paragraphs, sometimes with prefixes, sometimes without. With output format: ``` Generate a commit message in this exact format: type(scope): short description - Bullet point of what changed - Bullet point of why it changed Type must be one of: feat, fix, refactor, docs, test, chore. Scope is the affected module name. Short description is under 50 characters, present tense, lowercase. ``` Now you get the same output structure every time. The skill is reusable. ## Pattern 4: Include the "read first" step The best skills don't assume Claude knows your project. They tell Claude to look first. Take the /test skill from the awesome-claude-skills repo. Instead of "write tests," it does this: ``` Before writing tests: 1. Read the target file to understand function signatures and types 2. Find the existing test directory and read 1-2 existing tests 3. Identify the testing framework (Jest, Vitest, Pytest, etc.) 4. Note the import style and assertion patterns Then generate tests covering: - Happy path - Edge cases (empty, null, zero, max values) - Error cases - Async behavior (if applicable) Match exact import style and patterns from existing tests. Run tests after writing them. Fix failures before finishing. ``` The "read first" step is what separates skills that produce code matching your project from skills that produce generic code that breaks your linter. ## Pattern 5: Define what the skill does NOT do Counterintuitive but powerful. The best skills explicitly list what's out of scope. From Anthropic's official PDF skill: ``` ## Out of Scope This skill does NOT: - Handle scanned PDFs (use OCR skill instead) - Create PDFs from scratch (use document-generation skill) - Process password-protected files ``` Why this matters: when a user asks for something the skill can't do, Claude doesn't try and fail. It either picks a different skill or asks for clarification. You get fewer broken outputs and more correct routing. This pattern shows up in 70% of high-quality skills and almost never in low-quality ones. ## Pattern 6: Keep it under 500 lines Every skill loads into Claude's context when invoked. A 2000-line skill eats 5000+ tokens before doing anything. The longer the skill, the more chance Claude loses focus halfway through and starts ignoring instructions at the bottom. The official Anthropic skills (frontend-design, code-review, security-guidance) are all under 300 lines. The community skills with the most installs (Superpowers, Context7, mcp-builder) are similarly tight. If your skill is getting long, split it. Use the progressive disclosure pattern: ``` SKILL.md (under 200 lines, always loaded) ├── ADVANCED_PATTERNS.md (loaded only when needed) ├── REFERENCE.md (loaded only when referenced) └── EXAMPLES.md (loaded only when Claude needs examples) ``` In SKILL.md you reference the other files: ``` For complex form filling, see [FORMS.md](FORMS.md) For full API reference, see [REFERENCE.md](REFERENCE.md) For more examples, see [EXAMPLES.md](EXAMPLES.md) ``` Claude loads the supporting files only when the task actually needs them. ## A real example: The /commit skill, broken down Here's a /commit skill that follows all 6 patterns. This is what good looks like: ``` --- name: commit description: Create structured git commits from current changes. Use when user says "commit", "save changes", "commit this", or after finishing a feature. Breaks changes into logical units with clear messages. --- Create commits from current git state. ## Process 1. Run `git status` and `git diff` to see all changes 2. Group related changes into logical units (one feature = one commit) 3. For each unit, generate a commit message in this format: type(scope): short description - What changed - Why it changed (if not obvious) 4. Stage and commit each unit separately using `git add` then `git commit` 5. Show summary: "Created N commits: [list of titles]" ## Rules - Type must be: feat, fix, refactor, docs, test, chore - Description is under 50 characters, lowercase, present tense - Bullets are concise, no fluff - Never combine unrelated changes in one commit ## Out of Scope - Pushing to remote (use /push or git push manually) - Creating PRs (use /pr skill) - Merging branches ``` Notice: - Description tells Claude WHEN - Instructions are directive (imperative verbs, numbered steps) - Output format is explicit (the commit message structure) - "Read first" step is built in (git status, git diff) - Out of scope is defined - Total length: under 50 lines This skill works on every project, in every language, every time. ## What kills skills The skills that don't work share these failure patterns: DESCRIPTION FAILURES: - Under 50 characters - Inconsistent point of view ("I help" vs "You can use this") - No trigger keywords - No use case context CONTENT FAILURES: - Conversational instead of directive - No output format specified - No "read first" step - No out-of-scope section - Over 1000 lines DESIGN FAILURES: - Trying to do 5 things in one skill - Hardcoded to one project's specifics - No version control on the skill itself - Never updated after first write If your custom skill checks 3+ of these boxes, it's probably not getting invoked or producing bad output. ## How to fix existing skills Pull up your weakest skill (the one Claude never invokes). Run through this checklist: 1. Description: Does it have at least 3 trigger keywords? 2. Description: Is the use case in the first 250 characters? 3. Instructions: Are they imperative verbs in numbered steps? 4. Output: Is the format specified explicitly? 5. Project awareness: Does it tell Claude to read existing files first? 6. Scope: Does it list what the skill does NOT do? 7. Length: Is the SKILL.md under 500 lines? Fix the failed ones. Test by asking Claude something the skill should handle without invoking it manually. If Claude picks the right skill, your description is working. If it picks a different skill or none at all, the description needs more trigger context. ## The compounding effect Bad skills make Claude slower (eating context for nothing), produce inconsistent output (no format), and route incorrectly (vague descriptions). Good skills compound in the opposite direction. Each well-written skill makes Claude better at picking the right one for any task. The skills become a system, not a collection. The skills folder of someone who's been doing this for 6 months looks completely different from someone who just started. Same Claude, completely different output quality.

AIFCC — AI Fluent CxO Club

読み書きそろばん、AI。経営者が AI を自分で動かせるようになるコミュニティ。

完璧なスキルの解剖学——100の優良事例からリバースエンジニアリングした6つのパターン | AIFCC