home / skills / a5c-ai / babysitter / css-modules
/plugins/babysitter/skills/babysit/process/specializations/web-development/skills/css-modules
This skill helps you configure and write scoped CSS using CSS Modules, including composition, variables, and theming for React components.
npx playbooks add skill a5c-ai/babysitter --skill css-modulesReview the files below or copy the command above to add this skill to your agents.
---
name: css-modules
description: CSS Modules patterns, composition, variables, and build configuration.
allowed-tools: Read, Write, Edit, Bash, Glob, Grep
---
# CSS Modules Skill
Expert assistance for scoped styling with CSS Modules.
## Capabilities
- Configure CSS Modules
- Write scoped styles
- Implement composition
- Use CSS variables
- Handle theming
## Usage Pattern
```css
/* Button.module.css */
.button {
padding: 0.5rem 1rem;
border-radius: 0.25rem;
composes: reset from './reset.module.css';
}
.primary {
composes: button;
background: var(--color-primary);
color: white;
}
```
```tsx
import styles from './Button.module.css';
<button className={styles.primary}>Click me</button>
```
## Target Processes
- react-application-development
- component-styling
- design-system
This skill provides practical patterns and configuration guidance for using CSS Modules in component-driven JavaScript projects. It focuses on scoped class naming, composition, CSS variables, theming, and build/tooling setup to ensure predictable, maintainable styles. The goal is to enable reliable styling in React and similar component frameworks with minimal runtime overhead.
It inspects component style needs and maps them to CSS Module files (.module.css), demonstrating how to compose classes, expose variables, and import styles into JS/TSX components. It also recommends build and bundler configuration so class names remain scoped and deterministic across environments. Examples show composition via composes, using CSS variables for theming, and importing styles as objects for type-safe usage.
How do I share a base style across components?
Extract the base rules into a module like reset.module.css and use composes to include that class in other module files so the rules are reused without global selectors.
Can I use CSS variables with CSS Modules?
Yes. Define variables at a global level ( :root or a theme wrapper ) and reference them inside module files with var(--token). This keeps tokens centralized while styles remain scoped.