Chatgpt apps

From LeoYeAI/openclaw-master-skills · View interactive version

Chatgpt apps is an AI agent skill from the GitHub repository LeoYeAI/openclaw-master-skills. Complete ChatGPT Apps builder - Create, design, implement, test, and deploy ChatGPT Apps with MCP servers, widgets, auth, database integration, and automated deployment

How to use this skill

Skill file

ChatGPT Apps Builder

Complete workflow for building, testing, and deploying ChatGPT Apps from concept to production.

Commands


Table of Contents

  1. Create New App
  2. Add MCP Tool
  3. Add Widget
  4. Add Authentication
  5. Add Database
  6. Generate Golden Prompts
  7. Validate App
  8. Test App
  9. Deploy App
  10. Resume App

1. Create New App

Purpose: Create a new ChatGPT App from concept to working code.

Workflow

Phase 1: Conceptualization
  1. Ask for the app idea

"What ChatGPT App would you like to build? Describe what it does and the problem it solves."

  1. Analyze against UX Principles
  1. Check for Anti-Patterns
  1. Define Use Cases

Create 3-5 primary use cases with user stories.

Phase 2: Design
  1. Tool Topology
  1. Widget Design

For each widget:

  1. Data Model

Design entities and relationships.

  1. Auth Requirements
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:

Phase 4: Testing
Phase 5: Deployment

2. Add MCP Tool

Purpose: Add a new MCP tool to your ChatGPT App.

Workflow

  1. Gather Information
  1. Classify Tool Type
  1. Design Input Schema

Create Zod schema with appropriate types and descriptions.

  1. Generate Tool Handler

Use chatgpt-mcp-generator agent to create:

  1. Register Tool

Update server/index.ts with metadata:

```typescript

{

name: "my-tool",

_meta: {

"openai/toolInvocation/invoking": "Loading...",

"openai/toolInvocation/invoked": "Done",

"openai/outputTemplate": "ui://widget/my-widget.html", // if widget

}

}

```

  1. 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

  1. Card Grid - Multiple items in grid
  2. Stats Dashboard - Key metrics display
  3. Table - Tabular data
  4. Bar Chart - Simple visualizations
  5. Detail Widget - Single item details

Workflow

  1. Gather Information
  1. Define Data Shape

Document expected structure with TypeScript interface.

  1. Add Widget Config

```typescript

const widgets: WidgetConfig[] = [

{

id: "my-widget",

name: "My Widget",

description: "Displays data",

templateUri: "ui://widget/my-widget.html",

invoking: "Loading...",

invoked: "Ready",

mockData: { /* sample */ },

},

];

```

  1. Add Widget HTML

Generate HTML with:

  1. Create/Update Tool

Link tool to widget via widgetId.

  1. 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

Providers

Auth0:

Supabase Auth:

Workflow

  1. Choose Provider

Ask user preference based on needs.

  1. Guide Setup
  1. Generate Auth Code

Use chatgpt-auth-generator agent to create:

  1. Update Server

Add auth middleware to protect routes.

  1. Update Environment

```bash

# Auth0

AUTH0_DOMAIN=your-tenant.auth0.com

AUTH0_CLIENT_ID=...

AUTH0_CLIENT_SECRET=...

# Supabase (from database setup)

SUPABASE_URL=...

SUPABASE_ANON_KEY=...

```

  1. Test

Verify login flow and user isolation.


5. Add Database

Purpose: Configure PostgreSQL database using Supabase.

When to Add

Workflow

  1. Check Supabase Setup

Verify account and project exist.

  1. Gather Credentials
  1. Define Entities

For each entity, specify:

  1. Generate Schema

Use chatgpt-database-generator agent to create SQL with:

  1. Setup Connection Pool

```typescript

import { createClient } from '@supabase/supabase-js';

const supabase = createClient(

process.env.SUPABASE_URL!,

process.env.SUPABASE_SERVICE_ROLE_KEY!

);

```

  1. 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

3 Categories

  1. Direct Prompts - Explicit tool invocation
  1. Indirect Prompts - Outcome-based, ChatGPT should infer tool
  1. Negative Prompts - Should NOT trigger tool

Workflow

  1. Analyze Tools

Review each tool's purpose and inputs.

  1. Generate Prompts

For each tool, create:

  1. Best Practices
  1. Save Output

Write to .chatgpt-app/golden-prompts.json:

```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

  1. Required Files
  1. Server Implementation
  1. Widget Configuration
  1. Tool Response Format
  1. Resource Handler Format
  1. Widget HTML Structure
  1. Endpoint Existence
  1. Package.json Scripts
  1. Annotation Validation
  1. Database Validation (if 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

  1. MCP Protocol
  1. Schema Validation
  1. Widget Tests
  1. Golden Prompt Tests

Workflow

  1. Start Server in Test Mode

```bash

HTTP_MODE=true NODE_ENV=test npm run dev

```

  1. Run MCP Inspector

Test protocol compliance:

  1. Schema Validation

Verify schemas compile and match implementation.

  1. Golden Prompt Tests

Use ChatGPT to test prompts:

  1. Generate Report

```json

{

"passed": 42,

"failed": 3,

"categories": {

"mcp": "✅",

"schema": "✅",

"widgets": "✅",

"prompts": "⚠️ 3 failures"

},

"timing": "2.3s"

}

```

Fixing Failures

For each failure, explain:


9. Deploy App

Purpose: Deploy ChatGPT App to Render with PostgreSQL and health checks.

Prerequisites

Workflow

  1. Pre-flight Check
  1. Generate render.yaml

```yaml

services:

name: {app-name}

runtime: docker

plan: free

healthCheckPath: /health

envVars:

value: 3000

value: true

value: production

generateValue: true

# Add auth/database vars if needed

```

  1. Generate Dockerfile

```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"]

```

  1. Deploy

Option A: Automated (if Render MCP available)

Use Render MCP agent to deploy.

Option B: Manual

  1. Verify Deployment
  1. Configure ChatGPT Connector

10. Resume App

Purpose: Resume building an in-progress ChatGPT App.

Workflow

  1. Load State

Read .chatgpt-app/state.json:

```json

{

"appName": "My Task Manager",

"phase": "Implementation",

"tools": ["list-tasks", "create-task"],

"widgets": ["task-list"],

"auth": false,

"database": true,

"validated": false,

"deployed": false

}

```

  1. Display Progress

Show current status:

  1. Offer Next Steps

Based on phase:

Concept Phase:

Implementation Phase:

Testing Phase:

Deployment Phase:

  1. Continue Work

Based on user's choice, invoke the appropriate workflow section.


Best Practices

  1. Always save state after each major step
  2. Validate before moving forward (especially before deployment)
  3. Use agents for code generation (chatgpt-mcp-generator, chatgpt-auth-generator, etc.)
  4. Test at every phase (preview widgets, test tools, run golden prompts)
  5. Keep it conversational - guide the user naturally through the workflow
  6. Explain trade-offs when offering choices (Auth0 vs Supabase, etc.)
  7. 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:

  1. Check if .chatgpt-app/state.json exists
  2. If yes → use Resume App workflow
  3. If no → use Create New App workflow

Always guide users through the natural progression:

Concept → Implementation → Testing → Deployment

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.