一键导入
go-types-conversion
Naming convention for type-translation files and functions. Use when creating or editing files that convert between domain, API, and DB types.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Naming convention for type-translation files and functions. Use when creating or editing files that convert between domain, API, and DB types.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Work on OpenMeter currency primitives in pkg/currencyx for fiat and custom currency codes, shared currency interfaces, rounding modes, calculators, allocation precision, fiat/custom boundaries, and callers in billing, charges, ledger, product catalog, subscriptions, API, or currency registry code.
Work with OpenMeter billing charges, including the root charges facade, charge meta queries, charge creation and advancement, usage-based lifecycle state machines, realization runs, and charges test setup. Use when modifying `openmeter/billing/charges/...` or charge-related tests.
Write end-to-end tests for OpenMeter against a live server. Use when adding tests under e2e/ that exercise API endpoints over HTTP (v1 generated SDK or v3 raw HTTP).
Work with the OpenMeter billing package. Use this skill whenever touching invoice lifecycle, billing profiles, customer overrides, invoice line items, gathering invoices, standard invoices, the invoice state machine, billing validation issues, billing-subscription sync, the billing worker, invoice calculation, rating/pricing engine, or tax config on billing objects. Also use when writing or debugging billing integration tests (BaseSuite, SubscriptionMixin), billing adapter (Ent queries), billing HTTP handlers, or the subscription→billing sync algorithm. Trigger this skill for any file under `openmeter/billing/`, `openmeter/billing/worker/`, `openmeter/billing/service/`, `openmeter/billing/adapter/`, `openmeter/billing/rating/`, `test/billing/`, or `cmd/billing-worker/`.
Use when writing or refactoring Go collection/pointer helper code in OpenMeter, especially when choosing between standard library slices/maps helpers and github.com/samber/lo for cloning, copying, equality, sorting, pointer literals, slice-to-map transforms, map keys/values, mapping, filtering, grouping, uniqueness, set-like conversions, and map entry transformations.
Add or modify API endpoints using TypeSpec. Use when adding new API routes, modifying request/response types, or changing the OpenAPI spec.
| name | go-types-conversion |
| description | Naming convention for type-translation files and functions. Use when creating or editing files that convert between domain, API, and DB types. |
| user-invocable | true |
| allowed-tools | Read, Edit, Write, Grep, Glob |
Apply to new and touched code. Do not rename legacy symbols unsolicited.
| Path contains | File name | Purpose |
|---|---|---|
httpdriver/, httphandler/, api/v3/handlers/ | convert.go | API ↔ domain |
adapter/, repo/ | mapping.go | DB ↔ domain |
Split large files by entity: convert_plan.go, mapping_subscription.go.
mapper.go is forbidden. Rename it to convert.go or mapping.go (based on layer) when the file is touched.
From<Qualifier><Thing> / To<Qualifier><Thing>The qualifier is API or DB — no other qualifiers (Domain, Model, package-name infixes).
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.
FromAPI<Thing> — takes the API type <Thing> as input, returns the domain representation.ToAPI<Thing> — takes the domain type as input, returns the API type <Thing>.FromDB<Thing> / ToDB<Thing>.// API ↔ domain
FromAPIPlan(a api.Plan) (plan.Plan, error)
ToAPIPlan(p plan.Plan) api.Plan
// Suffix is the API type name, even when domain type differs
FromAPIPlanCreate(a api.PlanCreate) (plan.CreateInput, error)
ToAPIPlanCreate(p plan.CreateInput) api.PlanCreate
FromAPIProRatingConfig(a api.ProRatingConfig) (productcatalog.ProRatingConfig, error)
ToAPIProRatingConfig(p productcatalog.ProRatingConfig) *api.ProRatingConfig
// DB ↔ domain — suffix is the DB type name
FromDBSubscription(row *db.Subscription) (subscription.Subscription, error)
ToDBSubscription(s subscription.Subscription) *db.Subscription
FromDBChargeFlatFee(row *entdb.ChargeFlatFee) (flatfee.Charge, error)
ToDBChargeFlatFee(c flatfee.Charge) *entdb.ChargeFlatFee
FromAPIPlanCreate, not bare FromAPI).fromDB, toAPI).(T, error). Infallible (projection) → T. Typically FromAPI… / FromDB… is fallible; the reverse is not.FromAPIPlans, ToDBSubscriptions. Same suffix rule — the plural of the non-domain type name.Map…, Convert…To…, primary As…<Source>To<Target> shape (e.g. APIToPlan)FromAPI / ToDB without a type suffixAPI. DB/persistence on one side → DB.Plan, PlanCreate, ChargeFlatFee).(T, error), infallible → T.mapper.go? Flag it — should be convert.go or mapping.go based on layer. Offer to rename as part of the edit. Don't rename silently.Grep for the old name to catch misses, keep the rename in its own commit.// Code generated header? Off-limits regardless.Lead with the specific rename and the reason. Keep it short.
MapChargeFlatFeeFromDB— useFromDBChargeFlatFee. Want me to rename and update callers?
Direction looks inverted —
FromAPI…returns a domain type, so this should beToAPIPlan. Drop the error return if it can't actually fail.
This file is
mapper.go— should beconvert.gosince it lives inhttphandler/. Want me to rename it?