Skip to content

Commit e32176d

Browse files
committed
docs(skills): read bundled Rstack docs
1 parent 52dc7a4 commit e32176d

1 file changed

Lines changed: 37 additions & 76 deletions

File tree

  • .agents/skills/rstack-cli-best-practices
Lines changed: 37 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,92 +1,53 @@
11
---
22
name: rstack-cli-best-practices
3-
description: Guidance on using Rstack CLI, including `rs` commands, the `rstack.config.ts` file, and import paths from the `rstack` package. Use for Rstack CLI-related tasks.
3+
description: Guidance for Rstack CLI tasks. Use when running `rs` commands, editing `rstack.config.*`, using `rstack` package imports, or working with Rstack-powered apps, libraries, docs, tests, linting, formatting, Git hooks, staged files, and monorepos. Requires reading the version-matched documentation shipped in the installed `rstack` package before making changes.
44
---
55

66
# Rstack CLI Best Practices
77

8-
Rstack CLI is the `rstack` package, exposed through the `rs` binaries. It provides one CLI, one config file, and a consistent workflow for the Rstack JavaScript toolchain.
8+
## Rstack: ALWAYS read installed docs before working
99

10-
It covers web app, library, docs, test, lint, formatting, Git hook, and staged-file workflows.
10+
Before any Rstack work, find and read the relevant Markdown documentation shipped with the
11+
installed `rstack` package. Model knowledge and summaries in this skill can be outdated; the
12+
installed documentation is the source of truth for the project's Rstack version.
1113

12-
## Commands
14+
1. Resolve the documentation root from the project or workspace directory:
1315

14-
Use `rs -h` for top-level help, and `rs <command> -h` for command help where supported.
16+
```sh
17+
node -p "require('node:path').join(require('node:path').dirname(require.resolve('rstack/package.json')), 'dist/docs')"
18+
```
1519

16-
| Command | Purpose | Underlying tool | Config |
17-
| ------------ | -------------------------------- | --------------- | --------------- |
18-
| `rs dev` | Run the app dev server | Rsbuild | `define.app` |
19-
| `rs build` | Build the app for production | Rsbuild | `define.app` |
20-
| `rs preview` | Preview the app production build | Rsbuild | `define.app` |
21-
| `rs lib` | Build a library | Rslib | `define.lib` |
22-
| `rs doc` | Serve or build docs | Rspress | `define.doc` |
23-
| `rs test` | Run tests | Rstest | `define.test` |
24-
| `rs lint` | Lint code | Rslint | `define.lint` |
25-
| `rs fmt` | Format code | Prettier | `define.fmt` |
26-
| `rs setup` | Install project-local Git hooks | None | None |
27-
| `rs staged` | Run tasks on staged Git files | lint-staged | `define.staged` |
20+
The usual location is `node_modules/rstack/dist/docs`.
2821

29-
Key behavior:
22+
2. Read only the pages relevant to the task before proposing or making changes. If the correct
23+
page is unclear, start with the documentation index and search the documentation root with
24+
`rg -n "<keyword>" <docs-root>`.
3025

31-
- Unless `define.test` already sets `extends`, `rs test` extends `define.app` through `@rstest/adapter-rsbuild` or falls back to `define.lib` through `@rstest/adapter-rslib`. The app config takes precedence when both are defined.
32-
- `rs doc` requires the optional `@rspress/core` dependency.
26+
3. For exact CLI flags and behavior, also run `rs -h` or `rs <command> -h` when supported.
3327

34-
## rstack.config.ts
28+
If the package or bundled documentation cannot be resolved, verify that `rstack` is installed,
29+
report the installed version, and use CLI help plus the online Rstack documentation as a fallback.
30+
Do not guess from model memory.
3531

36-
Rstack CLI loads `rstack.config.{ts,js,mts,mjs}` by default.
32+
## Documentation map
3733

38-
Register config with `define.*`:
34+
These links target the usual project-local skill installation. If a link does not resolve, open
35+
the same relative path under the resolved documentation root.
3936

