Skip to content

Commit c6b7f9e

Browse files
authored
feat(rspress): add rspress best practices skill (#57)
1 parent 5beac9c commit c6b7f9e

2 files changed

Lines changed: 90 additions & 0 deletions

File tree

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,14 @@ Migrate tsc or tsup library projects to Rslib.
125125

126126
## Rspress Skills
127127

128+
### rspress-best-practices
129+
130+
```bash
131+
npx skills add rstackjs/agent-skills --skill rspress-best-practices
132+
```
133+
134+
Rspress best practices for config, CLI workflow, content organization, frontmatter, MDX, themes, i18n, search, static assets, deployment, and debugging. Use when writing, reviewing, or troubleshooting Rspress documentation sites.
135+
128136
### rspress-v2-upgrade
129137

130138
```bash
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
---
2+
name: rspress-best-practices
3+
description: Rspress best practices for config, CLI workflow, content organization, frontmatter, MDX, themes, i18n, search, static assets, deployment, and debugging. Use when writing, reviewing, or troubleshooting Rspress documentation sites.
4+
---
5+
6+
# Rspress Best Practices
7+
8+
Apply these rules when writing or reviewing Rspress (v2) sites.
9+
10+
## Configuration
11+
12+
- Use `rspress.config.ts` and `defineConfig` from `@rspress/core`
13+
- Set `root` explicitly when docs are not under the default `docs/` directory
14+
- Keep site-wide settings such as `title`, `description`, `icon`, `logo`, `base`, and `lang` in config instead of repeating them in page files
15+
- Prefer first-class Rspress options before custom theme code or low-level bundler overrides
16+
- Keep custom theme code in a top-level `theme/` directory and import original theme pieces from `@rspress/core/theme-original`
17+
18+
## CLI
19+
20+
- Use `rspress dev` for local development
21+
- Use `rspress build` for production output
22+
- Use `rspress preview` only for local preview of the built site
23+
- Use `rspress eject` only when CSS variables, class overrides, or layout wrapping cannot solve the customization
24+
25+
## Docs Structure And Navigation
26+
27+
- Keep docs content under one clear docs root and group pages by topic or workflow, not by team ownership
28+
- Use `_meta.json` or `_nav.json` to control sidebar and navigation labels/order instead of encoding order in filenames
29+
- Put reusable MDX snippets or shared components in shared files instead of duplicating them across pages
30+
- Keep landing pages concise and link to deeper task-oriented guides from them
31+
32+
## Writing And Frontmatter
33+
34+
- Add clear `title` and `description` frontmatter, and set `sidebar`, `outline`, `navbar`, or `footer` only when page defaults are not enough
35+
- Use `pageType: home`, `doc`, `doc-wide`, `custom`, or `blank` intentionally based on layout needs
36+
- Write task-first headings and short intros; avoid marketing-heavy copy in technical docs
37+
- Prefer one topic per page and split overly long pages by workflow or feature area
38+
- Keep code examples minimal, runnable, and version-accurate
39+
40+
## MDX And Components
41+
42+
- Use MDX for interactive docs and embedded components, but keep the main narrative understandable as plain markdown
43+
- Prefer documented Rspress theme/runtime APIs over importing from internal source paths
44+
- For app-wide UI or providers, use `globalUIComponents` or theme overrides instead of repeating imports in each page
45+
46+
## Theme And Styling
47+
48+
- Prefer CSS variables for brand colors, spacing, and surface styling
49+
- Prefer BEM class overrides or `Layout` slots before ejecting built-in components
50+
- In `theme/` files, keep `export * from '@rspress/core/theme-original'` unless intentionally replacing a named export
51+
- Avoid full component ejection unless config, CSS, and wrapping cannot meet the requirement
52+
53+
## I18n, Search, And AI
54+
55+
- For multilingual sites, organize locale content under per-language directories and keep navigation mirrored where practical
56+
- Keep descriptions and other frontmatter text in the same language as the page content
57+
- Configure search intentionally: use local search for small or medium sites, and hosted search when scale or cross-version indexing requires it
58+
- Enable `llms` or `ssgMd` only when the site benefits from machine-readable outputs, and keep descriptions accurate because those outputs surface page summaries
59+
60+
## Assets And Public Files
61+
62+
- Import source-managed images and components from docs/theme source when they belong to the content
63+
- Use `public/` only for assets that must keep stable URL paths, such as favicons, social images, or download files
64+
- Reference public assets by absolute site path and make sure they still work when `base` is set
65+
66+
## Plugins And Integration
67+
68+
- Prefer official Rspress plugins for search, preview, and API-doc scenarios before building custom solutions
69+
- For component or library docs, use `@rspress/plugin-preview` and `@rspress/plugin-api-docgen` when interactive demos or API tables are needed
70+
- Keep plugin usage explicit in config and remove unused plugins to reduce maintenance cost
71+
72+
## Build, Deploy, And Debugging
73+
74+
- Validate both `rspress dev` and `rspress build`; a page that works in dev can still fail during static generation
75+
- Verify broken links, missing assets, and wrong `base` handling before deployment
76+
- Keep generated output out of source control unless the hosting workflow explicitly requires committed artifacts
77+
- When debugging content issues, inspect the resolved docs root, frontmatter, and theme overrides before assuming a bundler problem
78+
79+
## Documentation
80+
81+
- For the latest Rspress docs, read https://rspress.rs/llms.txt
82+
- Use the config and API docs when checking exact option names or current behavior

0 commit comments

Comments
 (0)