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.
npx agentmods add rules/xyzbit/ai-coding/d-gen-po-model-converter-from-sqlgit clone --depth 1 https://github.com/xyzbit/AI-CodingWrote 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.
[](https://agentmods.dev/rules/xyzbit/ai-coding/d-gen-po-model-converter-from-sql)<a href="https://agentmods.dev/rules/xyzbit/ai-coding/d-gen-po-model-converter-from-sql"><img src="https://agentmods.dev/badge/rules/xyzbit/ai-coding/d-gen-po-model-converter-from-sql.svg" alt="Measured on agentmods" height="20"></a>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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.00012 | $0.01110 |
| Opus 5 | $0.00006 | $0.00555 |
| Sonnet 5 | $0.00002 | $0.00222 |
| Haiku 4.5 | $0.00001 | $0.00111 |
Grade A, and why
d-gen-po-model-converter-from-sql 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 5d 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.
How it starts
The opening of the file, as written. The whole thing — 151 lines — stays where its author put it; the contents beside it link to each section on GitHub.
SQL to Go Code Generator Rules
概述
根据 SQL CREATE TABLE 语句生成三个 Go 文件:Model、PO(持久化对象)和 Converter。
前置检查
- 检查项目的 go.mod 文件以获取正确的模块名
- 确认目标目录结构是否存在
文件生成规则
1. Model 文件
位置: domain/model/{表名}.go
要求:
- 结构体名称采用驼峰命名,如
UserAuth - 字段名采用驼峰命名
- 必须包含 json 标签
- 所有数据库字段都要映射,包括 created_time 和 updated_time
- 时间类型字段必须导入 "time" 包
示例:
package model
import "time"
type Users struct {
ID int64 `json:"id"`
Name string `json:"name"`
CreatedTime time.Time `json:"created_time"`
UpdatedTime time.Time `json:"updated_time"`
}
2. PO 文件
位置: infrastructure/po/{表名}.go 或 repository/adapter/po/{表名}.go
要求:
- 结构体名称与 Model 保持一致
- 必须包含 GORM 标签和 json 标签
- 表名方法必须实现
- 所有数据库字段都要映射,包括 created_time 和 updated_time
- 时间类型字段必须导入 "time" 包
示例:
package po
import "time"
type Users struct {
ID int64 `gorm:"column:id;primaryKey;autoIncrement" json:"id"`
Name string `gorm:"column:name;not null" json:"name"`
CreatedTime time.Time `gorm:"column:created_time;not null;default:CURRENT_TIMESTAMP" json:"created_time"`
UpdatedTime time.Time `gorm:"column:updated_time;not null;default:CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP" json:"updated_time"`
}
func (u *Users) TableName() string {
return "users"
}
3. Converter 文件
位置: infrastructure/converter/{表名}_converters.go
要求:
- 必须使用正确的模块导入路径(从 go.mod 获取)
- 必须实现四个转换函数:
- To{表名}PO: Model -> PO
- To{表名}Model: PO -> Model
- To{表名}POList: []Model -> []PO
- To{表名}ModelList: []PO -> []Model
- 所有函数都必须包含 nil 检查
- 必须转换所有字段,包括时间字段
示例:
package converter
import (
"nebula/domain/model"
"nebula/infrastructure/po"
)
func ToUsersPO(m *model.Users) *po.Users {
if m == nil {
return nil
}
return &po.Users{
ID: m.ID,
Name: m.Name,
CreatedTime: m.CreatedTime,
UpdatedTime: m.UpdatedTime,
}
}
// 其他转换函数...
数据类型映射规则
| SQL 类型 | Go 类型 | 说明 |
|---|---|---|
| BIGINT | int64 | 包括 UNSIGNED |
| INT | int | 包括 UNSIGNED |
| VARCHAR | string | 所有字符串类型 |
| TEXT | string | 所有文本类型 |
| TIMESTAMP | time.Time | 时间戳类型 |
| DATETIME | time.Time | 日期时间类型 |
| DECIMAL | float64 | 浮点数类型 |
| BOOL | bool | 布尔类型 |
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.
- 5d ago First seen · 151 lines · 12 tokens per session scan A 0bfd04dab791
d-gen-po-model-converter-from-sql is a cursor rule published in the GitHub repository xyzbit/AI-Coding (21 stars, last pushed 10mo ago), licensed Apache-2.0. It adds 12 tokens to every session and 1,110 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-08-30.
Other cursor rules, from other repositories
database-interaction-best-practices
Best practices when interacting with databases in backend Go code.
thing
Cursor rule "thing" from WeatherPal-AI/MCP-handle, covering rule name: thing orm usage guide, description, core concept, configuration and basic usage.
adapter-features
Database-specific features must be implemented in the specialized adapter only. Base adapters (postgres, mysql, etc.) must remain database-agnostic.
unit-tests-tdd
TDD required for behavior changes; ≥80% package coverage on touched packages; unit-test conventions.
integration-tests
Human-readable integration test requests; helpers vs httptest; suites/ vs per-DB placement.
backend
You are an expert in Go, Gin, Gorm, Gen, Cosy (https://cosy.uozi.org/) with a deep understanding of best practices and performance optimization techniques in these technologies.