Codex: Codex エージェントスキル
最終更新:2026-08-31
エージェントスキルにより Codex はドメイン固有の専門知識を持てます。人間の専門資格のようなものです。
📋 前提条件: Codex の基本操作と設定を理解していること
1. 学ぶ内容
- エージェントスキルの概念
- 内蔵スキル
- カスタムスキル
- スキルマーケットプレイス
2. エージェントスキルとは
エージェントスキルは Codex の能力拡張モジュールです。各スキルはドメイン固有の知識とワークフローをカプセル化します。
| 次元 | 説明 |
|---|---|
| 定義 | ドメイン固有の能力パッケージ |
| 内容 | システムプロンプト + ツール呼び出し + ワークフロー |
| 形式 | Markdown ファイル |
| 場所 | .codex/skills/ ディレクトリ |
3. 内蔵スキル
Codex には一般的なスキルがいくつか含まれています:
| スキル | 能力 | 最適な用途 |
|---|---|---|
| code-review | コードレビュー | PR レビュー |
| debug | デバッグと修正 | バグ修正 |
| test-gen | テスト生成 | テストの補充 |
| doc-gen | ドキュメント生成 | API ドキュメント |
| refactor | リファクタリング | コード最適化 |
| security | セキュリティスキャン | セキュリティ監査 |
(1) 内蔵スキルの使用
TEXT
📖 参照専用
> /skill code-review
> Review the code quality of src/auth.ts
> /skill debug
> Fix TypeError: Cannot read property 'id' of undefined
▶ 例1:Alice が内蔵スキルを使用
TEXT
📖 参照専用
# Alice がセキュリティスキルでセキュリティ監査を実行
> /skill security
> Scan the entire project for security vulnerabilities
# 出力:
# 🔴 [Critical] src/auth.ts:45 - Hardcoded secret key
# 🟡 [Medium] src/api.ts:23 - SQL concatenation not parameterized
# 🟢 [Low] src/utils.ts:12 - Missing input validation
4. カスタムスキル
(1) スキルファイルの作成
MARKDOWN
<!-- .codex/skills/react-component.md -->
# React Component Generator
## Role
You are a React component development expert, proficient in TypeScript and modern React patterns.
## Rules
- Use functional components
- Use TypeScript type annotations
- Define Props with interface
- Use CSS Modules or Tailwind
- Include Storybook story
- Include unit tests
## Workflow
1. Analyze component requirements
2. Define Props interface
3. Implement component logic
4. Add styles
5. Create Storybook story
6. Write unit tests
7. Verify TypeScript compilation
## Output Format
- Component file: src/components/ComponentName.tsx
- Style file: src/components/ComponentName.module.css
- Story file: src/components/ComponentName.stories.tsx
- Test file: src/components/ComponentName.test.tsx
(2) カスタムスキルの使用
TEXT
📖 参照専用
> /skill react-component
> Create a DatePicker component with date range selection support
▶ 例2:Bob がカスタムスキルを作成
MARKDOWN
<!-- .codex/skills/api-endpoint.md -->
# API Endpoint Generator
## Role
You are a FastAPI endpoint development expert.
## Rules
- Use Pydantic models for request/response validation
- All endpoints include error handling
- Use dependency injection
- Include Swagger documentation
- Write pytest tests
## Template
Reference src/api/templates/standard_endpoint.py
## Workflow
1. Define Pydantic request model
2. Define Pydantic response model
3. Implement endpoint logic
4. Add error handling
5. Write tests
6. Ensure pytest passes
5. スキル管理
(1) スキル一覧表示
TEXT
📖 参照専用
/skills list
(2) スキル詳細の表示
TEXT
📖 参照専用
/skills info code-review
(3) スキルの有効化/無効化
TEXT
📖 参照専用
/skills enable react-component
/skills disable doc-gen
(4) マーケットプレイスからのインストール
TEXT
📖 参照専用
/skills install graphql-api
6. スキルのベストプラクティス
| プラクティス | 説明 |
|---|---|
| 単一ドメイン | 各スキルは1つのドメインのみカバー |
| テンプレートを含める | コードテンプレートを参照として提供 |
| 明確なワークフロー | 明示的な実行ステップを定義 |
| 検証を含める | 出力の検証方法を指定 |
| 継続的な改善 | 使用フィードバックに基づいてスキルを改善 |
❓ よくある質問
Q スキルと AGENTS.md の違いは何ですか?
A AGENTS.md はプロジェクトレベルのルール(すべてのタスクに適用)、スキルはオプションの能力拡張(オンデマンドで有効化)です。
Q スキルを共有できますか?
A はい。スキルファイルをリポジトリにコミットすれば、チームメンバーが自動的に利用できます。スキルマーケットプレイスに公開することもできます。
Q スキルはトークン消費を増やしますか?
A はい。スキルのシステムプロンプトはコンテキストウィンドウのスペースを占有しますが、スキルなしで繰り返し説明するより効率的です。
Q 内蔵スキルを変更できますか?
A 直接はできませんが、同じ名前のカスタムスキルを作成して内蔵版を上書きできます。
Q 1つのタスクで複数のスキルを使用できますか?
A 推奨されません。各タスクは1つのスキルのみを使用し、指示の競合を避けるべきです。
📖 まとめ
- スキルは Codex の能力拡張モジュール
- 内蔵スキル:code-review / debug / test-gen / doc-gen / refactor / security
- カスタムスキル:
.codex/skills/ディレクトリに配置 - スキルの内容:役割定義 + ルール + ワークフロー + 出力フォーマット
- 単一ドメイン、テンプレートを含める、明確なワークフロー
📝 練習問題
- 基本 (⭐):内蔵スキルを使用してタスクを完了し、スキルなしの結果と比較する。
- 中級 (⭐⭐):自分の一般的な開発シナリオにカスタムスキルを作成する。
- 上級 (⭐⭐⭐):チームのすべての開発シナリオをカバーする完全なスキルライブラリを作成する。