All skills
openai avatar

/chatgpt-apps

@cb9153a official
by openaiopenai/skills28k stars
1,891

Build, scaffold, refactor, and troubleshoot ChatGPT Apps SDK applications that combine an MCP server and widget UI. Use when Codex needs to design tools, register UI resources, wire the MCP Apps bridge or ChatGPT compatibility APIs, apply Apps SDK metadata or CSP or domain settings, or produce a docs-aligned project scaffold. Prefer a docs-first workflow by invoking the openai-docs skill or OpenAI developer docs MCP tools before generating code.

Use this Skill: https://skilld.dev/gh/openai/skills/chatgpt-apps

This session only. Nothing lands on disk.

referenceswindow-openai-patterns.md

≈1.2k tokens on demand. Your agent reads this file only when SKILL.md points to it.

Window.openai Patterns

Load this reference when a task needs ChatGPT-only widget features, when translating older examples that use an app wrapper, or when a React widget should read host globals safely.

Core Rule

  • Build baseline widget behavior on the MCP Apps bridge: ui/* notifications, tools/call, ui/message, and ui/update-model-context.
  • Use window.openai only when the task specifically benefits from ChatGPT-only runtime conveniences.
  • Treat window.openai as additive. The app should still have a coherent baseline path on the MCP Apps standard when possible.

Canonical window.openai Surface

State And Data

  • window.openai.toolInput: tool arguments supplied by the host
  • window.openai.toolOutput: current structuredContent
  • window.openai.toolResponseMetadata: current _meta payload (widget-only)
  • window.openai.widgetState: persisted widget-local snapshot
  • window.openai.setWidgetState(state): persist widget-local snapshot after meaningful UI changes

Runtime APIs

  • window.openai.callTool(name, args): call another MCP tool from the widget
  • window.openai.sendFollowUpMessage({ prompt, scrollToBottom? }): ask ChatGPT to post a widget-authored follow-up message
  • window.openai.openExternal({ href, redirectUrl? }): open an external URL through ChatGPT's vetted flow
  • window.openai.requestDisplayMode({ mode }): request inline, pip, or fullscreen
  • window.openai.requestModal({ params, template? }): open a host-owned modal
  • window.openai.requestClose(): ask ChatGPT to close the widget
  • window.openai.uploadFile(file, options?): upload a file from the widget
  • window.openai.selectFiles(): open ChatGPT's file library picker and return app-authorized files
  • window.openai.getFileDownloadUrl({ fileId }): resolve a temporary download URL
  • window.openai.notifyIntrinsicHeight(...): report dynamic height changes
  • window.openai.setOpenInAppUrl({ href }): override the fullscreen punch-out target

Context Signals

  • window.openai.theme
  • window.openai.displayMode
  • window.openai.maxHeight
  • window.openai.safeArea
  • window.openai.view
  • window.openai.userAgent
  • window.openai.locale

Mapping From Repo Wrapper Examples

  • app.callServerTool({ name, arguments }): Use window.openai.callTool(name, args) when you intentionally want the ChatGPT compatibility layer. Use tools/call over the bridge when you want the portable MCP Apps path.
  • app.sendMessage(...): Use ui/message for portable bridge messaging. If the task is intentionally ChatGPT-specific, window.openai.sendFollowUpMessage({ prompt }) is the closest supported path.
  • app.updateModelContext(...): Use ui/update-model-context over the bridge. This is part of the standard bridge, not a window.openai feature.
  • app.openLink({ url }): Use window.openai.openExternal({ href: url }) when you intentionally want ChatGPT's external navigation flow.
  • app.requestDisplayMode({ mode }): Use window.openai.requestDisplayMode({ mode }).
  • app.getHostContext(): Read the documented globals directly (theme, displayMode, locale, maxHeight, safeArea, userAgent).
  • app.getHostCapabilities() / app.getHostVersion(): These are wrapper-level convenience APIs. Prefer feature detection (if (window.openai?.requestModal)) and the documented globals instead of teaching these as the primary public surface.

File Patterns

  • Use window.openai.uploadFile(file) when the user is adding a new local file inside the widget.
  • Use window.openai.uploadFile(file, { library: true }) when the upload should also be saved into the user's ChatGPT file library.
  • Use window.openai.selectFiles() when the user should be able to reuse files that are already in their ChatGPT file library instead of uploading again.
  • Use window.openai.getFileDownloadUrl({ fileId }) when the widget needs a temporary URL for previewing a file or forwarding it through a file-param payload.
  • Feature-detect these helpers in the widget (if (window.openai?.selectFiles)) and provide a fallback upload flow when a ChatGPT-only helper is unavailable.

React Helper Extraction

  • The repo's src/use-openai-global.ts is a good baseline for subscribing to host global changes without scattering direct window.openai reads through components.
  • The repo's src/use-widget-state.ts is a good baseline for mirroring React state into window.openai.setWidgetState(...).
  • The repo's src/use-widget-props.ts is a good baseline for reading typed toolOutput with a local fallback.
  • Keep these helpers optional. Do not force a React abstraction when a simple vanilla widget is enough.

Source: SKILL.md on GitHub

1 alert17d5 checks · Risk SAFE
  • Gen Agent Trust Hub17d

    This skill provides a robust framework for scaffolding ChatGPT Apps SDK applications, including MCP servers and widget UIs. It includes a built-in scaffolding script and detailed guidance on security best practices like Content Security Policy (CSP) and domain validation.

  • Socket17d

    No alerts

  • Snyk17d

    Risk: LOW · No issues

  • Runlayer6mo

    4/11 files flagged

  • ZeroLeaks5mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at cb9153a. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 months ago.

Activeupdated 7 months ago

README badge

README badge for openai/skills/chatgpt-apps

Scaffolds ChatGPT Apps SDK implementations with MCP server and widget UI, using a docs-first workflow that references current Apps SDK guidance before generating code. Targets tool planning, MCP server registration, widget scaffolding with the MCP Apps bridge, and validation against the Apps SDK contract. Integrates with the openai-docs skill to keep generated code aligned with official examples and patterns.

Generated from the current SKILL.md.

Does this skill work with Python MCP servers or only Node.js?
The skill supports both. It defaults to Node.js examples and includes a Node fallback scaffold, but explicitly asks about backend language during planning and can scaffold Python MCP servers when requested.
What's the relationship between this skill and the openai-docs skill?
This skill requires a docs-first workflow and must be paired with openai-docs (or the OpenAI docs MCP server directly) before generating code. Always fetch current Apps SDK docs before writing scaffolds.
Does this help with apps already built, or only greenfield projects?
It handles both. The skill can scaffold new apps, refactor existing ones against current docs, validate repos against the minimum working contract, and plan tool surfaces or architecture changes.
What happens if I want to use React for the widget?
The skill can scaffold React widgets. It prefers official OpenAI examples first when they match your stack, or adapts ext-apps React examples, and falls back to vanilla HTML only when no closer match exists.
Can this skill help with submission to the ChatGPT directory?
Yes. The skill includes an `submission-ready` archetype and can generate production-ready scaffolds with tool annotations, CSP, URI versioning, and guides for deployment and submission workflows.

Generated from the current SKILL.md. These answers refresh after source changes.