Agent skill

Crud Repository

by ArtisanCloud in ArtisanCloud/PowerX

PowerX CRUD Repository 规则(BaseRepository、tenant 约束、分页). An agent skill from ArtisanCloud/PowerX.

Apache-2.0Auto-check passedBackend & APIs

Install Crud Repository

skills CLI
$ npx skills add ArtisanCloud/PowerX --skill crud-repository -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install ArtisanCloud/PowerX crud-repository --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/ArtisanCloud/PowerX.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.codex/skills/crud/repository .claude/skills/crud-repository && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
crud-repository
GitHub stars
379
Token cost
~2k tokens
SKILL.md length
18 words
Files
1
Skills in repo
21
Repo updated
First seen
Licence
Apache-2.0

At a glance

PowerX CRUD Repository 规则(BaseRepository、tenant 约束、分页). An agent skill from ArtisanCloud/PowerX.

  • Works in 3 steps: 打开 本文件内嵌规则。 → 按规则执行实现/校对。 → 完成后按核对清单验收。
  • Backend & APIs work in your project
  • SKILL.md covers 步骤, 核对点 and 规则(内嵌)
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Crud Repository is an agent skill from ArtisanCloud/PowerX. PowerX CRUD Repository 规则(BaseRepository、tenant 约束、分页)。

Its SKILL.md is about 2k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Backend & APIs. The repository describes itself as: PowerX是一款以企业微信为基础的微信私域运营开放平台,帮助企业实现引流获客、精细运营。 The licence is Apache-2.0.

When your agent uses it

  • Backend & APIs work in your project

Example prompts

  • “/crud-repository”

Workflow steps

3 steps, taken from the first numbered list in SKILL.md.

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

What it can do on your machine

Read from SKILL.md and the folder at commit 3f7619d. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are yaml).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Crud Repository loads about 2k tokens when it runs. Until then it costs about 18 tokens; SKILL.md has 18 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~18
When it runs · the whole SKILL.md, loaded when a task matches
~2k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from ArtisanCloud/PowerX at commit 3f7619d, republished under its Apache-2.0 licence (© ArtisanCloud). 18 words, ~2,049 tokens.

