go-init
基于 gin + gorm + redis + zap + mix-go/xcli 的 Go 后端项目脚手架规范(源自 mindcloudxai_api 的实战架构)。Claude 应在用户提到 "初始化 Go 项目"、"创建 Go 后端服务"、"搭建 gin 项目"、"新建 Go API 项目"、"按…
Skill by dengmuming
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/dengmuming-go-init
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: backend
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md and code. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/go-init
What's inside
- Skill name
go-init- Description
- 基于 gin + gorm + redis + zap + mix-go/xcli 的 Go 后端项目脚手架规范(源自 mindcloudxai_api 的实战架构)。Claude 应在用户提到 "初始化 Go 项目"、"创建 Go 后端服务"、"搭建 gin 项目"、"新建 Go API 项目"、"按 mindcloudxai 风格搭建项目",或在现有此风格 Go 项目中"新增控制器/服务/模型/路由/计划任务命令/枚举/中间件"时使用本 skill,即使用户没有显式说"脚手架"或"模板"。也用于把已有的散乱 Go 代码改造成本规范的分层结构。
- License
- MIT
- Instructions
- 159 lines in SKILL.md · view on GitHub
Files (7)
- SKILL.md
- components-logger-config.md · references/
- components-mysql-redis.md · references/
- components-router-i18n.md · references/
- components-storage.md · references/
- components-xcli-cron.md · references/
- module-generation.md · references/
SKILL.md (first lines)
# go-init
为 Go 后端项目(HTTP API + 计划任务 + 命令行)提供一套统一的目录结构与组件接入规范。包含:从零搭建新项目,以及在已有项目中按规范扩展。
## 快速判断:用户在做什么?
| 用户意图 | 走哪条路径 |
|---|---|
| 新建一个空项目 / `go mod init` 后不知怎么组织 | **路径 A:新项目初始化** |
| 已有项目,要加一个接口 / 表 / 命令 | **路径 B:按规范扩展模块** |
| 散乱代码改造 | 先按路径 A 立骨架,再迁移代码进对应分层 |
不确定时主动询问用户:模块名(`go.mod` 的 module path)?需要哪些可选组件?
## 路径 A:新项目初始化
### A1. 目录骨架(必建)
```
<project>/
├── app/
│ ├── connection/{mysql,redis}/
│ ├── controller/ # 按域分子包,如 user/、project/
│ ├── service/ # 按域分子包,命名 xxxService
│ ├── model/ # 按域分子包,命名 xxxModel
│ ├── enums/{result}/
│ ├── middleware/
│ └── console/
│ ├── kernel.go
│ └── commands/
├── router/
│ ├── router.go
│ ├── middleware/ # auth.go, public.go(cors)
│ └── v1/ # web.go / api.go
├── config/config.go
├── global/global.go
├── util/{logger,i18nutil,app/response,common}/
├── lang/ # zh.toml, en.toml(若启用 i18n)
├── migrations/ # SQL 迁移
├── static/ public/ log/ output/
├── main.go
├── example.config.yaml
├── .gitignore
├── build.sh
├── run.bat
└── go.mod
```
> 一次性建目录命令(PowerShell,逐行确认;如用 bash 用 `mkdir -p`):
> `New-Item -ItemType Directory -Force -Path app/connection/mysql,app/connection/redis,app/controller,app/service,app/model,app/enums/result,app/middleware,app/console/commands,router/middleware,router/v1,config,global,util/logger,util/i18nutil,util/app/response,util/common,lang,migrations,static,public,log,output`
### A2. 必装核心组件(按顺序接入)
> 以下每一步的**完整代码模板**见 `references/`,本节只列接入顺序与关键点。
1. **`config/config.go`** — yaml 配置加载(`gopkg.in/yaml.v2`),暴露 `config.GlobalConfig` 单例与 `InitConfig()`。
→ 见 `references/components-logger-config.md`
2. **`global/global.go`** — 声明全局单例:`Db *gorm.DB`、`Redis *MindCloudRedis`、`Logger *zap.Logger`、`RestyClient *resty.Client`。**禁止在任何业务包里再定义全局**。
3. **`util/logger/logger.go`** — `zap` + `lumberjack` 的滚动日志,输出到 `./log/log.log` 与 stdout。
→ 见 `references/components-logger-config.md`
4. **`app/connection/mysql/mysql.go`** — `gorm.Open` 单例工厂 `GetDbClient()`,使用单数表名 `SingularTable: true`。
→ 见 `references/components-mysql-redis.md`
5. **`app/connection/redis/redis.go`** — 自封装 `MindCloudRedis`(暴露 `Get/Set/LPush/RPop/...`),返回 `*MindCloudRedis`。
→ 见 `references/components-mysql-redis.md`
6. **`router/router.go`** — `InitRouter() *gin.Engine`:装 i18n bundle + `Cors` 中间件 + 静态资源 + `v1.InitWebRouter`。
→ 见 `references/components-router-i18n.md`
7. **`router/middleware/`** — `public.go`(CORS)、`auth.go`(`TokenAuth`/`AdminAuth`)。
8. **`util/app/response/response.go`** — 统一响应:`Success/Fail/TokenFail/PermissionDenied/FailWithErrorCode`,配合 `app/enums/result.ErrorCode`。
9. **`app/console/kernel.go`** — `xcli.Command` 列表,默认 `run` 命令调起 HTTP 服务;`Schedule()` 用 `robfig/cron` 跑定时任务。
→ 见 `references/components-xcli-cron.md`
10. **`main.go`** — `init()` 调 `initConfig()` 装填全局;`main()` 解析 `--host` `--schedule` flag,否则交给 `xcli.AddCommand(...).Run()`。
→ 完整模板见 `references/components-xcli-cron.md`
### A3. 可选组件(按需问用户)
- **i18n**:`lang/zh.toml` `lang/en.toml` + `suisrc/gin-i18n` + `util/i18nutil`
- **阿里云 OSS / 腾讯云 COS / STS**:见 `references/components-storage.md`
- **校验器多语言报错**:`go-playground/validator/v10` + `universal-translator` → `util/app/validator.go`
- **Excel 导出**:`360EntSecGroup-Skylar/excelize` → `util/office`
- **Resty HTTP 客户端**:`go-resty/resty/v2`(核心 `global.RestyClient`)
### A4. 配置与构建文件
- **`example.config.yaml`** — 配置模板(提交进库),项目实际配置 `config.yaml` **必须 .gitignore**。结构与 `config/config.go` 的 struct tag 完全对齐。
- **`.gitignore`** 至少包含:
```
*.exe
*.exe~
*.test
*.out
.idea/*
config.yaml
main
main.exe
build/*
tmp/*
log/*
output/*
.gocache
```
- **`build.sh`**:
```bash
#!/bin/bash
source /etc/profile
go mod tidy
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o "<binary_name>" main.go
```
- **`run.bat`**:本地 Windows 启动脚本(可选)
### A5. 收尾
- `go mod init <module>` → 让用户给出 module 名(不要瞎猜)
- `go mod tidy` 拉依赖
- 提示用户:复制 `example.config.yaml` 为 `config.yaml` 并填值,然后 `go run main.go`
- 计划任务模式:`go run main.go --schedule=true`
## 路径 B:在现有项目中按规范扩展
> 触发关键词:「加一个 XX 接口」「新增 XX 表」「写个定时任务跑 XX」「加个管理后台 XX 功能」From dengmuming/ai-vibe-coding, MIT.
More from dengmuming/ai-vibe-coding
- 0.624score
find-simplifications
dengmuming
Use when working in a codebase to find non-obvious simplification candidates, write proposed design notes or inline TODO/FIXME/XXX notes, or fold worthwhile…
SkillAFreshness: A★ 7Claude Code +9 - 0.624score
grill-code-review
dengmuming
Review changes since a fixed point along two independent axes — repository standards and the originating spec.
SkillAFreshness: A★ 7Claude Code +9 - 0.621score
dispatch
dengmuming
安全执行一个已经明确的工作项批次并返回可验证结果。Prepare 把批次整理到可执行、Dispatch 安排隔离 worktree 与执行器执行、Resume 恢复中断的执行。当用户给出一批已经明确的工作项(任务单、ticket、改动清单)要求执行时使用。跨会话的目标管理与验收生命周期不归本 skill。
SkillAFreshness: A★ 7Claude Code +9 - 0.618score
dev
dengmuming
从想法到上线的一条龙研发流程——grill 压实想法、to-spec 写成 spec、to-tickets 拆成工单、implement 落地代码。用户输入 /dev 触发,也可从任一段中途进入。
SkillAFreshness: A★ 7Claude Code +9 - 0.610score
debugging
dengmuming
Systematically debug an error or unexpected behavior.
SkillAFreshness: A★ 7Claude Code +9 - 0.599score
domain-modeling
dengmuming
Build and sharpen a project's domain model.
SkillAFreshness: A★ 7Claude Code +9 - 0.599score
codebase-design
dengmuming
Shared vocabulary for designing deep modules.
SkillAFreshness: A★ 7Claude Code +9
Signals
- Stars
- 7
- Forks
- 0
- Open issues
- 0
- Last commit (this folder)
- Oct 11, 2026 (17 days ago)
- Last release
- Oct 11, 2026 (17 days ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/dengmuming/ai-vibe-coding
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from dengmuming
- 0.624score
find-simplifications
dengmuming
Use when working in a codebase to find non-obvious simplification candidates, write proposed design notes or inline TODO/FIXME/XXX notes, or fold worthwhile…
SkillAFreshness: A★ 7Claude Code +9 - 0.624score
grill-code-review
dengmuming
Review changes since a fixed point along two independent axes — repository standards and the originating spec.
SkillAFreshness: A★ 7Claude Code +9 - 0.621score
dispatch
dengmuming
安全执行一个已经明确的工作项批次并返回可验证结果。Prepare 把批次整理到可执行、Dispatch 安排隔离 worktree 与执行器执行、Resume 恢复中断的执行。当用户给出一批已经明确的工作项(任务单、ticket、改动清单)要求执行时使用。跨会话的目标管理与验收生命周期不归本 skill。
SkillAFreshness: A★ 7Claude Code +9 - 0.618score
dev
dengmuming
从想法到上线的一条龙研发流程——grill 压实想法、to-spec 写成 spec、to-tickets 拆成工单、implement 落地代码。用户输入 /dev 触发,也可从任一段中途进入。
SkillAFreshness: A★ 7Claude Code +9 - 0.610score
debugging
dengmuming
Systematically debug an error or unexpected behavior.
SkillAFreshness: A★ 7Claude Code +9 - 0.599score
domain-modeling
dengmuming
Build and sharpen a project's domain model.
SkillAFreshness: A★ 7Claude Code +9
Cite this page
go-init skill. Agent Mart. https://agentmart.dev/skills/dengmuming-go-init (last updated 2026-10-24)