documentation/STYLE.md · main · 2026-09-06

Style Guide

One register for everything in this repository: the one README.md and specs/ already use. Short sentences. Say what, not why. Reasons go to the places named in section 1. Applies to new text now; existing text migrates in sweeps.

1. Where things go

Kind of textHomeNot here
What a command doesShort, Long, flag helpdesign reasons, history
How to do a taska guide doc (SOCIAL.md, PM.md, REVIEW.md)mechanism, rationale
Exact values: keys, layouts, env vars, artifactsa reference tableprose
Why something is the way it isthe commit body of the change; a constraint the next editor must respect gets one line at the point of constraintlonger comments, help text, subjects, a separate decisions file
What changed and whenthe commit body; STATIC-SITE.md for the page schemacode comments
A rule an implementation must followspecs/documentation

2. Prose rules

Apply to help, errors, TUI hints, site strings, log lines, guides, decisions, comments and commit messages.

3. Help text

FieldRuleLimit
Shortverb first, no period, no parenthetical50 characters
flag helpwhat the flag does; cobra prints the default60 characters, no parenthetical
Longone paragraph of what, then examples; anything longer goes to the guide and is linked12 lines
errorone sentence naming the thing and the next actionone line
stderr hintsame as error, prefixed gitsocial:one line

Examples, before and after.

Short:

Flag help:

Hint (the original has an em-dash where [em-dash] stands):

Long for push, 73 lines today:

Publish local GitMsg data to one or more remotes. On an s3 remote with
site.publish enabled, also publish the static site.

Remotes resolve in order: arguments, git config gitsocial.pushRemote,
then origin, or the first s3 remote when origin is not one. Diverged
gitmsg/* branches merge automatically. Diverged code branches fail
with a hint.

Examples:
  gitsocial push                # resolved remotes, data and site
  gitsocial push r2 backup      # named remotes, in order
  gitsocial push --site-only    # refresh the site, push no data
  gitsocial push --dry-run      # show what would be pushed

See documentation/S3.md for remotes and thin fork buckets.

The current text's explanations (the remote heuristic, the thin-fork escape hatch, why gitmsg branches merge cleanly) move to S3.md as guide steps, reference rows and decisions.

4. Documentation

Two kinds of doc. A file is one kind.

KindPurposeShapeExamples
Guidedo a tasksteps and commands in the order a user meets them; under 150 linesSOCIAL.md, PM.md, REVIEW.md
Referencelook a value uptables: keys, flags, layouts, env vars, artifactsSETTINGS.md, the layout and env sections of S3.md

Rules:

Example, the commits/ bullet in STATIC-SITE.md, 300 words today, becomes two things. The reasoning (why commits get no page of their own) stays in the commit that introduced the layer.

5. Comments

PlaceRule
file headerone line: // file.go - what this file holds
functionone line above each function saying what it does
inlineone line, only where the next lines are not obvious from the code
package docunder 10 lines, only for a package with a non-trivial contract
struct fieldtrailing, one line, only for a unit or a sentinel

Not in comments: why a design was chosen, what was tried, version history, threat models, invariants restated from another file, the same reasoning twice. When such a block comes out it becomes one of four things: a constraint the next editor must respect, as one line at the point of constraint; how a mechanism works, as a reference row in the owning doc; why this over the alternatives, in the commit body; or nothing, since git history keeps the deleted text.

Examples:

The same rules apply to Go, JS, CSS, HTML, shell and tests.

6. Commits

Example. Before, one commit with no body:

S3 backend: bucket writes go out in parallel and retry transient faults, a first push publishes the whole site, and push maintenance reports progress

After, three commits: S3: upload bucket writes in parallel with retry, with a body naming the concurrency default and the retried status codes; S3: publish the whole site on a first push; Push: report maintenance progress.

7. Tests

8. Checks

Planned, not yet in the gate: scripts/prose-check.sh counts em-dashes outside specs/; comment blocks over 3 lines in Go, JS, CSS and HTML outside package docs; Short over 50 characters; flag help over 60 characters or containing a parenthesis; commit subjects over 72 characters in the pushed range. The counts are compared with a committed baseline and may only go down. Until the script exists, the reviewer applies the same list by hand.