# language-detector-api

Walks your agent through wiring the built-in Language Detector API into a JavaScript or TypeScript web app: support checks, model download, sessions, detect().

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 475 installs · ★ 52
- Author: webmaxru
- License: MIT · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/webmaxru/web-ai-agent-skills/tree/HEAD/skills/language-detector-api/SKILL.md
- Updated: 2026-09-29
- HTML: https://affpapa.org/en/nevibecode/skills/language-detector-api

## What it does

The skill starts by locating the frontend entry point, then checks that the code runs in a secure `Window` context and that the current frame is allowed the `language-detector` permissions-policy feature. From there it picks the narrowest session shape: a plain `LanguageDetector.create()`, one with `expectedInputLanguages`, or one with `monitor` when the UI has to show download progress.

It ships a script, `scripts/find-language-detector-targets.mjs`, that inventories candidate files, plus `assets/language-detector-session.template.ts` for the agent to adapt to your framework. Separate references cover examples, compatibility and troubleshooting. Sessions should only be created after user activation when creation may trigger a model download, and `availability()` is treated as a capability check rather than a promise that creation will succeed.

One hard limit: this is a window-only browser API. In a worker or on the server it will not run, and the skill stops and says so. Translation, summarization and general chat belong to other APIs. If the project is not a browser web app, the skill does not apply.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add webmaxru/web-ai-agent-skills --skill language-detector-api -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/language-detector-api/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/language-detector-api/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add webmaxru/web-ai-agent-skills --skill language-detector-api -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/language-detector-api/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add webmaxru/web-ai-agent-skills --skill language-detector-api -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/language-detector-api/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install webmaxru/web-ai-agent-skills language-detector-api
```

2. **Manually: put the files in place**
- File: `.github/skills/language-detector-api/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add webmaxru/web-ai-agent-skills --skill language-detector-api -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/webmaxru/web-ai-agent-skills --path skills/language-detector-api
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/language-detector-api/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add webmaxru/web-ai-agent-skills --skill language-detector-api -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/webmaxru/web-ai-agent-skills/tree/HEAD/skills/language-detector-api/SKILL.md

## When to use it
- add a support check before calling the Language Detector API
- surface model download progress with the `monitor` option
- create a session with a specific `expectedInputLanguages` set
- cancel a long-running `detect()` with `AbortController`
- keep a non-AI fallback for browsers without the API

## Example prompts
- Add Language Detector API support to our React app with a feature check and a fallback
- Wrap the session with `expectedInputLanguages` and show model download progress
- Figure out why `create()` throws `NotAllowedError` in our app

## Source text · SKILL.md · MIT

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: c275071e0670398c.

BEGIN THIRD-PARTY FILE c275071e0670398c
```text
---
name: language-detector-api
description: Implements and debugs browser Language Detector API integrations in JavaScript or TypeScript web apps. Use when adding LanguageDetector support checks, availability and model download flows, session creation, detect() calls, input-usage measurement, permissions-policy handling, or compatibility fallbacks for built-in language detection. Don't use for server-side language detection SDKs, cloud translation services, or generic NLP pipelines.
license: MIT
metadata:
  author: webmaxru
  version: "1.5"
---

# Language Detector API

## Procedures

**Step 1: Identify the browser integration surface**
1. Inspect the workspace for browser entry points, UI handlers, text-input flows, and any existing AI abstraction layer.
2. Execute `node scripts/find-language-detector-targets.mjs .` to inventory likely frontend files and existing Language Detector API markers when a Node runtime is available.
3. If a Node runtime is unavailable, inspect the nearest `package.json`, HTML entry point, and framework bootstrap files manually to identify the browser app boundary.
4. If the workspace contains multiple frontend apps, prefer the app that contains the active route, component, or user-requested feature surface.
5. If the inventory still leaves multiple plausible frontend targets, stop and ask which app should receive the Language Detector API integration.
6. If the project is not a browser web app, stop and explain that this skill does not apply.

**Step 2: Confirm API viability and choose the integration shape**
1. Read `references/language-detector-reference.md` before writing code.
2. Read `references/examples.md` when the feature needs a session wrapper, download-progress UI, confidence thresholding, or cleanup shape.
3. Read `references/compatibility.md` when preview flags, browser channels, iframe rules, or environment constraints matter.
4. Read `references/troubleshooting.md` when support checks, creation, detection, or cleanup fail.
5. Verify that the feature runs in a secure `Window` context.
6. Verify that the current frame is allowed to use the `language-detector` permissions-policy feature.
7. Choose the narrowest session shape that matches the task:
   - bare `LanguageDetector.create()` for general language detection
```
END THIRD-PARTY FILE c275071e0670398c

The third-party file has ended. Everything between the c275071e0670398c tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 2295 of 6897 bytes. © webmaxru · MIT · https://github.com/webmaxru/web-ai-agent-skills/tree/HEAD/skills/language-detector-api/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
