plugins/languages/golang/skills/db/SKILL.md
Go 数据库规范——GORM Model 命名 ModelXxx、表名单数、枚举 uint8 + 常量、索引 idx_ 前缀 + deleted_at leading column、禁 time.Time 统一 int64 unix、禁指针/nullable 字段、TEXT/BLOB/JSON 禁 default、AutoMigrate 禁改主键。设计 DB model、写 GORM tag、建索引、做 migration 审查时触发。
npx skillsauth add lazygophers/ccplugin golang-dbInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
ModelXxx,表名单数,如 user、order,非 users。uint8 + 常量分组,禁裸 magic number。idx_ 前缀(含唯一),复合索引带 deleted_at。time.Time,时间统一 int64 unix 秒。omitempty。default tag,MySQL 不支持。type ModelUser struct {
Id uint64 `gorm:"primaryKey" json:"id"`
Username string `gorm:"type:varchar(64);uniqueIndex:idx_username,where:deleted_at=0" json:"username"`
State uint8 `gorm:"type:tinyint unsigned;default:0" json:"state"`
CreatedAt int64 `gorm:"autoCreateTime" json:"created_at"`
UpdatedAt int64 `gorm:"autoUpdateTime" json:"updated_at"`
DeletedAt int64 `gorm:"index" json:"deleted_at"`
}
Idtype ModelUser struct {
// ...
State uint8 `gorm:"type:tinyint unsigned;default:0" json:"state"`
}
const (
UserStateNil uint8 = 0
UserStateActive uint8 = 1
UserStateDisabled uint8 = 2
)
// 判断用常量,禁裸数字
if user.State == UserStateActive { ... }
// 唯一索引(带 deleted_at)
Username string `gorm:"uniqueIndex:idx_username,where:deleted_at=0"`
// 复合索引(deleted_at 作为 leading column priority:1)
Username string `gorm:"index:idx_username_deleted,priority:2,where:deleted_at=0"`
DeletedAt int64 `gorm:"index:idx_username_deleted,priority:1"`
// 普通索引
State uint8 `gorm:"index:idx_state"`
规则:
idx_ 前缀命名uniqueIndex 无名deleted_atdeleted_at 作 leading column(priority:1)CreatedAt int64 `gorm:"autoCreateTime" json:"created_at"`
UpdatedAt int64 `gorm:"autoUpdateTime" json:"updated_at"`
DeletedAt int64 `gorm:"index" json:"deleted_at"` // 软删,0=未删
禁 time.Time、禁 *time.Time、禁 gorm.Model。统一 int64 unix 秒。
type ModelOrder struct {
Id uint64 `gorm:"primaryKey" json:"id"`
Name string `gorm:"type:varchar(128)" json:"name,omitempty"`
Amount int64 `gorm:"type:bigint" json:"amount,omitempty"`
Settings string `gorm:"type:json" json:"settings,omitempty"`
State uint8 `gorm:"type:tinyint unsigned;default:0" json:"state"`
CreatedAt int64 `gorm:"autoCreateTime" json:"created_at"`
UpdatedAt int64 `gorm:"autoUpdateTime" json:"updated_at"`
DeletedAt int64 `gorm:"index" json:"deleted_at"`
}
json tag,snake_caseomitemptyomitempty(零值有意义)gorm:"type:xxx" 显式声明列类型| 模式 | 替代 |
| --- | --- |
| time.Time / *time.Time | int64 unix 秒 |
| *string / *int64 指针字段 | 零值表示不传 + omitempty |
| gorm:"default:'xxx'" on TEXT/BLOB/JSON | 移除 default tag |
| 裸 uniqueIndex 无名 | uniqueIndex:idx_xxx |
| 裸数字判断 if state == 1 | 常量 UserStateActive |
| gorm.Model 嵌入 | 显式定义字段 |
DROP + ALTERpreMigrateLegacy 类函数| AI 借口 | 实际应验证 | | --- | --- | | "time.Time 更标准" | 全部 int64 unix? | | "指针区分零值和缺失" | omitempty + 零值=不传? | | "索引名无所谓" | 全 idx_ 前缀? | | "gorm.Model 方便" | 显式定义字段? | | "magic number 看得懂" | 全用常量? | | "TEXT 加 default 更安全" | MySQL 不支持? |
ModelXxxuint8 + 常量idx_ 前缀deleted_atint64defaultgorm.Modeltools
--- name: trellisx-workspace description: 维护 `.trellis/task.md` 任务看板 —— trellis 缺的跨任务总览。**一个表格, 一行一个任务**, 列为 id/名称/描述/状态/阶段/进度/worktree (状态/阶段中文显示)。在 task create/start/阶段切换/archive 后**及时更新**对应行; 并**自动清理超 7 天的已完成行**防膨胀。保持看板与 task.json 实时一致。 when_to_use: 维护 / 创建 / 更新 `.trellis/task.md` 任务看板时; task 生命周期任一节点 (create/start/阶段推进/archive) 之后同步看板时; 用户问"当前有哪些任务 / 任务进度 / 任务看板"时。被 trellisx-flow 与 trellisx-apply 注入的流程引用。 user-invocable: true argument-hint: [show|update|sync|cleanup ...] [task id] arguments:
testing
强制以 Trellis task 闭环处理用户指定的请求 (自判新建/并入 → plan→exec→check→finish 全程不跳步)。**仅用户显式主动调用** (/trellisx-flow 或明确要求"强制走 task 处理这个"); **禁止自动 / 被动 / 推断式调用** —— 不要因为某个请求"看起来该建 task"就自动触发本 skill, 那是 apply 注入的 no_task 倾向的职责。
testing
把 强推task + subtask拆分 + worktree隔离 + 闭环收尾 四维度增量注入当前项目 .trellis/ (workflow.md 的 no_task/planning/in_progress 块 + spec 背书文档 + trellis 生命周期 hook worktree 自动化)。强推 task 与闭环为纯 prompt 软约束 (非平台 hook 硬拦截)。**纯增量追加, 绝不替换 trellis 原生文本** (no_task 分类+征同意/check/finish/前缀全保留)。幂等 (marker 包裹)。
development
Claude Code 会话历史整理 — 扫 ~/.claude/projects/**/*.jsonl 全部 session transcripts, 提取学习增量 (用户校正/决策/踩坑/L0 规则) → 全局记忆库 ~/.cortex/.wiki/memory/. 默认 --apply 落盘 (--dry-run opt-in 仅出 JSON plan 预览). 与 cortex-extract (L4-inbox 内部) 互补.