skills/builderx_api-schemas/SKILL.md
Guidelines for creating Ecto Schemas in builderx_api, including composite primary keys, custom json function and Ecto.Changeset.
npx skillsauth add vuluu2k/skills builderx_api-schemasInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Conventions and structures for defining Ecto Schemas in the builderx_api project.
| Topic | Description | Reference |
|-------|-------------|-----------|
| Schema Definition | Primary keys, site_id attribute, timestamps | core-schema |
| JSON Serialization | Custom json/1 and json/2 implementation in Ecto Schema | core-schema |
defmodule BuilderxApi.Products.Product do
use Ecto.Schema
import Ecto.Changeset
alias BuilderxApi.Sites.Site
@primary_key {:id, :binary_id, autogenerate: true}
@foreign_key_type :binary_id
@non_required_fields [:id, :inserted_at, :updated_at]
schema "products" do
belongs_to(:site, Site, type: Ecto.UUID, primary_key: true)
field :name, :string
timestamps(type: :utc_datetime_usec)
end
def changeset(%__MODULE__{} = product, attrs \\ %{}) do
fields = __schema__(:fields) -- @non_required_fields
product
|> cast(attrs, fields)
|> validate_required([:site_id, :name])
end
# Custom serializer instead of using Phoenix Views
def json(%__MODULE__{} = product) do
fields = __schema__(:fields)
data = Map.take(product, fields)
data =
case Map.fetch(product, :site) do
{:ok, %Ecto.Association.NotLoaded{}} ->
data
{:ok, value} ->
Map.put(data, :site, Site.json(value))
_ ->
data
end
data
end
def json(products) when is_list(products) do
Enum.map(products, &json(&1))
end
def json(_), do: nil
end
development
Vue 3 Composition API — <script setup>, reactivity (shallowRef/ref), props without destructure, computed, watch, provide/inject, and composables. Use when the project uses modern Vue 3 Composition API style.
development
Vue 3 Options API — data, props, computed, methods, watch, emits, provide/inject, lifecycle hooks, and mixins. Use when the project uses Options API style (Vue 2 legacy or explicit Vue 3 Options API preference).
tools
Best practices for mixing Ant Design Vue components with Tailwind CSS utility classes. Use this skill to keep styling consistent without custom CSS files.
development
Pinia state management for Vue 3 using Composition API (Setup Stores) — TypeScript-first, storeToRefs for reactivity, focused stores, and API calls in composables. Use when the project uses Vue 3 Composition API / <script setup>.