SuperAPI AI Directory

prompt-engineering-helper

Agents & models

View repository

Updated 10-15 21:33

About this skill

Prompt Engineering Helper Skill

This skill supports the optimization and testing of LLM (Large Language Model) prompts.

Overview

This skill provides comprehensive support for improving the quality of LLM prompts. It supports all processes necessary for prompt engineering, including prompt analysis, improvement suggestions, A/B testing, application of best practices, and performance evaluation.

Main Features

  • Prompt Analysis: Evaluate the strengths and weaknesses of the current prompt
  • Improvement Suggestions: Present rewrite proposals for more effective prompts
  • A/B Testing: Compare and evaluate multiple prompt variations
  • Best Practice Application: Apply industry-standard prompt design patterns
  • Reproducibility Verification: Test whether consistent results can be obtained with the same prompt
  • Few-shot Example Optimization: Selection and placement of effective examples
  • Chain-of-Thought: Prompt design that makes the reasoning process explicit
  • Evaluation Metrics: Scoring based on indicators such as clarity, specificity, completeness, and safety
  • Token Optimization: Maintain quality while reducing cost
  • Multimodal Support: Prompts containing text, images, and structured data

Evaluation Criteria for Prompt Analysis

1. Clarity

Whether the prompt conveys its intent clearly without ambiguity

Good:

以下の顧客レビューを分析し、次の情報を抽出してください:
1. 感情(ポジティブ/ネガティブ/中立)
2. 主なトピック(最大3つ)
3. 改善提案(あれば)

レビュー: {review_text}

出力形式:
{
  "sentiment": "ポジティブ|ネガティブ|中立",
  "topics": ["トピック1", "トピック2", "トピック3"],
  "suggestions": ["提案1", "提案2"]
}

Avoid:

このレビューについて分析してください。

2. Specificity

Whether the task details, constraints, and expected output are clearly defined

Good:

以下のPythonコードをレビューし、以下の観点で問題点を指摘してください:
- セキュリティ脆弱性(SQLインジェクション、XSSなど)
- パフォーマンスの問題(N+1クエリ、不要なループなど)
- コードスタイル(PEP8違反)

各問題について:
1. 問題の種類
2. 該当する行番号
3. 具体的な改善案

を提示してください。

Avoid:

このコードをレビューしてください。

3. Completeness

Whether all necessary information, constraints, and handling of edge cases are included

Good:

以下の条件でタスク管理アプリのユーザーストーリーを生成してください:

対象ユーザー: フリーランスエンジニア
主な機能: タスク作成、編集、削除、優先度設定、期限管理
制約:
- モバイルファーストのデザイン
- オフライン対応
- 最大タスク数: 1000件

各ユーザーストーリーは以下の形式で出力:
"As a [ユーザータイプ], I want to [アクション] so that [目的]"

10件のユーザーストーリーを生成してください。

Avoid:

タスク管理アプリのユーザーストーリーを作ってください。

4. Context Provision

Whether sufficient background information is provided for the LLM to make appropriate judgments

Good:

あなたは経験豊富なReactコンサルタントです。
クライアントは中規模のECサイト(月間10万PV)を運営しており、
現在のReactアプリケーションのパフォーマンスに課題を抱えています。

以下のコードを分析し、パフォーマンス改善のための具体的な提案を
3つ挙げてください。各提案には以下を含めてください:
- 問題点
- 改善案
- 期待される効果
- 実装の難易度(低/中/高)

コード:
{code}

Avoid:

このReactコードを改善してください。

5. Structure

Whether the prompt is logically structured and easy to read

Good:

# タスク
GitHubリポジトリのREADME.mdを生成してください。

## 入力情報
- プロジェクト名: {project_name}
- 説明: {description}
- 主な機能: {features}
- 技術スタック: {tech_stack}

## 出力要件
1. プロジェクト概要(2-3文)
2. 主な機能リスト
3. インストール手順
4. 使用例
5. ライセンス情報

