{"meta":{"title":"カスタム スキル","intro":"スキルは、Copilotの機能を拡張する再利用可能なプロンプト モジュールです。 ディレクトリからスキルを読み込み、特定の分野やワークフロー向けの特殊な機能を Copilot に提供します。","product":"GitHub Copilot","breadcrumbs":[{"href":"/ja/copilot","title":"GitHub Copilot"},{"href":"/ja/copilot/how-tos","title":"方法"},{"href":"/ja/copilot/how-tos/copilot-sdk","title":"Copilot SDK"},{"href":"/ja/copilot/how-tos/copilot-sdk/features","title":"機能"},{"href":"/ja/copilot/how-tos/copilot-sdk/features/skills","title":"スキル"}],"documentType":"article"},"body":"# カスタム スキル\n\nスキルは、Copilotの機能を拡張する再利用可能なプロンプト モジュールです。 ディレクトリからスキルを読み込み、特定の分野やワークフロー向けの特殊な機能を Copilot に提供します。\n\n<!-- markdownlint-disable GHD046 GHD005 -->\n\n<!-- Suppressed: GHD046 (outdated release terminology), GHD005 (hardcoded data variable) -->\n\n## Overview\n\nスキルは、`SKILL.md` ファイルを含む名前の付いたディレクトリです。これは、Copilot に指示を提供する Markdown ドキュメントです。 読み込まれると、スキルのコンテンツがセッション コンテキストに挿入されます。\n\nスキルを使用すると、次のことができるようになります。\n\n* 再利用可能なモジュールにドメインの専門知識をパッケージ化する\n* プロジェクト間で特殊な動作を共有する\n* 複雑なエージェント構成を整理する\n* セッションごとの機能の有効化/無効化\n\n## スキルの読み込み\n\nセッションの作成時にスキルを含むディレクトリを指定します。\n\n<div class=\"ghd-codetabs\">\n<div class=\"ghd-codetab\" data-lang=\"typescript\" data-label=\"TypeScript\"><div class=\"ghd-codetab-fallback-label\" role=\"heading\" aria-level=\"3\">TypeScript</div>\n\n```typescript\nimport { CopilotClient } from \"@github/copilot-sdk\";\n\nconst client = new CopilotClient();\nconst session = await client.createSession({\n    model: \"gpt-5.4\",\n    skillDirectories: [\n        \"./skills/code-review\",\n        \"./skills/documentation\",\n    ],\n    onPermissionRequest: async () => ({ kind: \"approve-once\" }),\n});\n\n// Copilot now has access to skills in those directories\nawait session.sendAndWait({ prompt: \"Review this code for security issues\" });\n```\n\n</div>\n\n<div class=\"ghd-codetab\" data-lang=\"python\" data-label=\"Python\"><div class=\"ghd-codetab-fallback-label\" role=\"heading\" aria-level=\"3\">Python</div>\n\n```python\nfrom copilot import CopilotClient, PermissionDecisionApproveOnce\n\nasync def main():\n    client = CopilotClient()\n    await client.start()\n\n    session = await client.create_session(\n        on_permission_request=lambda req, inv: PermissionDecisionApproveOnce(),\n        model=\"gpt-5.4\",\n        skill_directories=[\n            \"./skills/code-review\",\n            \"./skills/documentation\",\n        ],\n    )\n\n    # Copilot now has access to skills in those directories\n    await session.send_and_wait(\"Review this code for security issues\")\n\n    await client.stop()\n```\n\n</div>\n\n<div class=\"ghd-codetab\" data-lang=\"go\" data-label=\"Go\"><div class=\"ghd-codetab-fallback-label\" role=\"heading\" aria-level=\"3\">Go</div>\n\n```golang\npackage main\n\nimport (\n    \"context\"\n    \"log\"\n    copilot \"github.com/github/copilot-sdk/go\"\n    \"github.com/github/copilot-sdk/go/rpc\"\n)\n\nfunc main() {\n    ctx := context.Background()\n    client := copilot.NewClient(nil)\n    if err := client.Start(ctx); err != nil {\n        log.Fatal(err)\n    }\n    defer client.Stop()\n\n    session, err := client.CreateSession(ctx, &copilot.SessionConfig{\n        Model: \"gpt-5.4\",\n        SkillDirectories: []string{\n            \"./skills/code-review\",\n            \"./skills/documentation\",\n        },\n        OnPermissionRequest: func(req copilot.PermissionRequest, inv copilot.PermissionInvocation) (rpc.PermissionDecision, error) {\n            return &rpc.PermissionDecisionApproveOnce{}, nil\n        },\n    })\n    if err != nil {\n        log.Fatal(err)\n    }\n\n    // Copilot now has access to skills in those directories\n    _, err = session.SendAndWait(ctx, copilot.MessageOptions{\n        Prompt: \"Review this code for security issues\",\n    })\n    if err != nil {\n        log.Fatal(err)\n    }\n}\n```\n\n</div>\n\n<div class=\"ghd-codetab\" data-lang=\"dotnet\" data-label=\".NET\"><div class=\"ghd-codetab-fallback-label\" role=\"heading\" aria-level=\"3\">.NET</div>\n\n```csharp\nusing GitHub.Copilot;\nusing GitHub.Copilot.Rpc;\n\nawait using var client = new CopilotClient();\nawait using var session = await client.CreateSessionAsync(new SessionConfig\n{\n    Model = \"gpt-5.4\",\n    SkillDirectories = new List<string>\n    {\n        \"./skills/code-review\",\n        \"./skills/documentation\",\n    },\n    OnPermissionRequest = (req, inv) =>\n        Task.FromResult(PermissionDecision.ApproveOnce()),\n});\n\n// Copilot now has access to skills in those directories\nawait session.SendAndWaitAsync(new MessageOptions\n{\n    Prompt = \"Review this code for security issues\"\n});\n```\n\n</div>\n\n<div class=\"ghd-codetab\" data-lang=\"java\" data-label=\"Java\"><div class=\"ghd-codetab-fallback-label\" role=\"heading\" aria-level=\"3\">Java</div>\n\n```java\nimport com.github.copilot.CopilotClient;\nimport com.github.copilot.rpc.*;\nimport java.util.List;\n\ntry (var client = new CopilotClient()) {\n    client.start().get();\n\n    var session = client.createSession(\n        new SessionConfig()\n            .setModel(\"gpt-5.4\")\n            .setSkillDirectories(List.of(\n                \"./skills/code-review\",\n                \"./skills/documentation\"\n            ))\n            .setOnPermissionRequest(PermissionHandler.APPROVE_ALL)\n    ).get();\n\n    // Copilot now has access to skills in those directories\n    session.sendAndWait(new MessageOptions()\n        .setPrompt(\"Review this code for security issues\")\n    ).get();\n}\n```\n\n</div>\n\n</div>\n\n## スキルの無効化\n\n他のユーザーをアクティブにしたまま、特定のスキルを無効にします。\n\n<div class=\"ghd-codetabs\">\n<div class=\"ghd-codetab\" data-lang=\"typescript\" data-label=\"TypeScript\"><div class=\"ghd-codetab-fallback-label\" role=\"heading\" aria-level=\"3\">TypeScript</div>\n\n```typescript\nconst session = await client.createSession({\n    skillDirectories: [\"./skills\"],\n    disabledSkills: [\"experimental-feature\", \"deprecated-tool\"],\n});\n```\n\n</div>\n\n<div class=\"ghd-codetab\" data-lang=\"python\" data-label=\"Python\"><div class=\"ghd-codetab-fallback-label\" role=\"heading\" aria-level=\"3\">Python</div>\n\n```python\nfrom copilot.session import PermissionHandler\n\nsession = await client.create_session(\n    on_permission_request=PermissionHandler.approve_all,\n    skill_directories=[\"./skills\"],\n    disabled_skills=[\"experimental-feature\", \"deprecated-tool\"],\n)\n```\n\n</div>\n\n<div class=\"ghd-codetab\" data-lang=\"go\" data-label=\"Go\"><div class=\"ghd-codetab-fallback-label\" role=\"heading\" aria-level=\"3\">Go</div>\n\n```golang\nsession, _ := client.CreateSession(context.Background(), &copilot.SessionConfig{\n    SkillDirectories: []string{\"./skills\"},\n    DisabledSkills:   []string{\"experimental-feature\", \"deprecated-tool\"},\n})\n```\n\n</div>\n\n<div class=\"ghd-codetab\" data-lang=\"dotnet\" data-label=\".NET\"><div class=\"ghd-codetab-fallback-label\" role=\"heading\" aria-level=\"3\">.NET</div>\n\n```csharp\nvar session = await client.CreateSessionAsync(new SessionConfig\n{\n    SkillDirectories = new List<string> { \"./skills\" },\n    DisabledSkills = new List<string> { \"experimental-feature\", \"deprecated-tool\" },\n});\n```\n\n</div>\n\n<div class=\"ghd-codetab\" data-lang=\"java\" data-label=\"Java\"><div class=\"ghd-codetab-fallback-label\" role=\"heading\" aria-level=\"3\">Java</div>\n\n<!-- docs-validate: skip -->\n\n```java\nimport com.github.copilot.rpc.*;\nimport java.util.List;\n\nvar session = client.createSession(\n    new SessionConfig()\n        .setSkillDirectories(List.of(\"./skills\"))\n        .setDisabledSkills(List.of(\"experimental-feature\", \"deprecated-tool\"))\n        .setOnPermissionRequest(PermissionHandler.APPROVE_ALL)\n).get();\n```\n\n</div>\n\n</div>\n\n## スキル ディレクトリ構造\n\n各スキルは、 `SKILL.md` ファイルを含む名前付きサブディレクトリです。\n\n```text\nskills/\n├── code-review/\n│   └── SKILL.md\n└── documentation/\n    └── SKILL.md\n```\n\n`skillDirectories` オプションは、親ディレクトリ (例: `./skills`) を指します。 CLI は、即時サブディレクトリ内のすべての `SKILL.md` ファイルを検出します。\n\n### SKILL.md 形式\n\n`SKILL.md` ファイルは、オプションの YAML frontmatter を含むマークダウン ドキュメントです。\n\n```markdown\n---\nname: code-review\ndescription: Specialized code review capabilities\n---\n\n# Code Review Guidelines\n\nWhen reviewing code, always check for:\n\n1. **Security vulnerabilities** - SQL injection, XSS, etc.\n2. **Performance issues** - N+1 queries, memory leaks\n3. **Code style** - Consistent formatting, naming conventions\n4. **Test coverage** - Are critical paths tested?\n\nProvide specific line-number references and suggested fixes.\n```\n\nフロントマターのフィールド:\n\n* **`name`**: スキルの識別子 (選択的に無効にするために `disabledSkills` で使用されます)。 省略すると、ディレクトリ名が使用されます。\n* **`description`**: スキルが実行する内容の簡単な説明。\n\nマークダウン本文には、スキルの読み込み時にセッション コンテキストに挿入される命令が含まれます。\n\n## 構成オプション\n\n### SessionConfig スキル フィールド\n\n| Language | フィールド               | タイプ            | Description       |\n| -------- | ------------------- | -------------- | ----------------- |\n| Node.js  | `skillDirectories`  | `string[]`     | スキルを読み込むためのディレクトリ |\n| Node.js  | `disabledSkills`    | `string[]`     | 無効にするスキル          |\n| Python   | `skill_directories` | `list[str]`    | スキルを読み込むためのディレクトリ |\n| Python   | `disabled_skills`   | `list[str]`    | 無効にするスキル          |\n| Go       | `SkillDirectories`  | `[]string`     | スキルを読み込むためのディレクトリ |\n| Go       | `DisabledSkills`    | `[]string`     | 無効にするスキル          |\n| .NET     | `SkillDirectories`  | `List<string>` | スキルを読み込むためのディレクトリ |\n| .NET     | `DisabledSkills`    | `List<string>` | 無効にするスキル          |\n\n## ベスト プラクティス\n\n1. **ドメイン別に整理** する - 関連するスキルをグループ化する ( `skills/security/`、 `skills/testing/`など)\n\n2. **フロントマッターを使用する** - わかりやすくするために YAML フロントマッターに `name` と `description` を含める\n\n3. **ドキュメントの依存関係** - スキルに必要なツールまたは MCP サーバーに注意してください\n\n4. **分離してスキルをテスト** する - 組み合わせる前にスキルの動作を確認する\n\n5. **相対パスを使用** する - 環境間でスキルを移植可能にする\n\n## 他の機能との組み合わせ\n\n### スキル + カスタム エージェント\n\nエージェントの `skills` フィールドにリストされているスキルは **、一括で事前に読み込まれます**。その完全なコンテンツは起動時にエージェントのコンテキストに挿入されるため、エージェントはスキル ツールを呼び出すことなく、すぐにスキル命令にアクセスできます。 スキル名は、セッション レベルの `skillDirectories`から解決されます。\n\n```typescript\nconst session = await client.createSession({\n    skillDirectories: [\"./skills/security\"],\n    customAgents: [{\n        name: \"security-auditor\",\n        description: \"Security-focused code reviewer\",\n        prompt: \"Focus on OWASP Top 10 vulnerabilities\",\n        skills: [\"security-scan\", \"dependency-check\"],\n    }],\n    onPermissionRequest: async () => ({ kind: \"approve-once\" }),\n});\n```\n\n> \\[!NOTE]\n> スキルはオプトインされます。 `skills` を省略すると、スキル コンテンツは挿入されません。 サブエージェントは親からスキルを継承しません。エージェントごとに明示的に一覧表示する必要があります。\n\n### スキル + MCP サーバー\n\nスキルは MCP サーバーの機能を補完できます。\n\n```typescript\nconst session = await client.createSession({\n    skillDirectories: [\"./skills/database\"],\n    mcpServers: {\n        postgres: {\n            type: \"local\",\n            command: \"npx\",\n            args: [\"-y\", \"@modelcontextprotocol/server-postgres\"],\n            tools: [\"*\"],\n        },\n    },\n    onPermissionRequest: async () => ({ kind: \"approve-once\" }),\n});\n```\n\n## Troubleshooting\n\n### スキルが読み込まれていない\n\n1. **パスの確認** - スキル ディレクトリのパスが正しく、 `SKILL.md` ファイルを含むサブディレクトリが含まれていることを確認します\n2. **アクセス許可を確認** する - SDK がディレクトリを読み取ることができることを確認する\n3. **SKILL.md の形式を確認** - Markdown が正しい形式になっており、YAML フロントマターで有効な構文が使用されていることを確認する\n4. **デバッグ ログを有効にする** - スキルの読み込みログを表示するように `logLevel: \"debug\"` を設定する\n\n### スキルの競合\n\n複数のスキルが競合する手順を提供する場合:\n\n* `disabledSkills`を使用して競合するスキルを除外する\n* スキル ディレクトリを再構成して重複を回避する\n\n## こちらも参照ください\n\n* [初めてのCopilot搭載アプリを構築する](/ja/copilot/how-tos/copilot-sdk/getting-started#create-custom-agents) - 特殊な AI ペルソナを定義する\n* [初めてのCopilot搭載アプリを構築する](/ja/copilot/how-tos/copilot-sdk/getting-started#step-4-add-a-custom-tool) - 独自のツールを構築する\n* [GitHub Copilot SDK での MCP サーバーの使用](/ja/copilot/how-tos/copilot-sdk/features/mcp) - 外部ツール プロバイダーを接続する"}