Add code-style rules: var-at-top + functional args #10
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "code-style-rules"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Adds a Code Style section to .claude/rules/project-conventions.md with two rules that orchestrator + dispatched agents must apply going forward.
Summary
Variable declarations: prefer top-of-block. Group vars in a single var(...) block at the top of the function rather than scattering := lines. Preference, not absolute — scope-local short-lived vars (loop indices, throw-away buffers) stay where they're used. Convention: blank line between domain vars and trailing err.
Dependencies: functional args, not interfaces. Domain code (services, handlers, stores) receives function arguments, one per capability. Tests stub closures — no mock libraries. Multi-method dependencies use multiple func args (no struct-of-funcs shortcut). Exceptions: stdlib interfaces (http.Handler, io.Reader, etc.) and third-party we can't change (sqlc.Queries) — those wrap at the boundary and we pass extracted methods into domain code.
Migration
Existing merged code stays as-is. Follow-up beads will refactor it to the new style after Foundation closes. Current in-flight PRs (#7, #8, #9) land as-is.
Test plan
5f1261ba8781953aa0d4