## 制約
- Markdown形式
- 合計文字数: 500-800字
- コードブロックは適切にハイライト

Avoid:

README.mdを作ってください。プロジェクト名は{project_name}で、
説明は{description}です。機能は{features}で技術スタックは{tech_stack}です。
インストール方法と使い方も書いてください。

Prompt Improvement Patterns

Pattern 1: Zero-shot → Few-shot

Before (Zero-shot):

以下のテキストを英語に翻訳してください:
{text}

After (Few-shot):

以下の例を参考に、テキストを英語に翻訳してください:

例1:
日本語: 今日は良い天気ですね。
英語: It's nice weather today.

例2:
日本語: 会議は午後3時に始まります。
英語: The meeting starts at 3 PM.

例3:
日本語: このプロジェクトは順調に進んでいます。
英語: This project is progressing smoothly.

翻訳してください:
{text}

Pattern 2: Ambiguous → Specific

Before:

このデータを分析してください。

After:

以下のCSVデータを分析し、次の情報を抽出してください:

1. 基本統計量(平均、中央値、標準偏差)
2. 外れ値の検出(±3σ)
3. 欠損値の数とパーセンテージ
4. カテゴリ変数の分布

出力形式: JSON
{
  "statistics": {...},
  "outliers": [...],
  "missing_values": {...},
  "categorical_distribution": {...}
}

データ:
{csv_data}

Pattern 3: Single Step → Chain-of-Thought

Before:

この数学の問題を解いてください:
{problem}

After:

以下の数学の問題を、ステップバイステップで解いてください:

問題: {problem}

解答手順:
1. 問題の理解: 何を求められているか明確にする
2. 既知の情報と未知の情報を整理
3. 適用できる公式や定理を特定
4. 計算プロセスを段階的に記述
5. 答えを検証

最終的な答えは以下の形式で出力:
答え: [数値] [単位]

Pattern 4: Unconstrained → Constrained

Before:

ブログ記事を書いてください。
テーマ: {topic}

After:

以下の制約に従って、ブログ記事を執筆してください:

テーマ: {topic}
対象読者: 初心者エンジニア(経験1-2年)
文体: カジュアルだが専門的
文字数: 1500-2000字
構成:
  1. 導入(問題提起): 200字
  2. 本文(解決策・説明): 1000字
  3. 具体例・コード: 500字
  4. まとめ: 300字

含めるべき要素:
- 実践的なコード例
- 初心者が陥りやすい落とし穴
- 参考リンク(2-3個)

避けるべき要素:
- 過度に専門的な用語(必要な場合は説明を追加)
- 古い情報(2020年以前の技術)

Pattern 5: Explicit Output Format

Before:

このJSON APIレスポンスからエラー情報を抽出してください。
{api_response}

After:

以下のJSON APIレスポンスからエラー情報を抽出し、
指定した形式で出力してください:

入力:
{api_response}

出力形式(TypeScript型定義):
interface ErrorInfo {
  statusCode: number;
  errorType: string;
  message: string;
  timestamp: string;
  affectedFields?: string[];
}

出力例:
{
  "statusCode": 400,
  "errorType": "ValidationError",
  "message": "Invalid email format",
  "timestamp": "2024-11-22T10:30:00Z",
  "affectedFields": ["email"]
}

抽出してください:

A/B Testing Feature

How to Use

以下の2つのプロンプトを比較評価してください:

プロンプトA:
「この文章を要約してください。」

プロンプトB:
「以下の文章を3つの箇条書きで要約してください。各箇条書きは1文で簡潔に。」

評価基準:
- 明確性
- 具体性
- 再現性
- 出力の品質

テストケース: 3つの異なる入力文章

Example Evaluation Report

## A/Bテスト結果

### プロンプトA
スコア: 65/100
- 明確性: 6/10(タスクが曖昧)
- 具体性: 5/10(要約の形式が不明確)
- 再現性: 7/10(比較的一貫した結果)
- 出力の品質: 6/10(要約の長さが不安定)

