vibes-plug 2.5.0 → 2.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (177) hide show
  1. package/.claude/rules/vibes-plug-core.md +32 -0
  2. package/.cursor/rules/vibes-plug-core.mdc +51 -0
  3. package/.cursorrules +42 -0
  4. package/AGENTS.md +37 -7
  5. package/BLUEPRINT.md +309 -217
  6. package/CHANGELOG.md +133 -1
  7. package/CLAUDE.md +70 -0
  8. package/LICENSE +1 -1
  9. package/README.md +641 -415
  10. package/index.js +19 -0
  11. package/package.json +44 -8
  12. package/plugin.json +24 -7
  13. package/scripts/generate_swarm_gif.py +295 -0
  14. package/scripts/install.js +201 -0
  15. package/skills/accessibility-testing-expert/SKILL.md +116 -0
  16. package/skills/ai-cost-token-optimizer/SKILL.md +82 -52
  17. package/skills/ai-evals-benchmark-expert/SKILL.md +188 -0
  18. package/skills/ai-llm-integration-expert/SKILL.md +185 -178
  19. package/skills/ai-media-generation-expert/SKILL.md +172 -0
  20. package/skills/ai-prompt-engineering-expert/SKILL.md +84 -0
  21. package/skills/angular-expert/SKILL.md +148 -0
  22. package/skills/api-design-expert/SKILL.md +6 -3
  23. package/skills/api-gateway-proxy-expert/SKILL.md +81 -0
  24. package/skills/app-analyzer-optimizer/SKILL.md +6 -3
  25. package/skills/apple-ecosystem-expert/SKILL.md +144 -141
  26. package/skills/{asisten_ramah → asisten-ramah}/SKILL.md +7 -1
  27. package/skills/astro-framework-expert/SKILL.md +200 -0
  28. package/skills/async-queue-temporal-expert/SKILL.md +210 -24
  29. package/skills/authentication-identity-expert/SKILL.md +278 -275
  30. package/skills/auto-doc-updater/SKILL.md +7 -1
  31. package/skills/autonomous-chaos-monkey/SKILL.md +63 -63
  32. package/skills/autonomous-red-teamer/SKILL.md +172 -28
  33. package/skills/autonomous-tdd-debugger/SKILL.md +70 -64
  34. package/skills/background-jobs-queue-expert/SKILL.md +235 -0
  35. package/skills/biome-linter-formatter-expert/SKILL.md +89 -0
  36. package/skills/blockchain-web3-expert/SKILL.md +115 -0
  37. package/skills/bootstrap-to-modern/SKILL.md +9 -6
  38. package/skills/brainstorming/SKILL.md +58 -50
  39. package/skills/browser-automation-expert/SKILL.md +197 -21
  40. package/skills/bun-runtime-expert/SKILL.md +7 -1
  41. package/skills/chatbot-messaging-expert/SKILL.md +114 -0
  42. package/skills/ci-cd-devops-architect/SKILL.md +45 -36
  43. package/skills/cloud-hosting-expert/SKILL.md +7 -1
  44. package/skills/coderabbit/SKILL.md +7 -1
  45. package/skills/compliance-gdpr-privacy-expert/SKILL.md +85 -0
  46. package/skills/cron-scheduler-expert/SKILL.md +303 -297
  47. package/skills/data-pipeline-etl-expert/SKILL.md +84 -0
  48. package/skills/data-telemetry-expert/SKILL.md +7 -1
  49. package/skills/data-visualization-expert/SKILL.md +154 -0
  50. package/skills/database-migration-versioning-expert/SKILL.md +90 -0
  51. package/skills/database-orm-expert/SKILL.md +13 -3
  52. package/skills/dependency-upgrade-migrator/SKILL.md +300 -294
  53. package/skills/design-system-architect/SKILL.md +278 -259
  54. package/skills/desktop-electron-expert/SKILL.md +128 -0
  55. package/skills/documentation-site-expert/SKILL.md +59 -0
  56. package/skills/doku-mcp-server/SKILL.md +7 -1
  57. package/skills/doku-payment-gateway/SKILL.md +7 -1
  58. package/skills/domain-driven-design-expert/SKILL.md +82 -0
  59. package/skills/e2e-testing-expert/SKILL.md +7 -1
  60. package/skills/ecommerce-expert/SKILL.md +87 -0
  61. package/skills/edge-serverless-db-expert/SKILL.md +98 -42
  62. package/skills/email-notification-expert/SKILL.md +367 -361
  63. package/skills/error-resilience-expert/SKILL.md +485 -479
  64. package/skills/event-driven-architect/SKILL.md +7 -1
  65. package/skills/feature-flag-analytics-expert/SKILL.md +65 -45
  66. package/skills/file-upload-media-expert/SKILL.md +436 -430
  67. package/skills/firebase-security-expert/SKILL.md +7 -1
  68. package/skills/form-validation-expert/SKILL.md +406 -400
  69. package/skills/fullstack-expert/SKILL.md +60 -1
  70. package/skills/gemini-agent-booster/SKILL.md +173 -135
  71. package/skills/geospatial-maps-expert/SKILL.md +80 -0
  72. package/skills/global-a11y-i18n-expert/SKILL.md +7 -1
  73. package/skills/glsl-shader-expert/SKILL.md +106 -100
  74. package/skills/go-programming-expert/SKILL.md +21 -15
  75. package/skills/graph-rag-knowledge-expert/SKILL.md +159 -0
  76. package/skills/graphql-apollo-expert/SKILL.md +113 -107
  77. package/skills/headless-cms-expert/SKILL.md +181 -0
  78. package/skills/hig/SKILL.md +7 -1
  79. package/skills/js-backend-expert/SKILL.md +218 -216
  80. package/skills/legacy-code-translator/SKILL.md +70 -64
  81. package/skills/local-slm-edge-ai-expert/SKILL.md +167 -0
  82. package/skills/logging-error-tracking-expert/SKILL.md +343 -337
  83. package/skills/mcp-client-orchestrator/SKILL.md +75 -69
  84. package/skills/mcp-server-architect/SKILL.md +294 -194
  85. package/skills/micro-frontend-architect/SKILL.md +111 -105
  86. package/skills/mobile-expo-expert/SKILL.md +8 -2
  87. package/skills/mobile-push-notification-expert/SKILL.md +70 -50
  88. package/skills/modern-css-native-expert/SKILL.md +189 -0
  89. package/skills/monday-design-aesthetic/SKILL.md +7 -1
  90. package/skills/monorepo-architect/SKILL.md +7 -1
  91. package/skills/mpa-orchestrator/SKILL.md +20 -1
  92. package/skills/multi-agent-orchestration/SKILL.md +254 -234
  93. package/skills/multiple-entry-points/SKILL.md +37 -1
  94. package/skills/mvc-expert/SKILL.md +7 -1
  95. package/skills/n8n-automation-expert/SKILL.md +89 -0
  96. package/skills/nextjs-app-router-expert/SKILL.md +148 -0
  97. package/skills/openapi-swagger-codegen-expert/SKILL.md +67 -0
  98. package/skills/payment-gateway-expert/SKILL.md +85 -1
  99. package/skills/pdf-document-generation-expert/SKILL.md +91 -0
  100. package/skills/performance-web-vitals/SKILL.md +7 -1
  101. package/skills/post-quantum-crypto-migrator/SKILL.md +57 -57
  102. package/skills/prd-architect/SKILL.md +7 -1
  103. package/skills/proactive-background-watcher/SKILL.md +67 -61
  104. package/skills/production-ready-hardener/SKILL.md +461 -455
  105. package/skills/project-context-mapper/SKILL.md +84 -78
  106. package/skills/pwa-offline-first-expert/SKILL.md +185 -0
  107. package/skills/python-programming-expert/SKILL.md +407 -401
  108. package/skills/rate-limit-abuse-prevention/SKILL.md +376 -370
  109. package/skills/realtime-collaboration-expert/SKILL.md +55 -1
  110. package/skills/rich-text-editor-expert/SKILL.md +177 -0
  111. package/skills/rust-programming-expert/SKILL.md +7 -1
  112. package/skills/saas-billing/SKILL.md +7 -1
  113. package/skills/saas-multi-tenant/SKILL.md +7 -1
  114. package/skills/saas-mvp-launcher/SKILL.md +20 -1
  115. package/skills/saas-transformer/SKILL.md +499 -488
  116. package/skills/scalability-clean-code/SKILL.md +7 -1
  117. package/skills/search-engine-expert/SKILL.md +89 -0
  118. package/skills/secure-fuzz-testing/SKILL.md +7 -1
  119. package/skills/self-evolving-memory-graph/SKILL.md +90 -74
  120. package/skills/self-healing-cloud-orchestrator/SKILL.md +57 -57
  121. package/skills/senior-frontend/SKILL.md +141 -161
  122. package/skills/seo/SKILL.md +41 -17
  123. package/skills/session-context-loader/SKILL.md +82 -76
  124. package/skills/session-handoff-resume/SKILL.md +7 -1
  125. package/skills/{skill_baru → skill-baru}/SKILL.md +8 -2
  126. package/skills/solidjs-expert/SKILL.md +80 -0
  127. package/skills/spa-orchestrator/SKILL.md +20 -1
  128. package/skills/sse-websocket-streaming-expert/SKILL.md +93 -0
  129. package/skills/state-management-expert/SKILL.md +7 -1
  130. package/skills/supabase-migration/SKILL.md +47 -1
  131. package/skills/supabase-security-expert/SKILL.md +7 -1
  132. package/skills/svelte-sveltekit-expert/SKILL.md +91 -0
  133. package/skills/svg-animation-motion-expert/SKILL.md +115 -0
  134. package/skills/tailwind-expert/SKILL.md +88 -136
  135. package/skills/tanstack-query-expert/SKILL.md +7 -1
  136. package/skills/tauri-expert/SKILL.md +7 -1
  137. package/skills/token-saver/SKILL.md +1 -1
  138. package/skills/typescript-expert/SKILL.md +12 -6
  139. package/skills/ui-components-expert/SKILL.md +165 -279
  140. package/skills/ui-ux-pro-max/SKILL.md +23 -3
  141. package/skills/vector-db-rag-expert/SKILL.md +175 -19
  142. package/skills/vibe-code-gardener/SKILL.md +1 -1
  143. package/skills/visual-qa-vision-agent/SKILL.md +70 -64
  144. package/skills/voice-ai-realtime-agent/SKILL.md +202 -0
  145. package/skills/vue-frontend-expert/SKILL.md +131 -125
  146. package/skills/wasm-edge-computing-expert/SKILL.md +97 -0
  147. package/skills/web-3d-graphics-expert/SKILL.md +136 -130
  148. package/skills/web-game-engine-expert/SKILL.md +101 -95
  149. package/skills/web-scraper/SKILL.md +157 -207
  150. package/skills/website-design-cloner/SKILL.md +179 -173
  151. package/skills/webxr-ar-vr-expert/SKILL.md +122 -116
  152. package/skills/wordpress-headless-expert/SKILL.md +144 -0
  153. package/skills/zero-to-prod-orchestrator/SKILL.md +52 -27
  154. package/skills/zero-trust-secret-vault/SKILL.md +87 -39
  155. package/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
  156. package/.github/workflows/publish.yml +0 -20
  157. package/CONTRIBUTING.md +0 -199
  158. package/SECURITY.md +0 -21
  159. package/banner.png +0 -0
  160. package/skills/autonomous-swarm-director/SKILL.md +0 -69
  161. package/skills/hyper-context-synthesizer/SKILL.md +0 -55
  162. package/skills/llm-cost-arbitrage-router/SKILL.md +0 -59
  163. package/skills/senior-fullstack/SKILL.md +0 -167
  164. package/skills/senior-fullstack/references/architecture_patterns.md +0 -160
  165. package/skills/senior-fullstack/references/development_workflows.md +0 -222
  166. package/skills/senior-fullstack/references/tech_stack_guide.md +0 -190
  167. package/skills/senior-fullstack/scripts/code_quality_analyzer.py +0 -114
  168. package/skills/senior-fullstack/scripts/fullstack_scaffolder.py +0 -114
  169. package/skills/senior-fullstack/scripts/project_scaffolder.py +0 -114
  170. package/skills/seo-aeo-landing-page-writer/SKILL.md +0 -97
  171. package/skills/seo-geo/SKILL.md +0 -188
  172. package/skills/ui-ux-pro-max/scripts/__pycache__/core.cpython-310.pyc +0 -0
  173. package/skills/ui-ux-pro-max/scripts/__pycache__/core.cpython-312.pyc +0 -0
  174. package/skills/ui-ux-pro-max/scripts/__pycache__/design_system.cpython-310.pyc +0 -0
  175. package/skills/ui-ux-pro-max/scripts/__pycache__/design_system.cpython-312.pyc +0 -0
  176. package/skills/ui_ux_expert/SKILL.md +0 -125
  177. package/vibes-swarm-demo.gif +0 -0
