You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
description: Naming convention for type-translation files and functions. Use when creating or editing files that convert between domain, API, and DB types.
4
+
user-invocable: true
5
+
allowed-tools: Read, Edit, Write, Grep, Glob
6
+
---
7
+
8
+
# Type Translation Naming
9
+
10
+
Apply to new and touched code. Do not rename legacy symbols unsolicited.
The qualifier is `API` or `DB` — no other qualifiers (`Domain`, `Model`, package-name infixes).
28
+
29
+
The suffix `<Thing>` is the **non-domain type's unqualified name** — the API type or DB type, not the domain type. This keeps it stable: a matched pair (`FromAPI<Thing>` / `ToAPI<Thing>`) always refers to the same non-domain type, regardless of direction.
30
+
31
+
-`FromAPI<Thing>` — takes the API type `<Thing>` as input, returns the domain representation.
32
+
-`ToAPI<Thing>` — takes the domain type as input, returns the API type `<Thing>`.
33
+
- Same for `FromDB<Thing>` / `ToDB<Thing>`.
34
+
35
+
### Examples
36
+
37
+
```go
38
+
// API ↔ domain
39
+
FromAPIPlan(a api.Plan) (plan.Plan, error)
40
+
ToAPIPlan(p plan.Plan) api.Plan
41
+
42
+
// Suffix is the API type name, even when domain type differs
0 commit comments