Skip to content

Commit a567f48

Browse files
committed
doc: technical writing instructions for agents
Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
1 parent 4badc0f commit a567f48

2 files changed

Lines changed: 68 additions & 1 deletion

File tree

‎.claude/rules/technical-writing.md‎

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
---
2+
paths:
3+
- "**/*.go"
4+
- "**/*.md"
5+
---
6+
7+
# Technical writing style (go-openapi)
8+
9+
Applies to every committed comment, commit message, README and doc-site page.
10+
11+
The standard is Ernest Gowers, *Plain Words*: **be short, be simple, be human.**
12+
His worked example is the whole rule:
13+
14+
DON'T Was this the realisation of an anticipated liability?
15+
DO Did you expect to have to do this?
16+
17+
The abstract nouns carry no information; the concrete verb carries all of it.
18+
19+
## Two tests
20+
21+
**The grep test.** Does the sentence contain something a reader can search for — an
22+
identifier, a file, a flag, an error, a number with a unit? Prose that names nothing has
23+
described the code without pointing at it.
24+
25+
**The quotability test.** A sentence that would survive being quoted on its own is too
26+
pleased with itself. Rewrite it until it merely sounds true.
27+
28+
## Never define by inversion
29+
30+
The worst and most frequent fault. A copula whose subject or predicate is a wh-clause
31+
promises a definition and delivers a metaphor. Both directions are banned:
32+
33+
DON'T Coverage is what says which templates a suite never reaches.
34+
DON'T What is lost is the doc comment.
35+
DO Coverage records which templates the suite never executed.
36+
DO A synthesized type loses its doc comment.
37+
38+
The rewrite is mechanical: find the verb hiding inside the wh-clause and make it the main
39+
verb of the sentence.
40+
41+
`which is why` pointing back at a fact just stated is legitimate, and rationed — one per
42+
comment is plenty.
43+
44+
## The rest
45+
46+
- **Name the thing.** `WithRoots`, not "the option that scopes a repository". Name the
47+
error, the file, the flag, the upstream package, the constant.
48+
- **Statement, not aphorism.** State mechanism and effect. Never close a paragraph on a
49+
maxim: the reflex lands hardest on a closing sentence.
50+
- **Keep a subject.** "New returns an error if the source is unreadable", not "What a
51+
source leaves out is settled where it is declared".
52+
- **Plain verbs.** add, fix, return, parse, reject, cap, prune, record. Code does not say,
53+
judge, grant, refuse, know, mean to, or reach for. `report` is fine when something
54+
genuinely reports.
55+
- **Keep the numbers.** Sizes with units, counts, ratios, advisory ids. `286 -> 178 KiB`,
56+
`GHSA-v2xp-g8xf-22pf`. Dropping them for a smoother sentence loses information.
57+
- **Be human.** Address the reader where there is advice: "Use `WithRoot` to confine local
58+
loading." Admit the awkward thing rather than smoothing it over.
59+
60+
## Self-check
61+
62+
# definition by inversion, both directions
63+
grep -rnE '\b(is|are) (what|where) [a-z]' --include='*.go' --include='*.md' .
64+
grep -rnE '(^|\. )What [a-z][a-z ,-]{3,50} (is|are) ' --include='*.go' --include='*.md' .
65+
66+
Subtract the legitimate `which/that/this/it is what` before judging the first one.
67+
Neither grep is a verdict — they find one fault out of six. The others need reading.

‎pointer.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ func (p *Pointer) set(node, data any, nameProvider NameProvider) (any, error) {
284284
// new child reference (e.g. a slice header returned by an "-" append) into its parent on the way
285285
// back up.
286286
//
287-
// Returning the (possibly new) node at each level is what makes append work at any depth without
287+
// Returning the (possibly new) node at each level makes append work at any depth without
288288
// requiring the caller to pass a pointer to the containing slice: the new slice header propagates
289289
// up and each parent rebinds it via the appropriate kind-specific setter.
290290
func (p *Pointer) setAt(node any, tokens []string, data any, nameProvider NameProvider) (any, error) {

0 commit comments

Comments
 (0)