Prompt
When changing or adding code, keep logic and dependencies clean:
- Centralize invariants in the owning function: if you need to clamp/validate values, apply it inside the core method that produces/returns them (the “source of truth”) rather than at every call site.
- Respect package layering: lower-level packages must not import higher-level/business packages (no reverse dependencies). Define contracts in the appropriate layer so dependencies flow downward only.
- Reuse existing utilities: avoid adding tiny wrappers/helpers when an approved library/helper already exists.
Example (centralize clamping):
// prefer: clamp inside Calculate (source of truth)
first, request, _ := ts.perf.Calculate() // already returns clamped request
Example (no reverse dependency):
- If
llmis a bottom package, it should notimport objects(business). Move shared types to a neutral/lower package or pass data via interfaces defined at the lower layer.
Example (reuse utility):
v := lo.ToPtr(123) // instead of custom xptr.IntPtr(123)