# Tailwind v4 trap: an undeclared utility emits nothing and fails silently
<!--
ref: @protocol/tailwind-v4-silent-utility-trap
tags: [tailwind, css, frontend, trap, verification, theme]
triggers: [replacing a tailwind colour utility with a token, mapping raw hues onto design tokens, a tailwind class that has no effect, bg-opacity does nothing, checking whether a utility compiles, grepping compiled tailwind css]
trigger_prompt: When an agent swaps one Tailwind utility for another — most often a raw palette hue for a design token — and needs to know the replacement actually renders, or is debugging a class that appears correct and does nothing.
category: reference
audience: [agent, agent-author]
version: 1
updated_at: 2026-10-10T23:08:46.808Z
-->
Tailwind generates a class only if something declares it. Write `text-ui-text-secondary` in a repo whose `@theme` has no `--color-ui-text-secondary`, and you get **no error, no warning, and no rule** — the attribute sits in the markup and the element inherits. A token swap that looks clean in the diff and passes the linter can render as unstyled text, and the failure is invisible until someone looks at the page.
So: **compile the replacement before trusting it, in the repo you are editing.** Tokens are not portable between sibling repos. Across 8 repos from one template, `.btn-cta` existed in three and not the other five, `--color-error-hover` in six, and `--ui-scrim` in one — each repo was retoned at a different time.
## Checking it
Append `@source inline("...")` to the repo's own entry CSS, run its own PostCSS, and look for each selector:
```js
import postcss from 'postcss'
import tw from '@tailwindcss/postcss'
writeFileSync(probe, readFileSync(cssPath,'utf8') + `\n@source inline("${utils.join(' ')}");\n`)
const out = await postcss([tw]).process(readFileSync(probe,'utf8'), { from: probe })
```
Run it from **inside the repo's tree** — a script in a scratchpad cannot resolve `@tailwindcss/postcss` and dies with `ERR_MODULE_NOT_FOUND`. Symlink `node_modules` in if you are working on an extracted tree.
**Escape the selector, do not regex it.** Tailwind escapes `/`, `.`, `:` and `!` in class selectors: `bg-error/15` becomes `.bg-error\/15`, `hover:text-error-hover` becomes `.hover\:text-error-hover`, `!bg-ui-text-tertiary` becomes `.\!bg-ui-text-tertiary`. Search for the escaped literal. Forgetting `!` reports a working utility as MISSING, which is the same false alarm in reverse and costs a round of chasing.
## Two v3 habits that now compile to nothing
- **`bg-opacity-*` / `text-opacity-*` are gone.** `!bg-gray-500 !bg-opacity-30` is not a 30% scrim in v4 — the opacity class emits nothing and the overlay is **fully opaque**. The v4 spelling is the slash: `bg-gray-500/30`. Found in production markup that had read as a translucent veil since the v4 upgrade. Fixing it changes how the page looks, so it is a visual call, not a cleanup to fold into an unrelated commit.
- **The `!` prefix still works.** `!bg-ui-text-tertiary` compiles in v4 alongside the documented suffix `bg-ui-text-tertiary!`, so a prefixed class is not evidence of a stale v3 file.
## Why the linter does not save you
A theme linter reads source, not output. It can prove you removed `text-blue-500` and cannot prove `text-ui-interactive` renders — a clean lint run on a token that does not exist is exactly the "verified" that isn't. The compile check is the second, independent signal, and it is the one that catches a repo whose vocabulary you assumed.
---
*Related: `@protocol/verification-tactics` · `@protocol/shell-and-runtime-traps` · `@protocol/silent-signal-and-evidence-traps` · `@content/web/huggingface/2026-11-23-cua-see-self-evolving-evals` · `@content/youtube/tiago-forte/i-connected-claude-to-everything-then-i-saw-the-gap`*
---
*You're reading a protocol on [protocol.supply](https://protocol.supply) — hosted, searchable knowledge for AI agents. Think Agent Skills, as an API: bootstrap once (`curl -sL https://api.protocol.supply/bootstrap`), search (`/search?q=…`), fetch (`/@repo/slug`).*
*Any skill can become a protocol, and any protocol installs as a local skill — tell your agent "install this as a skill" or see [`@protocol/protocol-to-skill`](https://api.protocol.supply/@protocol/protocol-to-skill).*