rspack-best-practices — Claude Code skill: setup and rules
Ruleset for configuring, troubleshooting, and profiling Rspack builds. Helps coding agents apply native loaders and optimize bundle performance.
npx skills add rstackjs/agent-skills --skill rspack-best-practices -a claude-codeWhat rspack-best-practices does
This skill guides coding agents through creating and reviewing rspack.config.ts. It directs the model to apply defineConfig, keep loader rules narrow with explicit conditions, and favor native Rspack loaders over community JavaScript packages.
The instructions cover type checking, asset management, and CSS processing. The assistant configures built-in CSS modules, integrates @tailwindcss/webpack or builtin:lightningcss-loader, and drops legacy tools like file-loader. For performance bottlenecks, it suggests tracing compiler phases with RSPACK_PROFILE=OVERVIEW or analyzing CPU profiles with --cpu-prof.
Keeping legacy tools like babel-loader or terser removes most speed gains from Rspack. The skill also enforces security by preventing .map file deployment to public servers when production source maps are active.
What it helps with
- configure
rspack.config.tsusing native loaders - migrate legacy Webpack rules to Rspack asset modules
- integrate CSS processing with
builtin:lightningcss-loader - debug slow build steps with
RSPACK_PROFILE=OVERVIEW
Example prompts for the agent
- Review my
rspack.config.tsand replace slow loaders with native alternatives - Set up TypeScript type checking with
ts-checker-rspack-plugin - Profile our Rspack build bottlenecks and suggest optimizations
How to install rspack-best-practices
1Skills CLI (Vercel)
npx skills add rstackjs/agent-skills --skill rspack-best-practices -a claude-code2Manually: put the files in place
~/.claude/skills/rspack-best-practices/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/rspack-best-practices/
1Skills CLI (Vercel)
npx skills add rstackjs/agent-skills --skill rspack-best-practices -a codex2Manually: put the files in place
.agents/skills/rspack-best-practices/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add rstackjs/agent-skills --skill rspack-best-practices -a cursor2Manually: put the files in place
.cursor/skills/rspack-best-practices/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install rstackjs/agent-skills rspack-best-practices2Manually: put the files in place
.github/skills/rspack-best-practices/SKILL.md1Skills CLI (Vercel)
npx skills add rstackjs/agent-skills --skill rspack-best-practices -a gemini-cli2Platform CLI
gemini skills install https://github.com/rstackjs/agent-skills --path skills/rspack-best-practicesManually: put the files in place
.devin/skills/rspack-best-practices/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add rstackjs/agent-skills --skill rspack-best-practices -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about rspack-best-practices
How to install rspack-best-practices in Claude Code?
Run npx skills add rstackjs/agent-skills --skill rspack-best-practices -a claude-code. This installs the file into ~/.claude/skills/rspack-best-practices/SKILL.md.
What does rspack-best-practices do?
It teaches coding assistants proven patterns for Rspack configuration. The agent prioritizes built-in plugins, sets up asset modules, and enforces safe production source map handling.
Which profiling methods does this skill recommend?
It recommends Node CPU profiling via --cpu-prof for JavaScript overhead. For bottlenecks inside the compiler itself, it guides the agent to use RSPACK_PROFILE=OVERVIEW.
Source text
SKILL.md · MIT
--- name: rspack-best-practices description: Configure, review, or troubleshoot Rspack builds, including loaders, CSS, assets, type checking, bundle optimization, and profiling. --- # Rspack best practices Apply these rules when writing or reviewing Rspack projects. ## Configuration - Use `rspack.config.ts` and `defineConfig` - Define explicit `entry` values for multi-page applications - Keep one main config and branch by `process.env.NODE_ENV` only when needed - Keep rule conditions narrow and explicit (`test`, `include`, `exclude`, `resourceQuery`) - Prefer built-in Rspack plugins/loaders over community JS alternatives when equivalent features exist ## CLI If `@rspack/cli` is installed: - Use `rspack dev` for local development - Use `rspack build` for production build - Use `rspack preview` only for local production preview ## Type checking - Use `ts-checker-rspack-plugin` for integrated dev/build type checks - Or run `tsc --noEmit`/`vue-tsc --noEmit` as an explicit script step ## CSS Choose one strategy: - Built-in CSS (`type: 'css' | 'css/auto' | 'css/module'`) for modern setups - `css-loader` + `CssExtractRspackPlugin` for webpack migration compatibility - `style-loader` for pure style-in-JS runtime injection scenarios Optional: - Use `builtin:lightningcss-loader` when goals are syntax downgrade + vendor prefixing - Use `sass-loader`/`less-loader` for preprocessing Sass/Less files - Use `@tailwindcss/webpack` for Tailwind CSS integration ## Bundle size optimization - Prefer dynamic `import()` for non-critical code paths - Prefer lightweight libraries where possible - Keep `target` aligned with real compatibility requirements ## Asset management - Import source-managed assets from project source directories, not from `public` - Reference `public` files by absolute URL path - Prefer asset modules (`asset`, `asset/resource`, `asset/inline`, `asset/source`) over legacy `file-loader`/`url-loader`/`raw-loader` ## Profiling - Use Node CPU profiling (`--cpu-prof`) when JavaScript-side overhead is suspected - Use `RSPACK_PROFILE=OVERVIEW` and analyze trace output for compiler-phase bottlenecks - Replace known slow stacks first (`babel-loader`, PostCSS, terser) with Rspack built-ins when feasible ## Security - Do not publish `.map` files to public servers/CDNs when production source maps are enabled ## Documentation - For the latest (v2) docs, read http://rspack.rs/llms.txt - For Rspack v1 docs, read http://v1.rspack.rs/llms.txt
© rstackjs · MIT · rstackjs/agent-skills