You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: skills/rsdoctor-analysis/SKILL.md
+55-28Lines changed: 55 additions & 28 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ description: Use when analyzing Rspack/Webpack bundles from local `rsdoctor-data
5
5
6
6
# Rsdoctor Analysis Assistant Skill
7
7
8
-
Use `@rsdoctor/agent-cli` to read `rsdoctor-data.json` and provide evidence-based optimization recommendations.
8
+
Use the globally installed `rsdoctor-agent` CLI from `@rsdoctor/agent-cli` to read `rsdoctor-data.json` and provide evidence-based optimization recommendations.
9
9
10
10
**Use the latest version of `@rsdoctor/agent-cli`, and ensure `@rsdoctor/rspack-plugin` is >= 1.5.9.**
- Use `@rsdoctor/agent-cli` for bundle data access; prefer background execution when possible, then collect and summarize outputs.
17
+
- Use the `rsdoctor-agent` command for bundle data access; prefer background execution when possible, then collect and summarize outputs.
18
+
- Before the first analysis command, ensure `@rsdoctor/agent-cli` is installed globally and current:
19
+
- Check the latest version with `npm view @rsdoctor/agent-cli version`.
20
+
- Check the installed CLI version with `rsdoctor-agent --version`.
21
+
- If `rsdoctor-agent` is missing or not the latest version, install the latest global CLI with `npm install -g @rsdoctor/agent-cli@latest`, then run commands with `rsdoctor-agent`.
22
+
- Run CLI version checks at most once per session unless the CLI is missing, a command fails with a version-related error, or the user explicitly asks to refresh.
18
23
- Reuse already returned results from current context whenever possible. Do not re-run the same subcommand unless required fields are missing or the user asks for a refresh.
19
-
- Every `@rsdoctor/agent-cli` data-fetch command supports `--filter`; use it by default to keep only fields required for the current question.
20
-
- Build `--filter` field selections from [reference/rsdoctor-data-types.md](reference/rsdoctor-data-types.md) so field names match `@rsdoctor/types` instead of guessing from raw output.
21
-
- For side-effects investigations, use small pagination (`--page-size 10` / `--side-effects-page-size 10`). Do not use oversized page sizes.
22
-
- For retained emitted module analysis, prefer `tree-shaking retained-modules` with `--emitted-only`, bounded `--category`, `--sort gzipSize`, `--limit`, and a narrow `--filter`.
23
-
- For broader tree-shaking issues, use `tree-shaking summary` directly and control output with `--filter` plus `--compact` where useful.
24
+
- Every `rsdoctor-agent` data-fetch command supports `--filter`; use it by default with fields from [references/rsdoctor-data-types.md](references/rsdoctor-data-types.md).
25
+
- Add `--compact` to `rsdoctor-agent` commands whenever possible. If a command does not support `--compact`, keep output small with `--filter`, pagination, and `--limit`.
26
+
- Default bundle analysis must build a compact summary first and produce the report from that summary, not from broad raw CLI output.
27
+
- Default bundle analysis must execute independent data-fetch commands in parallel when the runtime supports parallel tool calls.
28
+
- Do not leave the default evidence set unless required fields are missing, the user asks for a specific deep dive, or the compact summary shows a finding that needs one narrow supporting query.
29
+
- For tree-shaking side-effects investigations, prefer `tree-shaking retained-modules --emitted-only --category side-effects --limit 10` with a narrow `--filter`. If falling back to `tree-shaking summary` or `modules side-effects`, use small pagination (`--page-size 10` / `--side-effects-page-size 10`) and stop as soon as one command exceeds `5k` tokens or `500 KB` raw output.
30
+
- For retained emitted module analysis, prefer `tree-shaking retained-modules` with `--emitted-only`, bounded `--category`, `--sort gzipSize`, `--limit`, and a narrow `--filter`. Do not pass `--compact` to `tree-shaking retained-modules`.
31
+
- For broader tree-shaking issues, use `tree-shaking summary` only as a fallback when retained-module output lacks required fields or aggregate context is required; keep output compact.
24
32
- Treat `tree-shaking bailout-reasons` as high-volume by default. Do not run it unless the user explicitly asks for bailout reason analysis, and always pass the target module list with `--modules` (maximum 100 modules).
25
-
- Use a per-step token budget gate: if one command exceeds `20k` tokens (o200k_base) or raw output exceeds `2 MB`, stop adding broad-scope commands and switch to filtered or targeted queries.
33
+
- Use a per-step token budget gate: if one command exceeds `5k` tokens (o200k_base), `500 KB`raw output, or a few hundred transcript lines, stop adding broad-scope commands and switch to compact, filtered, paginated, or targeted queries.
26
34
- For duplicate packages and tree-shaking issues, do first-pass issue identification by default. Do not immediately trace reference/import chains.
27
35
- At the end of analysis, provide next-step choices and let the user decide whether to continue with reference-chain tracing.
28
36
- Do not modify user code/config except these explicit cases:
- Optional verification workflow (only with user confirmation):
32
40
- If the goal is to validate optimization impact, you may adjust `splitChunks` and re-run build to compare results.
33
41
- Ask for user confirmation before modifying `splitChunks` and before re-running build.
34
-
- In Codex, do not run `install` or `build` inside sandbox.
35
42
- For all analysis commands, provide recommendations only. Do not auto-apply optimization edits.
36
43
44
+
## Default Evidence Set
45
+
46
+
For default bundle analysis, populate only this compact summary shape: `assetsTop`, `packagesTop`, `duplicatePackages`, `crossChunkPackages`, `retainedModulesTop`, and `buildCost`.
|`retainedModulesTop`|`tree-shaking retained-modules --limit 10`| filtered fields only; no `--compact`|
56
+
37
57
## Workflow
38
58
39
59
1. Locate or verify `rsdoctor-data.json`. If it is missing or plugin setup is needed, use the install references below.
40
-
2. Choose the command from [reference/command-map.md](reference/command-map.md). Start with `list` + `query` when possible; fall back to direct `<group> <subcommand>` when needed.
41
-
3. Before each data fetch, choose the minimal fields needed for the current question, map them with [reference/rsdoctor-data-types.md](reference/rsdoctor-data-types.md), and pass `--filter`.
42
-
4. For common cases such as similar packages, media assets, bundle optimization, duplicate packages, and tree-shaking questions, use [reference/common-analysis-patterns.md](reference/common-analysis-patterns.md).
43
-
5. Synthesize findings in the required response format. Ask before chain tracing or optimization verification.
60
+
2. Run CLI version checks only if they have not already been completed in the current session, unless the CLI is missing, a command fails with a version-related error, or the user asks to refresh.
61
+
3. For default bundle analysis, run the fixed evidence set above with fixed `--filter` fields and fixed Top-N limits. Run independent data fetches in parallel when possible.
62
+
4. For non-default analysis, choose the minimal fields needed for the user's question, map them with [references/rsdoctor-data-types.md](references/rsdoctor-data-types.md), and keep command output compact.
63
+
5. For common cases such as similar packages, media assets, bundle optimization, duplicate packages, and tree-shaking questions, use [references/common-analysis-patterns.md](references/common-analysis-patterns.md).
64
+
6. Synthesize findings from the compact summary in the required response format. Ask before chain tracing, broader commands, or optimization verification.
65
+
7. Track wall-clock timing only when the user asks about performance, elapsed time, or efficiency. If timing is requested, use coarse `command`, `model_analysis`, and `output_generation` buckets without adding commands only to improve precision.
66
+
67
+
## Execution Environment
68
+
69
+
- In Codex, do not run `install`, `build`, global CLI installation, version checks, or `rsdoctor-agent...` inside sandbox. Run Rsdoctor CLI setup and data-fetch commands outside sandbox so they can access project files and dependencies normally.
44
70
45
71
## References
46
72
47
-
- Commands and options: [reference/command-map.md](reference/command-map.md)
48
-
- Install, config, data location, and troubleshooting: [reference/install-rsdoctor.md](reference/install-rsdoctor.md), [reference/install-rsdoctor-rspack.md](reference/install-rsdoctor-rspack.md), [reference/install-rsdoctor-webpack.md](reference/install-rsdoctor-webpack.md), [reference/install-rsdoctor-common.md](reference/install-rsdoctor-common.md)
49
-
- Raw data fields and `--filter` construction: [reference/rsdoctor-data-types.md](reference/rsdoctor-data-types.md)
50
-
- Similar packages, media assets, bundle optimize, and common question patterns: [reference/common-analysis-patterns.md](reference/common-analysis-patterns.md)
73
+
- Commands and options: [references/command-map.md](references/command-map.md)
74
+
- Install, config, data location, and troubleshooting: [references/install-rsdoctor.md](references/install-rsdoctor.md), [references/install-rsdoctor-rspack.md](references/install-rsdoctor-rspack.md), [references/install-rsdoctor-webpack.md](references/install-rsdoctor-webpack.md), [references/install-rsdoctor-common.md](references/install-rsdoctor-common.md)
75
+
- Raw data fields and `--filter` construction: [references/rsdoctor-data-types.md](references/rsdoctor-data-types.md)
76
+
- Similar packages, media assets, bundle optimize, and common question patterns: [references/common-analysis-patterns.md](references/common-analysis-patterns.md)
51
77
52
78
## Response Format
53
79
54
-
1. High-priority issues in current build data:
55
-
- Include concrete evidence (size/time/count/path/rule code).
56
-
2. Proposed solutions:
57
-
- Provide actionable recommendations with priority (High/Med/Low).
58
-
3. Optional reference-chain follow-up choices:
59
-
- For duplicate packages and tree-shaking issues, provide a short "continue tracing vs stop here" choice.
60
-
- Only trace chains after user confirmation.
61
-
4. Whether deeper analysis is still needed:
80
+
1. Issues found in the current build and recommended fixes:
81
+
- Group each issue with its fix recommendation instead of splitting issues and solutions into separate sections.
82
+
- Include concrete evidence for each issue (size/time/count/path/rule code).
83
+
- Provide an actionable fix with priority (High/Med/Low) for each issue.
84
+
- For duplicate packages and tree-shaking issues, include a short "continue tracing vs stop here" choice. Only trace chains after user confirmation.
85
+
2. Whether deeper analysis is still needed:
62
86
- List remaining gaps by issue categories (for example: dependency duplication, chunking strategy, tree-shaking barriers, loader cost, asset volume).
63
87
- Do not output suggested commands in this section; output category-level follow-up directions only.
64
88
65
89
Formatting:
66
90
67
91
- For Top-N insights, prefer a table: `Name | Volume/Time | Count | Recommendation`.
68
-
- For large output, use `--compact`.
92
+
- For large output, use command-specific size controls such as `--filter`, pagination, and `--limit`. Do not use `--compact` with `tree-shaking retained-modules`.
69
93
70
94
## Troubleshooting
71
95
72
96
-`rsdoctor-data.json` missing:
73
97
- Configure plugin and run `RSDOCTOR=true npm run build`.
74
98
- Command not found:
75
-
- Verify `npx @rsdoctor/agent-cli@latest list` works in current shell.
76
-
- If using binary mode, verify `rsdoctor-agent` exists in PATH.
99
+
- Verify `rsdoctor-agent` exists in PATH.
100
+
- Check `npm view @rsdoctor/agent-cli version` and `rsdoctor-agent --version`.
101
+
- If missing or outdated, run `npm install -g @rsdoctor/agent-cli@latest`, then retry with `rsdoctor-agent`.
77
102
-`query` reports unknown tool:
78
103
- Run `list` and use one of the catalog tool names, or switch to direct `<group> <subcommand>` mode.
79
104
- Build/install blocked in sandbox:
80
105
- Re-run outside sandbox.
106
+
-`rsdoctor-agent...` blocked or incomplete in Codex sandbox:
107
+
- Re-run outside sandbox.
81
108
- JSON read error:
82
109
- Verify file path, JSON validity, and permissions.
0 commit comments