converting-css-modules-to-tailwind — скилл для Claude Code: миграция
Переводит компонент с CSS Modules на утилитарные классы Tailwind: разбирает styles.xxx, чистит импорты и удаляет файл модуля.
npx skills add spencerpauly/awesome-cursor-skills --skill converting-css-modules-to-tailwind -a claude-codeЧто делает converting-css-modules-to-tailwind
Скилл берёт один компонент и его .module.css или .module.scss, сопоставляет каждую ссылку styles.xxx с CSS-правилом и заменяет её на классы Tailwind. Дальше он проходит по типовым местам модулей: composes, условные className через clsx, динамический выбор класса по варианту, :global(...). Для динамики советует объект-справочник вида variantClasses[variant], а не сборку имени класса из строк.
После конвертации скилл убирает строку импорта модуля, удаляет сам файл и проверяет, не осталось ли других импортов этого модуля в проекте. Вложенные селекторы SCSS он разворачивает в утилиты на каждом элементе, переменные $ предлагает перенести в тему tailwind.config.ts, а миксины заменить композицией утилит или отдельным компонентом. Псевдоэлементы с content требуют префиксов before: или after: и значения content-['...'].
Работает по одному компоненту за раз, целые папки не берёт. Если в модуле есть :nth-child или :first-of-type, а подходящего варианта в Tailwind нет, скилл оставляет минимальное CSS-правило. Создавать @apply-классы вместо модуля он не станет: смысл миграции в том, чтобы убрать лишний слой.
Какие задачи решает
- перевести компонент с
.module.cssна классы Tailwind - разобрать
composesи разложить его по утилитам - заменить
styles[variant]на объект с классами вариантов - перенести
:global(...)в глобальную таблицу стилей - удалить файл модуля и найти оставшиеся импорты
Примеры запросов агенту
- переведи
Card.module.cssна Tailwind, компонентCard.tsx - убери
styles.xxxизButton.tsxи удали модуль - разбери
composesвButton.module.scssи замени на утилиты
Как установить converting-css-modules-to-tailwind
1Через Skills CLI (Vercel)
npx skills add spencerpauly/awesome-cursor-skills --skill converting-css-modules-to-tailwind -a claude-code2Вручную: положить файлы
~/.claude/skills/converting-css-modules-to-tailwind/SKILL.mdПапка скилла целиком; для одного проекта — .claude/skills/converting-css-modules-to-tailwind/
1Через Skills CLI (Vercel)
npx skills add spencerpauly/awesome-cursor-skills --skill converting-css-modules-to-tailwind -a codex2Вручную: положить файлы
.agents/skills/converting-css-modules-to-tailwind/SKILL.mdДля всех проектов — ~/.agents/skills/
1Через Skills CLI (Vercel)
npx skills add spencerpauly/awesome-cursor-skills --skill converting-css-modules-to-tailwind -a cursor2Вручную: положить файлы
.cursor/skills/converting-css-modules-to-tailwind/SKILL.mdCursor читает и .agents/skills/, и .claude/skills/
1GitHub CLI
gh skill install spencerpauly/awesome-cursor-skills converting-css-modules-to-tailwind2Вручную: положить файлы
.github/skills/converting-css-modules-to-tailwind/SKILL.md1Через Skills CLI (Vercel)
npx skills add spencerpauly/awesome-cursor-skills --skill converting-css-modules-to-tailwind -a gemini-cli2Командой платформы
gemini skills install https://github.com/spencerpauly/awesome-cursor-skills --path resources/converting-css-modules-to-tailwindВручную: положить файлы
.devin/skills/converting-css-modules-to-tailwind/SKILL.mdСтарый путь .windsurf/skills/ тоже читается
Через Skills CLI (Vercel)
npx skills add spencerpauly/awesome-cursor-skills --skill converting-css-modules-to-tailwind -a opencodeClaude.ai
Упакуйте папку в zip и загрузите в Settings → Capabilities → Skills
По шагам, с командами для каждой платформы: Как установить скилл в Claude Code: пять способов
Вопросы о converting-css-modules-to-tailwind
Как установить converting-css-modules-to-tailwind в Claude?
Выполните npx skills add spencerpauly/awesome-cursor-skills --skill converting-css-modules-to-tailwind -a claude-code. Файл скилла окажется по пути ~/.claude/skills/converting-css-modules-to-tailwind/SKILL.md.
Что делает converting-css-modules-to-tailwind?
Мигрирует компонент с CSS Modules на утилитарные классы Tailwind. Заодно чистит импорт модуля, удаляет файл и проверяет, не ссылается ли на него что-то ещё.
Как скилл обходится с :nth-child и псевдоэлементами?
Для :nth-child и :first-of-type он ищет подходящий вариант в Tailwind, а если такого нет — оставляет минимальное CSS-правило. Псевдоэлементам с content нужны префиксы before: или after: и значение content-['...'].
Исходный текст
SKILL.md · CC0-1.0
---
name: converting-css-modules-to-tailwind
description: Migrate CSS Modules (.module.css/.module.scss) to Tailwind utility classes. Handles styles object removal, className interpolation, composition, and global overrides.
user-invocable: true
---
# Converting CSS Modules to Tailwind
Migrate a component from CSS Modules (`.module.css` / `.module.scss`) to Tailwind utility classes.
## Workflow
### 1. Inventory the Module
Read the `.module.css` file and the component that imports it. Map every `styles.xxx` reference to the CSS rule it resolves to.
```tsx
// Before
import styles from './Card.module.css';
<div className={styles.card}>
<h2 className={styles.title}>{title}</h2>
<p className={styles.body}>{children}</p>
</div>
```
```css
/* Card.module.css */
.card { display: flex; flex-direction: column; gap: 16px; padding: 24px; border-radius: 12px; background: white; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
.title { font-size: 20px; font-weight: 600; color: #111827; }
.body { font-size: 14px; color: #6b7280; line-height: 1.6; }
```
### 2. Convert Each Class
Replace `styles.xxx` with equivalent Tailwind utilities:
```tsx
// After
<div className="flex flex-col gap-4 p-6 rounded-xl bg-white shadow-sm">
<h2 className="text-xl font-semibold text-gray-900">{title}</h2>
<p className="text-sm text-gray-500 leading-relaxed">{children}</p>
</div>
```
### 3. Handle CSS Modules Patterns
**`composes` keyword:**
```css
.base { padding: 8px 16px; border-radius: 4px; }
.primary { composes: base; background: blue; color: white; }
```
→ Flatten into a single set of utilities. If reuse is needed, extract a component, not a class.
**Conditional classNames with `clsx`/`classnames`:**
```tsx
// Before
className={clsx(styles.button, isActive && styles.active)}
// After
className={clsx("px-4 py-2 rounded", isActive && "bg-blue-600 text-white")}
```
**Dynamic class selection:**
```tsx
// Before
className={styles[variant]}
// After — use a lookup object
const variantClasses = {
primary: "bg-blue-600 text-white hover:bg-blue-700",
secondary: "bg-gray-100 text-gray-900 hover:bg-gray-200",
danger: "bg-red-600 text-white hover:bg-red-700",
};
className={variantClasses[variant]}
```
**CSS Modules global overrides:**
```css
:global(.some-library-class) { ... }
```
→ Move to `globals.css` with `@layer components { }` or use Tailwind's `@apply` in the global stylesheet.
**SCSS features (nesting, variables, mixins):**
- Nested selectors → flatten into utility classes on each element
- SCSS `$variables` → map to `tailwind.config.ts` theme values
- Mixins → replace with utility composition or extract components
### 4. Clean Up
1. Remove the `import styles from './Xxx.module.css'` line
2. Delete the `.module.css` / `.module.scss` file
3. If the component had a co-located `index.ts` barrel that re-exported styles, update it
4. Search the codebase for any other imports of the deleted module
5. Run the app and verify visually — check for regressions
## Rules
- Convert one component at a time — don't batch entire directories
- Keep conditional logic in `clsx()` or template literals, not in CSS
- If a module has pseudo-element styles (`:before`, `:after` with `content`), those need `before:` / `after:` prefixes plus `content-['...']` in Tailwind
- For `:nth-child`, `:first-of-type`, etc. — check if Tailwind has a matching variant, otherwise keep a minimal CSS rule
- Don't create `@apply` classes to replicate what the module did — the goal is to eliminate the indirection
© spencerpauly · CC0-1.0 · spencerpauly/awesome-cursor-skills