Claude Code
配置 Claude Code 以编写和维护 Jamdesk 文档,包含 CLAUDE.md 模板与 MCP 服务器连接。
Claude Code 是 Anthropic 推出的 Claude 命令行工具。它会读取你的完整项目目录,从文件中学习你的写作风格和 docs.json 的结构,所写的页面能与现有页面自然衔接。
我们用这套配置维护 Jamdesk 自己的文档。下面的 CLAUDE.md 模板与我们实际使用的版本非常接近,你可以根据项目进行调整。我们建议保留页面结构规则、"接下来做什么?"卡片约定,以及严格的组件列表。
在交互式迭代方面,Claude Code 比 Codex 更出色。你可以起草一个页面,阅读结果,对某个章节提出意见,然后让 Claude 在同一会话中重写。它始终保持完整的项目上下文。若是无需人工干预的多文件批量任务,Codex 则是更好的选择。
快速设置
从 claude.ai/code 安装。
将你的文档添加为 MCP 数据源:
claude mcp add --transport http my-docs https://your-project.jamdesk.app/_mcp将 your-project 替换为你的 Jamdesk 子域名。如果已上线自定义域名,请改用它:https://docs.acme.com/_mcp。此后 Claude 即可搜索并阅读你已发布的文档。详见 MCP 服务器。
在文档项目根目录创建 CLAUDE.md。这能让 Claude 始终掌握你的文档标准、可用组件和写作风格。
CLAUDE.md 模板
将此文件添加到 Jamdesk 文档项目的根目录:
# Documentation Project
Jamdesk docs project. Pages are MDX (Markdown + React components). Config is in `docs.json`.
## How This Project Works
- `docs.json`: navigation structure, theme, colors, branding. Pages must be listed here to appear in the sidebar.
- `*.mdx` files: documentation pages. Every page needs `title` and `description` frontmatter.
- `images/`: static assets. Always use `.webp` format.
- `snippets/`: reusable MDX fragments. Import with `<Snippet file="name.mdx" />`.
## Page Template
Every page follows this structure:
---
title: Clear, Specific Title
description: One sentence. Used in search results and social previews.
---
Opening paragraph: what this page covers and who it's for. No heading needed.
## First Section
Content. Use components where they help, not for decoration.
## What's Next?
<Columns cols={2}>
<Card title="Related Page" icon="arrow-right" href="/path">
Why the reader would go here next
</Card>
</Columns>
The opening paragraph comes right after frontmatter, with no heading before it. "What's Next?" is always the last section. Card descriptions explain why, not what ("Set up search for your docs", not "Search configuration page").
## Writing Style
Start with why. What problem does this page solve? Show that first, then walk through how to use the feature.
Use progressive disclosure: a simple example near the top, advanced options tucked into Accordions or later sections.
Active voice. "Run this command", not "This command should be run".
One idea per paragraph. If you reach for "also" or "additionally", start a new paragraph instead.
Code examples must actually work. Never show partial code or pseudocode. Every block should be complete and copy-pasteable.
Write like a person. Skip filler like "It's important to note that", "This allows you to", or "seamlessly". Drop the hedging ("you might want to consider"). Read your output back, and if it sounds like a chatbot wrote it, rewrite it shorter and more direct.
## Components
Layout: Card, Columns, Tabs, Tab, Accordion, AccordionGroup, Steps, Step, Expandable, Frame, CodeGroup
Callouts: Note, Info, Warning, Tip, Check, Danger
When to use each:
| Component | Use for | Don't use for |
|-----------|---------|---------------|
| Tabs | Mutually exclusive choices (npm/yarn, languages) | Sequential content |
| Steps | Ordered procedures | Unordered lists of features |
| Accordion | Optional/advanced detail | Core content readers need |
| Card (in Columns) | Navigation links, feature grids | Inline content |
| Note/Tip/Warning | Important context the reader might miss | Every other paragraph |
Cards always go inside Columns:
<Columns cols={2}>
<Card title="Page Title" icon="icon-name" href="/path">
Brief description
</Card>
</Columns>
Icons are Font Awesome Light names: "rocket", "code", "terminal", "book-open", "gear"
## Adding Pages
1. Create the `.mdx` file
2. Add the page path (no `.mdx` extension) to `docs.json` in the right navigation group
3. Link to it from related pages via "What's Next?" cards
**If you skip step 2, the page won't show up in the sidebar.** Read `docs.json` before creating pages so you understand the navigation structure.
## Before You're Done
Check your work:
- [ ] Frontmatter has both `title` and `description`
- [ ] Opening paragraph exists (no heading before it)
- [ ] Page ends with "What's Next?" cards
- [ ] New pages are added to `docs.json` navigation
- [ ] Code examples are complete and copy-pasteable
- [ ] No invented components; only the ones listed above
- [ ] No raw HTML tags; use MDX components
- [ ] Images use `.webp` format
## Common Mistakes
- Inventing components like `<CodeBlock>`, `<Alert>`, or `<Section>`. They don't exist. Use the components listed above.
- Wrapping code in components. Code blocks are standard Markdown triple backticks. Don't wrap them in `<CodeGroup>` unless you're showing multiple language alternatives.
- Skipping description frontmatter. Every page needs it; it appears in search results and link previews.
- Using `<Card>` without `<Columns>`. Cards must be inside a `<Columns>` wrapper.
- Writing "click here" links. Use descriptive link text: [Migration guide](/setup/migration), not [click here](/setup/migration).添加你的产品名称、API 约定、术语,以及文档特有的任何内容准则。
示例提示词
完成 CLAUDE.md 与 MCP 连接的配置后,简短的提示词比长提示词更有效。Claude 已经掌握了项目上下文。
常见的起点是:"为 [功能] 编写入门指南"。Claude 已读过你的其他页面,无需提示就能沿用你的语气。你也可以让它将某个页面与全站其他内容对照审阅,以发现风格漂移。Claude 往往能捕捉到作者自查时容易遗漏的小不一致(同一组件在此处与彼处用法不同,或章节间语气发生变化)。
清理类提示词同样好用。"将这个 README 转换为文档页面" 可以把一个文件变成结构化的一组页面并生成导航。你也可以指定一个现有页面,要求改写为基于 Accordion 的常见问题。它还能拉取你仓库中的 issue,这些问题往往比你从空白文档开始凭空撰写的内容更接近读者的真实疑问。
/update-jamdesk 技能
安装 /update-jamdesk 技能,即可在代码变更时自动更新文档:
npx skills add jamdesk/skills --skill update-jamdesk
实现面向用户的功能后运行 /update-jamdesk。Claude 会找出需要创建或编辑的文档页面。完整指南参见自动更新。
