crud-proto-gen

crud-proto-gen is a skill for Claude Code, Codex from ArtisanCloud/PowerX. It costs 21 tokens per session (2,194 once invoked), scanned A, original, Apache-2.0.

A set of rules for generating Go code from Protocol Buffer files, which define structured service and message contracts. It standardizes folders, the buf generation tool, package paths, Make targets, version control, and generated output.

In plain words
What is it for?
Use it when adding or reviewing gRPC or other Protocol Buffer contracts, generation commands, Go package settings, and cleanup or linting targets.
Why use it?
It prevents generated API code from being placed inconsistently or produced with mismatched tools and package paths.

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/proto-gen
Any agent
npx skills add ArtisanCloud/PowerX --skill proto-gen
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-proto-gen

README.md
[![agentmods](https://agentmods.dev/badge/skills/artisancloud/powerx/proto-gen.svg)](https://agentmods.dev/skills/artisancloud/powerx/proto-gen)
Your own site
<a href="https://agentmods.dev/skills/artisancloud/powerx/proto-gen"><img src="https://agentmods.dev/badge/skills/artisancloud/powerx/proto-gen.svg" alt="Measured on agentmods" height="20"></a>
Per session 21 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,194 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.1 $0.00021 $0.02194
Opus 5 $0.00010 $0.01097
Sonnet 5 $0.00004 $0.00439
Haiku 4.5 $0.00002 $0.00219

Measured today against content hash 39fbc6ae7934, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-05, from the pricing page.

Security

Grade A, and why

crud-proto-gen 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/proto-gen/SKILL.md · 239 lines

How it starts

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

PowerX CRUD Proto Gen

步骤

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

核对点

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

规则(内嵌)

proto_gen.yaml

kind: ruleset
name: proto_gen
version: 1.0.2
owner: powerx
status: stable

meta:
  intent: >
    统一 Proto 的组织与生成规范:使用 buf 管理、版本化与生成;go_package 与生成路径一致;
    Make 目标必须存在;生成物输出到 api/grpc/gen 下并纳入 .gitignore(或采用只读提交策略)。
  references:
    - crud_grpc.yaml
    - transport_grpc.yaml

scope:
  applies_to:
    - "api/grpc/**/*.proto"
    - "api/grpc/contracts/buf.yaml"
    - "api/grpc/contracts/buf.gen.yaml"
    - "buf.work.yaml"
    - "Makefile"
    - ".gitignore"

principles:
  - 目录规范:源 proto 放在 api/grpc/**;生成代码放在 api/grpc/gen/**。
  - 工具规范:使用 buf(lint/breaking/生成),不直接手写 protoc 命令(由 buf.gen.yaml 驱动)。
  - 包路径一致:每个 proto 必须设置 option go_package,且与生成前缀 github.com/ArtisanCloud/PowerX/api/grpc/gen 保持一致。
  - 生成产物可清理:必须提供 proto-gen / proto-lint / proto-clean 的 Make 目标。
  - 版本可控:api/grpc/contracts/buf.yaml 指定 lint/breaking 规则;api/grpc/contracts/buf.gen.yaml 锁定插件版本(尽量锁到 minor)。
  - 产物纳管:默认在 .gitignore 忽略 api/grpc/gen;如需提交产物,需锁定插件版本并允许提交。
  - Workspace:使用 buf.work.yaml 管理多目录输入,禁止在 buf.yaml 使用 build.roots 等 v0 字段。

checks:

  # ===== 基本文件存在 =====
  - id: proto.files.required
    level: error
    when: { glob: "api/grpc/**/*.proto" }
    assert:
      - must_exist_glob: "api/grpc/**/*.proto"

  - id: buf.configs.exist
    level: error
    when:
      any_of:
        - file: "api/grpc/contracts/buf.yaml"
        - file: "api/grpc/contracts/buf.gen.yaml"
    assert:
      - file_exists: "api/grpc/contracts/buf.yaml"
      - file_exists: "api/grpc/contracts/buf.gen.yaml"

  - id: buf.workspace.exists
    level: error
    when: { file: "buf.work.yaml" }
    assert:
      - file_exists: "buf.work.yaml"
      - must_contain_regex: "^version:\\s*v1\\b"
      - must_contain: "directories:"
    message: "必须使用 workspace(buf.work.yaml)管理多目录输入。"

  # ===== go_package 必须存在且与生成路径前缀一致 =====
  - id: proto.go_package.set
    level: error
    when: { glob: "api/grpc/**/*.proto" }
    assert:
      - must_contain_regex: "option\\s+go_package\\s*=\\s*\"[^\"]+\";"

  - id: proto.go_package.path_match
    level: warn
    when: { glob: "api/grpc/**/*.proto" }
    assert:
      - should_contain_regex: "option go_package = \"github.com/ArtisanCloud/PowerX/api/grpc/gen/.+;[a-zA-Z0-9_]+\";"
    message: "建议 go_package 使用 github.com/ArtisanCloud/PowerX/api/grpc/gen/<domain>;pkgname 前缀"

  # ===== buf.yaml 的 lint / breaking 规则(不再要求 build.*)=====
  - id: buf.yaml.rules
    level: error
    when: { file: "api/grpc/contracts/buf.yaml" }
    assert:
      - must_contain_regex: "^version:\\s*v1\\b"
      - must_contain: "lint:"
      - must_contain: "breaking:"
      - must_contain_any:
          - "use: [DEFAULT]"
          - "use:\n  - DEFAULT"
      - must_not_contain_regex: "\\bbuild\\s*:"
      - must_not_contain_regex: "\\bbuild\\.roots\\b"

  # ===== buf.gen.yaml 的 go/grpc 插件与输出路径 =====
  - id: buf.gen.outputs
    level: error
    when: { file: "api/grpc/contracts/buf.gen.yaml" }
    assert:
      - must_contain_regex: "plugin:\\s*buf.build/protocolbuffers/go(:|\\b)"
      - must_contain_regex: "plugin:\\s*buf.build/grpc/go(:|\\b)"
      - must_contain_regex: "out:\\s*api/grpc/gen"
      - must_contain: "opt:\n          - paths=source_relative"
      - must_contain: "managed:"
      - must_contain: "go_package_prefix:"
      - must_contain: "default: github.com/ArtisanCloud/PowerX/api/grpc/gen"

  # ===== Makefile 目标 =====
  - id: make.targets
    level: error
    when: { file: "Makefile" }
    assert:
      - must_contain_regex: "^proto-gen:"
      - must_contain_regex: "^proto-lint:"
      - must_contain_regex: "^proto-clean:"

  # ===== 产物纳管:默认忽略 api/grpc/gen =====
  - id: gitignore.gen
    level: warn
    when: { file: ".gitignore" }
    assert:
      - should_contain_any:
          - "/api/grpc/gen/"
          - "api/grpc/gen/"

acceptance:
  checklist:
    - "[ ] 源 proto 位于 api/grpc/**;api/grpc/contracts/buf.yaml 与 api/grpc/contracts/buf.gen.yaml 存在"
    - "[ ] 每个 proto 设置了 option go_package,且前缀为 github.com/ArtisanCloud/PowerX/api/grpc/gen/**"
    - "[ ] 使用 workspace:仓库根存在 buf.work.yaml,且目录收纳正确"
    - "[ ] buf.yaml 启用了 lint/breaking(DEFAULT),且未使用 build.*"
    - "[ ] buf.gen.yaml 输出到 api/grpc/gen,且 paths=source_relative;managed.go_package_prefix.default=github.com/ArtisanCloud/PowerX/api/grpc/gen"
    - "[ ] Makefile 提供 proto-gen / proto-lint / proto-clean"
    - "[ ] api/grpc/gen 已在 .gitignore(或锁定插件版本并允许提交产物)"

templates:

  buf_yaml: |
    # api/grpc/contracts/buf.yaml
    version: v1
    name: buf.build/powerx/core
    lint:
      use:
        - DEFAULT
    breaking:
      use:
        - FILE
      ignore_unstable_packages: true

  buf_gen_yaml: |
    # api/grpc/contracts/buf.gen.yaml
    version: v1
    plugins:
      - plugin: buf.build/protocolbuffers/go:v1.33.0
        out: api/grpc/gen
        opt:
          - paths=source_relative
      - plugin: buf.build/grpc/go:v1.3.0
        out: api/grpc/gen
        opt:
          - paths=source_relative
    managed:
      enabled: true
      go_package_prefix:
        default: github.com/ArtisanCloud/PowerX/api/grpc/gen
        except:
          - buf.build/googleapis/googleapis
          - buf.build/protocolbuffers/wellknowntypes

  makefile_targets: |
    # Makefile(片段)
    .PHONY: proto-gen proto-lint proto-clean

    # 建议在仓库根执行(buf 会向上查找 buf.work.yaml)
    proto-gen:
    \tbuf generate --template api/grpc/contracts/buf.gen.yaml --path api/grpc

    proto-lint:
    \tbuf lint --config api/grpc/contracts/buf.yaml && buf breaking --against '.git#branch=main' --config api/grpc/contracts/buf.yaml || true

    proto-clean:
    \trm -rf api/grpc/gen/*

  proto_example: |
    // api/grpc/media/asset.proto
    syntax = "proto3";
    package powerx.media.v1;
    option go_package = "github.com/ArtisanCloud/PowerX/api/grpc/gen/powerx/media/v1;mediav1";

    import "google/protobuf/empty.proto";
    import "google/protobuf/timestamp.proto";

    message Pagination {
      int64 total = 1;
      int32 page = 2;
      int32 page_size = 3;
      int32 pages = 4;
    }

    message MediaAsset {
      string id = 1;
      uint64 tenant_id = 2;
      string name = 3;
      string code = 4;
      string meta_json = 5;
      int32 status = 6;
      google.protobuf.Timestamp created_at = 7;
      google.protobuf.Timestamp updated_at = 8;
    }

    message GetMediaAssetRequest { string id = 1; }
    message MediaAssetResponse { MediaAsset data = 1; }

    service MediaAssetService {
      rpc GetMediaAsset(GetMediaAssetRequest) returns (MediaAssetResponse);
    }

  gitignore_snippet: |
    # .gitignore(片段)
    /api/grpc/gen/

Read the full file on GitHub · 239 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 · 239 lines · 21 tokens per session scan A 39fbc6ae7934

Subscribe to this mod's changes

crud-proto-gen is a skill published in the GitHub repository ArtisanCloud/PowerX (364 stars, last pushed 4d ago), licensed Apache-2.0. It adds 21 tokens to every session and 2,194 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.