AI App Generator
Build full-stack AI applications with Next.js, AI SDK, and ai-elements.
Quick Start
1. Scaffold Project
bunx --bun shadcn@latest create --name my-ai-app --template next --preset "https://ui.shadcn.com/init?base=radix&style=nova&baseColor=neutral&theme=neutral&iconLibrary=lucide&font=geist-sans&menuAccent=subtle&menuColor=default&radius=default"
cd my-ai-app
2. Install Dependencies
bun add ai@6 @ai-sdk/react @ai-sdk/anthropic zod
bunx --bun ai-elements@latest
Version: the patterns below target AI SDK 6 (ToolLoopAgent,
createAgentUIStreamResponse, toUIMessageStreamResponse), which is why the
install is pinned to ai@6 — an unpinned bun add ai resolves to v7 and the
examples here will not match. For a v7 build, scaffold with these steps and
then follow /ai-sdk-7 for the API surface.
3. Configure Environment
# .env.local - Choose your provider
ANTHROPIC_API_KEY=sk-ant-...
# OPENAI_API_KEY=sk-...
# GOOGLE_GENERATIVE_AI_API_KEY=...
4. Generate Application
Based on user requirements, generate:
- Chatbot: See references/chatbot.md
- Agent Dashboard: See references/agent-dashboard.md
- Custom: Combine patterns as needed
Application Types
Chatbot
Simple conversational AI with streaming responses.
| Feature |
Implementation |
| Chat UI |
Conversation + Message + PromptInput |
| API |
streamText + toUIMessageStreamResponse |
| Extras |
Reasoning, Sources, File attachments |
Agent Dashboard
Multi-agent interface with tool visualization.
| Feature |
Implementation |
| Agents |
ToolLoopAgent with tools |
| UI |
Dashboard layout + Tool components |
| API |
createAgentUIStreamResponse |
| Extras |
Status monitoring, tool approval |
Custom AI App
Mix and match based on user needs:
- Web search chatbot
- Code generation assistant
- Document analyzer
- Multi-modal chat
Project Structure
my-ai-app/
├── app/
│ ├── page.tsx # Main UI
│ ├── layout.tsx # Root layout
│ ├── globals.css # Theme
│ └── api/
│ └── chat/
│ └── route.ts # AI endpoint
├── components/
│ ├── ai-elements/ # AI Elements components
│ ├── ui/ # shadcn/ui components
│ └── chat.tsx # Chat component (if extracted)
├── lib/
│ ├── utils.ts # Utilities
│ └── ai.ts # AI configuration (optional)
├── ai/ # Agent definitions (if needed)
│ └── assistant.ts
└── .env.local # API keys
See references/project-structure.md for details.
Core Patterns
API Route
// app/api/chat/route.ts
import { streamText, UIMessage, convertToModelMessages } from 'ai';
import { anthropic } from '@ai-sdk/anthropic';
export const maxDuration = 30;
export async function POST(req: Request) {
const { messages }: { messages: UIMessage[] } = await req.json();
const result = streamText({
model: anthropic('claude-sonnet-5'),
messages: await convertToModelMessages(messages),
system: 'You are a helpful assistant.',
});
return result.toUIMessageStreamResponse({
sendSources: true,
sendReasoning: true,
});
}
Chat Page
// app/page.tsx
'use client';
import { useChat } from '@ai-sdk/react';
import { DefaultChatTransport } from 'ai';
import {
Conversation,
ConversationContent,
ConversationScrollButton,
} from '@/components/ai-elements/conversation';
import {
Message,
MessageContent,
MessageResponse,
} from '@/components/ai-elements/message';
import {
PromptInput,
PromptInputBody,
PromptInputTextarea,
PromptInputFooter,
PromptInputSubmit,
type PromptInputMessage,
} from '@/components/ai-elements/prompt-input';
import { Loader } from '@/components/ai-elements/loader';
import { useState } from 'react';
export default function ChatPage() {
const [input, setInput] = useState('');
const { messages, sendMessage, status } = useChat({
transport: new DefaultChatTransport({ api: '/api/chat' }),
});
const handleSubmit = (message: PromptInputMessage) => {
if (!message.text.trim()) return;
sendMessage({ text: message.text, files: message.files });
setInput('');
};
return (
<div className="flex h-screen flex-col p-4">
<Conversation className="flex-1">
<ConversationContent>
{messages.map((message) => (
<div key={message.id}>
{message.parts.map((part, i) => {
if (part.type === 'text') {
return (
<Message key={i} from={message.role}>
<MessageContent>
<MessageResponse>{part.text}</MessageResponse>
</MessageContent>
</Message>
);
}
return null;
})}
</div>
))}
{status === 'submitted' && <Loader />}
</ConversationContent>
<ConversationScrollButton />
</Conversation>
<PromptInput className="mt-4">
<PromptInputBody>
<PromptInputTextarea
value={input}
=> setInput(e.target.value)}
/>
</PromptInputBody>
<PromptInputFooter>
<div />
<PromptInputSubmit status={status} />
</PromptInputFooter>
</PromptInput>
</div>
);
}
Skill References
For detailed patterns, see:
| Need |
Skill |
Reference |
| Chat UI components |
/ai-elements |
chatbot.md |
| Next.js patterns |
/nextjs-shadcn |
architecture.md |
| AI SDK functions |
/ai-sdk-6 |
core-functions.md |
| Agents & tools |
/ai-sdk-6 |
agents.md |
| Caching |
/cache-components |
REFERENCE.md |
| Production patterns |
/nextjs-chatbot |
DB persistence, HITL approval, consent, feedback, search |
| Code review & cleanup |
code-simplifier agent |
DRY/KISS/YAGNI validation |
Workflow
Phase 1: Understand Requirements
Ask user:
- What type of AI app? (chatbot, agent, custom)
- What features? (reasoning, sources, tools, file upload)
- What style? (vega=classic, nova=compact, maia=soft/rounded, lyra=boxy/sharp, mira=dense) — default: nova
- What font? (geist-sans, inter, jetbrains-mono, figtree, dm-sans, outfit, noto-sans, nunito-sans, roboto, raleway, public-sans) — default: geist-sans
- What base color? (neutral, zinc, slate, gray, stone) — default: neutral
- What theme accent? (neutral, blue, green, orange, red, rose, violet) — default: neutral
- What border radius style? (default, sm, md, lg, xl)
- Component library? (radix=default, base-ui)
Phase 2: Scaffold Project
Run scaffolding commands based on requirements.
Phase 3: Generate Files
Create files based on application type:
- API route (
app/api/chat/route.ts)
- Main page (
app/page.tsx)
- Components (if needed)
- Agents (if needed)
Phase 4: Configure
- Set up
.env.local
- Configure
next.config.ts if needed
- Add any additional dependencies
Phase 5: Verify
bun dev
Test the application works correctly.
References
- Chatbot Templates - Full chatbot implementation
- Agent Dashboard Templates - Agent-based apps
- Project Structure - Directory layout
- Examples - Copy-paste examples
Package Manager
Always use bun in new projects, never npm:
bun add (not npm install)
bunx --bun (not npx)
bun dev (not npm run dev)
In an existing repo, respect the project's packageManager field and lockfile instead of switching to bun.
1---2name: ai-app3description: |4 Full-stack AI application generator with Next.js, AI SDK, and ai-elements.5 Use when creating chatbots, agent dashboards, or custom AI applications.67 Triggers: chatbot, chat app, agent dashboard, AI application, Next.js AI,8 useChat, streamText, ai-elements, build AI app, create chatbot9argument-hint: "[app-type or description]"10metadata:11 source: https://skillmd.com/skills/laguagu/ai-app12---1314# AI App Generator1516Build full-stack AI applications with Next.js, AI SDK, and ai-elements.1718## Quick Start1920### 1. Scaffold Project2122```bash23bunx --bun shadcn@latest create --name my-ai-app --template next --preset "https://ui.shadcn.com/init?base=radix&style=nova&baseColor=neutral&theme=neutral&iconLibrary=lucide&font=geist-sans&menuAccent=subtle&menuColor=default&radius=default"24cd my-ai-app25```2627### 2. Install Dependencies2829```bash30bun add ai@6 @ai-sdk/react @ai-sdk/anthropic zod31bunx --bun ai-elements@latest32```3334> **Version:** the patterns below target **AI SDK 6** (`ToolLoopAgent`,35> `createAgentUIStreamResponse`, `toUIMessageStreamResponse`), which is why the36> install is pinned to `ai@6` — an unpinned `bun add ai` resolves to v7 and the37> examples here will not match. For a v7 build, scaffold with these steps and38> then follow `/ai-sdk-7` for the API surface.3940### 3. Configure Environment4142```bash43# .env.local - Choose your provider44ANTHROPIC_API_KEY=sk-ant-...45# OPENAI_API_KEY=sk-...46# GOOGLE_GENERATIVE_AI_API_KEY=...47```4849### 4. Generate Application5051Based on user requirements, generate:52- **Chatbot**: See [references/chatbot.md](references/chatbot.md)53- **Agent Dashboard**: See [references/agent-dashboard.md](references/agent-dashboard.md)54- **Custom**: Combine patterns as needed5556## Application Types5758### Chatbot5960Simple conversational AI with streaming responses.6162| Feature | Implementation |63|---------|----------------|64| Chat UI | Conversation + Message + PromptInput |65| API | streamText + toUIMessageStreamResponse |66| Extras | Reasoning, Sources, File attachments |6768### Agent Dashboard6970Multi-agent interface with tool visualization.7172| Feature | Implementation |73|---------|----------------|74| Agents | ToolLoopAgent with tools |75| UI | Dashboard layout + Tool components |76| API | createAgentUIStreamResponse |77| Extras | Status monitoring, tool approval |7879### Custom AI App8081Mix and match based on user needs:82- Web search chatbot83- Code generation assistant84- Document analyzer85- Multi-modal chat8687## Project Structure8889```90my-ai-app/91├── app/92│ ├── page.tsx # Main UI93│ ├── layout.tsx # Root layout94│ ├── globals.css # Theme95│ └── api/96│ └── chat/97│ └── route.ts # AI endpoint98├── components/99│ ├── ai-elements/ # AI Elements components100│ ├── ui/ # shadcn/ui components101│ └── chat.tsx # Chat component (if extracted)102├── lib/103│ ├── utils.ts # Utilities104│ └── ai.ts # AI configuration (optional)105├── ai/ # Agent definitions (if needed)106│ └── assistant.ts107└── .env.local # API keys108```109110See [references/project-structure.md](references/project-structure.md) for details.111112## Core Patterns113114### API Route115116```typescript117// app/api/chat/route.ts118import { streamText, UIMessage, convertToModelMessages } from 'ai';119import { anthropic } from '@ai-sdk/anthropic';120121export const maxDuration = 30;122123export async function POST(req: Request) {124 const { messages }: { messages: UIMessage[] } = await req.json();125126 const result = streamText({127 model: anthropic('claude-sonnet-5'),128 messages: await convertToModelMessages(messages),129 system: 'You are a helpful assistant.',130 });131132 return result.toUIMessageStreamResponse({133 sendSources: true,134 sendReasoning: true,135 });136}137```138139### Chat Page140141```tsx142// app/page.tsx143'use client';144import { useChat } from '@ai-sdk/react';145import { DefaultChatTransport } from 'ai';146import {147 Conversation,148 ConversationContent,149 ConversationScrollButton,150} from '@/components/ai-elements/conversation';151import {152 Message,153 MessageContent,154 MessageResponse,155} from '@/components/ai-elements/message';156import {157 PromptInput,158 PromptInputBody,159 PromptInputTextarea,160 PromptInputFooter,161 PromptInputSubmit,162 type PromptInputMessage,163} from '@/components/ai-elements/prompt-input';164import { Loader } from '@/components/ai-elements/loader';165import { useState } from 'react';166167export default function ChatPage() {168 const [input, setInput] = useState('');169 const { messages, sendMessage, status } = useChat({170 transport: new DefaultChatTransport({ api: '/api/chat' }),171 });172173 const handleSubmit = (message: PromptInputMessage) => {174 if (!message.text.trim()) return;175 sendMessage({ text: message.text, files: message.files });176 setInput('');177 };178179 return (180 <div className="flex h-screen flex-col p-4">181 <Conversation className="flex-1">182 <ConversationContent>183 {messages.map((message) => (184 <div key={message.id}>185 {message.parts.map((part, i) => {186 if (part.type === 'text') {187 return (188 <Message key={i} from={message.role}>189 <MessageContent>190 <MessageResponse>{part.text}</MessageResponse>191 </MessageContent>192 </Message>193 );194 }195 return null;196 })}197 </div>198 ))}199 {status === 'submitted' && <Loader />}200 </ConversationContent>201 <ConversationScrollButton />202 </Conversation>203204 <PromptInput onSubmit={handleSubmit} className="mt-4">205 <PromptInputBody>206 <PromptInputTextarea207 value={input}208 onChange={(e) => setInput(e.target.value)}209 />210 </PromptInputBody>211 <PromptInputFooter>212 <div />213 <PromptInputSubmit status={status} />214 </PromptInputFooter>215 </PromptInput>216 </div>217 );218}219```220221## Skill References222223For detailed patterns, see:224225| Need | Skill | Reference |226|------|-------|-----------|227| Chat UI components | `/ai-elements` | [chatbot.md](references/chatbot.md) |228| Next.js patterns | `/nextjs-shadcn` | [architecture.md](../nextjs-shadcn/references/architecture.md) |229| AI SDK functions | `/ai-sdk-6` | [core-functions.md](../ai-sdk-6/references/core-functions.md) |230| Agents & tools | `/ai-sdk-6` | [agents.md](../ai-sdk-6/references/agents.md) |231| Caching | `/cache-components` | [REFERENCE.md](../cache-components/REFERENCE.md) |232| Production patterns | `/nextjs-chatbot` | DB persistence, HITL approval, consent, feedback, search |233| Code review & cleanup | `code-simplifier` agent | DRY/KISS/YAGNI validation |234235## Workflow236237### Phase 1: Understand Requirements238239Ask user:240- What type of AI app? (chatbot, agent, custom)241- What features? (reasoning, sources, tools, file upload)242- What style? (vega=classic, nova=compact, maia=soft/rounded, lyra=boxy/sharp, mira=dense) — default: nova243- What font? (geist-sans, inter, jetbrains-mono, figtree, dm-sans, outfit, noto-sans, nunito-sans, roboto, raleway, public-sans) — default: geist-sans244- What base color? (neutral, zinc, slate, gray, stone) — default: neutral245- What theme accent? (neutral, blue, green, orange, red, rose, violet) — default: neutral246- What border radius style? (default, sm, md, lg, xl)247- Component library? (radix=default, base-ui)248249### Phase 2: Scaffold Project250251Run scaffolding commands based on requirements.252253### Phase 3: Generate Files254255Create files based on application type:256- API route (`app/api/chat/route.ts`)257- Main page (`app/page.tsx`)258- Components (if needed)259- Agents (if needed)260261### Phase 4: Configure262263- Set up `.env.local`264- Configure `next.config.ts` if needed265- Add any additional dependencies266267### Phase 5: Verify268269```bash270bun dev271```272273Test the application works correctly.274275## References276277- [Chatbot Templates](references/chatbot.md) - Full chatbot implementation278- [Agent Dashboard Templates](references/agent-dashboard.md) - Agent-based apps279- [Project Structure](references/project-structure.md) - Directory layout280- [Examples](references/examples.md) - Copy-paste examples281282## Package Manager283284**Always use bun** in new projects, never npm:285- `bun add` (not npm install)286- `bunx --bun` (not npx)287- `bun dev` (not npm run dev)288289In an existing repo, respect the project's `packageManager` field and lockfile instead of switching to bun.