40-
```ts
41-
import { define } from 'rstack';
42-
43-
define.app({
44-
// Rsbuild config for `rs dev`, `rs build`, and `rs preview`
45-
});
46-
47-
define.test({
48-
// Rstest config for `rs test`
49-
});
50-
```
51-
52-
- `define.app(config)`: Rsbuild config for `rs dev`, `rs build`, and `rs preview`. Docs: https://rsbuild.rs/config/
53-
- `define.lib(config)`: Rslib config for `rs lib`; Docs: https://rslib.rs/config/
54-
- `define.doc(config)`: Rspress config for `rs doc`; Docs: https://rspress.rs/api/config/config-basic
55-
- `define.test(config)`: Rstest config for `rs test`; Docs: https://rstest.rs/config/
56-
- `define.lint(config)`: Rslint config for `rs lint`; Docs: https://rslint.rs/config/
57-
- `define.fmt(config)`: Formatting options for `rs fmt`.
58-
- `define.staged(config)`: lint-staged config for `rs staged`; accepts `Record<string, string | string[]>`.
59-
60-
### Lazy Configuration
61-
62-
Prefer async functions with dynamic imports for dependencies. Avoid top-level sync imports of heavy dependencies in `rstack.config.ts`.
63-
64-
```ts
65-
import { define } from 'rstack';
66-
67-
define.app(async () => {
68-
const { pluginReact } = await import('@rsbuild/plugin-react');
69-
return {
70-
plugins: [pluginReact()],
71-
};
72-
});
73-
```
74-
75-
## Import Paths
76-
77-
Prefer Rstack-exported paths:
78-
79-
| Instead of | Prefer |
80-
| ------------------------- | ------------------------ |
81-
| `@rsbuild/core` | `rstack/app` |
82-
| `@rslib/core` | `rstack/lib` |
83-
| `@rstest/core` | `rstack/test` |
84-
| `@rslint/core` | `rstack/lint` |
85-
| `@rsbuild/core/types` | `rstack/types` |
86-
| `@rslib/core/types` | `rstack/types` |
87-
| `@rstest/core/globals` | `rstack/test/globals` |
88-
| `@rstest/core/importMeta` | `rstack/test/importMeta` |
89-
90-
## Git Hooks
91-
92-
Use [`rs setup`](https://rstack.rs/guide/cli/setup) for project-local Git hooks, commonly with `rs staged` in a `pre-commit` hook.
37+
- [Overview](../../../node_modules/rstack/dist/docs/index.md)
38+
- [Quick start and command overview](../../../node_modules/rstack/dist/docs/guide/quick-start.md)
39+
- [Configuration](../../../node_modules/rstack/dist/docs/guide/configuration.md)
40+
- [API and import paths](../../../node_modules/rstack/dist/docs/guide/api-reference.md)
41+
- [Monorepos](../../../node_modules/rstack/dist/docs/guide/monorepo.md)
42+
- [Testing](../../../node_modules/rstack/dist/docs/guide/testing.md)
43+
- [Formatting](../../../node_modules/rstack/dist/docs/guide/formatting.md)
44+
- CLI commands: [dev](../../../node_modules/rstack/dist/docs/guide/cli/dev.md),
45+
[build](../../../node_modules/rstack/dist/docs/guide/cli/build.md),
46+
[preview](../../../node_modules/rstack/dist/docs/guide/cli/preview.md),
47+
[lib](../../../node_modules/rstack/dist/docs/guide/cli/lib.md),
48+
[doc](../../../node_modules/rstack/dist/docs/guide/cli/doc.md),
49+
[test](../../../node_modules/rstack/dist/docs/guide/cli/test.md),
50+
[lint](../../../node_modules/rstack/dist/docs/guide/cli/lint.md),
51+
[fmt](../../../node_modules/rstack/dist/docs/guide/cli/fmt.md),
52+
[setup](../../../node_modules/rstack/dist/docs/guide/cli/setup.md), and
53+
[staged](../../../node_modules/rstack/dist/docs/guide/cli/staged.md)

0 commit comments

Comments
 (0)