|
| 1 | +# Language Guide |
| 2 | + |
| 3 | +Rules for writing junior-dev-friendly engineering documentation. |
| 4 | + |
| 5 | +## Core Principle |
| 6 | + |
| 7 | +Documentation is for the person joining the team tomorrow with two years of experience. |
| 8 | +Not for the person who built the system. Not for a computer science professor. |
| 9 | + |
| 10 | +## Rules |
| 11 | + |
| 12 | +### 1. Define every acronym on first use |
| 13 | + |
| 14 | +Bad: "The app uses OIDC via an M2M flow with RS256 JWT validation." |
| 15 | +Good: "The app uses OpenID Connect (OIDC) — an identity layer on top of OAuth 2.0 — to verify who you are. It validates the JSON Web Token (JWT) using the RS256 algorithm (a public-key signature scheme)." |
| 16 | + |
| 17 | +Define once per document, in parentheses after the first use. Not in a glossary at the bottom — by the time the reader gets there, they're already confused. |
| 18 | + |
| 19 | +### 2. One idea per sentence |
| 20 | + |
| 21 | +Bad: "The session cookie, which is HttpOnly and therefore inaccessible to JavaScript running in the browser, contains a base64-encoded JSON object that includes the access token, refresh token, and expiry timestamp, and is validated on every request by re-verifying the JWT signature against Kinde's public JWKS endpoint." |
| 22 | + |
| 23 | +Good: |
| 24 | +"The session is stored in an HttpOnly cookie — JavaScript running in the browser cannot read it (this prevents XSS attacks from stealing sessions). |
| 25 | +The cookie contains a base64-encoded JSON object with the access token, refresh token, and expiry time. |
| 26 | +The server validates this cookie on every request by checking the JWT signature against Kinde's public key." |
| 27 | + |
| 28 | +### 3. Explain the "why" before the "what" |
| 29 | + |
| 30 | +Bad: "Post text is stored in GCS." |
| 31 | +Good: "Firestore documents have a 1 MB size limit, which long-form posts would easily exceed. Post text is therefore stored in GCS (Google Cloud Storage), with Firestore holding only a path reference." |
| 32 | + |
| 33 | +### 4. Use "you" (second person) consistently |
| 34 | + |
| 35 | +Bad: "The developer must add their email to `infra/shared/main.tf`." |
| 36 | +Good: "Add your email to `infra/shared/main.tf`." |
| 37 | + |
| 38 | +The reader is always "you". Never "the developer", "the user", "one", or passive voice. |
| 39 | + |
| 40 | +### 5. Keep `## Overview` to 3 sentences max |
| 41 | + |
| 42 | +The overview answers three questions: |
| 43 | +1. What is this? (one sentence) |
| 44 | +2. Where does it live in the codebase? (one sentence) |
| 45 | +3. Why does it exist / what problem does it solve? (one sentence) |
| 46 | + |
| 47 | +Everything else goes in Design or Implementation. |
| 48 | + |
| 49 | +### 6. Use tables for lists of 3+ related properties |
| 50 | + |
| 51 | +Bad: |
| 52 | +"The cookie is set with HttpOnly=true to prevent XSS. It uses Secure=true in production to require HTTPS. SameSite=Lax is set for CSRF protection." |
| 53 | + |
| 54 | +Good: |
| 55 | +| Property | Value | Purpose | |
| 56 | +|----------|-------|---------| |
| 57 | +| HttpOnly | true | Prevents JavaScript from reading the cookie (XSS protection) | |
| 58 | +| Secure | true in prod | Cookie only sent over HTTPS | |
| 59 | +| SameSite | Lax | Prevents CSRF attacks | |
| 60 | + |
| 61 | +### 7. Use diagrams to replace, not supplement, prose |
| 62 | + |
| 63 | +If you have a numbered list describing a multi-step flow, replace it with a `sequenceDiagram` or `flowchart`. Keep the numbered list only if the diagram would be harder to read (e.g. a list of 3 simple steps). |
| 64 | + |
| 65 | +The goal is: can a new team member understand the flow in 30 seconds from the diagram alone? |
| 66 | + |
| 67 | +### 8. Avoid impl-detail jargon in Overview and Requirements |
| 68 | + |
| 69 | +- No class names, function names, or file paths in `## Overview` |
| 70 | +- No TypeScript generics or internal abstractions in `## Requirements` |
| 71 | +- Save those for `## Design` and `## Implementation` |
| 72 | + |
| 73 | +### 9. Code blocks for everything executable |
| 74 | + |
| 75 | +Any command, path, variable value, or snippet that the reader might copy-paste: put it in a code block. |
| 76 | + |
| 77 | +Bad: "Run pnpm install then just dev." |
| 78 | +Good: Run `pnpm install` then `just dev`. |
| 79 | +Or: |
| 80 | +```bash |
| 81 | +pnpm install |
| 82 | +just dev |
| 83 | +``` |
| 84 | + |
| 85 | +### 10. Link; don't duplicate |
| 86 | + |
| 87 | +If auth.md already explains the session format, link to it — don't repeat it. Use the `## References` section. Duplication creates maintenance debt. |
0 commit comments