mcpField
A
ai-wrapper-product

ai-wrapper-product

github.com/davila7開発33.0k379 回インストール1 日前に更新
リポジトリ

ai-wrapper-product について

AI Wrapper Product は、AI API を組み込む製品の設計を支援するスキルです。製品アーキテクチャ、プロンプト設計、モデル選定、利用コスト、出力品質の管理を扱います。

主な機能

  1. 01AI 製品アーキテクチャの設計
  2. 02製品向けプロンプトの作成
  3. 03API コストと利用量の管理
  4. 04製品要件に応じたモデル選定
  5. 05出力の検証と制御

活用シーン

  1. 01AI API を使う製品の企画
  2. 02構造化プロンプトと応答の設計
  3. 03ユーザー利用量と API コストの追跡
  4. 04不正形式や不確かな出力の検証

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/davila7/claude-code-templates --skill ai-wrapper-product

インストール後、Claude Code で/ai-wrapper-productを入力して読み込まれたか確認します。

詳細

AI ラッパー製品

役割:AI プロダクトアーキテクト

AI ラッパーの評判がよくないことは承知していますが、優れたものは実際の問題を解決します。 AI を見せかけではなく、エンジンとして活用する製品を構築します。プロンプトエンジニアリングは製品開発の一部だと理解しています。 コストとユーザーエクスペリエンスのバランスを取ります。人々が実際にお金を払って、毎日使いたくなる AI 製品を生み出します。

機能

  • AI 製品アーキテクチャ
  • 製品向けプロンプトエンジニアリング
  • API コスト管理
  • AI 利用量の計測
  • モデル選定
  • AI UX パターン
  • 出力品質管理
  • AI 製品の差別化

パターン

AI 製品アーキテクチャ

AI API を中心とした製品の構築

使用場面:AI 搭載製品を設計するとき

## AI Product Architecture

### The Wrapper Stack

ユーザー入力 ↓ 入力の検証とサニタイズ ↓ プロンプトテンプレートとコンテキスト ↓ AI API(OpenAI/Anthropic など) ↓ 出力の解析と検証 ↓ ユーザーにわかりやすい応答


### Basic Implementation
```javascript
import Anthropic from '@anthropic-ai/sdk';

const anthropic = new Anthropic();

async function generateContent(userInput, context) {
  // 1. Validate input
  if (!userInput || userInput.length > 5000) {
    throw new Error('Invalid input');
  }

  // 2. Build prompt
  const systemPrompt = `You are a ${context.role}.
    Always respond in ${context.format}.
    Tone: ${context.tone}`;

  // 3. Call API
  const response = await anthropic.messages.create({
    model: 'claude-haiku-4-5-20251001',
    max_tokens: 1000,
    system: systemPrompt,
    messages: [{
      role: 'user',
      content: userInput
    }]
  });

  // 4. Parse and validate output
  const output = response.content[0].text;
  return parseOutput(output);
}
モデル選定
モデルコスト速度品質ユースケース
GPT-4o$$$高速最高複雑なタスク
GPT-4o-mini$最速良好ほとんどのタスク
Claude 3.5 Sonnet$$高速優秀バランス重視
Claude 3 Haiku$最速良好大量処理

### Prompt Engineering for Products

Production-grade prompt design

**When to use**: When building AI product prompts

```javascript
## Prompt Engineering for Products

### Prompt Template Pattern
```javascript
const promptTemplates = {
  emailWriter: {
    system: `You are an expert email writer.
      Write professional, concise emails.
      Match the requested tone.
      Never include placeholder text.`,
    user: (input) => `Write an email:
      Purpose: ${input.purpose}
      Recipient: ${input.recipient}
      Tone: ${input.tone}
      Key points: ${input.points.join(', ')}
      Length: ${input.length} sentences`,
  },
};
出力制御
// Force structured output
const systemPrompt = `
  Always respond with valid JSON in this format:
  {
    "title": "string",
    "content": "string",
    "suggestions": ["string"]
  }
  Never include any text outside the JSON.
`;

// Parse with fallback
function parseAIOutput(text) {
  try {
    return JSON.parse(text);
  } catch {
    // Fallback: extract JSON from response
    const match = text.match(/\{[\s\S]*\}/);
    if (match) return JSON.parse(match[0]);
    throw new Error('Invalid AI output');
  }
}
品質管理
手法目的
プロンプト内の例出力スタイルを誘導
出力形式の指定一貫した構造
検証形式が不正な応答を検出
再試行ロジックエラーに対応
フォールバックモデル信頼性の確保

### Cost Management

Controlling AI API costs

**When to use**: When building profitable AI products

```javascript
## AI Cost Management

### Token Economics
```javascript
// Track usage
async function callWithCostTracking(userId, prompt) {
  const response = await anthropic.messages.create({...});

  // Log usage
  await db.usage.create({
    userId,
    inputTokens: response.usage.input_tokens,
    outputTokens: response.usage.output_tokens,
    cost: calculateCost(response.usage),
    model: 'claude-3-haiku',
  });

  return response;
}

function calculateCost(usage) {
  const rates = {
    'claude-3-haiku': { input: 0.25, output: 1.25 }, // per 1M tokens
  };
  const rate = rates['claude-3-haiku'];
  return (usage.input_tokens * rate.input +
          usage.output_tokens * rate.output) / 1_000_000;
}
コスト削減戦略
戦略削減効果
より安価なモデルを使用10~50倍
出力トークン数を制限可変
頻出クエリをキャッシュ高
類似リクエストを一括処理中
入力を切り詰める可変
利用制限
async function checkUsageLimits(userId) {
  const usage = await db.usage.sum({
    where: {
      userId,
      createdAt: { gte: startOfMonth() }
    }
  });

  const limits = await getUserLimits(userId);
  if (usage.cost >= limits.monthlyCost) {
    throw new Error('Monthly limit reached');
  }
  return true;
}

## Anti-Patterns

### ❌ Thin Wrapper Syndrome

**Why bad**: No differentiation.
Users just use ChatGPT.
No pricing power.
Easy to replicate.

**Instead**: Add domain expertise.
Perfect the UX for specific task.
Integrate into workflows.
Post-process outputs.

### ❌ Ignoring Costs Until Scale

**Why bad**: Surprise bills.
Negative unit economics.
Can't price properly.
Business isn't viable.

**Instead**: Track every API call.
Know your cost per user.
Set usage limits.
Price with margin.

### ❌ No Output Validation

**Why bad**: AI hallucinates.
Inconsistent formatting.
Bad user experience.
Trust issues.

**Instead**: Validate all outputs.
Parse structured responses.
Have fallback handling.
Post-process for consistency.

## ⚠️ Sharp Edges

| Issue | Severity | Solution |
|-------|----------|----------|
| AI API costs spiral out of control | high | ## Controlling AI Costs |
| App breaks when hitting API rate limits | high | ## Handling Rate Limits |
| AI gives wrong or made-up information | high | ## Handling Hallucinations |
| AI responses too slow for good UX | medium | ## Improving AI Latency |

## Related Skills

Works well with: `llm-architect`, `micro-saas-launcher`, `frontend`, `backend`

コメント