jpskill.com
✍️ ライティング コミュニティ

ai-native-development

RAGやベクトルデータベースを活用し、LLMと連携したAIアプリケーションを構築、プロンプト技術やコスト最適化を駆使して、2025年以降のAI開発をリードするSkill。

📜 元の英語説明(参考)

Build AI-first applications with RAG pipelines, embeddings, vector databases, agentic workflows, and LLM integration. Master prompt engineering, function calling, streaming responses, and cost optimization for 2025+ AI development.

🇯🇵 日本人クリエイター向け解説

一言でいうと

RAGやベクトルデータベースを活用し、LLMと連携したAIアプリケーションを構築、プロンプト技術やコスト最適化を駆使して、2025年以降のAI開発をリードするSkill。

※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。

⚡ おすすめ: コマンド1行でインストール(60秒)

下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。

🍎 Mac / 🐧 Linux
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o ai-native-development.zip https://jpskill.com/download/17234.zip && unzip -o ai-native-development.zip && rm ai-native-development.zip
🪟 Windows (PowerShell)
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/17234.zip -OutFile "$d\ai-native-development.zip"; Expand-Archive "$d\ai-native-development.zip" -DestinationPath $d -Force; ri "$d\ai-native-development.zip"

完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。

💾 手動でダウンロードしたい(コマンドが難しい人向け)
  1. 1. 下の青いボタンを押して ai-native-development.zip をダウンロード
  2. 2. ZIPファイルをダブルクリックで解凍 → ai-native-development フォルダができる
  3. 3. そのフォルダを C:\Users\あなたの名前\.claude\skills\(Win)または ~/.claude/skills/(Mac)へ移動
  4. 4. Claude Code を再起動

⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。

🎯 このSkillでできること

下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。

📦 インストール方法 (3ステップ)

  1. 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
  2. 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
  3. 3. 展開してできたフォルダを、ホームフォルダの .claude/skills/ に置く
    • · macOS / Linux: ~/.claude/skills/
    • · Windows: %USERPROFILE%\.claude\skills\

Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。

詳しい使い方ガイドを見る →
最終更新
2026-05-18
取得日時
2026-05-18
同梱ファイル
6

📖 Skill本文(日本語訳)

※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。

AIネイティブ開発

概要

AIネイティブ開発は、AIを後付けではなく、第一級の市民として扱うアプリケーションの構築に焦点を当てています。このスキルは、LLMの統合、RAG (Retrieval-Augmented Generation) の実装、ベクトルデータベースの使用、エージェントワークフローの構築、AIアプリケーションのパフォーマンスとコストの最適化のための包括的なパターンを提供します。

このスキルを使用する場面:

  • チャットボット、Q&Aシステム、または会話型インターフェースの構築
  • セマンティック検索またはレコメンデーションエンジンの実装
  • ツールを使用し、アクションを実行できるAIエージェントの作成
  • LLM (OpenAI、Anthropic、オープンソースモデル) のアプリケーションへの統合
  • ナレッジ検索のためのRAGシステムの構築
  • AIのコストとレイテンシの最適化
  • AIの可観測性とモニタリングの実装

AIネイティブ開発が重要な理由

従来のソフトウェアは決定的ですが、AIネイティブアプリケーションは確率的です。

  • コンテキストがすべて: LLMが正確な回答を提供するには、関連するコンテキストが必要です。
  • ファインチューニングよりもRAG: 検索はファインチューニングよりも安価で柔軟性があります。
  • 埋め込みはセマンティック検索を可能にする: キーワードマッチングを超えて意味を理解する
  • エージェントワークフロー: LLMは、自律的に推論、計画、およびツールを使用できます。
  • コスト管理: トークンの使用量は、運用コストに直接影響します。
  • 可観測性: 確率的システムのデバッグには、新しいアプローチが必要です。
  • プロンプトエンジニアリング: どのように質問するかが、何を質問するかと同じくらい重要です。

コアコンセプト

1. 埋め込みとベクトル検索

埋め込みは、セマンティックな意味を捉えたテキストのベクトル表現です。類似した概念は、類似したベクトルを持ちます。

主な機能:

  • テキストを高次元ベクトル (1536または3072次元) に変換
  • コサイン類似度を使用してセマンティックな類似性を測定
  • ベクトル検索を通じて関連ドキュメントを見つける
  • 効率のためのバッチ処理

