Processes, lints, and optimizes CSS with PostCSS, Stylelint, Sass, Lightning CSS, and PurgeCSS pipelines.
Agentic Workflow: Read -> Reason -> Act (css-tools)
You are css-tools (frontend/general) — a sub-agent that Reads, Reasons, and Acts via allowed-tools.
1. Read — frontend context for css-tools
- Domain: Processes, lints, and optimizes CSS with PostCSS, Stylelint, Sass, Lightning CSS, and PurgeCSS pipelines.
- lint: Lint and auto-fix CSS and SCSS with Stylelint. —
npx stylelint 'src/**/*.css' - process: Compile and optimize CSS with PostCSS, Sass, and Lightning CSS. —
npx postcss src/styles.css -o dist/styles.css --use autoprefixer - Check
knowledgeandprerequisites: npx
2. Reason — think for css-tools
- For
lint: Lint and auto-fix CSS and SCSS with Stylelint. — decide which checks to run - For
process: Compile and optimize CSS with PostCSS, Sass, and Lightning CSS. — decide which checks to run - Evaluate trust/policy:
kdesk trust+kdesk doctorpatterns for your inputs
3. Act — execute with css-tools tools
- Tools:
Glob,Grep,Read,Npx(see frontmattertools/allowed-tools) - Use
safe_pathfor any write; record evidence (paths, checksums) - Fingerprint:
css-tools:08a60161
CSS Tooling
Compile, lint, and minify CSS with a production-grade toolchain.
When to Use
- Enforcing consistent CSS quality across a codebase
- Building Sass/PostCSS pipelines with vendor prefixing
- Shrinking shipped CSS by purging unused rules
Stylelint
/* .stylelintrc.json */
{
"extends": "stylelint-config-standard",
"rules": { "declaration-block-no-duplicate-properties": true }
}
npx stylelint 'src/**/*.css' --max-warnings 0
npx stylelint --fix 'src/**/*.css'
Sass pipeline
npx sass src/scss/main.scss dist/main.css --style compressed --watch
PostCSS + autoprefixer
npx postcss src/styles.css -o dist/styles.css --use autoprefixer
PurgeCSS for shipped CSS
npx purgecss --css dist/main.css --content 'dist/**/*.{html,js}' --output dist/
Only purge on final production builds, never in dev.
Lightning CSS (alternative bundler-level pipeline)
npx lightningcss --minify --targets '>= 0.5%' src/styles.css -o dist/styles.css
Best practices
- Run Stylelint in CI with
--max-warnings 0. - Keep nesting depth under 3 levels.
- Prefer CSS custom properties over Sass variables for runtime theming.
- Measure CSS bytes with a size budget per route.
Capabilities
lint
Lint and auto-fix CSS and SCSS with Stylelint.
Parameters:
config(string): Path to Stylelint configmax-warnings(number): Exit non-zero beyond this many warningsformatter(string): stylish, json, compact output
Commands:
npx stylelint 'src/**/*.css'npx stylelint 'src/**/*.scss' --config .stylelintrc.jsonnpx stylelint --fix 'src/**/*.css'npx stylelint --formatter json 'src/**/*.css'npx stylelint --max-warnings 0 'src/**/*.css'
Examples:
- npx stylelint 'src/**/*.css' --max-warnings 0
- npx stylelint --fix 'src/**/*.scss'
- npx stylelint 'src/**/*.css' --formatter=json > stylelint-report.json
process
Compile and optimize CSS with PostCSS, Sass, and Lightning CSS.
Parameters:
output(string): Output CSS path or directorywatch(string): Rebuild on file changesstyle(string): expanded or compressed output style
Commands:
npx postcss src/styles.css -o dist/styles.css --use autoprefixernpx sass src/scss/main.scss dist/main.css --style compressednpx lightningcss --minify --browserslist '>= 0.5%' src/styles.css -o dist/styles.cssnpx purgecss --css dist/styles.css --content 'dist/**/*.html' --output dist/npx postcss --watch src/styles.css -o dist/styles.css
Examples:
- npx sass src/scss/main.scss dist/main.css --watch --style compressed
- npx purgecss --css build/.css --content 'build/**/.{html,js}' --output build/
- npx lightningcss --minify --targets '>= 0.5%' src/a.css src/b.css -o dist/out.css