npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

gorig_gen_cli

v1.2.0

Published

gorig scaffolding and code generator CLI tool

Readme

gorig_gen_cli

gorig_gen_cli 是面向 Gorig 框架的官方脚手架与代码生成 CLI 工具。支持基于 DDD(领域驱动设计)架构一键初始化项目骨架、创建业务领域模块、自动生成 OpenAPI 文档及 ReDoc 在线预览。


📦 安装与使用

全局安装

npm install -g gorig_gen_cli

免安装直接运行 (推荐)

npx gorig_gen_cli@latest <command>

🚀 快速上手

1. 初始化新项目 (init)

创建并初始化一个新的 Gorig 后端服务项目:

# 全局命令方式
gorig_gen_cli init my-app

# 或 npx 方式
npx gorig_gen_cli@latest init my-app

该命令将自动创建:

  • go.mod (Go 1.23) 并引入最新 github.com/WnJee/gorig 依赖;
  • 多环境配置文件:_bin/dev.yaml、_bin/local.yaml、_bin/prod.yaml;
  • 程序入口与主启动流程:_cmd/main.go;
  • 外层接口服务注册:api/init.go;
  • DDD 领域模型初始化:domain/init.go;
  • 定时任务管理:cron/cron.go;
  • 全局配置映射:global/config.go。

2. 创建业务模块 (create)

在项目根目录下,使用 create 命令快速生成指定的业务模块:

# 全局命令方式
gorig_gen_cli create user

# 或 npx 方式
npx gorig_gen_cli@latest create user

该命令采用清晰的分层与 DDD 领域模型设计,自动生成以下文件并完成自动注册:

├── api/user/
│   ├── controller.go     # HTTP 控制器:泛型安全入参绑定 (apix.BindReq) 与响应分发
│   └── router.go         # 路由组映射与注册 (httpx.RegisterRouter)
└── domain/user/
    ├── dto.go            # 领域入参 (UserReq)、出参 (UserResp) 与过滤 (UserFilter) DTO
    ├── model.go          # 数据实体定义与 GORM 自动迁移配置 (DConfig, AutoMigrate)
    └── service.go        # 领域核心业务逻辑 (基于 dx 泛型 ORM 操作)

自动注册机制:

  • 自动向 api/init.go 注入 _ "<projectName>/api/user",启动时自动注册路由;
  • 自动向 domain/init.go 注入 _ "<projectName>/domain/user",启动时自动执行模型迁移。

3. 生成与预览 API 文档 (doc)

解析项目路由、控制器与 DTO 实体,一键生成 OpenAPI 3.0 文档与 ReDoc 交互式文档页面:

# 生成所有模块文档并启动本地预览
gorig_gen_cli doc

# 仅生成指定模块的文档
gorig_gen_cli doc user

生成后可通过浏览器访问文档预览页面: http://127.0.0.1:8080/redoc.html


4. 安装与更新 AI Agent Skill (skill)

一键将官方 gorig-agent Skill 安装至当前项目或全局 AI Agent(Antigravity、Claude Code、Codex、Cursor)配置目录:

# 一键安装到当前项目以及本机已配置的所有 AI Agent 目录
npx gorig_gen_cli@latest skill

# 或安装至指定 Agent 平台 / 全局目录
npx gorig_gen_cli@latest skill install antigravity  # 安装到 Google Antigravity (~/.gemini/antigravity/skills/)
npx gorig_gen_cli@latest skill install claude       # 安装到 Claude Code (~/.claude/skills/)
npx gorig_gen_cli@latest skill install project      # 安装到当前项目目录 (.agent/skills/ 与 .claude/skills/)
npx gorig_gen_cli@latest skill install global       # 安装到本机所有 Agent 全局目录

安装完成后,在 AI Agent 中直接用业务语言提需求即可:

"使用 gorig-agent skill,使用 gorig_gen_cli 初始化项目并创建 order 模块,实现订单创建与支付状态流转。"


5. 查看 CLI 版本 (version)

gorig_gen_cli version

🏗️ 架构目录设计规范

基于 gorig_gen_cli init 生成的标准工程目录结构如下:

my-app/
├── .agent/                       # 【AI Agent 目录】预置框架 Skill
│   └── skills/
│       └── gorig-agent/
│           └── SKILL.md          # Gorig 框架 AI 交付规范
├── _bin/                         # 配置文件目录
│   ├── dev.yaml                  # 开发环境配置 (snake_case)
│   ├── local.yaml                # 本地环境配置 (snake_case)
│   └── prod.yaml                 # 生产环境配置 (snake_case)
├── _cmd/                         # 程序入口
│   └── main.go                   # main 入口
├── api/                          # 【外层接入层】HTTP 接口路由与控制器
│   ├── init.go                   # HTTP 服务注册与各模块路由自动导入
│   └── user/                     # user 业务的外层接入
│       ├── controller.go         # 控制器:调用 domain/user 领域服务
│       └── router.go             # 路由注册:声明 Gin 路由组
├── cron/                         # 定时任务目录
│   └── cron.go                   # 统一定时任务配置
├── domain/                       # 【DDD 领域层】专注业务模型与领域逻辑
│   ├── init.go                   # 领域模型初始化(AutoMigrate 注册)
│   └── user/                     # user 业务领域模型
│       ├── dto.go                # 请求 / 响应 / Filter DTO 结构定义
│       ├── model.go              # 数据表模型实体与 GORM 迁移配置 (DConfig)
│       └── service.go            # 领域核心业务逻辑 (基于 dx ORM)
├── global/                       # 全局通用对象
│   └── config.go                 # 全局配置映射
├── AGENTS.md                     # AI Agent 开发指南与规范
├── go.mod                        # Go 模块文件
└── go.sum

💻 启动与编译

进入项目目录后,可直接通过 Go 命令启动:

# 直接运行
go run _cmd/main.go

# 或构建二进制后执行
go build -o my-app _cmd/main.go && ./my-app

📄 License

MIT