monorepo-template / frontend
Cursor rule18 starsChanged 59 days agoApache-2.0View on GitHub
Tailwind CSS v4 - CSS-first config, @source detection, @theme tokens, semantic dark-mode tokens, static-string classes.
Where files are headingNew Cursor rule files have more rules about planning and tracking tasks, and fewer about code style.
Of the Cursor rule files we read, the 1,531 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository60 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .agents/skills/vercel-react-best-practices/AGENTS.mdAGENTS.md
- hooks/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- hooks/CLAUDE.mdCLAUDE.md
- .cursor/rules/backend/hono-gateway.mdcCursor rule
- .cursor/rules/backend/ports.mdcCursor rule
- .cursor/rules/backend/service-bindings.mdcCursor rule
- .cursor/rules/backend/workers-cache.mdcCursor rule
- .cursor/rules/backend/workers-config.mdcCursor rule
- .cursor/rules/contracts/contracts.mdcCursor rule
- .cursor/rules/core/agent-instructions.mdcCursor rule
- .cursor/rules/core/boundaries.mdcCursor rule
- .cursor/rules/core/guardrails.mdcCursor rule
- .cursor/rules/core/turborepo.mdcCursor rule
- .cursor/rules/core/worktrees.mdcCursor rule
- .cursor/rules/frontend/react.mdcCursor rule
- .cursor/rules/frontend/tanstack-query.mdcCursor rule
- .cursor/rules/frontend/tanstack-router.mdcCursor rule
- .cursor/rules/frontend/vite-config.mdcCursor rule
- .cursor/rules/ops/cd.mdcCursor rule
- .cursor/rules/ops/changesets.mdcCursor rule
- .cursor/rules/ops/ci.mdcCursor rule
- .cursor/rules/ops/previews.mdcCursor rule
- .cursor/rules/ops/quality-report.mdcCursor rule
- .cursor/rules/ops/release.mdcCursor rule
- .cursor/rules/quality/code-style.mdcCursor rule
- .cursor/rules/quality/comments.mdcCursor rule
- .cursor/rules/quality/knip.mdcCursor rule
- .cursor/rules/quality/lint-config.mdcCursor rule
- .cursor/rules/quality/markdown-style.mdcCursor rule
- .cursor/rules/quality/naming.mdcCursor rule
- .cursor/rules/quality/simplicity.mdcCursor rule
- .cursor/rules/quality/testing.mdcCursor rule
- .cursor/rules/quality/typescript-config.mdcCursor rule
- .cursor/rules/tests/front-react.mdcCursor rule
- .cursor/rules/tests/hono-workers.mdcCursor rule
- cfSkill
- changesetSkill
- front-vitestSkill
- git-commitSkill
- honoSkill
- monorepo-agent-setupSkill
- playwright-cliSkill
- pnpmSkill
- react-doctorSkill
- reviewSkill
- review-stackSkill
- run-appSkill
- security-auditSkill
- skills-updateSkill
- tanstack-configSkill
- tanstack-devtoolsSkill
- tanstack-querySkill
- tanstack-routerSkill
- turborepoSkill
- ui-ux-design-best-practicesSkill
- vercel-react-best-practicesSkill
- workers-best-practicesSkill
- skills-updateSkill
The file
We split this tailwind.mdc into the rules it gives an agent
1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 27
Never hardcode a single-theme palette: text-slate-200 / bg-white/5 assume one background and become unreadable on the other scheme.
≈ “Common” is an estimate: at least 1 in 5 of the 3,030 Cursor rule files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
---
description: "Tailwind CSS v4 - CSS-first config, @source detection, @theme tokens, semantic dark-mode tokens, static-string classes."
alwaysApply: false
globs: apps/front-*/src/**/*.{ts,tsx,css},apps/front-*/index.html
---
# Tailwind CSS v4
CSS-first v4: there is no `tailwind.config.js` / `postcss.config.js`. Motion and interaction depth: skill `ui-ux-design-best-practices`. Lint configuration: [lint-config.mdc](../quality/lint-config.mdc).
## Engine and source detection
- Single entry `@import "tailwindcss";` in `src/index.css` (canonical: `apps/front-app/src/index.css`), built by `@tailwindcss/vite` with Lightning CSS built in - no Autoprefixer/PostCSS step. Plugin order: [vite-config.mdc](vite-config.mdc).
- v4 detects sources automatically from the build's working directory (per app here), skipping `.gitignore`, `node_modules`, binaries, CSS, and lockfiles. The current `@source "../index.html"` + `@source "./**/*.{ts,tsx}"` defensively restate that default; keep them so detection stays cwd-independent.
- Register a workspace package only when it ships Tailwind classes this app renders, pointing at its real source (`@source "../../../packages/<pkg>/src";`), not the `node_modules` symlink. `@repo/dtos-common` / `@repo/enums-common` are class-free: never add them.
- `@source not "<path>";` excludes a large non-Tailwind directory. `@source inline("...")` safelists classes that never appear as literals - a last resort; prefer static strings.
## Tokens: `@theme` vs `:root`
- `@theme` only for a value that must generate a utility or variant, i.e. one in a Tailwind namespace (`--color-*`, `--spacing-*`, `--font-*`, `--radius-*`, `--shadow-*`, `--ease-*`, `--animate-*`, `--breakpoint-*`). `@theme` is top-level only (no nesting under selectors or media). Every other custom property stays in plain `:root` (e.g. `--health-glow-color`).
- `@keyframes` for an `--animate-*` token nest inside `@theme`, so they travel with the token.
- `@theme inline` when a token's value is itself a `var(...)` (semantic theming), so the utility resolves per scope instead of baking in one value.
- Font stacks are tokens (`@theme { --font-sans: ... }`, which preflight applies to `html`), never `font-family` on `:root`.
## Theming and dark mode
- Never hardcode a single-theme palette: `text-slate-200` / `bg-white/5` assume one background and become unreadable on the other scheme. With `color-scheme: light dark`, colors must adapt in both.
- Pattern: raw values in `:root` plus a dark scope, re-exposed as semantic `@theme inline` tokens that components use in both themes; add `--card` / `--border` / `--muted-foreground` / `--primary` the same way:
```css
:root { --background: oklch(1 0 0); --foreground: oklch(0.145 0 0); }
@media (prefers-color-scheme: dark) {
:root { --background: oklch(0.13 0 0); --foreground: oklch(0.985 0 0); }
}
@theme inline {
--color-background: var(--background);
--color-foreground: var(--foreground);
}
```
- `dark:` follows `prefers-color-scheme`. A manual class/attribute toggle declares the strategy once: `@custom-variant dark (&:where([data-theme="dark"], [data-theme="dark"] *));`.
## Custom styles
- `@apply` lives only in the global `index.css`, base element styles in `@layer base`; no per-feature `.css` files that `@apply`.
- `@layer base` holds true global resets only (`body`, `a`, …). App-shell layout (the `max-w-*` / `p-8` wrapper) and per-page type sizing are JSX utilities - the shell on the `RootLayout` wrapper in `__root.tsx`, heading sizes on the page's `<h1>` - never `#root` / `h1` rules in base CSS.
- New reusable utilities → `@utility name { ... }` (works with variants); new variants → `@custom-variant`.
- A separately bundled stylesheet (CSS module, scoped `<style>`) that uses `@apply` / `@variant` must first `@reference "<entry>.css";` - but prefer plain `var(--color-*)` there, because `@reference` reprocesses the file and slows builds.
## Classes in components
- Utilities in JSX; factor repetition into `src/components/ui/` primitives composed with `cx()` (see `Button.tsx`, `Card.tsx`).
- Variants are a `Record<Variant, string>` of complete, static class strings. Never build a class by interpolation (`` `bg-${color}-500` ``): the scanner reads source as plain text and will not emit it.
- A runtime value goes in `style` as a CSS variable, consumed with the v4 parentheses shorthand: `className="bg-(--brand)"` (= `bg-[var(--brand)]`; not v3 `bg-[--brand]`).
- **Every `className` token must be a Tailwind utility or a `@theme` token** - `no-unknown-classes` rejects typos, hallucinated utilities, and raw CSS class names; introduce a semantic token or an `@utility` instead. Use the canonical shorthands the linter enforces (`size-2.5`, not `h-2.5 w-2.5`); `pnpm lint:fix` fixes the fixable ones, and `oxfmt` owns class order.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

