tailwind-validator by shipshitdev/library
npx skills add https://github.com/shipshitdev/library --skill tailwind-validator验证项目是否正确使用 Tailwind CSS v4 并采用 CSS 优先配置。检测并标记应迁移的 Tailwind v3 模式。
关键提示:Claude 和其他 AI 助手通常默认使用 Tailwind v3 模式。此技能确保:
tailwind.config.js 模式@theme 块而非 JS 配置# 验证当前项目
python3 ~/.claude/skills/tailwind-validator/scripts/validate.py --root .
# 验证并提供自动修复建议
python3 ~/.claude/skills/tailwind-validator/scripts/validate.py --root . --suggest-fixes
# 严格模式(任何 v3 模式均视为失败)
python3 ~/.claude/skills/tailwind-validator/scripts/validate.py --root . --strict
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
// 良好:v4+
"tailwindcss": "^4.0.0"
// 不良:v3
"tailwindcss": "^3.4.0"
良好 - Tailwind v4:
/* app.css 或 globals.css */
@import "tailwindcss";
@theme {
--color-primary: #3b82f6;
--color-secondary: #64748b;
--font-sans: "Inter", sans-serif;
--breakpoint-3xl: 1920px;
}
不良 - Tailwind v3:
/* 旧的 v3 指令 */
@tailwind base;
@tailwind components;
@tailwind utilities;
不良 - v4 中不应存在:
tailwind.config.jstailwind.config.tstailwind.config.mjstailwind.config.cjs注意:这些文件在 v4 中已弃用。所有配置都应使用 @theme 在 CSS 中完成。
良好 - v4:
// postcss.config.js(最小化或不需要)
export default {
plugins: {
'@tailwindcss/postcss': {},
},
};
不良 - v3:
// postcss.config.js
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
};
良好:
@import "tailwindcss";
@import "tailwindcss/preflight";
@import "tailwindcss/utilities";
不良:
@tailwind base;
@tailwind components;
@tailwind utilities;
=== Tailwind 4 验证报告 ===
包版本:tailwindcss@4.0.14 ✓
CSS 配置:
✓ 在 src/app/globals.css 中找到 @import "tailwindcss"
✓ 找到包含 12 个自定义属性的 @theme 块
✗ 在 src/styles/legacy.css 中找到 @tailwind 指令(第 3 行)
配置文件:
✗ 找到 tailwind.config.ts - 应迁移到 CSS @theme
PostCSS:
✓ 使用 @tailwindcss/postcss 插件
摘要:发现 2 个问题
- 将 tailwind.config.ts 迁移到 CSS 中的 @theme
- 从 src/styles/legacy.css 中移除 @tailwind 指令
bun remove tailwindcss autoprefixer
bun add tailwindcss@latest @tailwindcss/postcss
export default {
plugins: {
'@tailwindcss/postcss': {},
},
};
之前(v3):
// tailwind.config.js
module.exports = {
theme: {
extend: {
colors: {
primary: '#3b82f6',
secondary: '#64748b',
},
fontFamily: {
sans: ['Inter', 'sans-serif'],
},
},
},
};
之后(v4):
/* globals.css */
@import "tailwindcss";
@theme {
--color-primary: #3b82f6;
--color-secondary: #64748b;
--font-sans: "Inter", sans-serif;
}
之前:
@tailwind base;
@tailwind components;
@tailwind utilities;
之后:
@import "tailwindcss";
rm tailwind.config.js tailwind.config.ts
| v3 模式 | v4 替代方案 |
|---|---|
@tailwind base | @import "tailwindcss" |
@tailwind utilities | @import "tailwindcss/utilities" |
tailwind.config.js | CSS 中的 @theme 块 |
theme.extend.colors | --color-* CSS 变量 |
theme.extend.spacing | --spacing-* CSS 变量 |
theme.extend.fontFamily | --font-* CSS 变量 |
content: ['./src/**/*.tsx'] | 不需要(自动检测) |
plugins: [require('@tailwindcss/forms')] | @plugin "@tailwindcss/forms" |
@import "tailwindcss";
@theme {
/* 颜色 */
--color-primary: #3b82f6;
--color-primary-50: #eff6ff;
--color-primary-900: #1e3a8a;
/* 排版 */
--font-sans: "Inter", system-ui, sans-serif;
--font-mono: "JetBrains Mono", monospace;
/* 间距(扩展默认比例) */
--spacing-128: 32rem;
/* 断点 */
--breakpoint-3xl: 1920px;
/* 动画 */
--animate-fade-in: fade-in 0.3s ease-out;
/* 阴影 */
--shadow-glow: 0 0 20px rgba(59, 130, 246, 0.5);
/* 边框半径 */
--radius-4xl: 2rem;
}
@keyframes fade-in {
from { opacity: 0; }
to { opacity: 1; }
}
shadcn/ui v2+ 支持 Tailwind v4。运行 shadcn CLI 后:
components.json 使用 CSS 变量@theme 包含 shadcn 颜色标记:@theme {
--color-background: hsl(0 0% 100%);
--color-foreground: hsl(222.2 84% 4.9%);
--color-card: hsl(0 0% 100%);
--color-card-foreground: hsl(222.2 84% 4.9%);
--color-popover: hsl(0 0% 100%);
--color-popover-foreground: hsl(222.2 84% 4.9%);
--color-primary: hsl(222.2 47.4% 11.2%);
--color-primary-foreground: hsl(210 40% 98%);
--color-secondary: hsl(210 40% 96.1%);
--color-secondary-foreground: hsl(222.2 47.4% 11.2%);
--color-muted: hsl(210 40% 96.1%);
--color-muted-foreground: hsl(215.4 16.3% 46.9%);
--color-accent: hsl(210 40% 96.1%);
--color-accent-foreground: hsl(222.2 47.4% 11.2%);
--color-destructive: hsl(0 84.2% 60.2%);
--color-destructive-foreground: hsl(210 40% 98%);
--color-border: hsl(214.3 31.8% 91.4%);
--color-input: hsl(214.3 31.8% 91.4%);
--color-ring: hsl(222.2 84% 4.9%);
--radius-sm: 0.25rem;
--radius-md: 0.375rem;
--radius-lg: 0.5rem;
}
添加到 CI 流水线:
# .github/workflows/lint.yml
- name: 验证 Tailwind v4
run: |
python3 ~/.claude/skills/tailwind-validator/scripts/validate.py \
--root . \
--strict \
--ci
某些工具仍会生成 v3 配置。删除该文件并使用 @theme 替代。
替换为 @import "tailwindcss"。旧指令在 v4 中不受支持。
移除 autoprefixer - 它已内置到 @tailwindcss/postcss 中。
v4 自动检测内容文件。完全移除 content 配置。
每周安装数
77
仓库
GitHub 星标数
18
首次出现
2026年1月20日
安全审计
安装于
codex56
opencode53
gemini-cli52
claude-code51
cursor51
github-copilot45
Validates that a project uses Tailwind CSS v4 with proper CSS-first configuration. Detects and flags Tailwind v3 patterns that should be migrated.
CRITICAL : Claude and other AI assistants often default to Tailwind v3 patterns. This skill ensures:
tailwind.config.js patterns are detected and flagged@theme blocks are used instead of JS config# Validate current project
python3 ~/.claude/skills/tailwind-validator/scripts/validate.py --root .
# Validate with auto-fix suggestions
python3 ~/.claude/skills/tailwind-validator/scripts/validate.py --root . --suggest-fixes
# Strict mode (fail on any v3 pattern)
python3 ~/.claude/skills/tailwind-validator/scripts/validate.py --root . --strict
// GOOD: v4+
"tailwindcss": "^4.0.0"
// BAD: v3
"tailwindcss": "^3.4.0"
GOOD - Tailwind v4:
/* app.css or globals.css */
@import "tailwindcss";
@theme {
--color-primary: #3b82f6;
--color-secondary: #64748b;
--font-sans: "Inter", sans-serif;
--breakpoint-3xl: 1920px;
}
BAD - Tailwind v3:
/* Old v3 directives */
@tailwind base;
@tailwind components;
@tailwind utilities;
BAD - Should not exist in v4:
tailwind.config.jstailwind.config.tstailwind.config.mjstailwind.config.cjsNote : These files are deprecated in v4. All configuration should be in CSS using @theme.
GOOD - v4:
// postcss.config.js (minimal or not needed)
export default {
plugins: {
'@tailwindcss/postcss': {},
},
};
BAD - v3:
// postcss.config.js
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
};
GOOD:
@import "tailwindcss";
@import "tailwindcss/preflight";
@import "tailwindcss/utilities";
BAD:
@tailwind base;
@tailwind components;
@tailwind utilities;
=== Tailwind 4 Validation Report ===
Package Version: tailwindcss@4.0.14 ✓
CSS Configuration:
✓ Found @import "tailwindcss" in src/app/globals.css
✓ Found @theme block with 12 custom properties
✗ Found @tailwind directive in src/styles/legacy.css (line 3)
Config Files:
✗ Found tailwind.config.ts - should migrate to CSS @theme
PostCSS:
✓ Using @tailwindcss/postcss plugin
Summary: 2 issues found
- Migrate tailwind.config.ts to @theme in CSS
- Remove @tailwind directives from src/styles/legacy.css
bun remove tailwindcss autoprefixer
bun add tailwindcss@latest @tailwindcss/postcss
export default {
plugins: {
'@tailwindcss/postcss': {},
},
};
Before (v3):
// tailwind.config.js
module.exports = {
theme: {
extend: {
colors: {
primary: '#3b82f6',
secondary: '#64748b',
},
fontFamily: {
sans: ['Inter', 'sans-serif'],
},
},
},
};
After (v4):
/* globals.css */
@import "tailwindcss";
@theme {
--color-primary: #3b82f6;
--color-secondary: #64748b;
--font-sans: "Inter", sans-serif;
}
Before:
@tailwind base;
@tailwind components;
@tailwind utilities;
After:
@import "tailwindcss";
rm tailwind.config.js tailwind.config.ts
| v3 Pattern | v4 Replacement |
|---|---|
@tailwind base | @import "tailwindcss" |
@tailwind utilities | @import "tailwindcss/utilities" |
tailwind.config.js | @theme block in CSS |
theme.extend.colors | --color-* CSS variables |
@import "tailwindcss";
@theme {
/* Colors */
--color-primary: #3b82f6;
--color-primary-50: #eff6ff;
--color-primary-900: #1e3a8a;
/* Typography */
--font-sans: "Inter", system-ui, sans-serif;
--font-mono: "JetBrains Mono", monospace;
/* Spacing (extends default scale) */
--spacing-128: 32rem;
/* Breakpoints */
--breakpoint-3xl: 1920px;
/* Animations */
--animate-fade-in: fade-in 0.3s ease-out;
/* Shadows */
--shadow-glow: 0 0 20px rgba(59, 130, 246, 0.5);
/* Border radius */
--radius-4xl: 2rem;
}
@keyframes fade-in {
from { opacity: 0; }
to { opacity: 1; }
}
shadcn/ui v2+ supports Tailwind v4. After running the shadcn CLI:
components.json uses CSS variables@theme includes shadcn color tokens:@theme {
--color-background: hsl(0 0% 100%);
--color-foreground: hsl(222.2 84% 4.9%);
--color-card: hsl(0 0% 100%);
--color-card-foreground: hsl(222.2 84% 4.9%);
--color-popover: hsl(0 0% 100%);
--color-popover-foreground: hsl(222.2 84% 4.9%);
--color-primary: hsl(222.2 47.4% 11.2%);
--color-primary-foreground: hsl(210 40% 98%);
--color-secondary: hsl(210 40% 96.1%);
--color-secondary-foreground: hsl(222.2 47.4% 11.2%);
--color-muted: hsl(210 40% 96.1%);
--color-muted-foreground: hsl(215.4 16.3% 46.9%);
--color-accent: hsl(210 40% 96.1%);
--color-accent-foreground: hsl(222.2 47.4% 11.2%);
--color-destructive: hsl(0 84.2% 60.2%);
--color-destructive-foreground: hsl(210 40% 98%);
--color-border: hsl(214.3 31.8% 91.4%);
--color-input: hsl(214.3 31.8% 91.4%);
--color-ring: hsl(222.2 84% 4.9%);
--radius-sm: 0.25rem;
--radius-md: 0.375rem;
--radius-lg: 0.5rem;
}
Add to your CI pipeline:
# .github/workflows/lint.yml
- name: Validate Tailwind v4
run: |
python3 ~/.claude/skills/tailwind-validator/scripts/validate.py \
--root . \
--strict \
--ci
Some tools still generate v3 configs. Delete the file and use @theme instead.
Replace with @import "tailwindcss". The old directives are not supported in v4.
Remove autoprefixer - it's built into @tailwindcss/postcss.
v4 auto-detects content files. Remove the content config entirely.
Weekly Installs
77
Repository
GitHub Stars
18
First Seen
Jan 20, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
codex56
opencode53
gemini-cli52
claude-code51
cursor51
github-copilot45
React视图过渡API使用指南:实现原生浏览器动画与状态管理
5,700 周安装
Datadog自动化监控:通过Rube MCP与Composio实现指标、日志、仪表板管理
69 周安装
Intercom自动化指南:通过Rube MCP与Composio实现客户支持对话管理
69 周安装
二进制初步分析指南:使用ReVa工具快速识别恶意软件与逆向工程
69 周安装
PrivateInvestigator 道德人员查找工具 | 公开数据调查、反向搜索与背景研究
69 周安装
TorchTitan:PyTorch原生分布式大语言模型预训练平台,支持4D并行与H100 GPU加速
69 周安装
screenshot 截图技能:跨平台桌面截图工具,支持macOS/Linux权限管理与多模式捕获
69 周安装
theme.extend.spacing | --spacing-* CSS variables |
theme.extend.fontFamily | --font-* CSS variables |
content: ['./src/**/*.tsx'] | Not needed (auto-detected) |
plugins: [require('@tailwindcss/forms')] | @plugin "@tailwindcss/forms" |