Rsdoctor Analysis
Use when analyzing Rspack/Webpack bundles from local `rsdoctor-data.json` and producing evidence-based optimization recommendations.
- Skill ID
- rstackjs/agent-skills/rsdoctor-analysis
- Publisher
- rstackjs
- Repository
- agent-skills
- Installs
- 0
- Files
- 8
- Synced
- Sep 23, 2026
Open any RiverX project, open the Skills panel in the chat, and search for this identifier. The files are fetched from the source repository at install time.
rstackjs/agent-skills/rsdoctor-analysisInstalls these files- SKILL.md
- references/command-map.md
- references/common-analysis-patterns.md
- references/install-rsdoctor-common.md
- references/install-rsdoctor-rspack.md
- references/install-rsdoctor-webpack.md
- references/install-rsdoctor.md
- references/rsdoctor-data-types.md
What this skill tells the agent
Rsdoctor analysis assistant skill
Use the globally installed rsdoctor-agent CLI from @rsdoctor/agent-cli only after a real rsdoctor-data.json path exists. Keep analysis read-only unless the user explicitly asks for install/config setup.
Response order (required): High-Priority Issues -> Proposed Solutions -> Optional Reference-Chain Follow-up Choices -> Next Deep-Dive Issue Categories (Not commands).
Core workflow
- Reuse current-session results and valid
.rsdoctor-analysis-cache.jsonentries before doing new work. - Locate
rsdoctor-data.jsonfast: user-provided path, thendist/rsdoctor-data.json,output/rsdoctor-data.json,static/rsdoctor-data.json,.rsdoctor/rsdoctor-data.json, then one boundedrg --filessearch excludingnode_modulesand.git. Treatmanifest.jsononly as an index. - If data exists, skip all plugin version/config/build generation logic. Update cache when useful.
- If data is missing, stop analysis: do not run
rsdoctor-agentanalysis commands, do not run the Analysis Gate, and either ask for the data path or run the Generation Gate below only when setup/generation is required. - After a real data file exists, run Analysis Gate at most once before the first
rsdoctor-agentdata-fetch command: verify global@rsdoctor/agent-cliwithnpm view @rsdoctor/agent-cli versionandrsdoctor-agent --version; install latest only if missing/outdated, a version-related error occurs, or the user asks to refresh. - Fetch only the Default Evidence Set first; run independent fetches in parallel when possible.
- Run the ROI Triage Gate below before selecting deep-dive commands or recommendations. Use it to rank issue categories by measured impact, then synthesize findings in the required response order.
Performance rules: parallelize independent checks, cache only derived facts (dataFile, dataFileMtime, pluginName, pluginVersion, dependency/config/plugin modification times), and invalidate cache when paths disappear, modification times change, the user asks to refresh, or cached values fail. Speculative plugin checks must not trigger generation; use them only after confirming the data file is missing.
ROI triage gate
Before recommending fixes, classify the current build into broad cost buckets and choose the highest-ROI lever from evidence, not intuition. This gate is generic for Rspack/Webpack projects; do not use framework-specific runtime layers unless the user's project exposes them in the data.
| Cost bucket | Evidence source | First lever |
|---|---|---|
| Assets/media | assetsTop, assets media, chunkGraph.assets | Compress, convert, deduplicate, subset, or lazy-load large assets |
| Large packages/modules | packagesTop, module/package size fields | Replace heavy packages, use deep imports, split non-critical code, or review direct dependency choices |
| Duplicate/cross-chunk cost | E1001/E1002, packages duplicates, cross-chunk package summaries | Deduplicate versions, tune package resolution, or adjust splitChunks/cache groups |
| Tree-shaking waste | retainedModulesTop, retained CJS/barrel/side-effects modules | Fix CJS/barrel imports, sideEffects declarations, or package entrypoints |
| Build-time cost | buildCost, loaders/plugins/directories cost data | Optimize loaders/plugins, cache, watcher, or source-map/dev settings; prioritize only when the user asks about build performance |
Decision rules:
- Report the measured breakdown first when it changes recommendation priority.
- Start with the largest bucket that maps to a practical fix; a smaller issue should not outrank a larger one unless the larger one is expected or intentionally unavoidable.
- Treat issuer/reference-chain tracing as second-pass work. Run it only when a high-impact candidate needs ownership evidence, or when the user asks "why" / "who imported this".
- Do not present aggregate rule output as sufficient evidence for a fix that requires a concrete file, package, chunk, size, or dependency path.
- If the largest bucket is structural or intentionally required, say that it is a wall and name the external change that would be needed instead of inventing low-impact source edits.
Generation gate
Identify pluginName (@rsdoctor/rspack-plugin or @rsdoctor/webpack-plugin) and determine pluginVersion from local files first: package.json, lockfile, then node_modules/<plugin>/package.json; use pnpm why / npm ls only as fallback.
Use this exact if/else decision tree; do not merge branches:
if pluginName is missing:
install/register the matching Rsdoctor plugin, then configure output.mode='brief' and output.options.type=['json']; build with RSDOCTOR=true only
else if pluginVersion is unknown:
resolve pluginVersion first; if still unknown, configure output.mode='brief' and output.options.type=['json']; build with RSDOCTOR=true only
else if pluginVersion >= 1.5.11:
do not edit plugin config just for JSON; build with RSDOCTOR_OUTPUT=json and RSDOCTOR=true if needed
else: # pluginVersion < 1.5.11
MUST configure output.mode='brief' and output.options.type=['json']; build with RSDOCTOR=true onlyPreflight every build command: RSDOCTOR_OUTPUT=json is allowed only in the pluginVersion >= 1.5.11 branch. For missing, unknown, or < 1.5.11, it is forbidden. For < 1.5.11, generating rsdoctor-data.json requires the plugin config below:
output: {
mode: 'brief',
options: {
type: ['json'],
},
}Evidence and command bounds
Default Evidence Set:
| Summary key | Evidence source | Bounds |
|---|---|---|
buildCost | build summary | filtered fields only |
assetsTop | top assets by raw/gzip size | fixed Top-N |
packagesTop | top packages by gzip size | fixed Top-N; avoid full packages list pages |
duplicatePackages | E1001 duplicate package summary | first-pass summary only |
crossChunkPackages | E1002 cross-chunk duplication summary | first-pass summary only |
retainedModulesTop | tree-shaking retained-modules --limit 10 | filtered fields only; no --compact |
Scope rules:
- Use
rsdoctor-agentfor bundle data access only afterrsdoctor-data.jsonexists; prefer parallel independent fetches; bound output with--filter, pagination, and--limit. - Default analysis stays within the Default Evidence Set. For non-default analysis, choose minimal fields from references/rsdoctor-data-types.md and patterns from references/common-analysis-patterns.md.
- Treat chain tracing, broad commands, optimization edits, splitChunks experiments, and build re-runs as opt-in follow-ups that require user confirmation.
- For duplicate packages and tree-shaking issues, identify issues first; trace reference/import chains only after user confirmation.
More from rstackjs
Use this skill in a project
Open any RiverX project, search the Skills panel for rstackjs/agent-skills/rsdoctor-analysis, and install it in one click.
