ChatGPT Apps Builder
Complete workflow for building, testing, and deploying ChatGPT Apps from concept to production.
Commands
/chatgpt-apps new - Create a new ChatGPT App
/chatgpt-apps add-tool - Add an MCP tool to your app
/chatgpt-apps add-widget - Add a widget to your app
/chatgpt-apps add-auth - Configure authentication
/chatgpt-apps add-database - Set up database
/chatgpt-apps validate - Validate your app
/chatgpt-apps test - Run tests
/chatgpt-apps deploy - Deploy to production
/chatgpt-apps resume - Resume working on an app
Table of Contents
- Create New App
- Add MCP Tool
- Add Widget
- Add Authentication
- Add Database
- Generate Golden Prompts
- Validate App
- Test App
- Deploy App
- Resume App
1. Create New App
Purpose: Create a new ChatGPT App from concept to working code.
Workflow
Phase 1: Conceptualization
Ask for the app idea
"What ChatGPT App would you like to build? Describe what it does and the problem it solves."
Analyze against UX Principles
- Conversational Leverage: What can users accomplish through natural language?
- Native Fit: How does this integrate with ChatGPT's conversational flow?
- Composability: Can tools work independently and combine with other apps?
Check for Anti-Patterns
- Static website content display
- Complex multi-step workflows requiring external tabs
- Duplicating ChatGPT's native capabilities
- Ads or upsells
Define Use Cases
Create 3-5 primary use cases with user stories.
Phase 2: Design
Tool Topology
- Query tools (readOnlyHint: true)
- Mutation tools (destructiveHint: false)
- Destructive tools (destructiveHint: true)
- Widget tools (return UI with _meta)
- External API tools (openWorldHint: true)
Widget Design
For each widget:
id - unique identifier (kebab-case)
name - display name
description - what it shows
mockData - sample data for preview
Data Model
Design entities and relationships.
Auth Requirements
- Single-user (no auth needed)
- Multi-user (Auth0 or Supabase Auth)
Phase 3: Implementation
Generate complete application with this structure:
{app-name}/
├── package.json
├── tsconfig.server.json
├── setup.sh
├── START.sh
├── .env.example
├── .gitignore
└── server/
└── index.ts
Critical Requirements:
Server class from @modelcontextprotocol/sdk/server/index.js
StreamableHTTPServerTransport for session management
- Widget URIs:
ui://widget/{widget-id}.html
- Widget MIME type:
text/html+skybridge
structuredContent in tool responses
_meta with openai/outputTemplate on tools
Phase 4: Testing
- Run setup:
./setup.sh
- Start dev:
./START.sh --dev
- Preview widgets:
http://localhost:3000/preview
- Test MCP connection
Phase 5: Deployment
- Generate Dockerfile and render.yaml
- Deploy to Render
- Configure ChatGPT connector
2. Add MCP Tool
Purpose: Add a new MCP tool to your ChatGPT App.
Workflow
Gather Information
- What does this tool do?
- What inputs does it need?
- What does it return?
Classify Tool Type
- Query (readOnlyHint: true) - Fetches data
- Mutation (destructiveHint: false) - Creates/updates data
- Destructive (destructiveHint: true) - Deletes data
- Widget - Returns UI content
- External (openWorldHint: true) - Calls external APIs
Design Input Schema
Create Zod schema with appropriate types and descriptions.
Generate Tool Handler
Use chatgpt-mcp-generator agent to create:
- Tool handler in
server/tools/
- Zod schema export
- Type exports
- Database queries (if needed)
Register Tool
Update server/index.ts with metadata:
{
name: "my-tool",
_meta: {
"openai/toolInvocation/invoking": "Loading...",
"openai/toolInvocation/invoked": "Done",
"openai/outputTemplate": "ui://widget/my-widget.html", // if widget
}
}
Update State
Add tool to .chatgpt-app/state.json.
Tool Naming
Use kebab-case: list-items, create-task, show-recipe-detail
Annotations Guide
| Scenario |
readOnlyHint |
destructiveHint |
openWorldHint |
| List/Get |
true |
false |
false |
| Create/Update |
false |
false |
false |
| Delete |
false |
true |
false |
| External API |
varies |
varies |
true |
3. Add Widget
Purpose: Add inline HTML widgets with HTML/CSS/JS and Apps SDK integration.
5 Widget Patterns
- Card Grid - Multiple items in grid
- Stats Dashboard - Key metrics display
- Table - Tabular data
- Bar Chart - Simple visualizations
- Detail Widget - Single item details
Workflow
Gather Information
- Widget purpose and data
- Visual design (cards, table, chart, etc.)
- Interactivity needs
Define Data Shape
Document expected structure with TypeScript interface.
Add Widget Config
const widgets: WidgetConfig[] = [
{
id: "my-widget",
name: "My Widget",
description: "Displays data",
templateUri: "ui://widget/my-widget.html",
invoking: "Loading...",
invoked: "Ready",
mockData: { /* sample */ },
},
];
Add Widget HTML
Generate HTML with:
- Preview mode support (
window.PREVIEW_DATA)
- OpenAI Apps SDK integration (
window.openai.toolOutput)
- Event listeners (
openai:set_globals)
- Polling fallback (100ms, 10s timeout)
Create/Update Tool
Link tool to widget via widgetId.
Test Widget
Preview at /preview/{widget-id} with mock data.
Widget HTML Structure
(function() {
let rendered = false;
function render(data) {
if (rendered || !data) return;
rendered = true;
// Render logic
}
function tryRender() {
if (window.PREVIEW_DATA) { render(window.PREVIEW_DATA); return; }
if (window.openai?.toolOutput) { render(window.openai.toolOutput); }
}
window.addEventListener('openai:set_globals', tryRender);
const poll = setInterval(() => {
if (window.openai?.toolOutput || window.PREVIEW_DATA) {
tryRender();
clearInterval(poll);
}
}, 100);
setTimeout(() => clearInterval(poll), 10000);
tryRender();
})();
4. Add Authentication
Purpose: Configure authentication using Auth0 or Supabase Auth.
When to Add
- Multiple users
- Persistent private data per user
- User-specific API credentials
Providers
Auth0:
- Enterprise-grade
- OAuth 2.1, PKCE flow
- Social logins (Google, GitHub, etc.)
Supabase Auth:
- Simpler setup
- Email/password default
- Integrates with Supabase database
Workflow
Choose Provider
Ask user preference based on needs.
Guide Setup
- Auth0: Create application, configure callback URLs, get credentials
- Supabase: Already configured with database setup
Generate Auth Code
Use chatgpt-auth-generator agent to create:
- Session management middleware
- User subject extraction
- Token validation
Update Server
Add auth middleware to protect routes.
Update Environment
# Auth0
AUTH0_DOMAIN=your-tenant.auth0.com
AUTH0_CLIENT_ID=...
AUTH0_CLIENT_SECRET=...
# Supabase (from database setup)
SUPABASE_URL=...
SUPABASE_ANON_KEY=...
Test
Verify login flow and user isolation.
5. Add Database
Purpose: Configure PostgreSQL database using Supabase.
When to Add
- Persistent user data
- Multi-entity relationships
- Query/filter capabilities
Workflow
Check Supabase Setup
Verify account and project exist.
Gather Credentials
- Project URL
- Anon key (public)
- Service role key (server-side)
Define Entities
For each entity, specify:
- Fields and types
- Relationships
- Indexes
Generate Schema
Use chatgpt-database-generator agent to create SQL with:
id (UUID primary key)
user_subject (varchar, indexed)
created_at (timestamptz)
updated_at (timestamptz)
- RLS policies for user isolation
Setup Connection Pool
import { createClient } from '@supabase/supabase-js';
const supabase = createClient(
process.env.SUPABASE_URL!,
process.env.SUPABASE_SERVICE_ROLE_KEY!
);
Apply Migrations
Run SQL in Supabase dashboard or via migration tool.
Query Pattern
Always filter by user_subject:
const { data } = await supabase
.from('tasks')
.select('*')
.eq('user_subject', userSubject);
6. Generate Golden Prompts
Purpose: Generate test prompts to validate ChatGPT correctly invokes tools.
Why Important
- Measure precision/recall
- Enable iteration
- Post-launch monitoring
3 Categories
Direct Prompts - Explicit tool invocation
- "Show me my task list"
- "Create a new task called..."
Indirect Prompts - Outcome-based, ChatGPT should infer tool
- "What do I need to do today?"
- "Help me organize my work"
Negative Prompts - Should NOT trigger tool
- "What is a task?"
- "Tell me about project management"
Workflow
Analyze Tools
Review each tool's purpose and inputs.
Generate Prompts
For each tool, create:
- 5+ direct prompts
- 5+ indirect prompts
- 3+ negative prompts
- 2+ edge case prompts
Best Practices
- Tool descriptions start with "Use this when..."
- State limitations clearly
- Include examples in descriptions
Save Output
Write to .chatgpt-app/golden-prompts.json:
{
"toolName": {
"direct": ["prompt1", "prompt2"],
"indirect": ["prompt1", "prompt2"],
"negative": ["prompt1", "prompt2"],
"edge": ["prompt1", "prompt2"]
}
}
7. Validate App
Purpose: Validation suite before deployment.
10 Validation Checks
Required Files
- package.json
- tsconfig.server.json
- setup.sh (executable)
- START.sh (executable)
- server/index.ts
- .env.example
Server Implementation
- Uses
Server from MCP SDK
- Has
StreamableHTTPServerTransport
- Session management with Map
- Correct request handlers
Widget Configuration
widgets array exists
- Each has id, name, description, templateUri, mockData
- URIs match pattern
ui://widget/{id}.html
Tool Response Format
- Returns
structuredContent (not just content)
- Widget tools have
_meta with openai/outputTemplate
Resource Handler Format
- MIME type:
text/html+skybridge
- Returns
_meta with serialization and CSP
Widget HTML Structure
- Preview mode support
- Event listeners for Apps SDK
- Polling fallback
- Render guard
Endpoint Existence
/health - Health check
/preview - Widget index
/preview/:widgetId - Widget preview
/mcp - MCP endpoint
Package.json Scripts
- Has
build:server
- Has
start with HTTP_MODE=true
- Has
dev with watch mode
- NO web build scripts (web/, ui/, client/)
Annotation Validation
- readOnlyHint set correctly
- destructiveHint for delete operations
- openWorldHint for external APIs
Database Validation (if enabled)
- Tables have required fields
- user_subject indexed
- RLS policies enabled
Common Errors
| Error |
Fix |
| Missing structuredContent |
Add to tool response |
| Wrong widget URI |
Use ui://widget/{id}.html |
| No session management |
Add Map<string, Transport> |
| Missing _meta |
Add to tool definition and response |
| Wrong MIME type |
Use text/html+skybridge |
Critical: Check file existence FIRST before other validations!
8. Test App
Purpose: Run automated tests using MCP Inspector and golden prompts.
4 Test Categories
MCP Protocol
- Server starts without errors
- Handles initialize
- Lists tools correctly
- Lists resources correctly
Schema Validation
- Tool schemas are valid Zod
- Required fields marked
- Types match implementation
Widget Tests
- All widgets render in preview mode
- Mock data loads correctly
- No console errors
Golden Prompt Tests
- Direct prompts trigger correct tools
- Indirect prompts work as expected
- Negative prompts don't trigger tools
Workflow
Start Server in Test Mode
HTTP_MODE=true NODE_ENV=test npm run dev
Run MCP Inspector
Test protocol compliance:
- Initialize connection
- List tools
- Call each tool with valid inputs
- Check responses
Schema Validation
Verify schemas compile and match implementation.
Golden Prompt Tests
Use ChatGPT to test prompts:
- Record which tool was called
- Compare to expected tool
- Calculate precision/recall
Generate Report
{
"passed": 42,
"failed": 3,
"categories": {
"mcp": "✅",
"schema": "✅",
"widgets": "✅",
"prompts": "⚠️ 3 failures"
},
"timing": "2.3s"
}
Fixing Failures
For each failure, explain:
- What failed
- Why it failed
- How to fix (with code example)
9. Deploy App
Purpose: Deploy ChatGPT App to Render with PostgreSQL and health checks.
Prerequisites
- ✅ Validation passed
- ✅ Tests passed
- ✅ Git repository clean
- ✅ Environment variables ready
Workflow
Pre-flight Check
- Run validation
- Run tests
- Check database connection (if enabled)
Generate render.yaml
services:
- type: web
name: {app-name}
runtime: docker
plan: free
healthCheckPath: /health
envVars:
- key: PORT
value: 3000
- key: HTTP_MODE
value: true
- key: NODE_ENV
value: production
- key: WIDGET_DOMAIN
generateValue: true
# Add auth/database vars if needed
Generate Dockerfile
FROM node:20-slim
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY dist ./dist
EXPOSE 3000
CMD ["node", "dist/server/index.js"]
Deploy
Option A: Automated (if Render MCP available)
Use Render MCP agent to deploy.
Option B: Manual
- Push to GitHub
- Connect repo in Render dashboard
- Set environment variables
- Deploy
Verify Deployment
- Health check:
https://{app}.onrender.com/health
- MCP endpoint:
https://{app}.onrender.com/mcp
- Tool discovery works
- Widgets render
Configure ChatGPT Connector
- URL:
https://{app}.onrender.com/mcp
- Test in ChatGPT
10. Resume App
Purpose: Resume building an in-progress ChatGPT App.
Workflow
Load State
Read .chatgpt-app/state.json:
{
"appName": "My Task Manager",
"phase": "Implementation",
"tools": ["list-tasks", "create-task"],
"widgets": ["task-list"],
"auth": false,
"database": true,
"validated": false,
"deployed": false
}
Display Progress
Show current status:
- App name
- Current phase
- Completed items (tools, widgets)
- Pending items (auth, validation, deployment)
Offer Next Steps
Based on phase:
Concept Phase:
- "Let's design the tools and widgets"
- "Shall we start implementation?"
Implementation Phase:
- "Add another tool?"
- "Add a widget?"
- "Set up authentication?"
- "Set up database?"
Testing Phase:
- "Generate golden prompts?"
- "Run validation?"
- "Run tests?"
Deployment Phase:
- "Deploy to Render?"
- "Configure ChatGPT connector?"
Continue Work
Based on user's choice, invoke the appropriate workflow section.
Best Practices
- Always save state after each major step
- Validate before moving forward (especially before deployment)
- Use agents for code generation (chatgpt-mcp-generator, chatgpt-auth-generator, etc.)
- Test at every phase (preview widgets, test tools, run golden prompts)
- Keep it conversational - guide the user naturally through the workflow
- Explain trade-offs when offering choices (Auth0 vs Supabase, etc.)
- Show examples when introducing new concepts
State Management
The .chatgpt-app/state.json file tracks progress:
{
"appName": "string",
"description": "string",
"phase": "Concept" | "Implementation" | "Testing" | "Deployment",
"tools": ["tool-name"],
"widgets": ["widget-id"],
"auth": {
"enabled": boolean,
"provider": "auth0" | "supabase" | null
},
"database": {
"enabled": boolean,
"entities": ["entity-name"]
},
"validated": boolean,
"tested": boolean,
"deployed": boolean,
"deploymentUrl": "string | null",
"goldenPromptsGenerated": boolean,
"lastUpdated": "ISO timestamp"
}
Command Reference
# Setup
./setup.sh
# Development
./START.sh --dev # Dev mode with watch
./START.sh --preview # Open preview in browser
./START.sh --stdio # STDIO mode (testing)
./START.sh # Production mode
# Testing
npm run validate # Type checking
curl http://localhost:3000/health
# Deployment
git push origin main # Trigger Render deploy
Getting Started
When the user invokes any chatgpt-app command:
- Check if
.chatgpt-app/state.json exists
- If yes → use Resume App workflow
- If no → use Create New App workflow
Always guide users through the natural progression:
Concept → Implementation → Testing → Deployment
1---
2name: chatgpt-apps
3description: Complete ChatGPT Apps builder - Create, design, implement, test, and deploy ChatGPT Apps with MCP servers, widgets, auth, database integration, and automated deployment
4homepage: https://github.com/hollaugo/prompt-circle-claude-plugins
5user-invocable: true
6metadata:
7 source: https://skillmd.com/skills/modbender/chatgpt-apps
8---
9
10# ChatGPT Apps Builder
11
12Complete workflow for building, testing, and deploying ChatGPT Apps from concept to production.
13
14## Commands
15
16- `/chatgpt-apps new` - Create a new ChatGPT App
17- `/chatgpt-apps add-tool` - Add an MCP tool to your app
18- `/chatgpt-apps add-widget` - Add a widget to your app
19- `/chatgpt-apps add-auth` - Configure authentication
20- `/chatgpt-apps add-database` - Set up database
21- `/chatgpt-apps validate` - Validate your app
22- `/chatgpt-apps test` - Run tests
23- `/chatgpt-apps deploy` - Deploy to production
24- `/chatgpt-apps resume` - Resume working on an app
25
26---
27
28## Table of Contents
29
301. [Create New App](#1-create-new-app)
312. [Add MCP Tool](#2-add-mcp-tool)
323. [Add Widget](#3-add-widget)
334. [Add Authentication](#4-add-authentication)
345. [Add Database](#5-add-database)
356. [Generate Golden Prompts](#6-generate-golden-prompts)
367. [Validate App](#7-validate-app)
378. [Test App](#8-test-app)
389. [Deploy App](#9-deploy-app)
3910. [Resume App](#10-resume-app)
40
41---
42
43## 1. Create New App
44
45**Purpose:** Create a new ChatGPT App from concept to working code.
46
47### Workflow
48
49#### Phase 1: Conceptualization
50
511. **Ask for the app idea**
52 "What ChatGPT App would you like to build? Describe what it does and the problem it solves."
53
542. **Analyze against UX Principles**
55 - **Conversational Leverage**: What can users accomplish through natural language?
56 - **Native Fit**: How does this integrate with ChatGPT's conversational flow?
57 - **Composability**: Can tools work independently and combine with other apps?
58
593. **Check for Anti-Patterns**
60 - Static website content display
61 - Complex multi-step workflows requiring external tabs
62 - Duplicating ChatGPT's native capabilities
63 - Ads or upsells
64
654. **Define Use Cases**
66 Create 3-5 primary use cases with user stories.
67
68#### Phase 2: Design
69
701. **Tool Topology**
71 - Query tools (readOnlyHint: true)
72 - Mutation tools (destructiveHint: false)
73 - Destructive tools (destructiveHint: true)
74 - Widget tools (return UI with _meta)
75 - External API tools (openWorldHint: true)
76
772. **Widget Design**
78 For each widget:
79 - `id` - unique identifier (kebab-case)
80 - `name` - display name
81 - `description` - what it shows
82 - `mockData` - sample data for preview
83
843. **Data Model**
85 Design entities and relationships.
86
874. **Auth Requirements**
88 - Single-user (no auth needed)
89 - Multi-user (Auth0 or Supabase Auth)
90
91#### Phase 3: Implementation
92
93Generate complete application with this structure:
94
95```
96{app-name}/
97├── package.json
98├── tsconfig.server.json
99├── setup.sh
100├── START.sh
101├── .env.example
102├── .gitignore
103└── server/
104 └── index.ts
105```
106
107**Critical Requirements:**
108- `Server` class from `@modelcontextprotocol/sdk/server/index.js`
109- `StreamableHTTPServerTransport` for session management
110- Widget URIs: `ui://widget/{widget-id}.html`
111- Widget MIME type: `text/html+skybridge`
112- `structuredContent` in tool responses
113- `_meta` with `openai/outputTemplate` on tools
114
115#### Phase 4: Testing
116- Run setup: `./setup.sh`
117- Start dev: `./START.sh --dev`
118- Preview widgets: `http://localhost:3000/preview`
119- Test MCP connection
120
121#### Phase 5: Deployment
122- Generate Dockerfile and render.yaml
123- Deploy to Render
124- Configure ChatGPT connector
125
126---
127
128## 2. Add MCP Tool
129
130**Purpose:** Add a new MCP tool to your ChatGPT App.
131
132### Workflow
133
1341. **Gather Information**
135 - What does this tool do?
136 - What inputs does it need?
137 - What does it return?
138
1392. **Classify Tool Type**
140 - **Query** (readOnlyHint: true) - Fetches data
141 - **Mutation** (destructiveHint: false) - Creates/updates data
142 - **Destructive** (destructiveHint: true) - Deletes data
143 - **Widget** - Returns UI content
144 - **External** (openWorldHint: true) - Calls external APIs
145
1463. **Design Input Schema**
147 Create Zod schema with appropriate types and descriptions.
148
1494. **Generate Tool Handler**
150 Use `chatgpt-mcp-generator` agent to create:
151 - Tool handler in `server/tools/`
152 - Zod schema export
153 - Type exports
154 - Database queries (if needed)
155
1565. **Register Tool**
157 Update `server/index.ts` with metadata:
158 ```typescript
159 {
160 name: "my-tool",
161 _meta: {
162 "openai/toolInvocation/invoking": "Loading...",
163 "openai/toolInvocation/invoked": "Done",
164 "openai/outputTemplate": "ui://widget/my-widget.html", // if widget
165 }
166 }
167 ```
168
1696. **Update State**
170 Add tool to `.chatgpt-app/state.json`.
171
172### Tool Naming
173Use kebab-case: `list-items`, `create-task`, `show-recipe-detail`
174
175### Annotations Guide
176
177| Scenario | readOnlyHint | destructiveHint | openWorldHint |
178|----------|--------------|-----------------|---------------|
179| List/Get | true | false | false |
180| Create/Update | false | false | false |
181| Delete | false | true | false |
182| External API | varies | varies | true |
183
184---
185
186## 3. Add Widget
187
188**Purpose:** Add inline HTML widgets with HTML/CSS/JS and Apps SDK integration.
189
190### 5 Widget Patterns
191
1921. **Card Grid** - Multiple items in grid
1932. **Stats Dashboard** - Key metrics display
1943. **Table** - Tabular data
1954. **Bar Chart** - Simple visualizations
1965. **Detail Widget** - Single item details
197
198### Workflow
199
2001. **Gather Information**
201 - Widget purpose and data
202 - Visual design (cards, table, chart, etc.)
203 - Interactivity needs
204
2052. **Define Data Shape**
206 Document expected structure with TypeScript interface.
207
2083. **Add Widget Config**
209 ```typescript
210 const widgets: WidgetConfig[] = [
211 {
212 id: "my-widget",
213 name: "My Widget",
214 description: "Displays data",
215 templateUri: "ui://widget/my-widget.html",
216 invoking: "Loading...",
217 invoked: "Ready",
218 mockData: { /* sample */ },
219 },
220 ];
221 ```
222
2234. **Add Widget HTML**
224 Generate HTML with:
225 - Preview mode support (`window.PREVIEW_DATA`)
226 - OpenAI Apps SDK integration (`window.openai.toolOutput`)
227 - Event listeners (`openai:set_globals`)
228 - Polling fallback (100ms, 10s timeout)
229
2305. **Create/Update Tool**
231 Link tool to widget via `widgetId`.
232
2336. **Test Widget**
234 Preview at `/preview/{widget-id}` with mock data.
235
236### Widget HTML Structure
237
238```javascript
239(function() {
240 let rendered = false;
241
242 function render(data) {
243 if (rendered || !data) return;
244 rendered = true;
245 // Render logic
246 }
247
248 function tryRender() {
249 if (window.PREVIEW_DATA) { render(window.PREVIEW_DATA); return; }
250 if (window.openai?.toolOutput) { render(window.openai.toolOutput); }
251 }
252
253 window.addEventListener('openai:set_globals', tryRender);
254
255 const poll = setInterval(() => {
256 if (window.openai?.toolOutput || window.PREVIEW_DATA) {
257 tryRender();
258 clearInterval(poll);
259 }
260 }, 100);
261 setTimeout(() => clearInterval(poll), 10000);
262
263 tryRender();
264})();
265```
266
267---
268
269## 4. Add Authentication
270
271**Purpose:** Configure authentication using Auth0 or Supabase Auth.
272
273### When to Add
274- Multiple users
275- Persistent private data per user
276- User-specific API credentials
277
278### Providers
279
280**Auth0:**
281- Enterprise-grade
282- OAuth 2.1, PKCE flow
283- Social logins (Google, GitHub, etc.)
284
285**Supabase Auth:**
286- Simpler setup
287- Email/password default
288- Integrates with Supabase database
289
290### Workflow
291
2921. **Choose Provider**
293 Ask user preference based on needs.
294
2952. **Guide Setup**
296 - **Auth0:** Create application, configure callback URLs, get credentials
297 - **Supabase:** Already configured with database setup
298
2993. **Generate Auth Code**
300 Use `chatgpt-auth-generator` agent to create:
301 - Session management middleware
302 - User subject extraction
303 - Token validation
304
3054. **Update Server**
306 Add auth middleware to protect routes.
307
3085. **Update Environment**
309 ```bash
310 # Auth0
311 AUTH0_DOMAIN=your-tenant.auth0.com
312 AUTH0_CLIENT_ID=...
313 AUTH0_CLIENT_SECRET=...
314
315 # Supabase (from database setup)
316 SUPABASE_URL=...
317 SUPABASE_ANON_KEY=...
318 ```
319
3206. **Test**
321 Verify login flow and user isolation.
322
323---
324
325## 5. Add Database
326
327**Purpose:** Configure PostgreSQL database using Supabase.
328
329### When to Add
330- Persistent user data
331- Multi-entity relationships
332- Query/filter capabilities
333
334### Workflow
335
3361. **Check Supabase Setup**
337 Verify account and project exist.
338
3392. **Gather Credentials**
340 - Project URL
341 - Anon key (public)
342 - Service role key (server-side)
343
3443. **Define Entities**
345 For each entity, specify:
346 - Fields and types
347 - Relationships
348 - Indexes
349
3504. **Generate Schema**
351 Use `chatgpt-database-generator` agent to create SQL with:
352 - `id` (UUID primary key)
353 - `user_subject` (varchar, indexed)
354 - `created_at` (timestamptz)
355 - `updated_at` (timestamptz)
356 - RLS policies for user isolation
357
3585. **Setup Connection Pool**
359 ```typescript
360 import { createClient } from '@supabase/supabase-js';
361
362 const supabase = createClient(
363 process.env.SUPABASE_URL!,
364 process.env.SUPABASE_SERVICE_ROLE_KEY!
365 );
366 ```
367
3686. **Apply Migrations**
369 Run SQL in Supabase dashboard or via migration tool.
370
371### Query Pattern
372
373Always filter by `user_subject`:
374
375```typescript
376const { data } = await supabase
377 .from('tasks')
378 .select('*')
379 .eq('user_subject', userSubject);
380```
381
382---
383
384## 6. Generate Golden Prompts
385
386**Purpose:** Generate test prompts to validate ChatGPT correctly invokes tools.
387
388### Why Important
389- Measure precision/recall
390- Enable iteration
391- Post-launch monitoring
392
393### 3 Categories
394
3951. **Direct Prompts** - Explicit tool invocation
396 - "Show me my task list"
397 - "Create a new task called..."
398
3992. **Indirect Prompts** - Outcome-based, ChatGPT should infer tool
400 - "What do I need to do today?"
401 - "Help me organize my work"
402
4033. **Negative Prompts** - Should NOT trigger tool
404 - "What is a task?"
405 - "Tell me about project management"
406
407### Workflow
408
4091. **Analyze Tools**
410 Review each tool's purpose and inputs.
411
4122. **Generate Prompts**
413 For each tool, create:
414 - 5+ direct prompts
415 - 5+ indirect prompts
416 - 3+ negative prompts
417 - 2+ edge case prompts
418
4193. **Best Practices**
420 - Tool descriptions start with "Use this when..."
421 - State limitations clearly
422 - Include examples in descriptions
423
4244. **Save Output**
425 Write to `.chatgpt-app/golden-prompts.json`:
426 ```json
427 {
428 "toolName": {
429 "direct": ["prompt1", "prompt2"],
430 "indirect": ["prompt1", "prompt2"],
431 "negative": ["prompt1", "prompt2"],
432 "edge": ["prompt1", "prompt2"]
433 }
434 }
435 ```
436
437---
438
439## 7. Validate App
440
441**Purpose:** Validation suite before deployment.
442
443### 10 Validation Checks
444
4451. **Required Files**
446 - package.json
447 - tsconfig.server.json
448 - setup.sh (executable)
449 - START.sh (executable)
450 - server/index.ts
451 - .env.example
452
4532. **Server Implementation**
454 - Uses `Server` from MCP SDK
455 - Has `StreamableHTTPServerTransport`
456 - Session management with Map
457 - Correct request handlers
458
4593. **Widget Configuration**
460 - `widgets` array exists
461 - Each has id, name, description, templateUri, mockData
462 - URIs match pattern `ui://widget/{id}.html`
463
4644. **Tool Response Format**
465 - Returns `structuredContent` (not just `content`)
466 - Widget tools have `_meta` with `openai/outputTemplate`
467
4685. **Resource Handler Format**
469 - MIME type: `text/html+skybridge`
470 - Returns `_meta` with serialization and CSP
471
4726. **Widget HTML Structure**
473 - Preview mode support
474 - Event listeners for Apps SDK
475 - Polling fallback
476 - Render guard
477
4787. **Endpoint Existence**
479 - `/health` - Health check
480 - `/preview` - Widget index
481 - `/preview/:widgetId` - Widget preview
482 - `/mcp` - MCP endpoint
483
4848. **Package.json Scripts**
485 - Has `build:server`
486 - Has `start` with HTTP_MODE=true
487 - Has `dev` with watch mode
488 - NO web build scripts (web/, ui/, client/)
489
4909. **Annotation Validation**
491 - readOnlyHint set correctly
492 - destructiveHint for delete operations
493 - openWorldHint for external APIs
494
49510. **Database Validation** (if enabled)
496 - Tables have required fields
497 - user_subject indexed
498 - RLS policies enabled
499
500### Common Errors
501
502| Error | Fix |
503|-------|-----|
504| Missing structuredContent | Add to tool response |
505| Wrong widget URI | Use ui://widget/{id}.html |
506| No session management | Add Map<string, Transport> |
507| Missing _meta | Add to tool definition and response |
508| Wrong MIME type | Use text/html+skybridge |
509
510**Critical:** Check file existence FIRST before other validations!
511
512---
513
514## 8. Test App
515
516**Purpose:** Run automated tests using MCP Inspector and golden prompts.
517
518### 4 Test Categories
519
5201. **MCP Protocol**
521 - Server starts without errors
522 - Handles initialize
523 - Lists tools correctly
524 - Lists resources correctly
525
5262. **Schema Validation**
527 - Tool schemas are valid Zod
528 - Required fields marked
529 - Types match implementation
530
5313. **Widget Tests**
532 - All widgets render in preview mode
533 - Mock data loads correctly
534 - No console errors
535
5364. **Golden Prompt Tests**
537 - Direct prompts trigger correct tools
538 - Indirect prompts work as expected
539 - Negative prompts don't trigger tools
540
541### Workflow
542
5431. **Start Server in Test Mode**
544 ```bash
545 HTTP_MODE=true NODE_ENV=test npm run dev
546 ```
547
5482. **Run MCP Inspector**
549 Test protocol compliance:
550 - Initialize connection
551 - List tools
552 - Call each tool with valid inputs
553 - Check responses
554
5553. **Schema Validation**
556 Verify schemas compile and match implementation.
557
5584. **Golden Prompt Tests**
559 Use ChatGPT to test prompts:
560 - Record which tool was called
561 - Compare to expected tool
562 - Calculate precision/recall
563
5645. **Generate Report**
565 ```json
566 {
567 "passed": 42,
568 "failed": 3,
569 "categories": {
570 "mcp": "✅",
571 "schema": "✅",
572 "widgets": "✅",
573 "prompts": "⚠️ 3 failures"
574 },
575 "timing": "2.3s"
576 }
577 ```
578
579### Fixing Failures
580
581For each failure, explain:
582- What failed
583- Why it failed
584- How to fix (with code example)
585
586---
587
588## 9. Deploy App
589
590**Purpose:** Deploy ChatGPT App to Render with PostgreSQL and health checks.
591
592### Prerequisites
593
594- ✅ Validation passed
595- ✅ Tests passed
596- ✅ Git repository clean
597- ✅ Environment variables ready
598
599### Workflow
600
6011. **Pre-flight Check**
602 - Run validation
603 - Run tests
604 - Check database connection (if enabled)
605
6062. **Generate render.yaml**
607 ```yaml
608 services:
609 - type: web
610 name: {app-name}
611 runtime: docker
612 plan: free
613 healthCheckPath: /health
614 envVars:
615 - key: PORT
616 value: 3000
617 - key: HTTP_MODE
618 value: true
619 - key: NODE_ENV
620 value: production
621 - key: WIDGET_DOMAIN
622 generateValue: true
623 # Add auth/database vars if needed
624 ```
625
6263. **Generate Dockerfile**
627 ```dockerfile
628 FROM node:20-slim
629 WORKDIR /app
630 COPY package*.json ./
631 RUN npm ci --only=production
632 COPY dist ./dist
633 EXPOSE 3000
634 CMD ["node", "dist/server/index.js"]
635 ```
636
6374. **Deploy**
638 **Option A: Automated (if Render MCP available)**
639 Use Render MCP agent to deploy.
640
641 **Option B: Manual**
642 - Push to GitHub
643 - Connect repo in Render dashboard
644 - Set environment variables
645 - Deploy
646
6475. **Verify Deployment**
648 - Health check: `https://{app}.onrender.com/health`
649 - MCP endpoint: `https://{app}.onrender.com/mcp`
650 - Tool discovery works
651 - Widgets render
652
6536. **Configure ChatGPT Connector**
654 - URL: `https://{app}.onrender.com/mcp`
655 - Test in ChatGPT
656
657---
658
659## 10. Resume App
660
661**Purpose:** Resume building an in-progress ChatGPT App.
662
663### Workflow
664
6651. **Load State**
666 Read `.chatgpt-app/state.json`:
667 ```json
668 {
669 "appName": "My Task Manager",
670 "phase": "Implementation",
671 "tools": ["list-tasks", "create-task"],
672 "widgets": ["task-list"],
673 "auth": false,
674 "database": true,
675 "validated": false,
676 "deployed": false
677 }
678 ```
679
6802. **Display Progress**
681 Show current status:
682 - App name
683 - Current phase
684 - Completed items (tools, widgets)
685 - Pending items (auth, validation, deployment)
686
6873. **Offer Next Steps**
688 Based on phase:
689
690 **Concept Phase:**
691 - "Let's design the tools and widgets"
692 - "Shall we start implementation?"
693
694 **Implementation Phase:**
695 - "Add another tool?"
696 - "Add a widget?"
697 - "Set up authentication?"
698 - "Set up database?"
699
700 **Testing Phase:**
701 - "Generate golden prompts?"
702 - "Run validation?"
703 - "Run tests?"
704
705 **Deployment Phase:**
706 - "Deploy to Render?"
707 - "Configure ChatGPT connector?"
708
7094. **Continue Work**
710 Based on user's choice, invoke the appropriate workflow section.
711
712---
713
714## Best Practices
715
7161. **Always save state** after each major step
7172. **Validate before moving forward** (especially before deployment)
7183. **Use agents for code generation** (chatgpt-mcp-generator, chatgpt-auth-generator, etc.)
7194. **Test at every phase** (preview widgets, test tools, run golden prompts)
7205. **Keep it conversational** - guide the user naturally through the workflow
7216. **Explain trade-offs** when offering choices (Auth0 vs Supabase, etc.)
7227. **Show examples** when introducing new concepts
723
724---
725
726## State Management
727
728The `.chatgpt-app/state.json` file tracks progress:
729
730```json
731{
732 "appName": "string",
733 "description": "string",
734 "phase": "Concept" | "Implementation" | "Testing" | "Deployment",
735 "tools": ["tool-name"],
736 "widgets": ["widget-id"],
737 "auth": {
738 "enabled": boolean,
739 "provider": "auth0" | "supabase" | null
740 },
741 "database": {
742 "enabled": boolean,
743 "entities": ["entity-name"]
744 },
745 "validated": boolean,
746 "tested": boolean,
747 "deployed": boolean,
748 "deploymentUrl": "string | null",
749 "goldenPromptsGenerated": boolean,
750 "lastUpdated": "ISO timestamp"
751}
752```
753
754---
755
756## Command Reference
757
758```bash
759# Setup
760./setup.sh
761
762# Development
763./START.sh --dev # Dev mode with watch
764./START.sh --preview # Open preview in browser
765./START.sh --stdio # STDIO mode (testing)
766./START.sh # Production mode
767
768# Testing
769npm run validate # Type checking
770curl http://localhost:3000/health
771
772# Deployment
773git push origin main # Trigger Render deploy
774```
775
776---
777
778## Getting Started
779
780When the user invokes any chatgpt-app command:
781
7821. Check if `.chatgpt-app/state.json` exists
7832. If yes → use **Resume App** workflow
7843. If no → use **Create New App** workflow
785
786Always guide users through the natural progression:
787**Concept → Implementation → Testing → Deployment**