### プロンプトB
スコア: 88/100
- 明確性: 9/10(タスクが明確)
- 具体性: 9/10(形式が詳細に指定)
- 再現性: 9/10(非常に一貫した結果)
- 出力の品質: 8/10(期待通りの出力)

### 推奨
プロンプトBを採用することを推奨します。
理由: 具体的な制約により、出力が安定し、品質が向上。

Best Practices Collection

1. Role Prompting

あなたは10年の経験を持つシニアPythonエンジニアです。
コードレビューの専門家として、以下のコードを評価してください。

2. Strict Specification of Output Format

必ず以下のJSON形式で出力してください。
他のテキストは一切含めないでください:

{
  "summary": "要約文",
  "key_points": ["ポイント1", "ポイント2"],
  "confidence": 0.85
}

3. Step-by-Step Instructions

以下の手順で分析を実行してください:

ステップ1: データの前処理
- 欠損値を確認
- 外れ値を検出

ステップ2: 探索的データ分析
- 各変数の分布を確認
- 相関関係を分析

ステップ3: 結果の要約
- 主要な発見を3つ挙げる
- 推奨アクションを提示

4. Handling Edge Cases

以下の入力に対して、適切に処理してください:

エッジケース:
- 入力が空文字列の場合 → "入力が空です"と返す
- 入力が1000文字を超える場合 → 最初の1000文字のみ処理
- 無効な形式の場合 → エラーメッセージを返す

通常ケース:
{normal_processing_instructions}

5. Recommended Values for Temperature Parameters

タスクの種類に応じた推奨設定:

創造的タスク(アイデア生成、ストーリー執筆):
- temperature: 0.7-0.9
- top_p: 0.9

分析的タスク(コードレビュー、データ分析):
- temperature: 0.1-0.3
- top_p: 0.1

翻訳・要約タスク:
- temperature: 0.3-0.5
- top_p: 0.5

Token Optimization

Compression of Redundant Prompts

Before (150 tokens):

あなたは非常に経験豊富で優秀なソフトウェアエンジニアです。
長年にわたってさまざまなプロジェクトに携わってきました。
以下のコードを丁寧にレビューしてください。
問題点があれば指摘し、改善案を提示してください。
できるだけ詳しく説明をお願いします。

After (45 tokens):

経験豊富なエンジニアとして、以下のコードをレビューし、
問題点と改善案を提示してください。

Utilization of System Messages

Before:

[ユーザーメッセージ]
あなたはPythonの専門家です。以下のコードを...

After:

[システムメッセージ]
You are a Python expert.

[ユーザーメッセージ]
以下のコードを...

Usage Examples

Basic Usage

以下のプロンプトを分析し、改善案を提示してください:

現在のプロンプト:
「このコードを直してください。」

期待する出力:
- 明確性、具体性、完全性のスコア
- 改善されたプロンプト
- 改善のポイント

Optimization of Few-shot Examples

以下のFew-shot例を評価し、より効果的な例を提案してください:

タスク: 感情分析
現在の例:
1. "良い" → ポジティブ
2. "悪い" → ネガティブ
3. "普通" → 中立

改善してください。

Prompt Template Generation

以下のタスク用のプロンプトテンプレートを生成してください:

タスク: コードレビュー
対象言語: TypeScript
重点項目: セキュリティ、パフォーマンス、型安全性

要件:
- 変数部分を{variable_name}で表現
- 評価基準を明確に
- 出力形式を指定

Prompt Design for Multi-step Tasks

複数のLLM呼び出しが必要なタスクのプロンプトチェーンを設計してください:

最終目標: ブログ記事の自動生成
ステップ:
1. トピック案の生成
2. アウトラインの作成
3. 各セクションの執筆
4. 編集・校正

各ステップのプロンプトを設計してください。

Evaluation Metrics Details

Clarity Score (0-10)

  • 10: Task is completely clear, zero ambiguity
  • 7-9: Mostly clear, but with some ambiguity
  • 4-6: Somewhat ambiguous, room for interpretation
  • 1-3: Very ambiguous, intent unclear
  • 0: Completely unclear

