Skip to content

Commit 9b9c1b3

Browse files
authored
docs(skills): use bundled Rstack docs index (#196)
1 parent 1832423 commit 9b9c1b3

2 files changed

Lines changed: 18 additions & 79 deletions

File tree

Lines changed: 10 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,92 +1,25 @@
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 work involving `rs` commands, `rstack.config.*`, package APIs, or Rstack-based projects and tooling.
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 CLI is the `rstack` package, exposed through the `rs` binaries. It provides one CLI, one
9+
config file, and a consistent workflow for the Rstack JavaScript toolchain.
910

1011
It covers web app, library, docs, test, lint, formatting, Git hook, and staged-file workflows.
1112

12-
## Commands
13+
## ALWAYS read installed docs before working
1314

14-
Use `rs -h` for top-level help, and `rs <command> -h` for command help where supported.
15+
Before any Rstack work, find and read the relevant Markdown documentation shipped with the installed `rstack` package.
1516

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` |
17+
Model knowledge can be outdated; the installed documentation is the source of truth for the project's Rstack version.
2818

29-
Key behavior:
19+
1. Start with `node_modules/rstack/dist/docs/llms.txt`, then read only the linked pages relevant to the task before proposing or making changes.
3020

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.
21+
2. For exact CLI flags and behavior, also run `rs -h` or `rs <command> -h` when supported.
3322

34-
## rstack.config.ts
23+
If the bundled docs are not available at that path, locate the installed `rstack` package.
3524

36-
Rstack CLI loads `rstack.config.{ts,js,mts,mjs}` by default.
37-
38-
Register config with `define.*`:
39-
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.
25+
If they are still unavailable, verify that `rstack` is installed, and use CLI help plus the online [Rstack documentation](https://rstack.rs/) as a fallback.

‎scripts/prepare-release.js‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env node
22
import { spawn } from 'node:child_process';
3-
import { copyFile, mkdir, readdir, rm } from 'node:fs/promises';
3+
import { copyFile, mkdir, readFile, readdir, rm, writeFile } from 'node:fs/promises';
44
import path from 'node:path';
55

66
const rootDir = path.resolve(import.meta.dirname, '..');
@@ -71,4 +71,10 @@ for (const relativePath of markdownFiles) {
7171
await copyFile(path.join(websiteDistDir, relativePath), destination);
7272
}
7373

74-
console.log(`Copied ${markdownFiles.length} English Markdown files to ${packageDocsDir}.`);
74+
const llmsTxt = await readFile(path.join(websiteDistDir, 'llms.txt'), 'utf8');
75+
const packageLlmsTxt = llmsTxt.replace(/\]\(\/(?!\/)/g, '](./');
76+
await writeFile(path.join(packageDocsDir, 'llms.txt'), packageLlmsTxt);
77+
78+
console.log(
79+
`Copied ${markdownFiles.length} English Markdown files and llms.txt to ${packageDocsDir}.`,
80+
);

0 commit comments

Comments
 (0)