system-prompt-engineering について
カスタムエージェントの役割、専門性、継続的な規則、境界を定めるシステムプロンプト設計スキルです。例の作成や検証を含む設計手順を示します。
主な機能
- 01エージェントの役割と専門性の定義
- 02継続的な規則と境界の設定
- 03主要シナリオの例の設計
- 04プロンプトの明確さと網羅性の検証
- 05システムプロンプトとユーザープロンプトの区別
活用シーン
- 01特化型カスタムエージェントの作成
- 02エージェントの継続的な振る舞いの設定
- 03システムプロンプトの不足点の確認
インストール
コマンドをコピーしてターミナルで実行します。
$
npx skills add https:/ / github.com/ melodic-software/ claude-code-plugins --skill system-prompt-engineeringインストール後、Claude Code で/system-prompt-engineeringを入力して読み込まれたか確認します。
詳細
システムプロンプトエンジニアリングスキル
カスタムエージェントのアイデンティティ、ルール、振る舞いを確立する、効果的なシステムプロンプトを設計します。
目的
すべての会話を通じてエージェントの振る舞いを形作るシステムプロンプトを作成します。システムプロンプトは、ユーザープロンプトよりも桁違いに重要です。
使用するタイミング
- 新しいカスタムエージェントを作成するとき
- エージェントの専門性を確立するとき
- 永続的なルールを定義するとき
- 特化したアシスタントを構築するとき
システムプロンプトとユーザープロンプト
| 項目 | システムプロンプト | ユーザープロンプト |
|---|---|---|
| 適用範囲 | すべての会話 | 単一のタスク |
| 持続性 | あらゆる内容に影響 | リクエストごと |
| 影響度 | 桁違いに高い | 影響範囲が小さい |
| セクション | 目的、指示、例 | すべてのセクション |
主なセクション
目的(必須)
エージェントが何者で、何をするのかを定義します。
## Purpose
You are a security expert specializing in code review.
Your role is to identify vulnerabilities and suggest fixes.
You focus on OWASP Top 10 and secure coding practices.
ガイドライン:
- 直接的で明確なアイデンティティの説明
- 具体的な専門分野
- エージェントが行うこと
指示(推奨)
ルール、制約、境界を定めます。
## Instructions
- Focus only on security concerns
- Always explain the reasoning behind findings
- Prioritize issues by severity (Critical, High, Medium, Low)
- Do not modify code without explicit permission
- When uncertain, ask clarifying questions
ガイドライン:
- 明確さを保つために箇条書きを使う
- 肯定的なルールと否定的なルール
- エッジケースへの対応
- 境界の定義
例(重要)
具体的な例を通じて振る舞いを形作ります。
## Examples
### Example 1: SQL Injection Finding
**Input:** "Review this login function"
**Output:** "Found SQL injection vulnerability at line 42. The user input is directly concatenated into the query string. Recommendation: Use parameterized queries instead."
### Example 2: Out of Scope Request
**Input:** "Fix this CSS styling issue"
**Output:** "That's outside my security focus. I specialize in security vulnerabilities, not styling. Consider consulting a frontend expert for CSS issues."
### Example 3: Clean Code
**Input:** "Check this authentication module"
**Output:** "Reviewed the authentication module. No security vulnerabilities found. The code follows secure practices: uses parameterized queries, hashes passwords with bcrypt, and implements rate limiting."
ガイドライン:
- 多様な例を2〜4件用意する
- よくあるケースを網羅する
- エッジケースを含める
- 望ましい出力形式を示す
設計プロセス
ステップ1:エージェントのアイデンティティを定義する
次の質問に答えます。
- このエージェントにはどのような専門知識がありますか?
- どの分野で動作しますか?
- 主な目的は何ですか?
- どのような口調を使うべきですか?
ステップ2:境界を定める
次の質問に答えます。
- エージェントは何をするべきですか?
- エージェントがしてはいけないことは何ですか?
- どのような場合に確認を求めるべきですか?
- どのような制約がありますか?
ステップ3:例を作成する
重要なシナリオごとに、次の点を検討します。
- 典型的な入力は何ですか?
- 理想的な出力は何ですか?
- エッジケースにはどのように対応するべきですか?
ステップ4:設計を検証する
次の点を確認します。
- 目的が明確かつ具体的である
- 指示に曖昧さがない
- 例が重要なシナリオを網羅している
- 境界が明確に定義されている
- 口調に一貫性がある
避けるべきこと
| 避けること | 理由 | 代わりに |
|---|---|---|
| 詳細なワークフロー | 自律性を損なう | 大まかなガイドライン |
| 動的な変数 | システムプロンプトは静的 | ユーザープロンプトを使う |
| 規定しすぎた形式 | 制約が強くなりすぎる | 柔軟なガイドライン |
| 「念のため」の情報をすべて含める | コンテキストが膨らむ | 必要なものだけにする |
システムプロンプトの構成
---
name: agent-name
description: When to use this agent (for auto-delegation)
tools: [minimal tool set]
model: sonnet
color: blue
---
# Agent Name
## Purpose
[Identity and role definition]
## Instructions
[Rules and constraints]
## Examples
### Example 1: [Scenario]
**Input:** [typical input]
**Output:** [ideal output]
### Example 2: [Edge Case]
**Input:** [edge case input]
**Output:** [handling output]
### Example 3: [Boundary]
**Input:** [out-of-scope request]
**Output:** [how to decline/redirect]
出力形式
システムプロンプトを設計するときは、次の形式を使います。
## System Prompt Design
**Agent Name:** [name]
**Domain:** [expertise area]
**Model:** [sonnet/opus/haiku]
### Purpose
[2-3 sentences defining identity]
### Instructions
- [rule 1]
- [rule 2]
- [rule 3]
### Examples
**Example 1:** [scenario]
- Input: [input]
- Output: [output]
**Example 2:** [scenario]
- Input: [input]
- Output: [output]
### Validation
- [ ] Purpose is specific
- [ ] Instructions are actionable
- [ ] Examples are diverse
- [ ] Boundaries are clear
よくあるエージェントの種類
エキスパートエージェント
重点:深い専門知識
## Purpose
You are an expert in [domain] with deep knowledge of [specifics].
ガードエージェント
重点:検証と安全性
## Instructions
- Validate all inputs against [criteria]
- Block requests that [conditions]
- Log suspicious activity
翻訳エージェント
重点:形式の変換
## Examples
### Input Format
[format A]
### Output Format
[format B]
重要な引用
「システムプロンプトは、ユーザープロンプトよりも桁違いに重要です。システムプロンプトは一度実行され、あらゆる内容に影響します。」
関連項目
- @system-vs-user-prompts.md - 違いとベストプラクティス
- @agent-expert-creation skill - エキスパートエージェントの作成
- @one-agent-one-purpose.md - 特化の原則
バージョン履歴
- v1.0.0 (2025-12-26):初回リリース
最終更新
日付: 2025-12-26 モデル: claude-opus-4-5-20251101
コメント
Markdown 対応