Specificity Score (0-10)

  • 10: All details, constraints, and format specified
  • 7-9: Key details included, some omitted
  • 4-6: Basic information only
  • 1-3: Almost no details
  • 0: Completely no specificity

Completeness Score (0-10)

  • 10: All necessary information, including handling edge cases
  • 7-9: Key information is present
  • 4-6: Basic information only, some missing
  • 1-3: Much information missing
  • 0: Almost no information

Reproducibility Score (0-10)

  • 10: Always the same output for the same input
  • 7-9: Mostly consistent output
  • 4-6: Occasionally different output
  • 1-3: Frequently different output
  • 0: Completely no consistency

Advanced Usage Examples

Optimization of System Prompts

以下のシステムプロンプトを最適化してください:

現在:
「あなたはAIアシスタントです。ユーザーの質問に答えてください。」

要件:
- タスクの専門性を明示
- 制約・ガイドラインを追加
- 出力形式のデフォルトを設定
- トーンとスタイルを定義

Designing Prompt Chains

以下の複雑なタスクをプロンプトチェーンに分解してください:

タスク: GitHubリポジトリの包括的な分析レポート生成

必要な分析:
1. コード品質評価
2. セキュリティ脆弱性検出
3. パフォーマンスボトルネック分析
4. アーキテクチャ評価
5. ドキュメント品質評価

各ステップのプロンプトと、ステップ間のデータ受け渡しを設計してください。

Optimization of Context Length

以下の長いコンテキストを含むプロンプトを最適化してください:

現在のコンテキスト: 10,000トークン(長文ドキュメント全体)

要件:
- コンテキストを5,000トークン以下に圧縮
- 重要情報は保持
- 必要に応じてRAG(Retrieval-Augmented Generation)を提案

Troubleshooting

Problem: Output is unstable

Solution:

  1. Lower the temperature parameter (0.0-0.2)
  2. Add few-shot examples
  3. Strictly specify the output format
  4. Emphasize consistency in the system prompt

Problem: Prompt is too long

Solution:

  1. Move common parts to the system message
  2. Remove redundant expressions
  3. Use only the minimum necessary examples
  4. Templatize for reuse

Problem: Unintended output

Solution:

  1. Eliminate ambiguity in the prompt
  2. Explicitly specify the output format
  3. State clearly what should be excluded
  4. Show expected output with few-shot examples

Problem: LLM does not follow instructions

Solution:

  1. Make instructions clear using bullet points
  2. Emphasize important instructions (bold、UPPERCASE)
  3. Clearly define the role setting
  4. Demonstrate correct behavior with few-shot examples

Summary of Best Practices

  1. Clarity: Describe the task without ambiguity
  2. Specificity: Specify details, constraints, and format
  3. Structured: Logically organized prompt
  4. Few-shot: Provide 2-5 effective examples
  5. Chain-of-Thought: Split complex tasks into steps
  6. Output format: Specify strictly (JSON, Markdown, etc.)
  7. Edge Cases: Clearly state error handling
  8. Role setting: Define an appropriate persona
  9. Token optimization: Concise but complete expression
  10. Testing: Verify consistency with multiple inputs

Version information

  • Skill Version: 1.0.0
  • Last updated: 2025-11-22
  • Supported LLMs: Claude, GPT-4, Gemini, etc.

Usage examples summary

Simple improvement

このプロンプトを改善してください:
「コードを書いてください。」

Detailed analysis

以下のプロンプトを詳細に分析してください:

プロンプト:
{your_prompt}

分析項目:
- 明確性スコア(理由付き)
- 具体性スコア(理由付き)
- 完全性スコア(理由付き)
- 改善点リスト
- 改善されたプロンプト

A/B Testing

プロンプトA と プロンプトB を比較評価してください。
テストケース: {test_cases}

評価レポートを生成してください。

Use this skill to systematically improve your prompt engineering!