Skip to content

Commit 0b63fba

Browse files
authored
docs: add repo AI guidance and skills (#22581)
1 parent b042c5f commit 0b63fba

13 files changed

Lines changed: 2146 additions & 2 deletions

.ai/AI-README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# AI Collaboration Guide
2+
3+
This directory stores repo-local guidance for AI agents working in `pingcap/docs`.
4+
5+
## Structure
6+
7+
- `.ai/shared/`: reusable repo policy, writing guidance, and translation guidance
8+
- `.ai/skills/`: workflow-specific instructions for recurring tasks in this repo
9+
10+
## Shared guidance
11+
12+
Read only the files that apply to the task:
13+
14+
- `.ai/shared/repo-conventions.md`: repository scope, branch rules, file naming, TOC expectations, TiDB Cloud boundaries, and validation habits
15+
- `.ai/shared/writing-style.md`: document structure, wording, formatting, headings, front matter, and repo-compatible writing style
16+
- `.ai/shared/translation-rules.md`: EN -> ZH translation constraints, traceability, structure preservation, and workflow expectations
17+
- `.ai/shared/translation-terms.md`: quick terminology reference for frequent translation terms
18+
19+
Use `resources/terms.md` when terminology is uncertain or not covered by the quick reference.
20+
21+
## Current skills
22+
23+
- `.ai/skills/review-doc-pr/`: review documentation PRs and Markdown diffs for factual accuracy, user usefulness, completeness, version fit, related-doc impact, links, and style
24+
- `.ai/skills/create-or-update-zh-translation-pr/`: create a new docs translation PR or update an existing one by combining repo-local scripts with minimal-edit translation rules and incremental source-diff handling
25+
26+
The translation skill includes bundled scripts under `.ai/skills/create-or-update-zh-translation-pr/scripts/` for:
27+
28+
- preparing structured translation inputs from a source PR
29+
- preparing structured translation inputs from either a full source PR or an update commit range
30+
- creating or reusing the translation branch
31+
- applying high-confidence deterministic updates before AI editing
32+
- committing, pushing, and creating or updating the PR with `gh`
33+
34+
## How to use it
35+
36+
Use progressive loading so the task stays grounded but efficient:
37+
38+
1. Start with the relevant shared guidance.
39+
2. Load a skill only when the task matches that workflow.
40+
3. If the selected skill includes bundled scripts, prefer the scripts over retyping ad hoc commands.
41+
4. Validate the files you changed with the repo's existing checks when practical.
42+
43+
Keep the task grounded in the existing repository rules, templates, scripts, and workflows.

.ai/shared/repo-conventions.md

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
# Repo Conventions
2+
3+
This file captures the repository-specific rules that agents should follow in `pingcap/docs`.
4+
5+
## Repository scope
6+
7+
- `pingcap/docs` stores the English TiDB documentation source.
8+
- `pingcap/docs-cn` stores the Chinese documentation source.
9+
- This repository is the source for the English TiDB documentation published on the PingCAP documentation website.
10+
- TiDB documentation and TiDB Cloud documentation do not always follow the same maintenance model. Do not assume they use the same branch, scope, or publication rules.
11+
12+
## Repository versions and branches
13+
14+
- The `master` branch tracks the latest development version of TiDB documentation.
15+
- Published TiDB documentation is maintained in the corresponding `release-<version>` branches.
16+
- Archived documentation is no longer maintained and should not receive normal documentation updates.
17+
- By default, target `master` unless the change clearly belongs to a maintained release branch.
18+
- Preserve branch intent. Do not treat release-branch behavior as the default development behavior, and do not move dev-only content into release branches.
19+
20+
## Choosing affected versions
21+
22+
Follow the repository's affected-version model when proposing or reviewing changes.
23+
24+
- By default, affected versions should be `master` only for documentation enhancements, missing-content additions, wording fixes, refactors within a topic, and general corrections that are not tied to a specific released behavior.
25+
- Choose the affected release branch or branches together with `master` when the change involves version-specific behavior, compatibility changes, changed default values, changed system variable behavior, display fixes, or broken-link fixes in published docs.
26+
- If a change applies to multiple maintained versions, prefer the latest applicable branch and use cherry-pick labels instead of opening parallel PRs by default.
27+
- If most of the change can be cherry-picked but some branches require different wording or follow-up edits, account for version-specific follow-up work and the relevant reminder labels.
28+
29+
## Cherry-pick and branch-follow-up conventions
30+
31+
- Use the repository's cherry-pick label workflow instead of inventing a custom multi-branch process.
32+
- If a change applies only to one documentation version, use that branch directly and do not add unnecessary cherry-pick labels.
33+
- If a change applies to multiple documentation versions, prefer a single PR on the latest applicable branch and rely on cherry-pick labels for the remaining maintained versions.
34+
- If branch-specific differences are expected, flag that clearly so reviewers know follow-up edits are required in the cherry-picked PRs.
35+
36+
## Repository layout and navigation
37+
38+
- Use the existing repository structure and nearby documents as the primary guide for where new content should live.
39+
- New navigable documents usually require a matching update in the appropriate `TOC.md` file.
40+
- When a document is added, removed, moved, or renamed, check whether related TOC files, aliases, links, and cross-document references also need updates.
41+
- Reuse existing document patterns in the same area before introducing a new structure.
42+
43+
## TiDB Cloud conventions
44+
45+
- In this repository, TiDB Cloud documentation is maintained in the `release-8.5` branch for content reuse.
46+
- To contribute to TiDB Cloud documentation, make sure the PR is based on `release-8.5`.
47+
- Use `TOC-tidb-cloud.md` and `TOC-tidb-cloud-*.md` to understand which documents are TiDB Cloud-only and which TiDB documents are reused by TiDB Cloud.
48+
- If a path in `TOC-tidb-cloud.md` or `TOC-tidb-cloud-*.md` starts with `/tidb-cloud/`, it is TiDB Cloud-only content.
49+
- If a path in `TOC-tidb-cloud.md` or `TOC-tidb-cloud-*.md` does not start with `/tidb-cloud/`, it is reused from TiDB documentation.
50+
- Be careful with `CustomContent` tags such as `<CustomContent platform="tidb">` and `<CustomContent platform="tidb-cloud">`. Do not change, remove, or expand them casually, because they control platform-specific rendering behavior.
51+
- When editing shared TiDB and TiDB Cloud content, verify whether the change applies to both platforms or only one.
52+
53+
## Contribution model
54+
55+
- New documents should follow the templates in `resources/doc-templates/` when applicable.
56+
- Keep PR descriptions compatible with `.github/pull_request_template.md`.
57+
- Keep changes scoped to the requested task. Do not broaden a focused doc update into unrelated cleanup.
58+
- Prefer existing repository workflows, labels, and conventions over ad hoc alternatives.
59+
- When contributing diagrams, follow the existing diagram-style guidance rather than introducing a new visual style.
60+
61+
## File naming rules
62+
63+
- Use file names that briefly describe the document content, for example, `destroy-tidb-cluster.md`.
64+
- Keep file names concise and general. Avoid overly specific wording that might require frequent renaming and cause unnecessary URL changes.
65+
- Except for special files such as `TOC.md`, `CONTRIBUTING.md`, and `README.md`, use lowercase letters only in file names.
66+
- If a file name contains multiple English words, separate them with hyphens (`-`).
67+
- Do not use underscores (`_`) in file names.
68+
- Use lowercase file extensions only.
69+
- Markdown files must use the `.md` extension.
70+
71+
## Content boundaries
72+
73+
- Preserve product behavior, version numbers, links, anchors, file intent, and branch intent unless the task explicitly requires changing them.
74+
- Do not silently change technical meaning while improving wording.
75+
- Avoid changing commands, code samples, UI strings, configuration names, API fields, JSON, EBNF content, or generated helper files unless the task directly requires it or they are factually wrong.
76+
- When editing syntax-related content, be careful not to break EBNF or other structured source formats.
77+
- Keep cross-repo translation traceability when work maps between `docs` and `docs-cn`.
78+
- When a translation-related task maps content across repositories, preserve the source PR relationship, terminology intent, and affected-file mapping.
79+
80+
## Front matter and document metadata
81+
82+
- Preserve existing front matter structure unless the task requires a metadata change.
83+
- When front matter is present, keep `title`, `summary`, `aliases`, and other metadata aligned with the document content.
84+
- If a file is moved or renamed, check whether `aliases` should be updated to preserve inbound links.
85+
- Do not add or remove metadata fields casually. Follow existing patterns in nearby documents.
86+
87+
## Linking and cross-document consistency
88+
89+
- Preserve repository-relative absolute links when that is the repository convention.
90+
- When editing a document that summarizes or references other docs, check whether those related docs also need updates.
91+
- If a term, version statement, feature behavior, workflow, or compatibility note changes in one place, check nearby overview, task, reference, and release-note content for possible follow-up updates.
92+
- When changing headings, verify whether anchors, intra-repo links, TOC entries, or external references might be affected.
93+
94+
## Validation habits
95+
96+
Use existing repository checks instead of inventing new ones.
97+
98+
- `./scripts/markdownlint <files>` for Markdown formatting
99+
- `./scripts/verify-links.sh` for link validation when links, anchors, moved files, or renamed files are involved
100+
- targeted repository scripts when the task touches glossary terms, keywords, anchor conflicts, or other specialized checks
101+
102+
If a full check is too expensive for the task, validate the files you changed and any directly affected TOC or link targets.
103+
104+
## Existing helpers
105+
106+
Look for established scripts and workflows before automating from scratch.
107+
108+
Use them as references for expected behavior, even when local credentials, permissions, or secrets prevent direct execution.
109+
110+
## Agent behavior in this repository
111+
112+
- Read the shared guidance in `.ai/shared/` before making non-trivial changes.
113+
- Use a matching skill in `.ai/skills/` when the task is workflow-specific.
114+
- Prefer minimal, targeted edits over broad rewrites.
115+
- Reuse existing wording, terminology, and document structure when they are already correct.
116+
- When unsure, check nearby docs, templates, and repository patterns before introducing a new approach.

.ai/shared/translation-rules.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Translation Rules
2+
3+
Use this file for EN -> ZH translation work that starts from changes in `pingcap/docs`.
4+
5+
## Scope
6+
7+
- This guidance is for mapping English docs work in `pingcap/docs` to Chinese docs work in `pingcap/docs-cn`.
8+
- Keep the translation faithful to the source change unless the target repo or branch requires a documented difference.
9+
10+
## Preserve structure
11+
12+
Keep the following stable unless translation requires a language-only adjustment:
13+
14+
- heading hierarchy
15+
- lists and numbering
16+
- tables and column order
17+
- code fences and info strings
18+
- links, anchors, and repo paths
19+
- commands, flags, API names, config keys, and version numbers
20+
- product names and branch names
21+
22+
Do not invent new product behavior, prerequisites, warnings, or version claims.
23+
24+
## Terminology
25+
26+
- Use `resources/terms.md` as the source of truth for terminology.
27+
- Use `.ai/shared/translation-terms.md` as a quick reference for high-frequency terms.
28+
- If a term is missing or ambiguous, keep the source term until you can verify the preferred translation.
29+
30+
## PR traceability
31+
32+
When preparing a translation PR:
33+
34+
- reference the source English PR or file links
35+
- preserve the intended affected versions as much as the target repo allows
36+
- keep the PR body compatible with `.github/pull_request_template.md`
37+
- make the relationship to the source PR explicit
38+
39+
## Workflow expectations
40+
41+
- Identify the source files and the target files before translating.
42+
- Check whether the target branch should be `master` or a release branch.
43+
- If a helper script is available, prefer adapting it over rewriting the workflow from scratch.
44+
- If local automation depends on unavailable tokens or secrets, still prepare the branch, file list, PR body, and follow-up instructions so a human can finish the workflow quickly.

.ai/shared/translation-terms.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Translation Terms
2+
3+
Use this file as a quick terminology reference for EN -> ZH translation work in the TiDB docs workflow.
4+
5+
For anything missing or unclear, check `resources/terms.md` before making a translation choice.
6+
7+
## High-frequency terms
8+
9+
| English | Preferred Chinese |
10+
| :-- | :-- |
11+
| cluster | 集群 |
12+
| node | 节点 |
13+
| instance | 实例 |
14+
| component | 组件 |
15+
| deployment | 部署 |
16+
| upgrade | 升级 |
17+
| configuration item | 配置项 |
18+
| parameter | 参数 |
19+
| system variable | 系统变量 |
20+
| feature | 特性 |
21+
| experimental feature | 实验特性 |
22+
| compatibility | 兼容性 |
23+
| limitation | 限制 |
24+
| high availability | 高可用 |
25+
| disaster recovery | 容灾 |
26+
| backup | 备份 |
27+
| restore | 恢复 |
28+
| migration | 迁移 |
29+
| replication | 复制 |
30+
| transaction | 事务 |
31+
| statement | 语句 |
32+
| table ||
33+
| schema | 数据库模式 |
34+
| index | 索引 |
35+
| query | 查询 |
36+
| SQL statement | SQL 语句 |
37+
| access | 访问 |
38+
| authentication | 身份验证 |
39+
| authorization | 授权 |
40+
| privilege | 权限 |
41+
| role | 角色 |
42+
| monitoring | 监控 |
43+
| alert | 报警/告警 |
44+
| log file | 日志文件 |
45+
| troubleshooting | 故障排查 |
46+
| glossary | 术语表 |
47+
48+
## Usage notes
49+
50+
- Keep product and feature names in English when that is the established repo usage.
51+
- Keep commands, flags, file paths, and configuration keys unchanged.
52+
- Prefer consistency with the target repo over ad hoc wording improvements.

.ai/shared/writing-style.md

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
# Writing Style
2+
3+
Use this guidance for authoring, editing, or reviewing Markdown in `pingcap/docs`.
4+
5+
## Overall principles
6+
7+
- Write for TiDB users, not for internal teams.
8+
- Use a conversational and friendly tone, but do not sound casual, playful, or promotional.
9+
- Prefer clear, direct, and practical language.
10+
- Do not pre-announce what the document will do. Start with useful information directly.
11+
- Write for a global audience. Avoid culture-specific references, vague shorthand, and region-specific assumptions.
12+
- Write accessibly. Prefer simple sentence structures and wording that is easy to scan and understand.
13+
14+
## File naming rules
15+
16+
- Use file names that briefly describe the document content, for example, `destroy-tidb-cluster.md`.
17+
- Keep file names concise and general. Avoid overly specific wording that might require frequent renaming and cause unnecessary URL changes.
18+
- Except for special files such as `TOC.md`, `CONTRIBUTING.md`, and `README.md`, use lowercase letters only in file names.
19+
- If a file name contains multiple English words, separate them with hyphens (`-`).
20+
- Do not use underscores (`_`) in file names.
21+
- Use lowercase file extensions only.
22+
- Markdown files must use the `.md` extension.
23+
24+
## Language and grammar
25+
26+
- Use second person, such as `you` and `your`, instead of `we`.
27+
- Use active voice whenever possible. Make it clear who performs the action.
28+
- Put conditions before instructions, not after.
29+
- Use standard American English spelling and punctuation.
30+
- Use serial commas.
31+
- Prefer concise and precise wording over decorative phrasing.
32+
- Preserve technical meaning. Do not rewrite in ways that change product behavior or scope.
33+
34+
## Structure and organization
35+
36+
- Keep the structure easy to scan with meaningful headings and short paragraphs.
37+
- Keep exactly one top-level heading per file.
38+
- Do not skip heading levels.
39+
- When frontmatter is present, keep the `title` aligned with the H1.
40+
- Write a concise `summary` that tells the reader what they will learn or do.
41+
- In `summary`, do not start with a special character such as `>`, `*`, `#`, `-`, or `[`. If the summary must begin with a special character, wrap the summary content in quotation marks.
42+
43+
## Choose the right document pattern
44+
45+
Use the existing templates in `resources/doc-templates/` as the primary shape guide.
46+
47+
- Task-style documents explain how to complete a procedure step by step.
48+
- Reference-style documents explain commands, parameters, options, system variables, configuration items, or APIs.
49+
- Use concept, troubleshooting, or new-feature templates when they better match the user task.
50+
51+
Match the document structure to the document type. Do not force a task flow into a reference document or a reference layout into a task document.
52+
53+
## Heading capitalization
54+
55+
Use capitalization consistently based on the file type and heading level:
56+
57+
- In TOC-related Markdown files, use title case for headings and navigation titles.
58+
- In regular Markdown files, use title case for the frontmatter `title`.
59+
- In regular Markdown files, use title case for the H1 heading.
60+
- In regular Markdown files, use sentence case for all headings below H1.
61+
62+
Keep the frontmatter `title` and the H1 aligned in wording and capitalization.
63+
64+
## Instructions and lists
65+
66+
- Use numbered lists for sequences of actions or ordered procedures.
67+
- Use bulleted lists for most other lists.
68+
- Use description lists for pairs of related items, such as a term and its definition.
69+
- In procedural content, make each step a clear action.
70+
- Put prerequisites, conditions, and important context before the steps they affect.
71+
- Keep lists parallel in grammar and structure.
72+
73+
## Links
74+
75+
- Use descriptive link text.
76+
- Do not use vague link text such as `here`, `click here`, or `this page`.
77+
- Preserve repository-relative absolute paths such as `/foo/bar.md` when that is the repository convention.
78+
- Prefer linking to the most relevant destination instead of adding multiple redundant links nearby.
79+
80+
## Formatting conventions
81+
82+
- Put code-related text in code font, including commands, file names, directory names, configuration items, parameter names, field names, environment variables, and literal values.
83+
- Put UI elements in bold.
84+
- Preserve code samples, commands, UI strings, API fields, JSON keys, and configuration names unless they are factually wrong or the task explicitly requires changing them.
85+
- Keep blank lines around headings, lists, and fenced code blocks.
86+
- Indent nested list content with 4 spaces in normal Markdown files.
87+
- Use unambiguous date formats when dates are necessary.
88+
- Keep punctuation and capitalization consistent within lists, headings, and tables.
89+
90+
## Notes, warnings, and emphasis
91+
92+
- Use notes and warnings only when they help the reader make a decision, avoid risk, or prevent confusion.
93+
- Do not overuse callouts for ordinary information.
94+
- Make warnings specific and actionable.
95+
- Do not use emphasis for decoration. Use it only when it improves clarity.
96+
97+
## Images
98+
99+
- Provide alt text for images.
100+
- Use images only when they add value that text alone cannot provide.
101+
- Keep screenshots and diagrams aligned with the current product behavior and UI text.
102+
103+
## Review lens
104+
105+
When reviewing or rewriting content, check these in order:
106+
107+
1. Is the content factually correct?
108+
2. Is the logic complete and easy to follow?
109+
3. Are other related documents also affected and likely to need updates?
110+
4. Does the structure match the document type?
111+
5. Does the wording improve clarity without changing product meaning?
112+
113+
Make feedback specific, actionable, and tied to the changed content. Avoid praise-only edits.

0 commit comments

Comments
 (0)