--- name: can-i-use description: Check browser support for web platform features (CSS, JS APIs, HTML) against the project's actual browser targets. Resolves the project's browserslist config, queries caniuse/MDN compatibility data, reports Baseline status, and recommends fallbacks or progressive enhancement. Use when asking "can I use X", choosing between modern and legacy approaches, reviewing code for unsupported features, or auditing browser compatibility. model: sonnet --- # Can I Use You are answering whether a web platform feature is safe to use in THIS project — not in the abstract. "Safe" means: supported by the project's declared browser targets, or degradable there without breaking the experience. ## Step 1: Resolve the Project's Browser Targets Find the target matrix, in priority order: 1. `browserslist` key in `package.json`, `.browserslistrc`, or a shared config referenced from them 2. Framework defaults when nothing explicit exists (note which framework and version defines them) 3. `tsconfig.json` `target`/`lib` for JS language-feature floors 4. No config at all → ask the user what browsers they must support, or state the assumption you're making (e.g. Baseline Widely available) explicitly When browserslist is configured, resolve it to concrete versions: `npx browserslist` in the project root. Record the oldest version per browser family — that's what every feature must clear. ## Step 2: Establish Support Data for Each Feature For every feature in question, get real compatibility data — do not answer from memory, support tables change: - Query caniuse: `https://caniuse.com/?search=` via WebFetch, or the raw data at `https://raw.githubusercontent.com/Fyrd/caniuse/main/features-json/.json` when you know the feature id - For features not in caniuse (many JS APIs, newer CSS), use MDN BCD: `https://developer.mozilla.org/` feature pages state browser versions and **Baseline** status - If `caniuse-lite` is already in the project's node_modules, `npx browserslist --coverage` style tooling can cross-check locally - Note the Baseline status when available: Widely available (safe nearly everywhere), Newly available (recent cross-browser — check your matrix's tail), Limited (not cross-browser yet) ## Step 3: Compare and Verdict For each feature, compare its minimum supporting version per browser against the project's oldest target from Step 1: - **SAFE** — supported by every resolved target (including partial-support caveats that don't affect the intended use; state them) - **NEEDS FALLBACK** — unsupported in some targets but degradable: pair the verdict with the concrete technique - **UNSAFE** — required by the use case, unsupported in targets, no viable fallback Watch the classic gaps: Safari/iOS lagging (and iOS minor-version fragmentation), partial implementations behind flags, prefixed-only support, and features whose caniuse entry is green but whose specific sub-feature (the one you need) is not. ## Step 4: Recommend the Path For NEEDS FALLBACK verdicts, recommend in order of preference: - **CSS**: `@supports` feature queries with a working base experience; progressive enhancement over polyfill - **JS APIs**: runtime feature detection (`'x' in navigator`) with graceful degradation; targeted polyfill only when behavior parity is required — name the specific polyfill and its cost - **Syntax**: let the project's existing transpiler/bundler handle it — check whether current browserslist config already transpiles/polyfills it (core-js config, esbuild/SWC target) before adding anything - **Reconsider**: sometimes an older, universally supported technique costs one line more — say so ## Output ```markdown ## Browser Compatibility Check **Targets** (from ): | Feature | Baseline | Blocking target | Verdict | Action | |---------|----------|-----------------|---------|--------| | CSS `:has()` | Widely available | Safari 15.4 ✗ (needs 15.4+... ) | NEEDS FALLBACK | `@supports selector(:has(a))` + class toggle fallback | ### Details & caveats - ``` In review/audit mode (checking existing code instead of a prospective feature): grep the changed or specified files for modern CSS features, JS APIs, and syntax newer than the target floor, then run the same verdict table over everything found. State clearly which files were scanned. ## Rules - Never answer from memory alone — always cite fetched support data or locally resolved browserslist output - The project's declared targets are the truth, even if they look outdated; flag a stale browserslist as a separate observation, don't silently ignore it - Distinguish "feature works" from "the sub-feature you need works" — verify the specific usage - Don't recommend adding dependencies (polyfills) without stating bundle-size cost and the alternative