tailwind-usage

Tailwind 优先、Less 兜底;避免双写与深层选择器滥用.

Cursor rule for Cursor

View the source file n9e/fe
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/n9e/fe/tailwind-usage
Clone the repo
git clone --depth 1 https://github.com/n9e/fe

Made for: Cursor.

Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 593 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin unknown No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.00593
Opus 5 $0.00000 $0.00296
Sonnet 5 $0.00000 $0.00119
Haiku 4.5 $0.00000 $0.00059

Measured today against content hash fba48ff439bc, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

tailwind-usage scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured today.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.cursor/rules/tailwind-usage.mdc · 47 lines

What it actually says

样式:Tailwind 优先 + 少量 Less

全局约定(颜色变量、最小改动等)见 .cursor/rules/app.mdc

原则

  1. 能直接用 Tailwind 表达的(布局、间距、排版、圆角、常见交互态)→ 用 Tailwind。
  2. Tailwind 不划算或做不到的 → 少量 Less/CSS,选择器尽量收束在页面/模块根类名下。
  3. 同一视觉属性不要同时被 Tailwind 与 Less 争抢(避免难排查的覆盖问题)。

优先用 Tailwind

  • 容器布局:flex / grid / gap / 内外边距 / 对齐。
  • 业务界面:按钮、表单外观、文案层级、状态色(需与主题变量一致时,用已有 Tailwind 主题映射或 CSS 变量类,不硬编码色值)。
  • 局部状态:hover / focus / disabled 等。
  • 仅当前组件使用的展示类样式。

用 Less / 普通 CSS 更合适的情况

  • 覆盖第三方组件内部结构(如 antd 深层节点、复杂表格头)。
  • 全局或跨多页复用的 token、keyframes、无法用工具类清晰表达的动画。
  • 强依赖复杂选择器(深层后代、兄弟组合、兼容向 hack 等)。

Less/CSS 侧要求:

  • 选择器尽量局部化;嵌套不宜过深(≤3 层为宜)。
  • 不复制一套与 Tailwind 等价的冗长规则。

实践技巧

  • 可在 className 中使用 antd 定向写法(如 [&_.ant-input-affix-wrapper])以减少裸 Less。
  • 单处 className 过长时,抽成本地常量字符串或小组件,不要为此回到大段 Less。
  • 改旧页面时优先增量迁移:先动当前需求触及的区块(如工具栏、列表行),再逐步收拢公共块。

自检

  • 是否出现 Tailwind 与 Less 同时控制同一属性
  • 是否新增了大段可被 Tailwind 替代的 Less?
  • 明暗主题下视觉是否与现有变量体系一致?
Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. today First seen · 47 lines · 0 tokens per session scan A fba48ff439bc

Subscribe to this mod's changes

tailwind-usage is a cursor rule published in the GitHub repository n9e/fe (302 stars, last pushed today), licensed Apache-2.0. It costs nothing until one of its globs matches a file; then it loads 593 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-01.