monolith-model-development
Use when creating or modifying GORM models in app/models, including generator usage, CRUD helper patterns, hooks, and migration registration.
来源信息
- 仓库
- cggonzal/monolith
- 最近来源活动
- 2026年2月14日 03:11
- 检测到的 SKILL.md 语言
- 英语
- 星标
- 0
- 分支
- 0
安装方式
默认使用会先检查来源的 Prompt;你也可以切换为直接命令,或下载本地副本。
检查来源文件
决定是否安装前,请先阅读 SKILL.md,以及 SkillsMP 当前展示的配套文件。
正在显示 SKILL.md
SKILL.md
来源说明 · 只读预览- name
- monolith-model-development
- description
- Use when creating or modifying GORM models in app/models, including generator usage, CRUD helper patterns, hooks, and migration registration.
# Monolith Model Development
## Use this skill when
- Adding a new persisted domain entity.
- Updating schema and model helpers.
## Default approach
1. Scaffold with `make generator model <Name> field:type...` when possible.
2. Confirm model is added to `db/db.go` AutoMigrate list.
3. Add/adjust helper functions in `app/models/<name>.go`.
4. Add tests under `app/models/*_test.go` and run `go test ./...`.
## Expected model conventions
- Embed `gorm.Model`.
- Include `IsActive bool` soft-delete style flag.
- Provide CRUD helpers (`CreateX`, `GetXByID`, `GetAllXs`, `UpdateX`, `DeleteX`).
- Keep validation in hooks (`BeforeSave`/`AfterSave`) or explicit helper functions.
## If you need full REST scaffolding
Use `make generator resource <singular> field:type...`.
This will create model + controller + routes + views in one pass.
## Migration notes
- Auto migration occurs during `db.InitDB()` on startup.
- Adding a model without registering it in AutoMigrate means no schema creation.
在 GitHub 查看