@@ -1,180 +1,187 @@
1
- ---
2
- name: ai-llm-integration-expert
3
- description: "Expert guide for integrating Large Language Models (LLMs), Model Context Protocol (MCP), RAG architecture, vector databases, and AI agents / Panduan ahli untuk integrasi LLM, Model Context Protocol (MCP), arsitektur RAG, vector database, dan agen AI."
4
- author: vibes-plug-swarm
5
- ---
6
-
7
- # AI & LLM Integration Expert (2026 Edition)
8
-
9
- [English](#english) | [Bahasa Indonesia](#bahasa-indonesia)
10
-
11
- ---
12
-
13
- <a name="english"></a>
14
- ## English
15
-
16
- ### Description
17
- Production-grade guidelines for integrating AI, Model Context Protocol (MCP), and Large Language Models (LLMs) into modern applications. Covers RAG pipelines, vector embeddings, real-time token streaming, agentic tool execution, memory architectures, prompt caching, and multi-model orchestration.
18
-
19
- ### Trigger Conditions
20
- - Integrating frontier models: **OpenAI GPT-4o / GPT-4.1 / GPT-5**, **Anthropic Claude 3.7 / Claude 4 Sonnet/Opus**, **Google Gemini 3.1 Pro/Flash/Ultra**, or open-source models (DeepSeek-V3/R2, Llama 4, Qwen 3).
21
- - Implementing **Model Context Protocol (MCP)** server or client integrations (MCP 1.9+).
22
- - Building AI chatbots, copilots, or **autonomous AI agent workflows** (LangGraph, OpenAI Agents SDK, Google ADK, Mastra.ai, Vercel AI SDK 4.x/5.x).
23
- - Building **agentic memory** systems (short-term, long-term, episodic) using Mem0, MemGPT, or Supabase-backed memory stores.
24
- - Implementing RAG with vector databases (Supabase `pgvector` HNSW, Qdrant, Pinecone, Weaviate).
25
- - Handling real-time AI token streaming via **SSE**, **Web Streams**, or **WebSockets**.
26
- - Designing AI agents with **tool-calling**, **computer use** (browser/OS automation), or **code interpreter** capabilities.
27
-
28
- ### Model Capability Matrix (2026)
29
-
30
- | Provider | Model | Context | Strengths |
31
- |---|---|---|---|
32
- | OpenAI | GPT-4o / GPT-4.1 | 128K | Multimodal, tool-calling, speed |
33
- | OpenAI | GPT-5 | 1M+ | Reasoning, agentic tasks |
34
- | Anthropic | Claude 4 Sonnet | 200K | Coding, long documents, Computer Use |
35
- | Anthropic | Claude 4 Opus | 200K | Complex reasoning, deep analysis |
36
- | Google | Gemini 3.1 Flash | 2M | Speed, cost efficiency, multimodal |
37
- | Google | Gemini 3.1 Pro | 2M | Code, reasoning, deep research |
38
- | Meta | Llama 4 Scout/Maverick | 512K | Open-source, self-hosted |
39
- | DeepSeek | V3 / R2 | 128K | Code, math, cost-efficient |
40
-
41
- ### Core Architecture Guidelines
42
-
43
- #### 1. Model Context Protocol (MCP) Integration (v1.9+)
44
- Standardize agent-tool interactions using MCP. The 2026 standard adds **Streamable HTTP transport** alongside stdio/SSE:
45
- - **MCP Servers**: Expose tools, resources, and prompt templates over JSON-RPC 2.0.
46
- - **Streamable HTTP**: New default transport for cloud-hosted MCP servers — supports bidirectional streaming without long-polling.
47
- - **Security & Scope**: Validate all incoming parameters with Zod schemas. Enforce strict authorization boundaries before executing tool calls.
48
- - **Tool namespacing**: Use `domain/action` naming (`files/read`, `db/query`) to avoid collisions in multi-server environments.
49
-
50
- #### 2. AI Agents SDK Landscape (2026)
51
- Choose the right agentic framework based on your needs:
52
-
53
- | Framework | Best For | Key Feature |
54
- |---|---|---|
55
- | **OpenAI Agents SDK** | GPT-5 native agents | Handoffs, guardrails, tracing built-in |
56
- | **Google ADK** | Gemini-powered agents | Multi-agent, streaming, Vertex AI integration |
57
- | **LangGraph** | Complex stateful workflows | Graph-based, human-in-the-loop, any LLM |
58
- | **Mastra.ai** | TypeScript-first agents | Built-in memory, evals, RAG |
59
- | **Vercel AI SDK 5.x** | Streaming UI + agents | RSC streaming, multi-provider, tool-calling |
60
-
61
- #### 3. Agentic Memory Architecture
62
- Production AI agents require persistent memory across sessions:
63
- - **Short-term (In-context)**: Pass recent conversation turns in the prompt window.
64
- - **Long-term (Vector Store)**: Store user preferences and past interactions as embeddings in `pgvector` or Qdrant; retrieve with semantic similarity.
65
- - **Episodic (Episodic Memory)**: Use **Mem0** or **MemGPT** to give agents human-like recall — automatically summarizes and indexes past interactions.
66
- - **Structured (Knowledge Graph)**: Use a graph DB (Neo4j, Kuzu) for entity relationships and factual memory.
67
-
68
- #### 4. Advanced RAG (Retrieval-Augmented Generation) Pipeline
69
- Build a production-grade RAG pipeline with hybrid search:
70
- 1. **Ingestion**: Chunk documents (500-1000 tokens, 10% overlap, respect semantic headings).
71
- 2. **Embedding**: Use `text-embedding-3-large` (OpenAI), `gemini-embedding-004` (Google), or `nomic-embed-text` (open-source).
72
- 3. **Storage & Hybrid Search**: PostgreSQL `pgvector` (HNSW index) or Qdrant. Combine vector cosine similarity with BM25 full-text search for hybrid retrieval.
73
- 4. **Reranking**: Apply cross-encoder reranker (Cohere Rerank 3, FlashRank) on top-K results.
74
- 5. **Generation**: Inject top contextual snippets into the system prompt with source citations.
75
-
76
- #### 5. Prompt Caching (Cost Optimization)
77
- Reduce costs by 80-90% on repeated long prompts using provider-native caching:
78
- - **Anthropic**: Automatic prompt caching for prompts > 1024 tokens (marked with `cache_control: {"type": "ephemeral"}`).
79
- - **OpenAI**: Automatic prefix caching for prompts > 1024 tokens in GPT-4o and later models.
80
- - **Google**: Context caching in Gemini API via `cachedContent` for large system prompts or documents.
81
-
82
- #### 6. Streaming Responses & Vercel AI SDK 5.x
83
- - **Backend (Next.js/Bun/FastAPI)**: Pipe stream chunks via Web Streams API or SSE.
84
- - **Frontend (React)**: Use Vercel AI SDK `useChat` / `useCompletion` for zero perceived latency.
85
- - **RSC Streaming**: Use AI SDK 5.x `streamUI` to stream React components from the server — agent-rendered UI.
86
-
87
- #### 7. Computer Use & Browser Agents
88
- Modern agents can control browsers and operating systems:
89
- - **Anthropic Computer Use**: Claude 4 can take screenshots and control mouse/keyboard (ideal for browser automation).
90
- - **Browser-Use**: Open-source library for browser-controlling agents with any LLM.
91
- - **Playwright MCP Server**: Expose a full browser to AI agents via MCP tools (`navigate`, `click`, `screenshot`).
92
-
93
- #### 8. Structured Output & Tool Calling
94
- - Use native Tool/Function Calling APIs with strict JSON schemas via Zod (`zodResponseFormat`).
95
- - Prefer **structured output mode** over prompt engineering for JSON guaranteed schema conformance.
96
- - Support reasoning models (DeepSeek-R2, Gemini 3.1 Pro Thinking, Claude 4 extended thinking) by separating internal `<think>` tokens from client-facing output.
97
-
98
- #### 9. Cost & Rate Limit Management
99
- - Monitor token consumption per session; store metrics in telemetry tables.
100
- - Implement **semantic caching** using Redis + vector similarity to skip redundant model queries.
101
- - Use **batch APIs** (OpenAI Batch, Anthropic Message Batches) for async, high-volume workloads at 50% cost reduction.
102
-
103
- #### 10. Skill Orchestration & Handoff
104
- - **Upstream Orchestrator**: Executes during **Phase 4** of `zero-to-prod-orchestrator` or after AI decision lock in `brainstorming`.
105
- - **MCP Server Architecture**: Delegate custom MCP server creation to `mcp-server-architect` and payment tools to `doku-mcp-server`.
106
- - **Multi-Agent & Swarm Workflows**: Delegate complex agent state graphs to `multi-agent-orchestration` and Gemini long-context optimization to `gemini-agent-booster`.
107
- - **Vector DB & Hybrid Search**: Delegate pgvector indexing and hybrid search tuning to `vector-db-rag-expert`.
108
- - **Token Budget & FinOps**: Delegate API cost optimization and prompt caching strategies to `ai-cost-token-optimizer`.
109
-
110
- ---
111
-
112
- <a name="bahasa-indonesia"></a>
113
- ## Bahasa Indonesia
114
-
115
- ### Deskripsi
116
- Panduan tingkat produksi untuk mengintegrasikan AI, Model Context Protocol (MCP), dan LLM ke dalam aplikasi modern. Mencakup pipeline RAG, streaming token real-time, eksekusi tool agen AI, arsitektur memori, prompt caching, dan orkestrasi multi-model.
117
-
118
- ### Kondisi Pemicu
119
- - Mengintegrasikan model frontier: GPT-4.1 / GPT-5, Claude 4 Sonnet/Opus, Gemini 3.1 Pro/Flash, atau model open-source (Llama 4, DeepSeek-V3/R2).
120
- - Mengimplementasikan server/klien MCP (v1.9+ dengan Streamable HTTP transport).
121
- - Membangun chatbot AI, copilot, atau alur kerja agen otonom (OpenAI Agents SDK, Google ADK, LangGraph, Mastra.ai).
122
- - Membangun sistem **memori agentik** (jangka pendek, jangka panjang, episodik) menggunakan Mem0 atau pgvector.
123
- - Mengimplementasikan RAG dengan vector database.
124
- - Merancang agen AI dengan tool-calling, Computer Use, atau code interpreter.
125
-
126
- ### Panduan Arsitektur Inti
127
-
128
- #### 1. Integrasi MCP (v1.9+)
129
- Standarisasi interaksi agen-tool menggunakan MCP. Standar 2026 menambahkan **Streamable HTTP transport** — transport default baru untuk MCP server yang di-host di cloud, mendukung streaming dua arah tanpa long-polling.
130
-
131
- #### 2. Ekosistem Agents SDK (2026)
132
- - **OpenAI Agents SDK**: Handoffs, guardrails, dan tracing bawaan untuk agen berbasis GPT-5.
133
- - **Google ADK**: Multi-agen, streaming, integrasi Vertex AI untuk agen Gemini.
134
- - **LangGraph**: Alur kerja stateful berbasis graph dengan dukungan human-in-the-loop.
135
- - **Mastra.ai**: Framework TypeScript-first dengan memori, evaluasi, dan RAG bawaan.
136
- - **Vercel AI SDK 5.x**: Streaming UI + agen dengan dukungan multi-provider dan RSC.
137
-
138
- #### 3. Arsitektur Memori Agentik
139
- - **Jangka Pendek**: Riwayat percakapan recent dalam context window.
140
- - **Jangka Panjang (Vector Store)**: Preferensi dan interaksi masa lalu sebagai embedding di pgvector atau Qdrant.
141
- - **Episodik**: Gunakan Mem0 atau MemGPT untuk recall mirip manusia — otomatis merangkum dan mengindeks interaksi lalu.
142
- - **Terstruktur (Knowledge Graph)**: Gunakan graph DB (Neo4j, Kuzu) untuk relasi entitas dan memori faktual.
143
-
144
- #### 4. Pipeline RAG Lanjutan
145
- 1. Chunking dokumen (500-1000 token, 10% overlap).
146
- 2. Embedding dengan `text-embedding-3-large` atau `gemini-embedding-004`.
147
- 3. Penyimpanan & pencarian hibrida: pgvector (HNSW) + BM25.
148
- 4. Reranking dengan Cohere Rerank 3 atau FlashRank.
149
- 5. Injeksi konteks terbaik ke system prompt.
150
-
151
- #### 5. Prompt Caching (Optimasi Biaya)
152
- Kurangi biaya 80-90% dengan caching prompt panjang:
153
- - **Anthropic**: Caching otomatis untuk prompt > 1024 token.
154
- - **OpenAI**: Prefix caching otomatis di GPT-4o ke atas.
155
- - **Google**: Context caching di Gemini API via `cachedContent`.
156
-
157
- #### 6. Streaming & Vercel AI SDK 5.x
158
- Gunakan `useChat` / `useCompletion` untuk zero perceived latency di sisi klien. Gunakan `streamUI` di AI SDK 5.x untuk stream komponen React dari server (agent-rendered UI).
159
-
160
- #### 7. Computer Use & Browser Agents
161
- Claude 4 dapat mengambil screenshot dan mengontrol mouse/keyboard. Gunakan **Browser-Use** atau **Playwright MCP Server** untuk memberi agen kontrol atas browser.
162
-
163
- #### 8. Output Terstruktur & Tool Calling
164
- Gunakan mode structured output (bukan prompt engineering) untuk jaminan kesesuaian skema JSON. Gunakan Zod (`zodResponseFormat`) untuk validasi type-safe.
165
-
166
- #### 9. Manajemen Biaya
167
- - Pantau konsumsi token per sesi di tabel telemetri.
168
- - Terapkan semantic caching dengan Redis + vektor.
169
- - Gunakan Batch API (OpenAI / Anthropic) untuk workload async volume tinggi dengan biaya 50% lebih hemat.
170
-
171
- #### 10. Orkestrasi Skill & Serah Terima
172
- - **Orkestrator Utama**: Dieksekusi pada **Fase 4** dari `zero-to-prod-orchestrator` atau setelah finalisasi arsitektur AI di `brainstorming`.
173
- - **Arsitektur MCP Server**: Delegasikan pembuatan MCP server ke `mcp-server-architect` dan integrasi pembayaran ke `doku-mcp-server`.
174
- - **Multi-Agent & Swarm Workflows**: Delegasikan alur state graph kompleks ke `multi-agent-orchestration` dan optimasi long-context Gemini ke `gemini-agent-booster`.
175
- - **Vector DB & Hybrid Search**: Delegasikan indeks pgvector dan pencarian hibrida ke `vector-db-rag-expert`.
176
- - **Token Budget & FinOps**: Delegasikan optimasi biaya API dan caching prompt ke `ai-cost-token-optimizer`.
177
-
1
+ ---
2
+ name: ai-llm-integration-expert
3
+ version: "2.8.0"
4
+ description: "Expert guide for integrating Large Language Models (LLMs), Model Context Protocol (MCP v1.x), hybrid reasoning models, RAG architecture, vector databases, and AI agents / Panduan ahli untuk integrasi LLM, Model Context Protocol (MCP), model hybrid reasoning, arsitektur RAG, vector database, dan agen AI."
5
+ author: "Roedy Rustam"
6
+ ---
7
+
8
+ # AI & LLM Integration Expert (2026 Edition)
9
+
10
+ [English](#english) | [Bahasa Indonesia](#bahasa-indonesia)
11
+
12
+ ---
13
+
14
+ <a name="english"></a>
15
+ ## English
16
+
17
+ ### Description
18
+ Production-grade guidelines for integrating AI, Model Context Protocol (MCP), hybrid reasoning models, and Large Language Models (LLMs) into modern software architectures. Covers hybrid reasoning token streaming, Streamable HTTP MCP transports, agentic memory architectures, native context caching, RAG pipelines, and multi-model orchestration.
19
+
20
+ ### Trigger Conditions
21
+ - Integrating frontier reasoning models: Anthropic Claude 3.7 Sonnet (Hybrid/Extended Thinking), Google Gemini 3.8 Flash / 3.1 Pro (Thinking Mode), OpenAI o1 / o3 / o3-mini / GPT-4.5 / GPT-4o, DeepSeek-R1 / V3, or open-source weights (Llama 4, Qwen 2.5/3 Coder).
22
+ - Implementing Model Context Protocol (MCP) server or client integrations with Streamable HTTP transport or MCP Sampling.
23
+ - Building AI chatbots, copilots, or autonomous AI agent workflows (LangGraph, OpenAI Agents SDK, Google ADK, Mastra.ai, Vercel AI SDK 5.x/6.x).
24
+ - Managing streaming reasoning tokens (`<think>` chunks) separately from final output in user interfaces.
25
+ - Implementing hybrid RAG with vector databases (Supabase pgvector HNSW, Qdrant, Pinecone) and cross-encoder rerankers.
26
+ - Building agentic memory systems (short-term, long-term semantic, episodic) using Mem0 or vector stores.
27
+ - Implementing cost optimization with provider-native Context Caching (Gemini `cachedContent`, Anthropic ephemeral prompt cache, OpenAI prefix cache).
28
+
29
+ ### Model Capability Matrix (2026)
30
+
31
+ | Provider | Model | Context | Reasoning Type | Primary Strength |
32
+ |---|---|---|---|---|
33
+ | Anthropic | Claude 3.7 Sonnet | 200K | Hybrid Thinking (Standard + Extended) | Code generation, complex reasoning, Computer Use |
34
+ | Anthropic | Claude 3.5 / 4 Opus | 200K | Deep Deliberation | Deep architectural synthesis, policy analysis |
35
+ | Google | Gemini 3.8 Flash | 1M–2M | Flash Thinking (Configurable Budget) | Ultra-low latency, multimodal live, high-frequency loops |
36
+ | Google | Gemini 3.1 / 3.5 Pro | 2M | Extended Reasoning | Needle-in-a-haystack, long-context repos, deep research |
37
+ | OpenAI | o3 / o3-mini | 200K | Native Test-Time Reasoning | Math, competitive coding, formal logic verification |
38
+ | OpenAI | GPT-4.5 / GPT-4o | 128K | Direct Instruction & Fast Tooling | Low-latency voice, structured JSON, tool-calling |
39
+ | DeepSeek | DeepSeek-R1 | 128K | Open Reasoning (Distill & MoE) | State-of-the-art open weights reasoning, math, coding |
40
+ | DeepSeek | DeepSeek-V3 | 128K | General Multimodal / Text | High throughput, extremely cost-efficient coding |
41
+ | Qwen | Qwen 2.5 / 3 Coder | 128K | Open Source Code Specialist | Self-hosted coding agent, local copilot integration |
42
+
43
+ ### Core Architecture Guidelines
44
+
45
+ #### 1. Hybrid Reasoning & Streaming Token Handling
46
+ Modern frontier models emit internal thinking/reasoning tokens during test-time compute:
47
+ - **Thinking Token Separation**: Separate internal `<think>` or reasoning chunks from conversational output. Stream reasoning into collapsible UI accordion blocks while presenting clean output to the user.
48
+ - **Vercel AI SDK 5.x/6.x Integration**:
49
+ ```typescript
50
+ import { streamText } from 'ai';
51
+ import { anthropic } from '@ai-sdk/anthropic';
52
+
53
+ const result = streamText({
54
+ model: anthropic('claude-3-7-sonnet-20250219'),
55
+ providerOptions: {
56
+ anthropic: {
57
+ thinking: { type: 'enabled', budgetTokens: 4096 },
58
+ },
59
+ },
60
+ prompt: 'Refactor this distributed consensus engine...',
61
+ });
62
+
63
+ // Access reasoning stream alongside main text
64
+ for await (const part of result.fullStream) {
65
+ if (part.type === 'reasoning') {
66
+ process.stdout.write(`[Thinking]: ${part.textDelta}`);
67
+ } else if (part.type === 'text-delta') {
68
+ process.stdout.write(part.textDelta);
69
+ }
70
+ }
71
+ ```
72
+
73
+ #### 2. Model Context Protocol (MCP) Streamable HTTP & Sampling
74
+ Standardize all agent-tool and agent-host communications using MCP specifications:
75
+ - **Streamable HTTP Transport**: Modern cloud deployments use Streamable HTTP (bidirectional JSON-RPC streaming over HTTP POST/SSE hybrid) instead of fragile stdio connections.
76
+ - **MCP Sampling**: Allow MCP servers to request LLM completions back from the host client, enabling nested agentic tools without distributing API keys to tool servers.
77
+ - **Authorization & Security**: Enforce OAuth 2.1 scoped bearer tokens on remote MCP endpoints. Validate all incoming tool inputs using strict Zod schemas.
78
+
79
+ #### 3. Agentic Memory Architecture
80
+ Production AI agents require multi-layered memory:
81
+ - **In-Context Working Memory**: Pass recent turn messages within the prompt window.
82
+ - **Long-Term Semantic Memory**: Embed user preferences and facts using pgvector (HNSW index) or Qdrant; perform cosine similarity searches.
83
+ - **Episodic Memory (Mem0 / MemGPT)**: Automatically synthesize session checkpoints and index past user decisions for human-like recall.
84
+ - **Knowledge Graph Memory**: Maintain structured entity-relationship triples (using Graph DB or relational junction tables) for multi-hop relationship retrieval.
85
+
86
+ #### 4. Advanced RAG & Late Chunking Pipeline
87
+ Build high-precision RAG pipelines:
88
+ 1. **Document Ingestion**: Chunk semantically (500–1000 tokens) with 10% overlap, or apply *Late Chunking* (chunking after full document contextual embedding).
89
+ 2. **Embeddings**: Utilize `text-embedding-3-large`, `gemini-embedding-004`, or local `bge-large-en-v1.5`.
90
+ 3. **Hybrid Search**: Combine dense vector cosine similarity with sparse BM25 / PostgreSQL `tsvector` queries.
91
+ 4. **Cross-Encoder Reranking**: Reorder top-K candidates using Cohere Rerank 3 or FlashRank before feeding into the prompt.
92
+ 5. **Context Window vs RAG Decision**: If document sets fit comfortably under 200k tokens and are queried repeatedly, prefer **Native Context Caching** over RAG chunking to eliminate retrieval boundary errors.
93
+
94
+ #### 5. Native Context Caching (Cost & Latency Optimization)
95
+ Leverage provider-native context caching for large, repeated context (>32k tokens):
96
+ - **Anthropic**: Use ephemeral prompt caching with `cache_control: { type: "ephemeral" }` on system prompts and tools.
97
+ - **OpenAI**: Take advantage of automatic prefix caching for matching prompt prefixes >1024 tokens.
98
+ - **Google Gemini**: Explicitly create and reuse cached content via `cachedContent` API for huge repositories, reducing costs up to 90%.
99
+
100
+ #### 6. Structured Output & Guardrails
101
+ - Utilize native Structured Outputs (`response_format: { type: "json_schema" }`) guaranteed by model token-level grammar masks.
102
+ - Use Zod schemas to define tool parameters and final structured entities.
103
+ - Implement rate limiting, circuit breakers, and semantic caching (Redis / Upstash vector cache) to prevent runaway recursive tool loops.
178
104
 
179
105
  ## Orchestration & Integration
180
- - Integrates with ai-cost-token-optimizer, multi-agent-orchestration, and vector-db-rag-expert.
106
+ - **`mcp-server-architect`**: Delegate custom MCP server implementation, schema definitions, and transport adapters.
107
+ - **`multi-agent-orchestration`**: Delegate complex multi-agent state graphs, swarm workflows, and supervisor patterns.
108
+ - **`gemini-agent-booster`**: Delegate Gemini 3.x long-context optimization, Multimodal Live API, and thinking budget controls.
109
+ - **`ai-prompt-engineering-expert`**: Delegate advanced prompt design, few-shot calibration, and system prompt evals.
110
+ - **`ai-cost-token-optimizer`**: Delegate API cost optimization, model routing, and token budget management.
111
+ - **`vector-db-rag-expert`**: Delegate pgvector HNSW indexing and hybrid retrieval fine-tuning.
112
+ - **`zero-to-prod-orchestrator`**: Executes this skill during Phase 4 architecture and implementation.
113
+
114
+ ---
115
+
116
+ <a name="bahasa-indonesia"></a>
117
+ ## Bahasa Indonesia
118
+
119
+ ### Deskripsi
120
+ Panduan tingkat produksi untuk mengintegrasikan AI, Model Context Protocol (MCP), model hybrid reasoning, dan Large Language Models (LLM) ke dalam arsitektur perangkat lunak modern. Mencakup penanganan streaming token penalaran, transport MCP Streamable HTTP, arsitektur memori agentik, context caching native, pipeline RAG, dan orkestrasi multi-model.
121
+
122
+ ### Kondisi Pemicu
123
+ - Mengintegrasikan model frontier reasoning: Anthropic Claude 3.7 Sonnet (Hybrid/Extended Thinking), Google Gemini 3.8 Flash / 3.1 Pro (Thinking Mode), OpenAI o1 / o3 / o3-mini / GPT-4.5 / GPT-4o, DeepSeek-R1 / V3, atau bobot open-source (Llama 4, Qwen 2.5/3 Coder).
124
+ - Mengimplementasikan server atau klien Model Context Protocol (MCP) dengan transport Streamable HTTP atau MCP Sampling.
125
+ - Membangun chatbot AI, copilot, atau workflow agen otonom (LangGraph, OpenAI Agents SDK, Google ADK, Mastra.ai, Vercel AI SDK 5.x/6.x).
126
+ - Mengelola streaming token penalaran (`<think>`) secara terpisah dari output akhir pada tampilan antarmuka pengguna.
127
+ - Mengimplementasikan RAG hibrida dengan database vektor (Supabase pgvector HNSW, Qdrant, Pinecone) dan reranker cross-encoder.
128
+ - Membangun sistem memori agentik (jangka pendek, semantik jangka panjang, episodik) menggunakan Mem0 atau vector store.
129
+ - Menerapkan optimasi biaya dengan Context Caching native provider (Gemini `cachedContent`, Anthropic ephemeral prompt cache, OpenAI prefix cache).
130
+
131
+ ### Matriks Kapabilitas Model (2026)
132
+
133
+ | Provider | Model | Konteks | Tipe Penalaran | Keunggulan Utama |
134
+ |---|---|---|---|---|
135
+ | Anthropic | Claude 3.7 Sonnet | 200K | Hybrid Thinking (Standar + Diperpanjang) | Generasi kode, penalaran kompleks, Computer Use |
136
+ | Anthropic | Claude 3.5 / 4 Opus | 200K | Deliberasi Mendalam | Sintesis arsitektur mendalam, analisis kebijakan |
137
+ | Google | Gemini 3.8 Flash | 1M–2M | Flash Thinking (Budget Terkonfigurasi) | Latensi ultra-rendah, multimodal live, loop cepat |
138
+ | Google | Gemini 3.1 / 3.5 Pro | 2M | Extended Reasoning | Needle-in-a-haystack, repo konteks panjang, riset |
139
+ | OpenAI | o3 / o3-mini | 200K | Test-Time Reasoning Native | Matematika, competitive coding, verifikasi logika |
140
+ | OpenAI | GPT-4.5 / GPT-4o | 128K | Instruksi Langsung & Tooling Cepat | Suara latensi rendah, JSON terstruktur, tool calling |
141
+ | DeepSeek | DeepSeek-R1 | 128K | Open Reasoning (Distill & MoE) | Penalaran open weights terdepan, matematika, koding |
142
+ | DeepSeek | DeepSeek-V3 | 128K | Teks & Multimodal Umum | Throughput tinggi, sangat hemat biaya untuk coding |
143
+ | Qwen | Qwen 2.5 / 3 Coder | 128K | Spesialis Kode Open Source | Agen coding mandiri / self-hosted, copilot lokal |
144
+
145
+ ### Panduan Arsitektur Inti
146
+
147
+ #### 1. Hybrid Reasoning & Penanganan Token Streaming
148
+ Model frontier modern menghasilkan token pemikiran (*thinking tokens*) selama proses penalaran:
149
+ - **Pemisahan Token Pemikiran**: Pisahkan blok `<think>` dari output teks akhir. Alirkan proses pemikiran ke dalam accordion UI yang dapat dibuka/tutup, sementara output utama disajikan dengan bersih kepada user.
150
+ - **Integrasi Vercel AI SDK 5.x/6.x**: Gunakan event listener `reasoning` pada stream untuk menangkap proses pemikiran model secara terpisah dari `text-delta`.
151
+
152
+ #### 2. Model Context Protocol (MCP) — Streamable HTTP & Sampling
153
+ Standarisasi seluruh komunikasi agen-ke-tool dan agen-ke-host menggunakan spesifikasi MCP:
154
+ - **Streamable HTTP Transport**: Standar cloud modern yang mendukung streaming dua arah JSON-RPC via HTTP POST/SSE hybrid tanpa ketergantungan koneksi stdio lokal.
155
+ - **MCP Sampling**: Memberikan izin kepada server MCP untuk meminta inferensi LLM kembali ke klien host, memungkinkan alat agentik modular tanpa membagikan API key sensitif.
156
+ - **Keamanan & Otorisasi**: Wajibkan bearer token berbasis OAuth 2.1 pada endpoint MCP publik dan validasi skema input dengan Zod.
157
+
158
+ #### 3. Arsitektur Memori Agentik
159
+ - **Memori Kerja In-Context**: Teruskan histori interaksi terbaru di jendela konteks.
160
+ - **Memori Semantik Jangka Panjang**: Simpan fakta dan preferensi pengguna di pgvector (indeks HNSW) atau Qdrant dengan pencarian kesamaan kosinus.
161
+ - **Memori Episodik (Mem0 / MemGPT)**: Sintesiskan ringkasan sesi secara berkala agar agen memiliki daya ingat historis jangka panjang.
162
+ - **Memori Graph Pengetahuan**: Hubungkan entitas relasional dalam basis data graf untuk kueri multi-langkah (*multi-hop reasoning*).
163
+
164
+ #### 4. Pipeline RAG Lanjutan & Late Chunking
165
+ 1. **Ingesti Dokumen**: Bagi dokumen secara semantik (500–1000 token, 10% overlap) atau gunakan metode *Late Chunking*.
166
+ 2. **Embedding**: Gunakan `text-embedding-3-large` atau `gemini-embedding-004`.
167
+ 3. **Pencarian Hibrida**: Kombinasikan dense vector cosine similarity dengan sparse keyword BM25 / PostgreSQL full-text search.
168
+ 4. **Cross-Encoder Reranking**: Susun ulang kandidat terbaik menggunakan Cohere Rerank 3 atau FlashRank sebelum diteruskan ke system prompt.
169
+ 5. **Keputusan Cache vs RAG**: Jika dokumen stabil dan berada di bawah 200k token, utamakan **Context Caching Native** daripada RAG chunking untuk menghindari hilangnya konteks di perbatasan potongan teks.
170
+
171
+ #### 5. Context Caching Native (Optimasi Biaya & Latensi)
172
+ - **Anthropic**: Terapkan prompt caching ephemeral dengan `cache_control: { type: "ephemeral" }`.
173
+ - **OpenAI**: Manfaatkan prefix caching otomatis untuk teks berulang >1024 token.
174
+ - **Google Gemini**: Buat objek cache eksplisit via API `cachedContent` untuk repositori kode besar guna menghemat hingga 90% biaya input token.
175
+
176
+ #### 6. Output Terstruktur & Guardrails
177
+ - Manfaatkan mode Structured Outputs native model dengan skema Zod untuk menjamin integritas JSON.
178
+ - Terapkan rate limiting, circuit breaker, dan semantic caching (Redis / Upstash) untuk mencegah pemanggilan tool secara rekursif tak berujung.
179
+
180
+ ## Integrasi Orkestrasi
181
+ - **`mcp-server-architect`**: Delegasikan pembuatan server MCP kustom, definisi skema, dan transport adapter.
182
+ - **`multi-agent-orchestration`**: Delegasikan alur kerja graph multi-agen, topologi swarm, dan pattern supervisor.
183
+ - **`gemini-agent-booster`**: Delegasikan optimasi long-context Gemini 3.x, Multimodal Live API, dan kontrol thinking budget.
184
+ - **`ai-prompt-engineering-expert`**: Delegasikan desain prompt lanjutan, kalibrasi few-shot, dan evaluasi prompt.
185
+ - **`ai-cost-token-optimizer`**: Delegasikan optimasi biaya API, routing model cerdas, dan token budget.
186
+ - **`vector-db-rag-expert`**: Delegasikan tuning indeks HNSW pgvector dan pencarian hibrida.
187
+ - **`zero-to-prod-orchestrator`**: Mengeksekusi skill ini pada Fase 4 perancangan arsitektur dan implementasi.
@@ -0,0 +1,172 @@
1
+ ---
2
+ name: ai-media-generation-expert
3
+ description: "Expert guide for AI image generation (Flux, DALL-E, Stable Diffusion), video generation (Sora, Runway), voice synthesis (ElevenLabs TTS), and speech recognition (Whisper STT) integration / Panduan ahli integrasi AI generasi gambar, video, suara (TTS), dan pengenalan suara (STT)."
4
+ author: "Roedy Rustam"
5
+ ---
6
+
7
+ # AI Media Generation Expert (2026 Edition)
8
+
9
+ [English](#english) | [Bahasa Indonesia](#bahasa-indonesia)
10
+
11
+ ---
12
+
13
+ <a name="english"></a>
14
+ ## English
15
+
16
+ ### Orchestration & Integration
17
+ - **`ai-llm-integration-expert`**: Core LLM patterns and model selection.
18
+ - **`file-upload-media-expert`**: Storage, CDN, and media pipeline for generated assets.
19
+ - **`sse-websocket-streaming-expert`**: Real-time streaming for progressive image/audio generation.
20
+ - **`async-queue-temporal-expert`**: Background job processing for long-running generation tasks.
21
+ - **`zero-trust-secret-vault`**: Secure API key management for Replicate, OpenAI, ElevenLabs.
22
+
23
+ ### Description
24
+ Production-grade guide for integrating AI-powered media generation into web and mobile applications. Covers image generation (Flux 1.1 Pro, SDXL, DALL-E 3), video generation (Sora, Runway Gen-3), text-to-speech (ElevenLabs v3, OpenAI TTS), speech-to-text (Whisper large-v3, Deepgram Nova-3), and voice cloning. Includes async processing patterns, cost optimization, and content safety filtering.
25
+
26
+ ### Trigger Conditions
27
+ - Integrating AI image generation (Flux, DALL-E, Stable Diffusion, Midjourney API).
28
+ - Building text-to-speech or speech-to-text features.
29
+ - Implementing voice cloning or AI avatar generation.
30
+ - Adding AI video generation or editing capabilities.
31
+ - Building media processing pipelines with AI models.
32
+
33
+ ---
34
+
35
+ ### Core Architecture
36
+
37
+ #### 1. Image Generation
38
+
39
+ **Provider Selection Matrix:**
40
+
41
+ | Provider | Model | Speed | Quality | Cost | Best For |
42
+ |----------|-------|-------|---------|------|----------|
43
+ | Replicate | Flux 1.1 Pro | ~3s | ★★★★★ | $0.04/img | Photorealism, text rendering |
44
+ | Replicate | Flux Schnell | ~1s | ★★★★ | $0.003/img | High-volume, previews |
45
+ | OpenAI | DALL-E 3 | ~5s | ★★★★ | $0.04/img | Creative, prompt following |
46
+ | Stability | SDXL Turbo | ~2s | ★★★★ | $0.002/img | Self-hosted, customization |
47
+
48
+ **Recommendation:** Use **Flux 1.1 Pro** via Replicate for production quality. Use **Flux Schnell** for previews/drafts.
49
+
50
+ ```typescript
51
+ // Image generation with Replicate (Flux)
52
+ import Replicate from 'replicate';
53
+
54
+ const replicate = new Replicate({ auth: process.env.REPLICATE_API_TOKEN });
55
+
56
+ async function generateImage(prompt: string, options?: {
57
+ width?: number;
58
+ height?: number;
59
+ model?: 'flux-1.1-pro' | 'flux-schnell';
60
+ }) {
61
+ const model = options?.model ?? 'flux-1.1-pro';
62
+ const output = await replicate.run(
63
+ `black-forest-labs/${model}`,
64
+ {
65
+ input: {
66
+ prompt,
67
+ width: options?.width ?? 1024,
68
+ height: options?.height ?? 1024,
69
+ num_inference_steps: model === 'flux-schnell' ? 4 : 28,
70
+ },
71
+ }
72
+ );
73
+ return output; // URL to generated image
74
+ }
75
+ ```
76
+
77
+ #### 2. Text-to-Speech (TTS)
78
+
79
+ **Provider Selection:**
80
+
81
+ | Provider | Model | Latency | Expressiveness | Cost |
82
+ |----------|-------|---------|----------------|------|
83
+ | ElevenLabs | eleven_v3 | ~500ms | ★★★★★ | $0.30/1K chars |
84
+ | ElevenLabs | eleven_flash_v2_5 | ~200ms | ★★★★ | $0.15/1K chars |
85
+ | OpenAI | tts-1-hd | ~300ms | ★★★ | $0.030/1K chars |
86
+
87
+ **Recommendation:** Use **ElevenLabs eleven_v3** for expressive content. Use **eleven_flash_v2_5** for real-time chatbots.
88
+
89
+ ```typescript
90
+ // ElevenLabs TTS streaming
91
+ async function textToSpeech(text: string, voiceId: string): Promise<ReadableStream> {
92
+ const response = await fetch(
93
+ `https://api.elevenlabs.io/v1/text-to-speech/${voiceId}/stream`,
94
+ {
95
+ method: 'POST',
96
+ headers: {
97
+ 'xi-api-key': process.env.ELEVENLABS_API_KEY!,
98
+ 'Content-Type': 'application/json',
99
+ },
100
+ body: JSON.stringify({
101
+ text,
102
+ model_id: 'eleven_v3',
103
+ voice_settings: { stability: 0.5, similarity_boost: 0.75 },
104
+ }),
105
+ }
106
+ );
107
+ return response.body!; // Stream audio chunks
108
+ }
109
+ ```
110
+
111
+ #### 3. Speech-to-Text (STT)
112
+
113
+ ```typescript
114
+ // OpenAI Whisper transcription
115
+ import OpenAI from 'openai';
116
+
117
+ const openai = new OpenAI();
118
+
119
+ async function transcribeAudio(audioFile: File) {
120
+ const transcription = await openai.audio.transcriptions.create({
121
+ file: audioFile,
122
+ model: 'whisper-1',
123
+ response_format: 'verbose_json',
124
+ timestamp_granularities: ['word', 'segment'],
125
+ });
126
+ return transcription;
127
+ }
128
+ ```
129
+
130
+ #### 4. Video Generation
131
+
132
+ ```typescript
133
+ // Replicate video generation (async with webhook)
134
+ async function generateVideo(prompt: string) {
135
+ const prediction = await replicate.predictions.create({
136
+ model: 'minimax/video-01',
137
+ input: { prompt, duration: 5 },
138
+ webhook: `${process.env.APP_URL}/api/webhooks/replicate`,
139
+ webhook_events_filter: ['completed'],
140
+ });
141
+ return prediction.id; // Poll or wait for webhook
142
+ }
143
+ ```
144
+
145
+ #### 5. Production Patterns
146
+
147
+ - **Async Processing:** Always use background jobs (BullMQ, Inngest) for generation tasks >2s.
148
+ - **Webhook Architecture:** Use webhooks for Replicate predictions instead of polling.
149
+ - **Content Safety:** Implement NSFW filtering (OpenAI Moderation API, Replicate safety checker).
150
+ - **Cost Control:** Set per-user daily limits. Cache identical prompts. Use cheaper models for drafts.
151
+ - **Storage Pipeline:** Generate → upload to S3/R2 → serve via CDN → store URL in DB.
152
+
153
+ ---
154
+
155
+ <a name="bahasa-indonesia"></a>
156
+ ## Bahasa Indonesia
157
+
158
+ ### Integrasi Orkestrasi
159
+ - **`ai-llm-integration-expert`**: Pola LLM inti dan pemilihan model.
160
+ - **`file-upload-media-expert`**: Penyimpanan, CDN, dan pipeline media untuk aset yang dihasilkan.
161
+ - **`sse-websocket-streaming-expert`**: Streaming real-time untuk generasi gambar/audio progresif.
162
+ - **`async-queue-temporal-expert`**: Pemrosesan job latar belakang untuk tugas generasi yang lama.
163
+
164
+ ### Deskripsi
165
+ Panduan tingkat produksi untuk mengintegrasikan generasi media berbasis AI ke dalam aplikasi web dan mobile. Mencakup generasi gambar (Flux 1.1 Pro, SDXL, DALL-E 3), generasi video (Sora, Runway Gen-3), text-to-speech (ElevenLabs v3, OpenAI TTS), speech-to-text (Whisper large-v3, Deepgram Nova-3), dan kloning suara.
166
+
167
+ ### Kondisi Pemicu
168
+ - Mengintegrasikan generasi gambar AI (Flux, DALL-E, Stable Diffusion).
169
+ - Membangun fitur text-to-speech atau speech-to-text.
170
+ - Mengimplementasikan kloning suara atau generasi avatar AI.
171
+ - Menambahkan kemampuan generasi atau editing video AI.
172
+ - Membangun pipeline pemrosesan media dengan model AI.
@@ -0,0 +1,84 @@
1
+ ---
2
+ name: ai-prompt-engineering-expert
3
+ description: "Expert guide for systematic Prompt Engineering, Chain-of-Thought, few-shot prompting, structured output (JSON mode), prompt versioning, and LLM evaluation / Panduan ahli rekayasa prompt dan evaluasi LLM."
4
+ author: "Roedy Rustam"
5
+ ---
6
+
7
+ # AI Prompt Engineering Expert
8
+
9
+ [English](#english) | [Bahasa Indonesia](#bahasa-indonesia)
10
+
11
+ ---
12
+
13
+ <a name="english"></a>
14
+ ## English
15
+
16
+ ### Description
17
+ A specialized guide focused purely on the *craft* of interacting with Large Language Models (LLMs). While `ai-llm-integration-expert` covers the architecture (RAG, Vector DBs, APIs), this skill covers how to write, version, evaluate, and defend prompts. It focuses on maximizing accuracy and reliability from foundation models (Claude, GPT-4, Llama 3, Gemini).
18
+
19
+ ### Trigger Conditions
20
+ - When writing complex system prompts for autonomous AI agents.
21
+ - When an LLM is hallucinating or returning poorly formatted data.
22
+ - When the user asks about "Chain-of-Thought", "few-shot", or "JSON mode".
23
+ - When building a prompt testing and evaluation pipeline (e.g., using LangSmith or Braintrust).
24
+ - When defending an application against Prompt Injection attacks.
25
+
26
+ ### Core Architectural Guidelines
27
+
28
+ #### 1. Structured Output (JSON Mode & Tool Calling)
29
+ Never rely on prompt instructions alone to get JSON. Always use the model's native Tool Calling/Function Calling capabilities or Structured Output mode (e.g., passing a JSON Schema).
30
+ - **Zod**: Use Zod to define your desired schema in TypeScript, then convert it to JSON Schema for the LLM. Parse the response back through Zod to guarantee type safety.
31
+
32
+ #### 2. Advanced Prompting Techniques
33
+ - **Chain-of-Thought (CoT)**: Force the model to think before it acts. Provide a `<thinking>` tag for the model to use before it outputs the final answer.
34
+ - **Few-Shot Prompting**: Provide 2-3 highly varied examples of the input-output pairs you expect.
35
+ - **Clear Boundaries**: Use XML tags to separate instructions from user input to prevent confusion (e.g., `<user_input>`, `<system_rules>`).
36
+
37
+ #### 3. Defense Against Prompt Injection
38
+ - Never trust user input. If you are building a tool that summarizes user-provided text, wrap the text tightly in delimiters and instruct the model to ignore any instructions within those delimiters.
39
+ - Keep system prompts isolated from the user's direct chat window.
40
+
41
+ #### 4. Prompt Versioning & Evaluation
42
+ - Prompts are code. Do not hardcode massive prompts directly in your application logic. Store them in version control (or a Prompt CMS like LangSmith).
43
+ - Build automated evaluation suites using LLM-as-a-Judge to score whether a change in the prompt improved or degraded performance on a golden dataset.
44
+
45
+ ## Orchestration & Integration
46
+ - Enhances `ai-llm-integration-expert` with high-quality, reliable prompt designs.
47
+ - Crucial for `gemini-agent-booster` when creating multi-agent swarms with distinct system personalities.
48
+ - Pairs with `autonomous-red-teamer` to penetration test prompts against injection attacks.
49
+
50
+ ---
51
+
52
+ <a name="bahasa-indonesia"></a>
53
+ ## Bahasa Indonesia
54
+
55
+ ### Deskripsi
56
+ Panduan khusus yang berfokus murni pada *seni dan sains* berinteraksi dengan Large Language Models (LLMs). Berbeda dengan `ai-llm-integration-expert` yang fokus pada infrastruktur (RAG, API), skill ini membahas cara menulis, memberikan versi, mengevaluasi, dan melindungi prompt untuk memaksimalkan akurasi model dasar.
57
+
58
+ ### Kondisi Pemicu
59
+ - Saat menyusun system prompt yang kompleks untuk agen AI otonom.
60
+ - Saat LLM berhalusinasi atau mengembalikan data dengan format yang salah.
61
+ - Saat Anda perlu menjamin output berformat JSON yang ketat.
62
+ - Saat melindungi aplikasi dari serangan *Prompt Injection*.
63
+
64
+ ### Panduan Arsitektur Inti
65
+
66
+ #### 1. Output Terstruktur (Structured Output)
67
+ Jangan hanya menyuruh model "berikan output JSON" di dalam teks prompt. Gunakan fitur *Tool Calling* / *Function Calling* bawaan model, atau berikan JSON Schema yang ketat. Gunakan Zod (di TypeScript) atau Pydantic (di Python) untuk memvalidasi output tersebut.
68
+
69
+ #### 2. Teknik Prompting Lanjutan
70
+ - **Chain-of-Thought (CoT)**: Selalu instruksikan model untuk "berpikir" terlebih dahulu sebelum memberikan jawaban akhir. Minta model untuk menuliskan alur logikanya di dalam tag `<thinking>`.
71
+ - **Few-Shot**: Berikan 2-3 contoh input dan output (contoh positif maupun negatif) agar model memahami pola yang Anda inginkan.
72
+ - **Pembatasan (Delimiters)**: Gunakan tag XML (`<aturan>`, `<data_pengguna>`) untuk memisahkan instruksi dari data mentah.
73
+
74
+ #### 3. Pertahanan Terhadap Prompt Injection
75
+ - Jika aplikasi Anda memproses teks dari pengguna eksternal (misal: ringkasan email), selalu bungkus teks tersebut dengan tag XML dan beri peringatan eksplisit pada model untuk mengabaikan instruksi apa pun yang berada di dalam tag tersebut.
76
+
77
+ #### 4. Versioning & Evaluasi
78
+ - Prompt adalah kode sumber (source code). Simpan dalam *version control* atau *Prompt Management System*.
79
+ - Buat pipeline evaluasi (LLM-as-a-Judge) untuk mengukur secara kuantitatif apakah perubahan prompt Anda meningkatkan atau menurunkan kualitas hasil.
80
+
81
+ ## Integrasi Orkestrasi
82
+ - Melengkapi `ai-llm-integration-expert` dengan desain prompt berkualitas tinggi.
83
+ - Sangat penting bagi `gemini-agent-booster` saat mengonfigurasi kepribadian agen yang berbeda-beda.
84
+ - Bekerja sama dengan `autonomous-red-teamer` untuk menguji ketahanan prompt dari serangan.