Download SKILL.mdSave it as .claude/skills/crud-repository/SKILL.md (or your agent's skills folder).
name
crud-repository
description
PowerX CRUD Repository 规则(BaseRepository、tenant 约束、分页)。

PowerX CRUD Repository

步骤

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

核对点

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

规则(内嵌)

repository.yaml
yaml
kind: ruleset
name: crud_repository
version: 1.0.0
owner: powerx
status: stable

meta:
  intent: >
    统一 Repository(持久化)层的接口与实现规范:只负责数据访问与映射,
    不承载业务逻辑;严格多租户隔离、软删、分页筛选与一致的错误/返回语义。
    CoreX 模块仓储统一采用 BaseRepository 泛型封装,便于事务注入与测试。
  references:
    - constitution.md
    - crud_model.yaml
    - crud_migration.yaml
    - crud_dto.yaml
    - crud_di.yaml

scope:
  codebase:
    repo_globs:
      - "internal/repository/**/**_repo.go"
      - "pkg/corex/db/persistence/repository/**/**_repo.go"
    model_globs:
      - "pkg/corex/db/persistence/model/**/**.go"

principles:
  - 目录规范:CoreX 仓库实现放置于 `pkg/corex/db/persistence/repository/<domain>/`,目录名使用 snake_case,对应的模型位于同层级 `model/`。
  - 职责单一:Repository 只做数据访问(SQL/GORM),禁止业务分支与权限判断。
  - 多租户强约束:所有查询均带 TenantID 条件;默认忽略软删(GORM 默认生效)。
  - 事务注入:方法接受 *gorm.DB(可为 tx),由 Service 层控制 tx 生命周期。
  - 上下文贯穿:方法首参为 context.Context,用于 tracing/超时/审计钩子。
  - 错误语义:不存在返回 gorm.ErrRecordNotFound(由 Service 翻译成 404);唯一冲突返回 ErrConflict(由 Service 翻译 409)。
  - 可测试性:提供接口与实现;实现命名 `XxxRepoImpl`,禁止全局单例。
  - 性能:列表查询必须显式选择字段/建立索引,禁止 N+1(注意 Preload 选择性)。

checks:

  # 目录/文件命名
  - id: repo.file.naming
    level: error
    when: { glob: "internal/repository/**/**_repo.go" }
    assert:
      - must_package_suffix: "repo"

  # BaseRepository 形态
  - id: repo.base_repository.pattern
    level: error
    when: { glob: "internal/repository/**/**_repo.go" }
    assert:
      - must_contain_regex: "type [A-Za-z0-9]+Repository struct {"
      - must_contain_regex: "\\*repository.BaseRepository"
      - must_contain_regex: "func New[A-Za-z0-9]+Repository\\(db \\*gorm\\.DB\\)"
      - must_not_import: ["github.com/gin-gonic/gin"]  # 不允许直接耦合 HTTP

  # 方法签名(ctx + db)
  - id: repo.method.signature
    level: error
    when: { glob: "internal/repository/**/**_repo.go" }
    assert:
      - must_contain_regex: "func \\(r \\*.*Repository\\) .*\\(ctx context\\.Context, db \\*gorm\\.DB"
      - must_import: ["context","gorm.io/gorm"]

  # 多租户条件
  - id: repo.must.tenant.scope
    level: error
    when: { glob: "internal/repository/**/**_repo.go" }
    assert:
      - contains_any:
          - "Where(\"tenant_id = ?\""
          - "Scopes(TenantScope("
          - "WithTenant("
    message: "所有 CRUD 查询必须带 TenantID(直写 Where 或统一 Scopes/TenantScope)"

  # 列表与分页(limit/offset 或 cursor)
  - id: repo.list.pagination
    level: error
    when: { glob: "internal/repository/**/**_repo.go" }
    assert:
      - contains_any: ["Limit(","Offset(","Scopes(Paginate("]

  # 冲突与不存在的错误
  - id: repo.error.mapping
    level: warn
    when: { glob: "internal/repository/**/**_repo.go" }
    assert:
      - contains_any: ["gorm.ErrRecordNotFound","ErrDuplicate","unique"]
    message: "建议把 gorm.ErrRecordNotFound 原样返回,由 Service 统一翻译为 404;唯一冲突包装为 ErrConflict"

  # 软删(默认开启),如实现硬删需标注
  - id: repo.soft_delete
    level: warn
    when: { glob: "internal/repository/**/**_repo.go" }
    assert:
      - should_contain_any: ["Delete(&m)","Unscoped().Delete("]

  # 性能/索引使用(建议)
  - id: repo.index.hint
    level: warn
    when: { glob: "internal/repository/**/**_repo.go" }
    assert:
      - should_contain_any: ["Select(","Omit("]

acceptance:
  checklist:
    - "[ ] 每个仓库文件包含接口 + 实现 + New 构造函数"
    - "[ ] 方法签名统一为 (ctx context.Context, db *gorm.DB, ...)"
    - "[ ] 所有查询带 TenantID 条件(Where/Scopes/TenantScope)"
    - "[ ] 列表查询有分页(Limit/Offset 或 Cursor)"
    - "[ ] 不做业务鉴权/分支;错误语义由 Service 统一翻译"
    - "[ ] 使用软删;如需硬删必须在 Service 授权并清晰标注"
    - "[ ] 可被 DI 装配(由 Deps 提供 *gorm.DB 注入)"

templates:

  repo_interface_impl_go: |
    // pkg/corex/db/persistence/repository/{{domain}}/{{resource}}_repo.go
    package {{domain}}repo

    import (
      "context"

      "gorm.io/gorm"
      m "{{module_path}}/pkg/corex/db/persistence/model/{{domain}}"
    )

    // {{Entity}}Repo 数据访问接口
    type {{Entity}}Repo interface {
      Create(ctx context.Context, db *gorm.DB, tenantID uint64, in *m.{{Entity}}) error
      GetByID(ctx context.Context, db *gorm.DB, tenantID uint64, id string) (*m.{{Entity}}, error)
      List(ctx context.Context, db *gorm.DB, tenantID uint64, pg Page, filters map[string]string) ([]*m.{{Entity}}, int64, error)
      Update(ctx context.Context, db *gorm.DB, tenantID uint64, in *m.{{Entity}}) error
      Delete(ctx context.Context, db *gorm.DB, tenantID uint64, id string, hard bool) error

      // Tx 透传辅助(可选)
      WithTx(ctx context.Context, db *gorm.DB, fn func(tx *gorm.DB) error) error
    }

    // 实现
    type {{Entity}}RepoImpl struct {
      db *gorm.DB
    }

    func New{{Entity}}Repo(db *gorm.DB) {{Entity}}Repo {
      return &{{Entity}}RepoImpl{db: db}
    }

    // 分页结构(按项目实际放置到共用包)
    type Page struct {
      Page     int
      PageSize int
      SortBy   string
      SortOrder string
    }

    func (r *{{Entity}}RepoImpl) Create(ctx context.Context, db *gorm.DB, tenantID uint64, in *m.{{Entity}}) error {
      in.TenantID = tenantID
      return db.WithContext(ctx).Create(in).Error
    }

    func (r *{{Entity}}RepoImpl) GetByID(ctx context.Context, db *gorm.DB, tenantID uint64, id string) (*m.{{Entity}}, error) {
      var out m.{{Entity}}
      err := db.WithContext(ctx).
        Where("tenant_id = ? AND id = ?", tenantID, id).
        First(&out).Error
      if err != nil {
        return nil, err // 由 Service 翻译为 404
      }
      return &out, nil
    }

    // 可抽成 Scopes:TenantScope / Filters / Paginate
    func (r *{{Entity}}RepoImpl) List(ctx context.Context, db *gorm.DB, tenantID uint64, pg Page, filters map[string]string) ([]*m.{{Entity}}, int64, error) {
      q := db.WithContext(ctx).Model(&m.{{Entity}}{}).Where("tenant_id = ?", tenantID)

      // 简化:按 filters 动态拼装(生产中建议固定白名单)
      if v, ok := filters["status"]; ok { q = q.Where("status = ?", v) }
      if v, ok := filters["q"]; ok { q = q.Where("name ILIKE ?", "%"+v+"%") }

      // 计数
      var total int64
      if err := q.Count(&total).Error; err != nil { return nil, 0, err }

      // 排序/分页
      orderBy := "created_at desc"
      if pg.SortBy != "" {
        if pg.SortOrder == "" { pg.SortOrder = "desc" }
        orderBy = pg.SortBy + " " + pg.SortOrder
      }
      if pg.Page <= 0 { pg.Page = 1 }
      if pg.PageSize <= 0 { pg.PageSize = 20 }

      var items []*m.{{Entity}}
      err := q.Order(orderBy).
        Limit(pg.PageSize).
        Offset((pg.Page-1)*pg.PageSize).
        Find(&items).Error
      if err != nil { return nil, 0, err }
      return items, total, nil
    }

    func (r *{{Entity}}RepoImpl) Update(ctx context.Context, db *gorm.DB, tenantID uint64, in *m.{{Entity}}) error {
      return db.WithContext(ctx).
        Model(&m.{{Entity}}{}).
        Where("tenant_id = ? AND id = ?", tenantID, in.ID).
        Updates(map[string]any{
          "name":   in.Name,
          "meta":   in.Meta,
          "status": in.Status,
        }).Error
    }

    func (r *{{Entity}}RepoImpl) Delete(ctx context.Context, db *gorm.DB, tenantID uint64, id string, hard bool) error {
      q := db.WithContext(ctx).Where("tenant_id = ? AND id = ?", tenantID, id)
      if hard {
        return q.Unscoped().Delete(&m.{{Entity}}{}).Error
      }
      return q.Delete(&m.{{Entity}}{}).Error
    }

    func (r *{{Entity}}RepoImpl) WithTx(ctx context.Context, db *gorm.DB, fn func(tx *gorm.DB) error) error {
      return db.WithContext(ctx).Transaction(func(tx *gorm.DB) error { return fn(tx) })
    }

  scopes_go: |
    // internal/repository/scopes/scopes.go (可选:集中放置)
    package scopes

    import "gorm.io/gorm"

    func TenantScope(tenantID uint64) func(*gorm.DB) *gorm.DB {
      return func(db *gorm.DB) *gorm.DB {
        return db.Where("tenant_id = ?", tenantID)
      }
    }

    func Paginate(page, pageSize int) func(*gorm.DB) *gorm.DB {
      if page <= 0 { page = 1 }
      if pageSize <= 0 { pageSize = 20 }
      return func(db *gorm.DB) *gorm.DB {
        return db.Limit(pageSize).Offset((page-1)*pageSize)
      }
    }

© ArtisanCloud, Apache-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in .codex/skills/crud/repository of ArtisanCloud/PowerX.

Open the folder on GitHubat commit 3f7619d

Compare with similar skills

Crud Repository next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Crud Repository compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Crud Repository this skillArtisanCloud/PowerX379—~2kAutomated safety check: PassApache-2.0
Configuring Horizoncoollabsio/coolify63k4 repos~898Automated safety check: PassMIT
Nestjs Best Practicesrolling-scopes/rsschool-app10k6 repos~1.2kAutomated safety check: PassMIT
Sub2API AdminWei-Shaw/sub2api44k1 repos~717Automated safety check: PassLGPL-3.0
Firecrawl Build Onboardingfirecrawl/firecrawl190k1 repos~1.4kAutomated safety check: NotesISC
Obsidian BasesAtmosphere/atmosphere3.8k22 repos~3.2kAutomated safety check: PassApache-2.0

Similar skills

  • Configuring Horizon

    coollabsio/coolify

    A skill your agent uses whenever the user mentions Horizon by name in a Laravel context.

    63k GitHub starsUsed in 4 repos~898 tokens
    Backend & APIsAuto-check passed
  • Nestjs Best Practices

    rolling-scopes/rsschool-app

    NestJS best practices and architecture patterns for building production-ready applications.

    10k GitHub starsUsed in 6 repos~1.2k tokens
    Backend & APIsAuto-check passed
  • Sub2API Admin

    Wei-Shaw/sub2api

    Manages a Sub2API deployment from the command line: accounts, redeem and invitation codes, groups, proxies, imports, exports and raw admin API calls.

    44k GitHub starsUsed in 1 repo~717 tokens
    Backend & APIsAuto-check passed
  • Firecrawl Build Onboarding

    firecrawl/firecrawl

    Gets Firecrawl working in a project: signs you in through the browser, saves FIRECRAWL_API_KEY to .env and picks the first SDK or REST path.

    190k GitHub starsUsed in 1 repo~1.4k tokens
    Backend & APIsAuto-check: notes
  • Obsidian Bases

    Atmosphere/atmosphere

    Create and edit Obsidian Bases (.base files) with views, filters, formulas, and summaries.

    3.8k GitHub starsUsed in 22 repos~3.2k tokens
    Backend & APIsAuto-check passed
  • Fortify Development

    coollabsio/coolify

    ACTIVATE when the user works on authentication in Laravel. An agent skill from coollabsio/coolify.

    63k GitHub starsUsed in 4 repos~1.9k tokens
    Backend & APIsAuto-check passed

More from ArtisanCloud/PowerX

All 21 skills in this repo
  • API Naming

    ArtisanCloud/PowerX

    PowerX API 命名与访问规范(/api/v1、/admin、/internal 边界). An agent skill from ArtisanCloud/PowerX.

    379 GitHub stars~1.1k tokensUpdated today
    Auto-check passed
  • Capability Governance

    ArtisanCloud/PowerX

    PowerX 底座 Capability 治理与发布准入规则。用于审计 REST/OpenAPI/gRPC/Gin 生成的能力候选、正式 platformcapabilities 目录、Capability Registry 登记、agentusable/permissioncode/risklevel 元数据、ignore…

    379 GitHub stars~3k tokensUpdated today
    Auto-check passed
  • Crud Di

    ArtisanCloud/PowerX

    PowerX CRUD 依赖注入规则(Deps 单入口、构造注入、跨传输复用). An agent skill from ArtisanCloud/PowerX.

    379 GitHub stars~1.3k tokensUpdated today
    Auto-check passed
  • Crud Grpc

    ArtisanCloud/PowerX

    PowerX CRUD gRPC 开发规范(proto、server、拦截器、错误映射). An agent skill from ArtisanCloud/PowerX.

    379 GitHub stars~1.3k tokensUpdated today
    Auto-check passed
  • Crud Handler HTTP

    ArtisanCloud/PowerX

    PowerX HTTP Handler 规则(绑定校验、统一回包、无 DB IO). An agent skill from ArtisanCloud/PowerX.

    379 GitHub stars~1.8k tokensUpdated today
    Auto-check passed
  • Crud HTTP

    ArtisanCloud/PowerX

    PowerX CRUD HTTP 开发规范(管理端路由、绑定、错误桥接、多租户). An agent skill from ArtisanCloud/PowerX.

    379 GitHub stars~2.2k tokensUpdated today
    Auto-check passed

Categories

Questions about Crud Repository

What does Crud Repository do?

PowerX CRUD Repository 规则(BaseRepository、tenant 约束、分页). An agent skill from ArtisanCloud/PowerX. Crud Repository is an agent skill from ArtisanCloud/PowerX.

When should I use Crud Repository?

Crud Repository fits situations like: backend & APIs work in your project.

How do I install Crud Repository in Claude Code?

Run `npx skills add ArtisanCloud/PowerX --skill crud-repository -a claude-code`. Or copy the skill folder (.codex/skills/crud/repository in ArtisanCloud/PowerX) into .claude/skills/crud-repository in your project. Claude Code loads it when a task matches its description.

How do I install Crud Repository in Codex?

Run `npx skills add ArtisanCloud/PowerX --skill crud-repository -a codex`. Or copy the skill folder (.codex/skills/crud/repository in ArtisanCloud/PowerX) into .agents/skills/crud-repository in your project. Codex loads it when a task matches its description.

Can I use Crud Repository in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add ArtisanCloud/PowerX --skill crud-repository -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/crud-repository, .gemini/skills/crud-repository, .github/skills/crud-repository and .opencode/skills/crud-repository in your project.

What does Crud Repository need to run?

SKILL.md names no scripts, command-line tools or credentials: Crud Repository is instructions for the agent only.

Does Crud Repository access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Crud Repository safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Crud Repository use?

Crud Repository is published under the Apache-2.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Crud Repository use?

About 2k tokens (SKILL.md is roughly 8.2k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Crud Repository?

Skills that share tags, products or a category with Crud Repository: Configuring Horizon (coollabsio/coolify, 63k stars), Nestjs Best Practices (rolling-scopes/rsschool-app, 10k stars), Sub2API Admin (Wei-Shaw/sub2api, 44k stars) and Firecrawl Build Onboarding (firecrawl/firecrawl, 190k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Crud Repository?

ArtisanCloud (a GitHub organization) maintains it in ArtisanCloud/PowerX, which has 379 GitHub stars. The repository holds 21 skills in this directory. The repository was last updated on October 9, 2026.

Source: ArtisanCloud/PowerX on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.