詳細な実装: 以下については references/vector-databases.md を参照してください。

  • OpenAI埋め込みの設定とバッチ処理
  • コサイン類似度アルゴリズム
  • チャンク戦略 (500〜1000トークン、10〜20%のオーバーラップ)

2. ベクトルデータベース

埋め込みを大規模に効率的に保存および検索します。

一般的なオプション:

  • Pinecone: サーバーレスのマネージドサービス ($0.096/時間)
  • Chroma: オープンソース、セルフホスト
  • Weaviate: 柔軟なスキーマ、ハイブリッド検索
  • Qdrant: Rustベース、高パフォーマンス

詳細な実装: 以下については references/vector-databases.md を参照してください。

  • 各データベースの完全な設定ガイド
  • アップサート、クエリ、更新、削除操作
  • メタデータフィルタリングとハイブリッド検索
  • コスト比較とベストプラクティス

3. RAG (Retrieval-Augmented Generation)

RAGは、検索システムとLLMを組み合わせて、正確で根拠のある回答を提供します。

コアパターン:

  1. ベクトルデータベースから関連ドキュメントを検索
  2. 上位の結果からコンテキストを構築
  3. 検索されたコンテキストを使用してLLMで回答を生成

高度なパターン:

  • 引用とソース追跡を備えたRAG
  • ハイブリッド検索 (セマンティック + キーワード)
  • より良いリコールのためのマルチクエリRAG
  • HyDE (Hypothetical Document Embeddings)
  • 関連性のためのコンテキスト圧縮

詳細な実装: 以下については references/rag-patterns.md を参照してください。

  • 完全なコードを備えた基本的なRAGパターンと高度なRAGパターン
  • 引用戦略
  • Reciprocal Rank Fusionを使用したハイブリッド検索
  • 会話メモリパターン
  • エラー処理と検証

4. 関数呼び出しとツール使用

LLMが外部ツールとAPIを確実に使用できるようにします。

機能:

  • JSONスキーマでツールを定義
  • LLMの決定に基づいて関数を実行
  • 並列ツール呼び出しを処理
  • ツール使用で応答をストリーム

詳細な実装: 以下については references/function-calling.md を参照してください。

  • ツール定義パターン (OpenAIとAnthropic)
  • 関数呼び出しループ
  • 並列およびストリーミングツール実行
  • Zodを使用した入力検証
  • エラー処理とフォールバック戦略

5. エージェントワークフロー

LLMが推論、計画、および自律的なアクションを実行できるようにします。

パターン:

  • ReAct: 観察による推論 + 行動ループ
  • Tree of Thoughts: 複数の推論パスを探索
  • Multi-Agent: 複雑なタスクで連携する専門エージェント
  • Autonomous Agents: 自己主導の目標達成

詳細な実装: 以下については references/agentic-workflows.md を参照してください。

  • 完全なReActループの実装
  • Tree of Thoughtsの探索
  • マルチエージェントコーディネーターパターン
  • エージェントメモリ管理
  • エラー回復と安全ガード

5.1 マルチエージェントオーケストレーション (Opus 4.5)

Opus 4.5の拡張された思考能力を活用した高度なマルチエージェントパターン。

拡張思考を使用する場面:

  • 3つ以上の専門エージェントの連携
  • エージェント出力間の複雑な依存関係の解決
  • エージェントの能力に基づく動的なタスク割り当て
  • エージェントが矛盾する結果を生成した場合の競合解決

オーケストレーターパターン:

interface AgentTask {
  id: string;
  type: 'research' | 'code' | 'review' | 'design';
  input: unknown;
  dependencies: string[]; // 最初に完了する必要があるタスクID
}

interface AgentResult {
  taskId: string;
  output: unknown;
  confidence: number;
  reasoning: string;
}

