crud-model

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

PowerX CRUD Model 规则(GORM 模型、多租户、索引、命名)。.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/artisancloud/powerx/model
Any agent
npx skills add ArtisanCloud/PowerX --skill model
Clone the repo
git clone --depth 1 https://github.com/ArtisanCloud/PowerX

Made for: Claude Code, 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.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.svg" alt="Measured on agentmods" 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. Scan, not verified.
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 $0.00024 $0.01647
Opus 5 $0.00012 $0.00823
Sonnet 5 $0.00005 $0.00329
Haiku 4.5 $0.00002 $0.00165

Measured today against content hash 456904e3a774, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, 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 today.

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. today 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 (364 stars, last pushed 3d 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. 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

om-judge-agent-session

Judge generated Open Mercato code from a standalone harness eval or a user-shared agent session bundle. Use for LLM-as-judge validation, generative eval review, session/artifact analysis, harness-quality diagnosis, "judge this session", "analyze this eval", or "oceń sesję/agenta"; checks fixed validation evidence…

open-mercato/open-mercato · 99 tokens

om-app-spec-writing

Write and review a business-level App Spec — domain model, workflows with ROI, user stories with failure paths, platform gap analysis in atomic commits, and a phased rollout — BEFORE any feature spec or code exists. One level above om-spec-writing, which decomposes the finished App Spec into feature specs. Use when…

open-mercato/open-mercato · 112 tokens

WRITE_ATTACHMENT_SERVICE

You are adding an inbound/attachment module to a domain crate. This module implements the attachment::AttachmentService trait so the crate can resolve its entity IDs into AI-consumable attachment content.

macro-inc/macro · 0 tokens

ai-sdk-development

TRIGGER when working with ai-sdk which is Laravel official first-party AI SDK. Activate when building, editing AI agents, chatbots, text generation, image generation, audio/TTS, transcription/STT, embeddings, RAG, vector stores, reranking, structured output, streaming, conversation memory, tools, queueing…

relaticle/relaticle · 146 tokens

skmtc-lang-kotlin

The Kotlin target-language layer for Skmtc generators (@skmtc/lang-kotlin): base factories, KtSnippet, the seven entity kinds, packages-from-paths imports, the head+value render model, KtAnnotation and the composition classes, sanitization and @SerialName placement, plus the current-API worked example (the shipped…

skmtc/skmtc · 117 tokens

skmtc-generator

Author and edit Skmtc generators — packages that project an OpenAPI domain model into application code. Method: clone the nearest stock generator, then apply the engine rules imitation can't teach. Assumes zero prior Skmtc knowledge. Use when asked to "write a skmtc generator", "author/clone/customize gen-x", "add a…

skmtc/skmtc · 110 tokens