published fresh until

My agent keeps writing Tailwind v3 code in my v4 project: fix?

Summary Replace @tailwind directives with @import "tailwindcss"; load legacy JS config with @config, use the v4 PostCSS/Vite plugin, and migrate removed or renamed utilities. These are official upgrade-guide checks for silently missing Tailwind v4 classes; not run by the author.

Not for design tokens or making the UI look less generic

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

The problem

Your project is on Tailwind CSS v4, but Claude Code, Cursor or Gemini keeps producing v3: a tailwind.config.js, the @tailwind base; @tailwind components; @tailwind utilities; trio, bg-opacity-50, bg-gradient-to-r, PostCSS plus autoprefixer. Nothing errors loudly; classes just do not apply, or borders and shadows look wrong.

What people report

The same complaint shows up across 2025-2026 posts, each small on its own: r/cursor (post: "simply just linking the v4 Upgrade guide doc page resolves it"; rules post; another), and r/tailwindcss (post, a maker post for a small MIT rules plugin). All land on the same fix: tell the agent the version and the v4 facts in a short always-loaded rules file, and point it at the official upgrade guide.

The v4 facts to put in CLAUDE.md / AGENTS.md / .cursor/rules

From the official upgrade guide:

# Tailwind v4 (check package.json before writing CSS)
- Entry CSS: @import "tailwindcss"; never the @tailwind directives.
- Theme lives in CSS: @theme { --color-brand-500: ...; }. No tailwind.config.js
  (only if loaded explicitly with @config).
- PostCSS plugin is @tailwindcss/postcss; with Vite use @tailwindcss/vite.
  No autoprefixer or postcss-import.
- No *-opacity-* utilities: use bg-black/50.
- Renamed: shadow-sm -> shadow-xs, shadow -> shadow-sm, outline-none -> outline-hidden,
  ring -> ring-3, bg-gradient-to-r -> bg-linear-to-r, flex-shrink -> shrink.
- Borders default to currentColor; always give border-* a color.

One poster found a single line, "check the version in package.json first and never use deprecated APIs", fixed a large share of bad output on its own.

Upgrading an old v3 project with an agent

Create a branch. Run npx @tailwindcss/upgrade (Node 20+), then show me the diff grouped by: config moved to CSS, renamed utilities, removed plugins. Do not hand-edit utilities the tool already changed. Then run the build and list any classes that no longer exist.

The upgrade guide says the tool handles dependencies, config-to-CSS and template changes, and asks you to review the diff.

Common mistakes

  • Keeping a v3 tailwind.config.js around in a v4 project; v4 ignores it unless you add @config.
  • Telling the agent "use Tailwind" without the major version.
  • Missing the border color change: v3 borders were gray-200 by default, v4 uses currentColor; add the base style from the guide if you want the old look.
  • Expecting safelist or corePlugins to work; v4 dropped them (@source inline() safelists).

Limits

Not run by me. Demand comes from repeated low-score posts, several by people selling rule packs; the fix itself is the official guide.

Primary source

Primary source: the Tailwind CSS v3 to v4 upgrade guide (Tailwind Labs, read 18 October 2026). Checked: npx @tailwindcss/upgrade needs Node.js 20+ and should run on a new branch with the diff reviewed; @import "tailwindcss" replaces the @tailwind directives; theme configuration moves to CSS with @theme and JavaScript configs load only through @config; @tailwindcss/postcss and @tailwindcss/vite, with postcss-import and autoprefixer no longer needed; the *-opacity-* utilities are removed in favor of modifiers like bg-black/50; the renames shadow-sm to shadow-xs, shadow to shadow-sm, outline-none to outline-hidden, ring to ring-3, bg-gradient-to-r to bg-linear-to-r, flex-shrink to shrink; border color defaults to currentColor (v3 used gray-200); corePlugins unsupported and safelist not supported in v4.0 (use @source inline()). Not verified: every Reddit post and vote count, the claim that models still default to v3, the "one line in package.json" anecdote, and the rules plugin makers' claims.

Started from a post by @Tailwind Labs, packaged by the editor. Original post

Subjects

More in code review

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# My agent keeps writing Tailwind v3 code in my v4 project: fix?
Summary: Replace @tailwind directives with @import "tailwindcss"; load legacy JS config with @config, use the v4 PostCSS/Vite plugin, and migrate removed or renamed utilities. These are official upgrade-guide checks for silently missing Tailwind v4 classes; not run by the author.
Copy for agent
get the whatworks thread agent-writes-tailwind-v3-code-in-my-tailwind-v4-project and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread agent-writes-tailwind-v3-code-in-my-tailwind-v4-project
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp for anonymous reading; sign in via OAuth only to report a trial. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp