update-docs
vercel/next.js
當使用者提出「更新我的變更所對應的文件」、「檢查此 PR 的文件」、「哪些文件需要更新」、「讓文件與程式碼保持同步」、「為此功能建立文件骨架」、「為此功能撰寫文件」、「檢視文件完整性」、「為此變更新增文件」、「哪些文件會受到影響」、「文件影響範圍」,或提及「docs/」、 「docs/01-app」、「docs/02-pages」、「MDX」、「文件更新」、「API 參考」、「.mdx 檔案」。 提供基於程式碼變更來更新 Next.js 文件的分步工作流程。
...展開全部Next.js 文件更新工具
引導您根據當前分支上的程式碼變更,更新 Next.js 文件。專為負責審查拉取請求(PR)以確認文件完整性的維護者所設計。
快速入門
- 分析變更:執行
git diff canary...HEAD --stat以查看哪些檔案已變更 - 識別受影響的文件:將變更後的原始檔案對應至文件路徑
- 審閱每份文件:逐步檢視更新內容,並需使用者確認
- 驗證:執行
pnpm lint以檢查格式 - 提交:將文件變更標記為待提交
工作流程:分析程式碼變更
步驟 1:取得差異
# See all changed files on this branch
git diff canary...HEAD --stat# See changes in specific areas
git diff canary...HEAD -- packages/next/src/
步驟 2:識別與文件相關的變更
請檢查以下領域的變更:
步驟 3:對應至文件檔案
使用 references/CODE-TO-DOCS-MAPPING.md 中的「程式碼到文件」對應功能,找出對應的文件檔案。
映射範例:
src/client/components/image.tsx→docs/01-app/03-api-reference/02-components/image.mdxsrc/server/config-shared.ts→docs/01-app/03-api-reference/05-config/
工作流程:更新現有文件
步驟 1:閱讀現行文件
在進行變更之前,請先閱讀現有文件以了解:
- 當前的結構與章節
- 正在使用的前置資訊欄位
- 是否使用
/來處理路由器專屬內容
步驟 2:確定需要更新的內容
常見的更新項目包括:
- 新增 props/選項:將其加入 props 表格,並建立一個說明使用方式的區段
- 行為變更:更新說明與範例
- 已廢棄的功能:新增廢棄通知與遷移指引
- 新增範例:依照規範新增程式碼區塊
步驟 3:經確認後套用更新
針對每項變更:
- 向使用者顯示您計劃變更的內容
- 在進行編輯前,請等待使用者確認
- 套用編輯
- 轉至下一項變更
步驟 4:檢查共享內容
若文件採用 source 字段模式(常見於 Pages Router 文件),則應編輯原始檔案。範例:
# docs/02-pages/... file with shared content
---
source: app/building-your-application/optimizing/images
---
請編輯 App Router 的原始碼,而非 Pages Router 的檔案。
步驟 5:驗證變更
pnpm lint # Check formatting
pnpm prettier-fix # Auto-fix formatting issues
工作流程:建立新功能文件骨架
當您要為完全新的功能新增文件時,請使用此流程。
步驟 1:確定文件類型
步驟 2:以正確的命名規則建立檔案
- 請使用 kebab-case 命名法:
my-new-feature.mdx - 若順序重要,請添加數字前綴:
05-my-new-feature.mdx - 根據功能類型將檔案放置於正確的目錄中
步驟 3:使用適當的範本
API 參考範本:
---
title: Feature Name
description: Brief description of what this feature does.
---{/* The content of this doc is shared between the app and pages router. You can use the `Content ` component to add content that is specific to the Pages Router. Any shared content should not be wrapped in a component. */}Brief introduction to the feature.## Reference### Props| Prop | Example | Type | Status |
| ----------------------- | ------------------ | ------ | -------- |
| [`propName`](#propname) | `propName="value"` | String | Required |#### `propName`Description of the prop.\`\`\`tsx filename="app/example.tsx" switcher
// TypeScript example
\`\`\`\`\`\`jsx filename="app/example.js" switcher
// JavaScript example
\`\`\`
指南範本:
---
title: How to do X in Next.js
nav_title: X
description: Learn how to implement X in your Next.js application.
---Introduction explaining why this guide is useful.## PrerequisitesWhat the reader needs to know before starting.## Step 1: First StepExplanation and code example.\`\`\`tsx filename="app/example.tsx" switcher
// Code example
\`\`\`## Step 2: Second StepContinue with more steps...## Next StepsRelated topics to explore.
步驟 4:新增相關連結
更新前置資訊以包含相關文件:
related:
title: Next Steps
description: Learn more about related features.
links:
- app/api-reference/functions/related-function
- app/guides/related-guide
文件編寫規範
請參閱 references/DOC-CONVENTIONS.md 以了解完整的格式規範。
快速參考
前置資訊(必填):
---
title: Page Title (2-3 words)
description: One or two sentences describing the page.
---
程式碼區塊:
\`\`\`tsx filename="app/page.tsx" switcher
// TypeScript first
\`\`\`\`\`\`jsx filename="app/page.js" switcher
// JavaScript second
\`\`\`
路由器專用內容:
Content only for App Router docs. Content only for Pages Router docs.
注意事項:
> **Good to know**: Single line note.> **Good to know**:
>
> - Multi-line note point 1
> - Multi-line note point 2
驗證清單
提交文件變更前:
- 前置資訊包含
title且description - 程式碼區塊具有
filename屬性 - TypeScript 範例使用
switcher搭配 JS 變體 - 屬性表格格式正確
- 相關連結指向有效的路徑
-
pnpm lint通過 - 變更內容能正確渲染(若提供預覽功能)
參考資料
references/DOC-CONVENTIONS.md- 完整的前置資訊與格式化規則references/CODE-TO-DOCS-MAPPING.md- 原始碼與文件之間的對應關係
Next.js Documentation Updater
Guides you through updating Next.js documentation based on code changes on the active branch. Designed for maintainers reviewing PRs for documentation completeness.
Quick Start
- Analyze changes: Run
git diff canary...HEAD --statto see what files changed - Identify affected docs: Map changed source files to documentation paths
- Review each doc: Walk through updates with user confirmation
- Validate: Run
pnpm lintto check formatting - Commit: Stage documentation changes
Workflow: Analyze Code Changes
Step 1: Get the diff
# See all changed files on this branch
git diff canary...HEAD --stat# See changes in specific areas
git diff canary...HEAD -- packages/next/src/
Step 2: Identify documentation-relevant changes
Look for changes in these areas:
Step 3: Map to documentation files
Use the code-to-docs mapping in references/CODE-TO-DOCS-MAPPING.md to find corresponding documentation files.
Example mappings:
src/client/components/image.tsx→docs/01-app/03-api-reference/02-components/image.mdxsrc/server/config-shared.ts→docs/01-app/03-api-reference/05-config/
Workflow: Update Existing Documentation
Step 1: Read the current documentation
Before making changes, read the existing doc to understand:
- Current structure and sections
- Frontmatter fields in use
- Whether it uses
<AppOnly>/<PagesOnly>for router-specific content
Step 2: Identify what needs updating
Common updates include:
- New props/options: Add to the props table and create a section explaining usage
- Changed behavior: Update descriptions and examples
- Deprecated features: Add deprecation notices and migration guidance
- New examples: Add code blocks following conventions
Step 3: Apply updates with confirmation
For each change:
- Show the user what you plan to change
- Wait for confirmation before editing
- Apply the edit
- Move to the next change
Step 4: Check for shared content
If the doc uses the source field pattern (common for Pages Router docs), the source file is the one to edit. Example:
# docs/02-pages/... file with shared content
---
source: app/building-your-application/optimizing/images
---
Edit the App Router source, not the Pages Router file.
Step 5: Validate changes
pnpm lint # Check formatting
pnpm prettier-fix # Auto-fix formatting issues
Workflow: Scaffold New Feature Documentation
Use this when adding documentation for entirely new features.
Step 1: Determine the doc type
Step 2: Create the file with proper naming
- Use kebab-case:
my-new-feature.mdx - Add numeric prefix if ordering matters:
05-my-new-feature.mdx - Place in the correct directory based on feature type
Step 3: Use the appropriate template
API Reference Template:
---
title: Feature Name
description: Brief description of what this feature does.
---{/* The content of this doc is shared between the app and pages router. You can use the `<PagesOnly>Content</PagesOnly>` component to add content that is specific to the Pages Router. Any shared content should not be wrapped in a component. */}Brief introduction to the feature.## Reference### Props<div style={{ overflowX: 'auto', width: '100%' }}>| Prop | Example | Type | Status |
| ----------------------- | ------------------ | ------ | -------- |
| [`propName`](#propname) | `propName="value"` | String | Required |</div>#### `propName`Description of the prop.\`\`\`tsx filename="app/example.tsx" switcher
// TypeScript example
\`\`\`\`\`\`jsx filename="app/example.js" switcher
// JavaScript example
\`\`\`
Guide Template:
---
title: How to do X in Next.js
nav_title: X
description: Learn how to implement X in your Next.js application.
---Introduction explaining why this guide is useful.## PrerequisitesWhat the reader needs to know before starting.## Step 1: First StepExplanation and code example.\`\`\`tsx filename="app/example.tsx" switcher
// Code example
\`\`\`## Step 2: Second StepContinue with more steps...## Next StepsRelated topics to explore.
Step 4: Add related links
Update frontmatter with related documentation:
related:
title: Next Steps
description: Learn more about related features.
links:
- app/api-reference/functions/related-function
- app/guides/related-guide
Documentation Conventions
See references/DOC-CONVENTIONS.md for complete formatting rules.
Quick Reference
Frontmatter (required):
---
title: Page Title (2-3 words)
description: One or two sentences describing the page.
---
Code blocks:
\`\`\`tsx filename="app/page.tsx" switcher
// TypeScript first
\`\`\`\`\`\`jsx filename="app/page.js" switcher
// JavaScript second
\`\`\`
Router-specific content:
<AppOnly>Content only for App Router docs.</AppOnly><PagesOnly>Content only for Pages Router docs.</PagesOnly>
Notes:
> **Good to know**: Single line note.> **Good to know**:
>
> - Multi-line note point 1
> - Multi-line note point 2
Validation Checklist
Before committing documentation changes:
- Frontmatter has
titleanddescription - Code blocks have
filenameattribute - TypeScript examples use
switcherwith JS variant - Props tables are properly formatted
- Related links point to valid paths
-
pnpm lintpasses - Changes render correctly (if preview available)
References
references/DOC-CONVENTIONS.md- Complete frontmatter and formatting rulesreferences/CODE-TO-DOCS-MAPPING.md- Source code to documentation mapping
所有檔案
3 個檔案安裝 update-docs
請下載並將技能檔案解壓縮至您的 .claude/skills/ 目錄中。
下載 ZIP複製儲存庫並將技能檔案複製到您的專案中。
git clone https://github.com/vercel/next.js/tree/canary/.agents/skills/update-docs # Copy the skill folder to .claude/skills/ or .codex/skills/
複製





首頁
