PowerX: Skill for Codex

.codex/skills/crud/model/SKILL.md

crud-model is a skill for Codex from ArtisanCloud/PowerX. It costs 24 tokens per session (1,647 once invoked), scanned A, original, Apache-2.0.

A set of rules for defining database models with GORM, a Go library that maps program structures to database tables. It covers tenants, soft deletion, table names, indexes, JSON fields, status fields, and migration registration.

In plain words
What is it for?
Creating multi-tenant CRUD models, declaring PostgreSQL JSON fields and constraints, defining table names, and preparing models for automatic migration.
Why use it?
It prevents models from using inconsistent names, ownership fields, indexes, or migration locations. It also keeps database-related code separate from request and transport types.

Skill for Codex

Written for Codex: installed under .codex/.

This is ArtisanCloud/PowerX's own configuration. It tells Codex how to work on PowerX itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything PowerX configures →

Reuse

Borrowing it

Nothing to install: this file belongs to ArtisanCloud/PowerX. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/ArtisanCloud/PowerX/release/v1.0.0/.codex/skills/crud/model/SKILL.md
Clone the repo
git clone --depth 1 https://github.com/ArtisanCloud/PowerX

Made for: Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for crud-model

README.md
[![agentmods](https://agentmods.dev/badge/skills/artisancloud/powerx/model/github.svg)](https://agentmods.dev/skills/artisancloud/powerx/model)
Your own site
<a href="https://agentmods.dev/skills/artisancloud/powerx/model"><img src="https://agentmods.dev/badge/skills/artisancloud/powerx/model/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for crud-model

Your own site · 80×15
<a href="https://agentmods.dev/skills/artisancloud/powerx/model"><img src="https://agentmods.dev/badge/skills/artisancloud/powerx/model.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 24 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,647 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00024 $0.01647
Opus 5.5 $0.00010 $0.00659
Sonnet 5.5 $0.00005 $0.00329
Haiku 4.5 $0.00002 $0.00165

Measured 1mo ago against content hash 456904e3a774, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

crud-model scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.codex/skills/crud/model/SKILL.md · 172 lines

How it starts

The opening of the file, as written. The whole thing — 172 lines — stays where its author put it; the contents beside it link to each section on GitHub.

PowerX CRUD Model

步骤

  1. 打开 本文件内嵌规则。
  2. 按规则执行实现/校对。
  3. 完成后按核对清单验收。

核对点

  • 与 PowerX 当前代码结构、路径与命名一致。
  • 仅在传输层/契约层做职责内改动,不跨层越界。

规则(内嵌)

model.yaml


kind: ruleset
name: crud_model
version: 1.0.0
owner: powerx
status: stable

meta:
  intent: >
    统一 GORM 模型约束(多租户、软删、表名、索引/唯一、JSONB、状态字段),
    以及迁移注册与目录放置的硬性规则,确保与 Repository/Service 分层契合。
  references:
    - constitution.md
    - dev_crud_http_guides.md

scope:
  codebase:
    model_dir: "pkg/corex/db/persistence/model"
    migrate_entry:
      - "cmd/database/migrate.go"                  # 总入口(集中触发)
    module_migrate_globs:
      - "internal/server/**/persistence/migrate.go"  # 模块内注册器(分散声明)

principles:
  - 模型必须嵌入 PowerModel 或 PowerUUIDModel;包含 DeletedAt 与 TenantID 字段。     # :contentReference[oaicite:21]{index=21}
  - 表名必须显式返回 `${schema}.${table}`,schema 由 PowerXSchema 控制。               # :contentReference[oaicite:22]{index=22}
  - 索引/唯一约束通过 GORM Tag 声明;JSON 字段统一使用 datatypes.JSON(JSONB)。        # :contentReference[oaicite:23]{index=23}
  - 状态字段统一命名 Status,默认值 1;禁止散落 SQL 文件,迁移统一走 AutoMigrate。      # :contentReference[oaicite:24]{index=24}
  - 模型源码文件需以 `_gorm.go` 结尾,保持与现有目录命名一致,便于一眼识别 GORM 实体。
  - 非持久化结构体(DTO/辅助类型)禁止携带 `gorm:""` Tag,避免误导迁移与仓储逻辑。
  - PowerX 核心模块的模型必须集中在 `pkg/corex/db/database/migration.go::MigrateCoreModels` 注册;独立 Server(如 Agent)可在自身 `internal/server/<module>/persistence/migrate.go` 中维护迁移函数。

checks:
  directories:
    - id: model.path
      level: error
      when:
        glob: "pkg/corex/db/persistence/model/**/**.go"
      assert:
        - must_package_suffix: "model"
  embedding_and_fields:
    - id: base_model.embedded
      level: error
      when:
        glob: "pkg/corex/db/persistence/model/**/**.go"
      assert:
        - must_embed_one_of: ["model.PowerModel","model.PowerUUIDModel"]
        - must_have_fields:
            - "TenantID uint64 `gorm:\"index;not null\"`"
            - "DeletedAt gorm.DeletedAt `gorm:\"index\"`"
        - should_have_fields:
            - "Status int16 `gorm:\"default:1;index\"`"
  table_naming:
    - id: table.name.func
      level: error
      when:
        glob: "pkg/corex/db/persistence/model/**/**.go"
      assert:
        - must_define: "func (*).TableName() string"
        - must_return_schema_const: "model.PowerXSchema"  # 返回 schema.table
  json_and_index:
    - id: jsonb.tag
      level: warn
      when:
        contains: "datatypes.JSON"
      assert:
        - must_have_tag: "gorm:\"type:jsonb\""
    - id: unique_and_index_tags
      level: warn
      when:
        glob: "pkg/corex/db/persistence/model/**/**.go"
      assert:
        - recommend_tags: ["uniqueIndex","index"]

  migration_registration:
    - id: migrate.fn.exists
      level: error
      when:
        glob: "internal/**/migration.go"
      assert:
        - must_define_like: "func Migrate*Models(db *gorm.DB) error"   # 模块自迁移注册  # :contentReference[oaicite:25]{index=25}
    - id: migrate.entry.calls
      level: warn
      when:
        file: "cmd/database/migrate.go"
      assert:
        - must_call: "Migrate*Models("

acceptance:
  checklist:
    - "[ ] 模型嵌入 PowerModel/PowerUUIDModel,并含 TenantID/DeletedAt/Status"           # :contentReference[oaicite:26]{index=26}
    - "[ ] 表名返回 ${schema}.${table},表名常量集中到 tables.go"
    - "[ ] JSON 字段使用 datatypes.JSON + jsonb"
    - "[ ] 唯一约束/复合索引通过 Tag 声明"
    - "[ ] 迁移函数 Migrate<Module>Models 已实现并在入口注册(核心模块写入 MigrateCoreModels,独立 Server 写入各自 migrate.go)"                           # :contentReference[oaicite:27]{index=27}
    - "[ ] 不交付 .sql,统一 AutoMigrate + 运行期校验"
    - "[ ] 文件命名采用 *_gorm.go,与 GORM 模型约定保持一致"

templates:
  model_go: |
    package {{domain}}model

    import (
      "time"
      "gorm.io/gorm"
      "gorm.io/datatypes"
      "github.com/ArtisanCloud/PowerX/pkg/corex/db/persistence/model"
    )

    const Table{{Entity}} = "{{$table}}"

    type {{Entity}} struct {
      model.PowerUUIDModel

      TenantID  uint64         `gorm:"index;not null"`
      Name      string         `gorm:"type:varchar(128);index"`
      Code      string         `gorm:"type:varchar(64);uniqueIndex:uk_{{table}}_tenant_code"`
      Meta      datatypes.JSON `gorm:"type:jsonb;default:'{}'"`
      Status    int16          `gorm:"default:1;index"`

      CreatedAt time.Time
      UpdatedAt time.Time
      DeletedAt gorm.DeletedAt `gorm:"index"`
    }

    func (*{{Entity}}) TableName() string {
      return model.PowerXSchema + "." + Table{{Entity}}
    }

  migrate_go: |
    package {{domain}}migration

    import (
      "gorm.io/gorm"
      dbm "{{module_path}}/pkg/corex/db/persistence/model/{{domain}}"
    )

    func Migrate{{Module}}Models(db *gorm.DB) error {
      if err := db.AutoMigrate(
        &dbm.{{Entity}}{},
      ); err != nil {
        return err
      }
      // 可选:运行期校验索引/约束
      // if !db.Migrator().HasIndex(&dbm.{{Entity}}{}, "uk_{{table}}_tenant_code") { ... }
      return nil
    }

Read the full file on GitHub · 172 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 1mo ago First seen · 172 lines · 24 tokens per session scan A 456904e3a774

Subscribe to this mod's changes

crud-model is a skill published in the GitHub repository ArtisanCloud/PowerX (382 stars, last pushed 2d ago), licensed Apache-2.0. It adds 24 tokens to every session and 1,647 once invoked, about $0.0001 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-04.

Related

Other skills, from other repositories

alloydb-basics

Manages clusters, instances, and backups for AlloyDB for PostgreSQL, and integrates with AlloyDB Model Context Protocol (MCP) tools for automated database operations. Use when creating, configuring, or administering AlloyDB databases. Do NOT use for general PostgreSQL instances (e.g. Cloud SQL) or other GCP databases.

google/skills · 72 tokens

postgresql-table-design

Use this skill when designing or reviewing a PostgreSQL-specific schema. Covers best-practices, data types, indexing, constraints, performance patterns, and advanced features.

wshobson/agents · 37 tokens

volcengine-rds-postgresql

A tool for operating PostgreSQL databases hosted by Volcano Engine's managed database service. PostgreSQL is a relational database used to store structured application data.

bytedance/agentkit-samples · 63 tokens

analyzing-insights-across-teams

Analyze PostHog insights, dashboards, or teams beyond the current project by querying the prod Postgres replicas synced into the dogfood data warehouse (US project 2, "PostHog App + Website"). Use when asked to analyze insights across all teams or projects, another team's insights, or fleet-wide insight/dashboard…

PostHog/posthog-foss · 115 tokens

dsql

Build with Aurora DSQL — manage schemas, execute queries, handle migrations, diagnose query plans, diagnose cluster performance, load data, and develop applications with a serverless, distributed SQL database. Covers IAM auth, multi-tenant patterns, MySQL-to-DSQL and PostgreSQL-to-DSQL schema conversion, foreign key…

awslabs/agent-plugins · 246 tokens

polar-local-environment

This skill should be used when setting up or managing Polar local development environment with Docker.

fcakyon/claude-codex-settings · 22 tokens