async function orchestrateAgents(
  goal: string,
  availableAgents: Agent[]
): Promise<AgentResult[]> {
  // ステップ1:拡張思考を使用して、目標をタスクに分解します
  const taskPlan = await planTasks(goal, availableAgents);

  // ステップ2:依存関係グラフを構築します
  const dependencyGraph = buildDependencyGraph(taskPlan.tasks);

  // ステップ3:依存関係を尊重してタスクを実行します
  const results: AgentResult[] = [];
  const completed = new Set<string>();

  while (completed.size < taskPlan.tasks.length) {
    // 満たされた依存関係を持つタスクを見つけます
    const ready = taskPlan.tasks.filter(task =>
      !completed.has(task.id) &&
      task.dependencies.every(dep => completed.has(dep))
    );

    // 準備完了のタスクを並行して実行します
    const batchResults = await Promise.all(
      ready.map(task => executeAgentTask(task, availableAgents))
    );

    // 結果を検証します - us
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開

AI-Native Development

Overview

AI-Native Development focuses on building applications where AI is a first-class citizen, not an afterthought. This skill provides comprehensive patterns for integrating LLMs, implementing RAG (Retrieval-Augmented Generation), using vector databases, building agentic workflows, and optimizing AI application performance and cost.

When to use this skill:

  • Building chatbots, Q&A systems, or conversational interfaces
  • Implementing semantic search or recommendation engines
  • Creating AI agents that can use tools and take actions
  • Integrating LLMs (OpenAI, Anthropic, open-source models) into applications
  • Building RAG systems for knowledge retrieval
  • Optimizing AI costs and latency
  • Implementing AI observability and monitoring

Why AI-Native Development Matters

Traditional software is deterministic; AI-native applications are probabilistic:

  • Context is Everything: LLMs need relevant context to provide accurate answers
  • RAG Over Fine-Tuning: Retrieval is cheaper and more flexible than fine-tuning
  • Embeddings Enable Semantic Search: Move beyond keyword matching to understanding meaning
  • Agentic Workflows: LLMs can reason, plan, and use tools autonomously
  • Cost Management: Token usage directly impacts operational costs
  • Observability: Debugging probabilistic systems requires new approaches
  • Prompt Engineering: How you ask matters as much as what you ask

Core Concepts

1. Embeddings & Vector Search

Embeddings are vector representations of text that capture semantic meaning. Similar concepts have similar vectors.

Key Capabilities:

  • Convert text to high-dimensional vectors (1536 or 3072 dimensions)
  • Measure semantic similarity using cosine similarity
  • Find relevant documents through vector search
  • Batch process for efficiency

Detailed Implementation: See references/vector-databases.md for:

  • OpenAI embeddings setup and batch processing
  • Cosine similarity algorithms
  • Chunking strategies (500-1000 tokens with 10-20% overlap)

2. Vector Databases

Store and retrieve embeddings efficiently at scale.

Popular Options:

  • Pinecone: Serverless, managed service ($0.096/hour)
  • Chroma: Open source, self-hosted
  • Weaviate: Flexible schema, hybrid search
  • Qdrant: Rust-based, high performance

Detailed Implementation: See references/vector-databases.md for:

  • Complete setup guides for each database
  • Upsert, query, update, delete operations
  • Metadata filtering and hybrid search
  • Cost comparison and best practices

3. RAG (Retrieval-Augmented Generation)

RAG combines retrieval systems with LLMs to provide accurate, grounded answers.

Core Pattern:

  1. Retrieve relevant documents from vector database
  2. Construct context from top results
  3. Generate answer with LLM using retrieved context

Advanced Patterns:

  • RAG with citations and source tracking
  • Hybrid search (semantic + keyword)
  • Multi-query RAG for better recall
  • HyDE (Hypothetical Document Embeddings)
  • Contextual compression for relevance

Detailed Implementation: See references/rag-patterns.md for:

  • Basic and advanced RAG patterns with full code
  • Citation strategies
  • Hybrid search with Reciprocal Rank Fusion
  • Conversation memory patterns
  • Error handling and validation

4. Function Calling & Tool Use

Enable LLMs to use external tools and APIs reliably.

Capabilities:

  • Define tools with JSON schemas
  • Execute functions based on LLM decisions
  • Handle parallel tool calls
  • Stream responses with tool use

Detailed Implementation: See references/function-calling.md for:

  • Tool definition patterns (OpenAI and Anthropic)
  • Function calling loops
  • Parallel and streaming tool execution
  • Input validation with Zod
  • Error handling and fallback strategies

5. Agentic Workflows

Enable LLMs to reason, plan, and take autonomous actions.

Patterns:

  • ReAct: Reasoning + Acting loop with observations
  • Tree of Thoughts: Explore multiple reasoning paths
  • Multi-Agent: Specialized agents collaborating on complex tasks
  • Autonomous Agents: Self-directed goal achievement

Detailed Implementation: See references/agentic-workflows.md for:

  • Complete ReAct loop implementation
  • Tree of Thoughts exploration
  • Multi-agent coordinator patterns
  • Agent memory management
  • Error recovery and safety guards

5.1 Multi-Agent Orchestration (Opus 4.5)

Advanced multi-agent patterns leveraging Opus 4.5's extended thinking capabilities.

When to Use Extended Thinking:

  • Coordinating 3+ specialized agents
  • Complex dependency resolution between agent outputs
  • Dynamic task allocation based on agent capabilities
  • Conflict resolution when agents produce contradictory results

Orchestrator Pattern:

interface AgentTask {
  id: string;
  type: 'research' | 'code' | 'review' | 'design';
  input: unknown;
  dependencies: string[]; // Task IDs that must complete first
}

interface AgentResult {
  taskId: string;
  output: unknown;
  confidence: number;
  reasoning: string;
}

async function orchestrateAgents(
  goal: string,
  availableAgents: Agent[]
): Promise<AgentResult[]> {
  // Step 1: Use extended thinking to decompose goal into tasks
  const taskPlan = await planTasks(goal, availableAgents);

  // Step 2: Build dependency graph
  const dependencyGraph = buildDependencyGraph(taskPlan.tasks);

  // Step 3: Execute tasks respecting dependencies
  const results: AgentResult[] = [];
  const completed = new Set<string>();

  while (completed.size < taskPlan.tasks.length) {
    // Find tasks with satisfied dependencies
    const ready = taskPlan.tasks.filter(task =>
      !completed.has(task.id) &&
      task.dependencies.every(dep => completed.has(dep))
    );

    // Execute ready tasks in parallel
    const batchResults = await Promise.all(
      ready.map(task => executeAgentTask(task, availableAgents))
    );

    // Validate results - use extended thinking for conflicts
    const validatedResults = await validateAndResolveConflicts(
      batchResults,
      results
    );

    results.push(...validatedResults);
    ready.forEach(task => completed.add(task.id));
  }

  return results;
}

Task Planning with Extended Thinking:

Based on Anthropic's Extended Thinking documentation:

import Anthropic from '@anthropic-ai/sdk';

const anthropic = new Anthropic();

async function planTasks(
  goal: string,
  agents: Agent[]
): Promise<{ tasks: AgentTask[]; rationale: string }> {
  // Extended thinking requires budget_tokens < max_tokens
  // Minimum budget: 1,024 tokens
  const response = await anthropic.messages.create({
    model: 'claude-opus-4-5-20251101', // Or claude-sonnet-4-5-20250929
    max_tokens: 16000,
    thinking: {
      type: 'enabled',
      budget_tokens: 10000 // Extended thinking for complex planning
    },
    messages: [{
      role: 'user',
      content: `
        Goal: ${goal}

        Available agents and their capabilities:
        ${agents.map(a => `- ${a.name}: ${a.capabilities.join(', ')}`).join('\n')}

        Decompose this goal into tasks. For each task, specify:
        1. Which agent should handle it
        2. What input it needs
        3. Which other tasks it depends on
        4. Expected output format

        Think carefully about:
        - Optimal parallelization opportunities
        - Potential conflicts between agent outputs
        - Information that needs to flow between tasks
      `
    }]
  });

  // Response contains thinking blocks followed by text blocks
  // content: [{ type: 'thinking', thinking: '...' }, { type: 'text', text: '...' }]
  return parseTaskPlan(response);
}

Conflict Resolution:

async function validateAndResolveConflicts(
  newResults: AgentResult[],
  existingResults: AgentResult[]
): Promise<AgentResult[]> {
  // Check for conflicts with existing results
  const conflicts = detectConflicts(newResults, existingResults);

  if (conflicts.length === 0) {
    return newResults;
  }

  // Use extended thinking to resolve conflicts
  const resolution = await anthropic.messages.create({
    model: 'claude-opus-4-5-20251101',
    max_tokens: 8000,
    thinking: {
      type: 'enabled',
      budget_tokens: 5000
    },
    messages: [{
      role: 'user',
      content: `
        The following agent outputs conflict:

        ${conflicts.map(c => `
          Conflict: ${c.description}
          Agent A (${c.agentA.name}): ${JSON.stringify(c.resultA)}
          Agent B (${c.agentB.name}): ${JSON.stringify(c.resultB)}
        `).join('\n\n')}

        Analyze each conflict and determine:
        1. Which output is more likely correct and why
        2. If both have merit, how to synthesize them
        3. What additional verification might be needed
      `
    }]
  });

  return applyResolutions(newResults, resolution);
}

Adaptive Agent Selection:

async function selectOptimalAgent(
  task: AgentTask,
  agents: Agent[],
  context: ExecutionContext
): Promise<Agent> {
  // Score each agent based on:
  // - Capability match
  // - Current load
  // - Historical performance on similar tasks
  // - Cost (model tier)

  const scores = agents.map(agent => ({
    agent,
    score: calculateAgentScore(agent, task, context)
  }));

  // For complex tasks, use Opus; for simple tasks, use Haiku
  const complexity = assessTaskComplexity(task);

  if (complexity > 0.7) {
    // Filter to agents that can use Opus
    const opusCapable = scores.filter(s => s.agent.supportsOpus);
    return opusCapable.sort((a, b) => b.score - a.score)[0].agent;
  }

  return scores.sort((a, b) => b.score - a.score)[0].agent;
}

Agent Communication Protocol:

interface AgentMessage {
  from: string;
  to: string | 'broadcast';
  type: 'request' | 'response' | 'update' | 'conflict';
  payload: unknown;
  timestamp: Date;
}

class AgentCommunicationBus {
  private messages: AgentMessage[] = [];
  private subscribers: Map<string, (msg: AgentMessage) => void> = new Map();

  send(message: AgentMessage): void {
    this.messages.push(message);

    if (message.to === 'broadcast') {
      this.subscribers.forEach(callback => callback(message));
    } else {
      this.subscribers.get(message.to)?.(message);
    }
  }

  subscribe(agentId: string, callback: (msg: AgentMessage) => void): void {
    this.subscribers.set(agentId, callback);
  }

  getHistory(agentId: string): AgentMessage[] {
    return this.messages.filter(
      m => m.from === agentId || m.to === agentId || m.to === 'broadcast'
    );
  }
}

6. Streaming Responses

Deliver real-time AI responses for better UX.

Capabilities:

  • Stream LLM output token-by-token
  • Server-Sent Events (SSE) for web clients
  • Streaming with function calls
  • Backpressure handling

Detailed Implementation: See ../streaming-api-patterns/SKILL.md for streaming patterns

7. Cost Optimization

Strategies:

  • Use smaller models for simple tasks (GPT-3.5 vs GPT-4)
  • Implement prompt caching (Anthropic's ephemeral cache)
  • Batch requests when possible
  • Set max_tokens to prevent runaway generation
  • Monitor usage with alerts

Token Counting:

import { encoding_for_model } from 'tiktoken'

function countTokens(text: string, model = 'gpt-4'): number {
  const encoder = encoding_for_model(model)
  const tokens = encoder.encode(text)
  encoder.free()
  return tokens.length
}

Detailed Implementation: See references/observability.md for:

  • Cost estimation and budget tracking
  • Model selection strategies
  • Prompt caching patterns

8. Observability & Monitoring

Track LLM performance, costs, and quality in production.

Tools:

  • LangSmith: Tracing, evaluation, monitoring
  • LangFuse: Open-source observability
  • Custom Logging: Structured logs with metrics

Key Metrics:

  • Throughput (requests/minute)
  • Latency (P50, P95, P99)
  • Token usage and cost
  • Error rate
  • Quality scores (relevance, coherence, factuality)

Detailed Implementation: See references/observability.md for:

  • LangSmith and LangFuse integration
  • Custom logger implementation
  • Performance monitoring
  • Quality evaluation
  • Debugging and error analysis

Searching References

This skill includes detailed reference material. Use grep to find specific patterns:

# Find RAG patterns
grep -r "RAG" references/

# Search for specific vector database
grep -A 10 "Pinecone Setup" references/vector-databases.md

# Find agentic workflow examples
grep -B 5 "ReAct Pattern" references/agentic-workflows.md

# Locate function calling patterns
grep -n "parallel.*tool" references/function-calling.md

# Search for cost optimization
grep -i "cost\|pricing\|budget" references/observability.md

# Find all code examples for embeddings
grep -A 20 "async function.*embedding" references/

Best Practices

Context Management

  • ✅ Keep context windows under 75% of model limit
  • ✅ Use sliding window for long conversations
  • ✅ Summarize old messages before they scroll out
  • ✅ Remove redundant or irrelevant context

Embedding Strategy

  • ✅ Chunk documents to 500-1000 tokens
  • ✅ Overlap chunks by 10-20% for continuity
  • ✅ Include metadata (title, source, date) with chunks
  • ✅ Re-embed when source data changes

RAG Quality

  • ✅ Use hybrid search (semantic + keyword)
  • ✅ Re-rank results for relevance
  • ✅ Include citation/source in context
  • ✅ Set temperature low (0.1-0.3) for factual answers
  • ✅ Validate answers against retrieved context

Function Calling

  • ✅ Provide clear, concise function descriptions
  • ✅ Use strict JSON schema for parameters
  • ✅ Handle missing or invalid parameters gracefully
  • ✅ Limit to 10-20 tools to avoid confusion
  • ✅ Validate function outputs before returning to LLM

Cost Optimization

  • ✅ Use smaller models for simple tasks
  • ✅ Implement prompt caching for repeated content
  • ✅ Batch requests when possible
  • ✅ Set max_tokens to prevent runaway generation
  • ✅ Monitor usage with alerts for anomalies

Security

  • ✅ Validate and sanitize user inputs
  • ✅ Never include secrets in prompts
  • ✅ Implement rate limiting
  • ✅ Filter outputs for harmful content
  • ✅ Use separate API keys per environment

Templates

Use the provided templates for common AI patterns:

  • templates/rag-pipeline.ts - Basic RAG implementation
  • templates/agentic-workflow.ts - ReAct agent pattern

Examples

Complete RAG Chatbot

See examples/chatbot-with-rag/ for a full-stack implementation:

  • Vector database setup with document ingestion
  • RAG query with citations
  • Streaming chat interface
  • Cost tracking and monitoring

Checklists

AI Implementation Checklist

See checklists/ai-implementation.md for comprehensive validation covering:

  • [ ] Vector database setup and configuration
  • [ ] Embedding generation and chunking strategy
  • [ ] RAG pipeline with quality validation
  • [ ] Function calling with error handling
  • [ ] Streaming response implementation
  • [ ] Cost monitoring and budget alerts
  • [ ] Observability and logging
  • [ ] Security and input validation

Common Patterns

Semantic Caching

Reduce costs by caching similar queries:

const cache = new Map<string, { embedding: number[]; response: string }>()

async function cachedRAG(query: string) {
  const queryEmbedding = await createEmbedding(query)

  // Check if similar query exists in cache
  for (const [cachedQuery, cached] of cache.entries()) {
    const similarity = cosineSimilarity(queryEmbedding, cached.embedding)
    if (similarity > 0.95) {
      return cached.response
    }
  }

  // Not cached, perform RAG
  const response = await ragQuery(query)
  cache.set(query, { embedding: queryEmbedding, response })
  return response
}

Conversational Memory

Maintain context across multiple turns:

interface ConversationMemory {
  messages: Message[] // Last 10 messages
  summary?: string // Summary of older messages
}

async function getConversationContext(userId: string): Promise<Message[]> {
  const memory = await db.memory.findUnique({ where: { userId } })

  return [
    { role: 'system', content: `Previous conversation summary: ${memory.summary}` },
    ...memory.messages.slice(-5) // Last 5 messages
  ]
}

Prompt Engineering

Few-Shot Learning

Provide examples to guide LLM behavior:

const fewShotExamples = `
Example 1:
Input: "I love this product!"
Sentiment: Positive

Example 2:
Input: "It's okay, nothing special"
Sentiment: Neutral
`

// Include in system prompt

Chain of Thought (CoT)

Ask LLM to show reasoning:

const prompt = `${problem}\n\nLet's think step by step:`

Resources


Next Steps

After mastering AI-Native Development:

  1. Explore Streaming API Patterns skill for real-time AI responses
  2. Use Type Safety & Validation skill for AI input/output validation
  3. Apply Edge Computing Patterns skill for global AI deployment
  4. Reference Observability Patterns for production monitoring

同梱ファイル

※ ZIPに含まれるファイル一覧。`SKILL.md` 本体に加え、参考資料・サンプル・スクリプトが入っている場合があります。