Claude Code
Use Claude's agentic coding capabilities to build applications with Stack0 integration.
🧠Agentic Coding
Claude Code can read documentation, create files, run commands, and implement complete features. Point it to Stack0's llms.txt for accurate API integration.
Getting Started
When using Claude Code (via CLI, API, or in tools like Cursor), provide Stack0 context for best results:
I'm building with Stack0 (stack0.dev) for email and file storage.Documentation: https://stack0.dev/llms.txtStack0 provides:- Transactional & marketing email (stack0.mail.send)- File storage with CDN (stack0.cdn.getUploadUrl)- Image processing & transforms- Screenshots of URLs- AI data extraction from web pagesSDK: @stack0/sdkAPI Key: process.env.STACK0_API_KEY
CLAUDE.md Project File
Create a CLAUDE.md file in your project root for Claude to reference:
# Project Context for Claude## Stack0 IntegrationThis project uses Stack0 for infrastructure services.### Setup```bashnpm install @stack0/sdk```### Environment```STACK0_API_KEY=sk_live_your_api_key```### SDK Initialization```typescriptimport { Stack0 } from '@stack0/sdk'const stack0 = new Stack0({apiKey: process.env.STACK0_API_KEY!})```## Common Patterns### Send Email```typescriptawait stack0.mail.send({from: 'noreply@myapp.com',to: 'user@example.com',subject: 'Hello!',html: '<h1>Welcome!</h1>',})```### Upload File to CDN```typescript// Get presigned upload URLconst { uploadUrl, cdnUrl, assetId } = await stack0.cdn.getUploadUrl({filename: 'image.png',mimeType: 'image/png',size: fileSize,})// Upload directlyawait fetch(uploadUrl, { method: 'PUT', body: fileBuffer })// Confirm uploadawait stack0.cdn.confirmUpload({ assetId })```### Take Screenshot```typescriptconst screenshot = await stack0.screenshots.capture({url: 'https://example.com',format: 'png',fullPage: false,})// screenshot.url contains the image```### Extract Data from URL```typescriptconst data = await stack0.extraction.extract({url: 'https://example.com/article',schema: {title: 'string',content: 'string',author: 'string',},})```## DocumentationFull API reference: https://stack0.dev/llms.txt
Example Prompts
Complete Feature Implementation
"Implement a contact form that sends emails using Stack0. Create the React component with validation, the API route handler, and wire everything together. Refer to CLAUDE.md for Stack0 setup."
File Upload System
"Build a file upload feature using Stack0 CDN. Include drag-and-drop UI, progress tracking, and display uploaded files with their CDN URLs. Follow the patterns in CLAUDE.md."
Email Notification System
"Add email notifications to this app: welcome email on signup, password reset emails, and order confirmation emails. Use Stack0 mail API as documented in CLAUDE.md."
Screenshot Service
"Create an API endpoint that accepts a URL and returns a screenshot using Stack0. Include caching and error handling. See CLAUDE.md for the screenshots API."
Multi-File Implementation
Claude Code excels at implementing features across multiple files:
Help me add email functionality to my Next.js app.I need:1. A shared Stack0 client in lib/stack0.ts2. An API route at app/api/email/send/route.ts3. A reusable sendEmail utility function4. Email templates for: welcome, password reset, notificationUse Stack0 SDK (@stack0/sdk) - see CLAUDE.md for setup.The API key is in STACK0_API_KEY env variable.Please implement all files and explain the structure.
Generated Code Example
Here's what Claude generates with proper context:
// lib/stack0.tsimport { Stack0 } from '@stack0/sdk'if (!process.env.STACK0_API_KEY) {throw new Error('Missing STACK0_API_KEY environment variable')}export const stack0 = new Stack0({apiKey: process.env.STACK0_API_KEY,})// Email utilitiesexport async function sendEmail(options: {to: stringsubject: stringhtml: stringfrom?: string}) {return stack0.mail.send({from: options.from || 'noreply@myapp.com',to: options.to,subject: options.subject,html: options.html,})}// File upload utilitiesexport async function getUploadUrl(file: { name: string; type: string; size: number }) {return stack0.cdn.getUploadUrl({filename: file.name,mimeType: file.type,size: file.size,})}export async function confirmUpload(assetId: string) {return stack0.cdn.confirmUpload({ assetId })}
// app/api/email/send/route.tsimport { sendEmail } from '@/lib/stack0'import { NextResponse } from 'next/server'import { z } from 'zod'const emailSchema = z.object({to: z.string().email(),subject: z.string().min(1),html: z.string().min(1),})export async function POST(request: Request) {try {const body = await request.json()const { to, subject, html } = emailSchema.parse(body)const result = await sendEmail({ to, subject, html })return NextResponse.json({success: true,messageId: result.id})} catch (error) {if (error instanceof z.ZodError) {return NextResponse.json({ error: 'Invalid request', details: error.errors },{ status: 400 })}console.error('Email send failed:', error)return NextResponse.json({ error: 'Failed to send email' },{ status: 500 })}}
Tips for Claude Code + Stack0
Use CLAUDE.md
Create a project context file with Stack0 patterns for consistent code generation.
Reference llms.txt
Point Claude to https://stack0.dev/llms.txt for complete API documentation.
Be Specific
Include file paths, validation requirements, and error handling expectations.
Iterate
Ask Claude to refine, add tests, or improve error handling in follow-up messages.