Skip to content

Commit c52450e

Browse files
bpmctclaude
andcommitted
docs: add documentation style guide for AI agents
Add comprehensive documentation style guide in .claude/docs/ directory following the format established in PR #21148 for PR_STYLE_GUIDE.md. This guide captures observed patterns from existing Coder documentation including: - Research requirements before writing (code verification, permissions, thresholds) - Document structure and organization patterns - Image usage and screenshot guidelines - Writing style and terminology conventions - Code examples and formatting standards - Documentation manifest requirements - Accuracy standards for specific numbers, permissions, and API endpoints - Proactive documentation approach for upcoming features 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 82bb833 commit c52450e

File tree

2 files changed

+295
-0
lines changed

2 files changed

+295
-0
lines changed

.claude/docs/DOCS_STYLE_GUIDE.md

Lines changed: 294 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,294 @@
1+
# Documentation Style Guide
2+
3+
This guide documents documentation patterns observed in the Coder repository, based on analysis of existing admin guides, tutorials, and reference documentation. This is specifically for documentation files in the `docs/` directory - see [CONTRIBUTING.md](../../docs/about/contributing/CONTRIBUTING.md) for general contribution guidelines.
4+
5+
## Research Before Writing
6+
7+
Before documenting a feature:
8+
9+
1. **Research similar documentation** - Read 10+ similar pages in `docs/` to understand writing style, structure, and conventions for your content type (admin guides, tutorials, reference docs, etc.)
10+
2. **Read the code implementation** - Check backend endpoints, frontend components, database queries
11+
3. **Verify permissions model** - Look up RBAC actions in `coderd/rbac/` (e.g., `view_insights` for Template Insights)
12+
4. **Check UI thresholds and defaults** - Review frontend code for color thresholds, time intervals, display logic
13+
5. **Cross-reference with tests** - Test files document expected behavior and edge cases
14+
6. **Verify API endpoints** - Check `coderd/coderd.go` for route registration
15+
16+
### Code Verification Checklist
17+
18+
When documenting features, always verify these implementation details:
19+
20+
- Read handler implementation in `coderd/`
21+
- Check permission requirements in `coderd/rbac/`
22+
- Review frontend components in `site/src/pages/` or `site/src/modules/`
23+
- Verify display thresholds and intervals (e.g., color codes, time defaults)
24+
- Confirm API endpoint paths and parameters
25+
- Check for server flags in serpent configuration
26+
27+
## Document Structure
28+
29+
### Title and Introduction Pattern
30+
31+
**H1 heading**: Single clear title without prefix
32+
33+
```markdown
34+
# Template Insights
35+
```
36+
37+
**Introduction**: 1-2 sentences describing what the feature does, concise and actionable
38+
39+
```markdown
40+
Template Insights provides detailed analytics and usage metrics for your Coder templates.
41+
```
42+
43+
### Premium Feature Callout
44+
45+
For Premium-only features, add `(Premium)` suffix to the H1 heading. The documentation system automatically links these to premium pricing information.
46+
47+
```markdown
48+
# Template Insights (Premium)
49+
```
50+
51+
### Overview Section Pattern
52+
53+
Common pattern after introduction:
54+
55+
```markdown
56+
## Overview
57+
58+
Template Insights offers visibility into:
59+
60+
- **Active Users**: Track the number of users actively using workspaces
61+
- **Application Usage**: See which applications users are accessing
62+
```
63+
64+
Use bold labels for capabilities, provides high-level understanding before details.
65+
66+
## Image Usage
67+
68+
### Placement and Format
69+
70+
**Place images after descriptive text**, then add caption:
71+
72+
```markdown
73+
![Template Insights page](../../images/admin/templates/template-insights.png)
74+
75+
<small>Template Insights showing weekly active users and connection latency metrics.</small>
76+
```
77+
78+
- Image format: `![Descriptive alt text](../../path/to/image.png)`
79+
- Caption: Use `<small>` tag below images
80+
- Alt text: Describe what's shown, not just repeat heading
81+
82+
### Image-Driven Documentation
83+
84+
When you have multiple screenshots showing different aspects of a feature:
85+
86+
1. **Structure sections around images** - Each major screenshot gets its own section
87+
2. **Describe what's visible** - Reference specific UI elements, data values shown in the screenshot
88+
3. **Flow naturally** - Let screenshots guide the reader through the feature
89+
90+
**Example**: Template Insights documentation has 3 screenshots that define the 3 main content sections.
91+
92+
### Screenshot Guidelines
93+
94+
**When screenshots are not available**: Use image placeholders with descriptive alt text and ask the user to provide screenshots:
95+
96+
```markdown
97+
![Placeholder: Template Insights page showing weekly active users chart](../../images/admin/templates/template-insights.png)
98+
```
99+
100+
Then ask: "Could you provide a screenshot of the Template Insights page? I've added a placeholder at [location]."
101+
102+
**When documenting with screenshots**:
103+
- Illustrate features being discussed in preceding text
104+
- Show actual UI/data, not abstract concepts
105+
- Reference specific values shown when explaining features
106+
- Organize documentation around key screenshots
107+
108+
## Content Organization
109+
110+
### Section Hierarchy
111+
112+
1. **H2 (##)**: Major sections - "Overview", "Accessing [Feature]", "Use Cases"
113+
2. **H3 (###)**: Subsections within major sections
114+
3. **H4 (####)**: Rare, only for deeply nested content
115+
116+
### Common Section Patterns
117+
118+
- **Accessing [Feature]**: How to navigate to/use the feature
119+
- **Use Cases**: Practical applications
120+
- **Permissions**: Access control information
121+
- **API Access**: Programmatic access details
122+
- **Related Documentation**: Links to related content
123+
124+
### Lists and Callouts
125+
126+
- **Unordered lists**: Non-sequential items, features, capabilities
127+
- **Ordered lists**: Step-by-step instructions
128+
- **Tables**: Comparing options, showing permissions, listing parameters
129+
- **Callouts**:
130+
- `> [!NOTE]` for additional information
131+
- `> [!WARNING]` for important warnings
132+
- `> [!TIP]` for helpful tips
133+
134+
## Writing Style
135+
136+
### Tone and Voice
137+
138+
- **Direct and concise**: Avoid unnecessary words
139+
- **Active voice**: "Template Insights tracks users" not "Users are tracked"
140+
- **Present tense**: "The chart displays..." not "The chart will display..."
141+
- **Second person**: "You can view..." for instructions
142+
143+
### Terminology
144+
145+
- **Consistent terms**: Use same term throughout (e.g., "workspace" not "workspace environment")
146+
- **Bold for UI elements**: "Navigate to the **Templates** page"
147+
- **Code formatting**: Use backticks for commands, file paths, code
148+
- Inline: `` `coder server` ``
149+
- Blocks: Use triple backticks with language identifier
150+
151+
### Instructions
152+
153+
- **Numbered lists** for sequential steps
154+
- **Start with verb**: "Navigate to", "Click", "Select", "Run"
155+
- **Be specific**: Include exact button/menu names in bold
156+
157+
## Code Examples
158+
159+
### Command Examples
160+
161+
```markdown
162+
```sh
163+
coder server --disable-template-insights
164+
```
165+
```
166+
167+
### Environment Variables
168+
169+
```markdown
170+
```sh
171+
CODER_DISABLE_TEMPLATE_INSIGHTS=true
172+
```
173+
```
174+
175+
### Code Comments
176+
177+
- Keep minimal
178+
- Explain non-obvious parameters
179+
- Use `# Comment` for shell, `// Comment` for other languages
180+
181+
## Links and References
182+
183+
### Internal Links
184+
185+
Use relative paths from current file location:
186+
187+
- `[Template Permissions](./template-permissions.md)`
188+
- `[API documentation](../../reference/api/insights.md)`
189+
190+
### Cross-References
191+
192+
- Link to related documentation at the end
193+
- Use descriptive text: "Learn about [template access control](./template-permissions.md)"
194+
- Not just: "[Click here](./template-permissions.md)"
195+
196+
### API References
197+
198+
Link to specific endpoints:
199+
200+
```markdown
201+
- `/api/v2/insights/templates` - Template usage metrics
202+
```
203+
204+
## Accuracy Standards
205+
206+
### Specific Numbers Matter
207+
208+
Document exact values from code:
209+
210+
- **Thresholds**: "green < 150ms, yellow 150-300ms, red ≥300ms"
211+
- **Time intervals**: "daily for templates < 5 weeks old, weekly for 5+ weeks"
212+
- **Counts and limits**: Use precise numbers, not approximations
213+
214+
### Permission Actions
215+
216+
- Use exact RBAC action names from code (e.g., `view_insights` not "view insights")
217+
- Reference permission system correctly (`template:view_insights` scope)
218+
- Specify which roles have permissions by default
219+
220+
### API Endpoints
221+
222+
- Use full, correct paths (e.g., `/api/v2/insights/templates` not `/insights/templates`)
223+
- Link to generated API documentation in `docs/reference/api/`
224+
225+
## Documentation Manifest
226+
227+
**CRITICAL**: All documentation pages must be added to `docs/manifest.json` to appear in navigation. Read the manifest file to understand the structure and find the appropriate section for your documentation. Place new pages in logical sections matching the existing hierarchy.
228+
229+
## Proactive Documentation
230+
231+
When documenting features that depend on upcoming PRs:
232+
233+
1. **Reference the PR explicitly** - Mention PR number and what it adds
234+
2. **Document the feature anyway** - Write as if feature exists
235+
3. **Link to auto-generated docs** - Point to CLI reference sections that will be created
236+
4. **Update PR description** - Note documentation is included proactively
237+
238+
**Example**: Template Insights docs include `--disable-template-insights` flag from PR #20940 before it merged, with link to `../../reference/cli/server.md#--disable-template-insights` that will exist when the PR lands.
239+
240+
## Special Sections
241+
242+
### Troubleshooting
243+
244+
- **H3 subheadings** for each issue
245+
- Format: Issue description followed by solution steps
246+
247+
### Prerequisites
248+
249+
- Bullet or numbered list
250+
- Include version requirements, dependencies, permissions
251+
252+
## Formatting Conventions
253+
254+
### Text Formatting
255+
256+
- **Bold** (`**text**`): UI elements, important concepts, labels
257+
- *Italic* (`*text*`): Rare, mainly for emphasis
258+
- `Code` (`` `text` ``): Commands, file paths, parameter names
259+
260+
### Tables
261+
262+
- Use for comparing options, listing parameters, showing permissions
263+
- Left-align text, right-align numbers
264+
- Keep simple - avoid nested formatting when possible
265+
266+
### Code Blocks
267+
268+
- **Always specify language**: `` ```sh ``, `` ```yaml ``, `` ```go ``
269+
- Include comments for complex examples
270+
- Keep minimal - show only relevant configuration
271+
272+
## Document Length
273+
274+
- **Comprehensive but scannable**: Cover all aspects but use clear headings
275+
- **Break up long sections**: Use H3 subheadings for logical chunks
276+
- **Visual hierarchy**: Images and code blocks break up text
277+
278+
## Auto-Generated Content
279+
280+
Some content is auto-generated with comments:
281+
282+
```markdown
283+
<!-- Code generated by 'make docs/...' DO NOT EDIT -->
284+
```
285+
286+
Don't manually edit auto-generated sections.
287+
288+
## Key Principles
289+
290+
1. **Research first** - Verify against actual code implementation
291+
2. **Be precise** - Use exact numbers, permission names, API paths
292+
3. **Visual structure** - Organize around screenshots when available
293+
4. **Link everything** - Related docs, API endpoints, CLI references
294+
5. **Manifest inclusion** - Add to manifest.json for navigation

CLAUDE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ clear what the new test covers.
197197
@.claude/docs/TESTING.md
198198
@.claude/docs/TROUBLESHOOTING.md
199199
@.claude/docs/DATABASE.md
200+
@.claude/docs/DOCS_STYLE_GUIDE.md
200201

201202
## Local Configuration
202203

0 commit comments

Comments
 (0)