Skip to content

docs(agents): forbid reinventing stdlib helpers and nil-passing#964

Merged
cpcloud merged 1 commit intomicasa-dev:mainfrom
cpcloud:agents-stdlib-rules
Apr 20, 2026
Merged

docs(agents): forbid reinventing stdlib helpers and nil-passing#964
cpcloud merged 1 commit intomicasa-dev:mainfrom
cpcloud:agents-stdlib-rules

Conversation

@cpcloud
Copy link
Copy Markdown
Collaborator

@cpcloud cpcloud commented Apr 20, 2026

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.

@cpcloud cpcloud added the documentation Improvements or additions to documentation label Apr 20, 2026
@cpcloud cpcloud merged commit 0507734 into micasa-dev:main Apr 20, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant