code-patterns
星标14
分支1
更新时间2026年3月8日 17:49
Reference for Go code patterns in this project. Read before creating new components.
安装
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
SKILL.md
readonly菜单
Reference for Go code patterns in this project. Read before creating new components.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | code-patterns |
| description | Reference for Go code patterns in this project. Read before creating new components. |
| user-invocable | false |
Read existing code to discover patterns before writing new code.
services/<name>.go — interface definition
services/<name>/<name>.go — implementation (var _ services.Interface = &impl{})
repos/<name>.go — interface definition (with WithUnitOfWork)
repos/<name>/<name>.go — SQL implementation using styx ORM
// api/handlers/<name>.go — standalone function, NOT a method
func HandleSomething(ctx telebot.Context) error {
svc := all.GetServices()
user, err := svc.User.GetUserByTelegramID(ctx.Sender().ID)
if err != nil {
return ctx.Send(models.ErrCommonResponse(err))
}
// ... business logic via svc.Wallet / svc.Contact / svc.Txn
return ctx.Send("result", telebot.ModeMarkdown)
}
Register in api/tele.go: bot.Handle("/command", handlers.HandleSomething)
Add struct to models/. Add to configs/database.go:syncTables() for auto-sync.