Implements and debugs browser Web Neural Network API integrations in JavaScript or TypeScript web apps. Use when adding navigator.ml checks, MLContext creation, MLGraphBuilder flows, device selection, tensor dispatch and readback, or explicit fallback paths to ONNX Runtime Web or other local runtimes. Don't use for model training, server-side ML inference, or cloud AI APIs.
76
96%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
View guide
—
The risk profile of this skill
Step 1: Identify the browser integration surface
node scripts/find-webnn-targets.mjs . to inventory likely frontend files and existing WebNN markers when a Node runtime is available.package.json, HTML entry point, framework bootstrap files, and worker entry files manually to identify the browser app boundary.Step 2: Confirm WebNN viability and choose the runtime shape
references/webnn-reference.md before writing code.references/examples.md when choosing between a direct WebNN graph flow and an adapter around an existing browser ML runtime.references/compatibility.md when native support, preview flags, device behavior, or backend differences matter.references/troubleshooting.md when context creation, graph build, tensor readback, or device selection fails.Window or Worker context (DedicatedWorker, SharedWorker, or ServiceWorker).powerPreference: "high-performance" for throughput, powerPreference: "low-power" for power-efficient acceleration, or accelerated: false to prefer CPU inference for maximum reach.accelerated and powerPreference as preferences, not guarantees. Browser backends can still partition graphs or fall back per operator.MLGraphBuilder flow when the application owns graph construction or can keep a small deterministic graph path.Step 3: Implement a guarded runtime adapter
assets/webnn-runtime.template.ts and adapt it to the framework, state model, and file layout in the workspace.window.isSecureContext, navigator.ml, and the requested execution context instead of scattering checks through UI components.MLContext only at the boundary where the app is ready to initialize local inference.accelerated and powerPreference values when the product has a real preference, and omit tuning that the product cannot justify.MLGraphBuilder when the feature uses direct WebNN operations, or route existing model execution through the app's existing local runtime adapter when that runtime is already responsible for model loading and pre/post-processing.context.writeTensor(), context.dispatch(), and await context.readTensor() in that order for direct graph execution.context.lost and rebuild the context, graph, and tensors if the browser invalidates the execution state.Step 4: Wire UX and fallback behavior
Step 5: Validate behavior
node scripts/find-webnn-targets.mjs . to confirm that the intended app boundary and WebNN markers still resolve to the edited integration surface.navigator.ml detection before debugging deeper runtime issues.accelerated and powerPreference settings and confirm that fallback behavior remains usable when an accelerated context cannot be created.context.opSupportLimits() when operator coverage or tensor data type support influences graph design.references/compatibility.md before treating runtime failures as application bugs.navigator.ml is missing, confirm secure-context requirements and browser support from references/compatibility.md before changing application code.createContext() fails for an accelerated or high-performance request, retry only through the product's approved fallback plan and surface the failure reason.build() or dispatch() fails, check references/examples.md and references/troubleshooting.md for operator, shape, and device mismatches before rewriting the feature.context.lost resolves, treat the current context, graph, and tensors as invalid and recreate them before the next inference attempt.f4c5a23
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.