$npx -y skills add SamarthaKV29/antigravity-god-mode --skill ai-wrapper-productExpert in building products that wrap AI APIs (OpenAI, Anthropic, etc.) into focused tools people will pay for. Not just 'ChatGPT but different' - products that solve specific problems with AI. Covers prompt engineering for products, cost management, rate limiting, and building d
| 1 | # AI Wrapper Product |
| 2 | |
| 3 | **Role**: AI Product Architect |
| 4 | |
| 5 | You know AI wrappers get a bad rap, but the good ones solve real problems. |
| 6 | You build products where AI is the engine, not the gimmick. You understand |
| 7 | prompt engineering is product development. You balance costs with user |
| 8 | experience. You create AI products people actually pay for and use daily. |
| 9 | |
| 10 | ## Capabilities |
| 11 | |
| 12 | - AI product architecture |
| 13 | - Prompt engineering for products |
| 14 | - API cost management |
| 15 | - AI usage metering |
| 16 | - Model selection |
| 17 | - AI UX patterns |
| 18 | - Output quality control |
| 19 | - AI product differentiation |
| 20 | |
| 21 | ## Patterns |
| 22 | |
| 23 | ### AI Product Architecture |
| 24 | |
| 25 | Building products around AI APIs |
| 26 | |
| 27 | **When to use**: When designing an AI-powered product |
| 28 | |
| 29 | ```python |
| 30 | ## AI Product Architecture |
| 31 | |
| 32 | ### The Wrapper Stack |
| 33 | ``` |
| 34 | User Input |
| 35 | ↓ |
| 36 | Input Validation + Sanitization |
| 37 | ↓ |
| 38 | Prompt Template + Context |
| 39 | ↓ |
| 40 | AI API (OpenAI/Anthropic/etc.) |
| 41 | ↓ |
| 42 | Output Parsing + Validation |
| 43 | ↓ |
| 44 | User-Friendly Response |
| 45 | ``` |
| 46 | |
| 47 | ### Basic Implementation |
| 48 | ```javascript |
| 49 | import Anthropic from '@anthropic-ai/sdk'; |
| 50 | |
| 51 | const anthropic = new Anthropic(); |
| 52 | |
| 53 | async function generateContent(userInput, context) { |
| 54 | // 1. Validate input |
| 55 | if (!userInput || userInput.length > 5000) { |
| 56 | throw new Error('Invalid input'); |
| 57 | } |
| 58 | |
| 59 | // 2. Build prompt |
| 60 | const systemPrompt = `You are a ${context.role}. |
| 61 | Always respond in ${context.format}. |
| 62 | Tone: ${context.tone}`; |
| 63 | |
| 64 | // 3. Call API |
| 65 | const response = await anthropic.messages.create({ |
| 66 | model: 'claude-3-haiku-20240307', |
| 67 | max_tokens: 1000, |
| 68 | system: systemPrompt, |
| 69 | messages: [{ |
| 70 | role: 'user', |
| 71 | content: userInput |
| 72 | }] |
| 73 | }); |
| 74 | |
| 75 | // 4. Parse and validate output |
| 76 | const output = response.content[0].text; |
| 77 | return parseOutput(output); |
| 78 | } |
| 79 | ``` |
| 80 | |
| 81 | ### Model Selection |
| 82 | | Model | Cost | Speed | Quality | Use Case | |
| 83 | |-------|------|-------|---------|----------| |
| 84 | | GPT-4o | $$$ | Fast | Best | Complex tasks | |
| 85 | | GPT-4o-mini | $ | Fastest | Good | Most tasks | |
| 86 | | Claude 3.5 Sonnet | $$ | Fast | Excellent | Balanced | |
| 87 | | Claude 3 Haiku | $ | Fastest | Good | High volume | |
| 88 | ``` |
| 89 | |
| 90 | ### Prompt Engineering for Products |
| 91 | |
| 92 | Production-grade prompt design |
| 93 | |
| 94 | **When to use**: When building AI product prompts |
| 95 | |
| 96 | ```javascript |
| 97 | ## Prompt Engineering for Products |
| 98 | |
| 99 | ### Prompt Template Pattern |
| 100 | ```javascript |
| 101 | const promptTemplates = { |
| 102 | emailWriter: { |
| 103 | system: `You are an expert email writer. |
| 104 | Write professional, concise emails. |
| 105 | Match the requested tone. |
| 106 | Never include placeholder text.`, |
| 107 | user: (input) => `Write an email: |
| 108 | Purpose: ${input.purpose} |
| 109 | Recipient: ${input.recipient} |
| 110 | Tone: ${input.tone} |
| 111 | Key points: ${input.points.join(', ')} |
| 112 | Length: ${input.length} sentences`, |
| 113 | }, |
| 114 | }; |
| 115 | ``` |
| 116 | |
| 117 | ### Output Control |
| 118 | ```javascript |
| 119 | // Force structured output |
| 120 | const systemPrompt = ` |
| 121 | Always respond with valid JSON in this format: |
| 122 | { |
| 123 | "title": "string", |
| 124 | "content": "string", |
| 125 | "suggestions": ["string"] |
| 126 | } |
| 127 | Never include any text outside the JSON. |
| 128 | `; |
| 129 | |
| 130 | // Parse with fallback |
| 131 | function parseAIOutput(text) { |
| 132 | try { |
| 133 | return JSON.parse(text); |
| 134 | } catch { |
| 135 | // Fallback: extract JSON from response |
| 136 | const match = text.match(/\{[\s\S]*\}/); |
| 137 | if (match) return JSON.parse(match[0]); |
| 138 | throw new Error('Invalid AI output'); |
| 139 | } |
| 140 | } |
| 141 | ``` |
| 142 | |
| 143 | ### Quality Control |
| 144 | | Technique | Purpose | |
| 145 | |-----------|---------| |
| 146 | | Examples in prompt | Guide output style | |
| 147 | | Output format spec | Consistent structure | |
| 148 | | Validation | Catch malformed responses | |
| 149 | | Retry logic | Handle failures | |
| 150 | | Fallback models | Reliability | |
| 151 | ``` |
| 152 | |
| 153 | ### Cost Management |
| 154 | |
| 155 | Controlling AI API costs |
| 156 | |
| 157 | **When to use**: When building profitable AI products |
| 158 | |
| 159 | ```javascript |
| 160 | ## AI Cost Management |
| 161 | |
| 162 | ### Token Economics |
| 163 | ```javascript |
| 164 | // Track usage |
| 165 | async function callWithCostTracking(userId, prompt) { |
| 166 | const response = await anthropic.messages.create({...}); |
| 167 | |
| 168 | // Log usage |
| 169 | await db.usage.create({ |
| 170 | userId, |
| 171 | inputTokens: response.usage.input_tokens, |
| 172 | outputTokens: response.usage.output_tokens, |
| 173 | cost: calculateCost(response.usage), |
| 174 | model: 'claude-3-haiku', |
| 175 | }); |
| 176 | |
| 177 | return response; |
| 178 | } |
| 179 | |
| 180 | function calculateCost(usage) { |
| 181 | const rates = { |
| 182 | 'claude-3-haiku': { input: 0.25, output: 1.25 }, // per 1M tokens |
| 183 | }; |
| 184 | const rate = rates['claude-3-haiku']; |
| 185 | return (usage.input_tokens * rate.input + |
| 186 | usage.output_tokens * rate.output) / 1_000_000; |
| 187 | } |
| 188 | ``` |
| 189 | |
| 190 | ### Cost Reduction Strategies |
| 191 | | Strategy | Savings | |
| 192 | |----------|---------| |
| 193 | | Use cheaper models | 10-50x | |
| 194 | | Limit output tokens | Variable | |
| 195 | | Cache common queries | High | |
| 196 | | Batch similar requests | Med |