Commit 0507734
authored
docs(agents): forbid reinventing stdlib helpers and nil-passing (#964)
## Summary
Two new rules in `AGENTS.md` under the "Architecture and code style"
hard rules, both triggered by real incidents during recent eval-harness
work:
- **Check the stdlib before writing a helper**: spend ten seconds
looking for a stdlib equivalent before defining a tiny utility
(`boolStr`, `max`, `min`, "convert primitive to string", "first non-zero
value"). Go 1.21+ builtin `min`/`max`, `strconv.FormatBool` /
`FormatInt`, `slices.Contains`, `maps.Keys`, `cmp.Or` — the stdlib
covers most of these. A helper that reimplements stdlib adds surface
area, hides the standard name, and tells reviewers "I didn't look."
- **Check your nils**: before passing a conceptual zero value (`nil`,
`""`, `0`) to a third-party function, read its godoc or grep for other
call sites. Functions that query the terminal, open files, or dial the
network commonly dereference their arguments.
`lipgloss.HasDarkBackground(os.Stdin, os.Stderr)` — not `(nil, nil)`.
"I'll pass nil and see" is a red flag.
No code change.1 parent 2535cf6 commit 0507734
1 file changed
Lines changed: 17 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
317 | 317 | | |
318 | 318 | | |
319 | 319 | | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
320 | 337 | | |
321 | 338 | | |
322 | 339 | | |
| |||
0 commit comments