Help us improve
Share bugs, ideas, or general feedback.
From web-ai-skills
Implements and debugs browser Prompt API integrations in JavaScript/TypeScript web apps. For LanguageModel availability, session creation, prompt/promptStreaming, structured output, download progress, or iframe permission-policy.
npx claudepluginhub webmaxru/ai-native-dev --plugin web-ai-skillsHow this skill is triggered — by the user, by Claude, or both
Slash command
/web-ai-skills:prompt-apiThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
**Step 1: Identify the integration surface**
Implements browser Language Detector API integrations in JS/TS web apps: support checks, model download flows, session creation, detect() calls, input-usage measurement, permissions-policy handling, and compatibility fallbacks.
Calls AI models (DeepSeek, Hunyuan, GLM, Kimi, MiniMax) from browser/Web apps via @cloudbase/js-sdk with generateText and streamText. Default for frontend AI. Do NOT propose Node.js proxy.
Provides expertise in modern JavaScript with ES6+ features, async patterns like promises and async/await, event loops, Node.js APIs, and browser/Node compatibility. Use for building, debugging performance, and migrating legacy JS.
Share bugs, ideas, or general feedback.
Step 1: Identify the integration surface
node scripts/find-frontend-targets.mjs . to inventory likely frontend files and existing Prompt API usage when a Node runtime is available.package.json, HTML entry point, and framework entry files manually to identify the browser app boundary.Step 2: Confirm Prompt API viability
references/prompt-api-reference.md before writing code.references/examples.md when the feature needs a spec-valid message shape for text, multimodal, prefix, or tool-enabled sessions.references/compatibility.md when the feature must support multiple browser generations or decide between native support and polyfills.references/polyfills.md when the feature needs concrete package installation or backend configuration examples for Prompt API or Task API polyfills.language-model permissions-policy allows access from the current frame.prompt(), promptStreaming(), initialPrompts, append(), measureContextUsage(), tools, or responseConstraint.Step 3: Implement a guarded session wrapper
assets/language-model-service.template.ts and adapt it to the framework, state model, and file layout in the workspace.LanguageModel.availability() using the same creation options that the feature will use at runtime, including expected modalities and tools.AbortController for cancelable prompts and call destroy() when the session is no longer needed.allow="language-model" on the embedding iframe.params(), topK, or temperature; the spec marks them EXPERIMENTAL and extension-only, so portable web page integrations must not require them.availability() as a passive capability check: if it reports downloading before user activation, do not assume the current page initiated that download or lock the UI into an app-started busy state.Step 4: Wire UX and fallback behavior
monitor listener during LanguageModel.create() and render progress in the UI.responseConstraint, use omitResponseConstraintInput only when the prompt already carries the required format instructions, and parse the returned string before using it.system messages belong in initialPrompts, prefix: true applies only to the final assistant message, and assistant message content must remain text-only.availability() reports downloading before the app has called create(), present that as informational browser state rather than a page-owned active download, and keep controls usable unless the app itself is busy.Step 5: Validate behavior
prompt() and long responses with promptStreaming() when applicable.references/troubleshooting.md if the integration throws NotSupportedError or behaves differently across frames or execution contexts.LanguageModel is missing, prefer progressive enhancement with a maintained Prompt API polyfill or a non-AI fallback instead of inventing a custom compatibility layer.availability() returns downloading before the app has called create(), treat it as passive browser state. Only surface live progress and block prompt submission when the app itself has started LanguageModel.create().availability() or prompt() throws NotSupportedError, align the creation and prompt options with the actual modalities, languages, message roles, and tools used by the feature.allow="language-model" from the embedding page before continuing.node scripts/find-frontend-targets.mjs . cannot run, identify the browser app boundary manually and continue only after a single target app is clear.