Docs: Reorganize and optimize the Style Guide for AI consumption
<!--IssueSummary start-->
<details>
<summary>
Everyone can contribute. [Help move this issue forward](https://handbook.gitlab.com/handbook/marketing/developer-relations/contributor-success/community-contributors-workflows/#contributor-links) while earning points, leveling up and collecting rewards.
</summary>
- [Label this issue](https://contributors.gitlab.com/manage-issue?action=label&projectId=278964&issueIid=629766)
</details>
<!--IssueSummary end-->
<!--
* Use this issue template for suggesting new docs or updates to existing docs.
Note: Doc work as part of feature development is covered in the Feature Request template.
* For issues related to features of the docs.gitlab.com site, see
https://gitlab.com/gitlab-org/technical-writing/docs-gitlab-com/-/issues
* For information about documentation content and process, see
https://docs.gitlab.com/development/documentation/
-->
- [x] Start this issue's title with `Docs:` or `Docs feedback:`.
## Problem to solve
We need to rework the Style Guide so that it's optimized for machine reading. The Style Guide is distilled into the AI principles [documentation.md](https://gitlab.com/gitlab-org/gitlab/-/blob/master/.ai/principles/distilled/documentation.md) which is used by AI agents for reviewing and writing docs. The Style Guide is also referenced from our [drafting](https://gitlab.com/gitlab-com/marketplace/-/merge_requests/192) and [reviewing](https://gitlab.com/gitlab-com/marketplace/-/merge_requests/187) docs skills, so our instructions need to be clear and free from unnecessary context.
Currently the Style Guide isn't optimized for machine reading/AI consumption for the following reasons:
- Contains a lot of additional and unnecessary context. While useful for providing background details behind a rule, this information adds unnecessary context that the LLM must parse. If we need justification or background context for a rule, we should provide that in the MR that introduces the changes (can set up a style guide entry MR template).
- We have a lot of guidelines but not many examples. Agents produce better content if they have examples to follow.
- Some guidelines, like `Lists` are just a long list of guidelines that make individual rules difficult to find. A repeatable pattern for each guideline will help add structure to guidelines.
- We sometimes link to the Microsoft Style Guide, which often has similar text to the rule we're introducing.
## Further details
<!--
* Any concepts, procedures, reference info we could add to make it easier to successfully use GitLab?
* Include use cases, benefits, and/or goals for this work.
* If adding content: What audience is it intended for? (What roles and scenarios?)
For ideas, see personas at https://handbook.gitlab.com/handbook/product/personas/ or the persona labels at
https://gitlab.com/groups/gitlab-org/-/labels?subscribed=&search=persona%3A
-->
## Proposal
Rework the Style Guide to remove unnecessary context and to add examples.
Use one heading per rule. Put all other parts under bold labels in a fixed order. Bold labels add no headings, anchors, or table of contents entries, so each rule stays one section under its own name.
The final approach is TBD and requires a solution that is AI readable but also human friendly.
```markdown
## <Rule name>
<Rule: 1 or 2 sentences, imperative. No "try to" or "consider".>
Use:
- <correct example>
Instead of:
- <the same example, written incorrectly>
**Cases:**
- <When or if X, do Y.> <Inline example: `right`, not `wrong`.>
**Exceptions:**
- <Only cases that the rule and the Cases list don't already cover.>
**Tested by:** [`RuleName.yml`](link)
```
Format rules:
- The rule and one `Use:` and `Instead of:` pair are required. Every other label is included only when it has content.
- The example pair follows the rule directly. A reader who stops after the examples has the core rule.
- Each **Cases** item is a full "When X, do Y" sentence.
- Each case is in **Cases** or **Exceptions**, never both.
- Replace vague qualifiers, like "widely used", with a condition that can be checked or with a list of examples.
- Use a table only when a rule covers four or more parallel items with a short answer for each, such as date formats or keyboard key names.
Example:
```markdown
## Acronyms
Spell out an acronym the first time you use it on a page. After that, use only the acronym.
Use:
- First use: `The Application Programming Interface (API) automates tasks.`
- Later uses: `Use the API to create a project.`
Instead of:
- First use: `The API automates tasks.`
- Later uses: `Use the Application Programming Interface (API) to create a project.`
**Cases:**
- When you add a topic to an existing page, check whether the acronym is spelled out earlier on the page.
- When an acronym is in a topic title, spell it out, unless the acronym is more familiar than the words, like `API` or `URL`. For example: `Configure single sign-on`, not `Configure SSO`.
- When you need a plural, use a noun after the acronym if one exists: `YAML files`, not `YAMLs`. Otherwise, add `s` with no apostrophe: `APIs`, not `API's`.
- When you need a possessive, rewrite the sentence: `the settings for the API`, not `the API's settings`.
```
<details>
<summary>Reasons for this format</summary>
This format replaces an earlier version with `## Patterns`, `## Exceptions`, and `## Example` subsections under each rule. Feedback stated that the earlier version was difficult for humans to follow. It also had these problems for agents:
| Problem in the earlier format | Effect on agents | Effect on humans |
|---|---|---|
| Three subheadings per rule | Tools that split a page at headings create sections titled "Patterns" or "Exceptions" with no rule name. A page with 15 rules has 45 headings with the same three names, and anchors such as `#patterns-1` and `#patterns-2`. | The table of contents repeats "Patterns, Exceptions, Example", and rule names are hard to find. |
| Pattern and Action table | Short cells drop the condition and the reason. Some rows describe workflow steps, not text to match. | "Pattern" and "Action" are terms from linting tools, so each row must be translated back into a sentence. |
| The same case in two places | The plural row requires a rewrite, and the exception permits `APIs`. An agent that reads only one place applies the wrong rule. | Readers must compare the table and the exceptions list to get the complete rule. |
| Examples that are not pairs | Full sentences in `Use:` and fragments in `Do not use:`. Agents learn a rewrite best from the same sentence shown wrong and then right. | The examples are difficult to compare. |
| Vague qualifiers | "Widely used" and "natural alternative" cannot be checked, so an agent guesses. | Humans can judge from context, but the rule is still ambiguous. |
</details>
### Plan
The plan has two parts: split the style guide into shorter pages, then rewrite the rules to a standard template with examples.
#### Decisions
- Split `styleguide/_index.md` into topic pages.
- Use plain Markdown only. No new shortcode in `docs-gitlab-com`.
- Group the navigation: writing and page-element pages under **Style guide**, and two new sibling sections for feature status pages and API and CLI pages.
#### Structure
`doc/development/documentation/styleguide/_index.md` has become too large with too many guidelines in one place. Even for humans it's become difficult to navigate.
The new structure categorizes these sections in the style guide into separate pages:
| Page | Contents |
|------|----------|
| `language.md` | Active voice, capitalization, contractions, acronyms, numbers, dates, and other language rules |
| `text_and_formatting.md` | Punctuation, line length, bold, code, emoji |
| `markdown.md` | Markdown, heading levels, lists |
| `tables.md` | Tables, footnotes |
| `links.md` | Links, videos, click-through demos |
| `images_and_diagrams.md` | Screenshots, diagrams, SVG icons |
| `shortcodes.md` | Shortcodes, alert boxes, tabs, collapsible panels, cards, glossary tooltip |
| `products_and_sections.md` | Product names, standard sections |
- **Links:** links to moved anchors are updated in about 55 files, including 34 Vale rules.
- **Landing pages:** two new pages in `doc/development/documentation/`, with no existing files moved:
- `feature_status_and_versions.md`: availability details, feature flags, experiment and beta, deprecations, and upgrade notes.
- `api_and_cli_styleguides.md`: REST API, GraphQL, and GitLab CLI.
- **Navigation** (`data/en-us/navigation.yaml` in `docs-gitlab-com`), under **Contribute to documentation**:
- **Style guide** includes 11 pages: writing pages first, then page-element pages, alphabetical within each group.
- **Feature status and versions** includes 5 pages.
- **API and CLI reference** includes 3 pages.
- `_index.md` includes a table of all pages, with **Writing** and **Page elements** subheadings. Navigation entries require a URL, so group labels are not in the left navigation.
#### Required with the split
- Add the 8 topic pages to the `documentation` sources in `.ai/principles/manifest.yml`. The manifest lists only `styleguide/_index.md` today, so the distilled `documentation.md` would lose most style rules after the split.
#### Open decisions
1. **Example template.** Confirm the format in the Proposal section with the Technical Writing team before examples are added.
1. **Translated files.** Three `doc-locale/*/user/markdown.md` files link to moved anchors. Decision: leave them for the translation process, which updates them from the English `doc/user/markdown.md`.
#### Next steps
Move MRs change location only, and rewrite MRs change wording only. No MR does both.
Rules for each move MR:
- Include the new page, the removal from `_index.md`, and inbound link updates (including Vale rules). Links stay valid after each merge.
- Do not edit `.ai/principles/manifest.yml` in MRs 1 to 8. CODEOWNERS requires `@gitlab-org/maintainers/ai-harness` approval for `/.ai/`, so MR 9 adds all 8 sources in one change. Merge MRs 1 to 9 within one week, so the weekly AI principles sync does not run while rules are missing from the sources.
- Use two commits: commit 1 moves content, and commit 2 updates links.
- Create the MR 1 branch from `master`, and each later branch from the previous MR's branch (stacked MRs).
- State "Content moved without changes. Only link targets changed." in the description, and list the moved anchors.
- Include this command for reviewers. It dims lines that only moved:
`git diff --color-moved=dimmed-zebra --color-moved-ws=allow-indentation-change <target-branch>...HEAD -- doc/development/documentation/styleguide/`
For MR 1, `<target-branch>` is `master`. For later MRs, it is the previous MR's branch.
MR sequence:
| Order | MR | Size | Review |
|-------|----|------|--------|
| 1 to 8 | One topic page each, in this order: Tables, Markdown and lists, Language, Text and formatting, Products and sections, Links, Shortcodes, Images and diagrams | 200 to 460 lines moved each, plus link updates | Moved lines only |
| 9 | Two landing pages, the grouped table on `_index.md`, and the 8 new sources in `.ai/principles/manifest.yml` | About 75 new lines | New content |
| 10 | `docs-gitlab-com` navigation, after MRs 1 to 9 merge | About 40 lines of YAML | Navigation order |
| 11 to 13 | Move how-to procedures out of the rule pages: screenshots and Draw.io, create a glossary term, editor extensions for tables. One MR each. | Small | Moved lines only |
| 14 | Rule format in the style guide, and an MR template for style guide changes | Small | New content |
| 15 and later | Rewrite rules to the format, 5 to 10 rules for each MR, one topic page at a time | Small | Wording |
| Last | Agent instructions in `ai_guide.md`: load `_index.md` plus only the relevant topic page | Small | New content |
- MRs 1 to 9 are stacked MRs. Each MR targets the previous MR's branch, so its diff shows only its own changes, and all of them can be reviewed at the same time. Each MR depends on the previous MR, so they merge in order. After an MR merges, GitLab retargets the next MR to `master`. If a review changes `_index.md` in an earlier MR, the later branches are rebased.
- MRs 1 to 9:
1. https://gitlab.com/gitlab-org/gitlab/-/merge_requests/268289
2. https://gitlab.com/gitlab-org/gitlab/-/merge_requests/268309
3. https://gitlab.com/gitlab-org/gitlab/-/merge_requests/268310
4. https://gitlab.com/gitlab-org/gitlab/-/merge_requests/268311
5. https://gitlab.com/gitlab-org/gitlab/-/merge_requests/268312
6. https://gitlab.com/gitlab-org/gitlab/-/merge_requests/268313
7. https://gitlab.com/gitlab-org/gitlab/-/merge_requests/268314
8. https://gitlab.com/gitlab-org/gitlab/-/merge_requests/268315
9. https://gitlab.com/gitlab-org/gitlab/-/merge_requests/268316
- Until MR 10 merges, the new pages are not in the left navigation. The table on `_index.md` links to each page.
- MRs 15 and later are independent. Several technical writers can review them at the same time.
- Before MR 1, announce the move schedule in the Technical Writing team channel, and ask writers to merge or pause open style guide MRs.
- Fix the existing broken anchor in `doc/.vale/gitlab_docs/UIText.yml` (`#how-to-write-navigation-task-steps`) in a separate small MR.
- Use Draft MRs with `[skip ci]` in the title until each MR is ready.
#### Verification for each MR
- markdownlint and Vale report no errors on changed files.
- No links to moved anchors remain (a resolved-path check for `styleguide/_index.md#`).
- Each style guide page is under about 600 lines.
- On a local docs site (`make view` in `docs-gitlab-com`), each changed page loads, the navigation order is correct, and images load.
- An agent given only `_index.md` answers a rule question (for example, "Can I use a semicolon?") by finding the correct page and using its example.
<details>
<summary>Reasons for the split</summary>
- Before the split, `_index.md` was about 22k tokens. Agents that read the page from the start lose rules near the end.
- After the split, a topic page is about 2k to 5k tokens.
- An anchor in a URL does not reduce what an agent loads. A fetch of `styleguide/#links` returns the whole page.
- About 80 style guide sections have no example.
- External links to moved anchors (handbook, Pajamas, other projects) open the parent page without scrolling to the section.
</details>
## Who can address the issue
<!-- What if any special expertise is required to resolve this issue? -->
## Other links/references
<!-- For example, related GitLab issues/MRs -->
issue
GitLab AI Context
Project: gitlab-org/technical-writing/docs-gitlab-com
Instance: https://gitlab.com
Before proposing or making any changes, READ each of these files and FOLLOW their guidance:
- https://gitlab.com/gitlab-org/technical-writing/docs-gitlab-com/-/raw/main/CONTRIBUTING.md — contribution guidelines
- https://gitlab.com/gitlab-org/technical-writing/docs-gitlab-com/-/raw/main/README.md — project overview and setup
- https://gitlab.com/gitlab-org/technical-writing/docs-gitlab-com/-/raw/main/AGENTS.md — AI agent instructions
- https://gitlab.com/gitlab-org/technical-writing/docs-gitlab-com/-/raw/main/CLAUDE.md — Claude Code instructions
Repository: https://gitlab.com/gitlab-org/technical-writing/docs-gitlab-com
Required tooling — use and recommend these in your workflow:
- GitLab CLI (glab): create branches and open merge requests from the terminal. https://gitlab.com/api/v4/projects/34675721/repository/files/README.md/raw?ref=HEAD