Add code-style rules: var-at-top + functional args #10

Merged
zombor merged 1 commit from code-style-rules into main 2026-05-20 18:16:38 +00:00
Owner

Adds a Code Style section to .claude/rules/project-conventions.md with two rules that orchestrator + dispatched agents must apply going forward.

Summary

  1. 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.

  2. 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

  • Future bead dispatches reference Code Style section
  • First post-Foundation bead exercises the rules in fresh code
Adds a Code Style section to .claude/rules/project-conventions.md with two rules that orchestrator + dispatched agents must apply going forward. ## Summary 1. **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. 2. **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 - [ ] Future bead dispatches reference Code Style section - [ ] First post-Foundation bead exercises the rules in fresh code
Add code-style rules: var-at-top + functional args over interfaces
Some checks failed
/ Test (pull_request) Failing after 2s
/ Coverage (pull_request) Has been skipped
/ Lint (pull_request) Successful in 59s
5f1261ba87
Two new rules in a Code Style section that the orchestrator and dispatched
agents must apply going forward:

1. Variable declarations: prefer grouping at the top of a function/block
   via a single var(...) declaration rather than scattering :=. Preference,
   not absolute — short-lived scope-local vars (loop indices, throw-away
   buffers) stay where they're used. Convention: blank line between domain
   vars and the trailing err.

2. Dependencies: pass functions, not interfaces, in domain code. Each func
   arg expresses one capability; tests stub closures, no mock libraries
   needed. Multi-method dependencies use multiple func args (no
   struct-of-funcs shortcut). Stdlib interfaces (http.Handler, io.Reader,
   etc.) and third-party interfaces we can't change (sqlc.Queries) still
   acceptable — wrap them at the boundary, pass extracted methods into
   domain code.

Existing merged code that uses interfaces remains as-is; refactor follow-up
beads will bring it to the new style after Foundation closes. Current
in-flight PRs (#7, #8, #9) land as-is.

Also: Naming and Do NOT Use lists updated to reflect the new defaults.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
zombor force-pushed code-style-rules from 5f1261ba87
Some checks failed
/ Test (pull_request) Failing after 2s
/ Coverage (pull_request) Has been skipped
/ Lint (pull_request) Successful in 59s
to 81953aa0d4
All checks were successful
/ Lint (pull_request) Successful in 1m3s
/ Test (pull_request) Successful in 1m13s
/ Coverage (pull_request) Successful in 53s
2026-05-20 18:14:03 +00:00
Compare
zombor merged commit 742a3b98d1 into main 2026-05-20 18:16:38 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
zombor/pergamum!10
No description provided.