api-generator

Generate and refactor Go API modules enforcing a three-layer architecture.

905|126|Updated Jan 27, 2023
One-click install
npx skills add https://github.com/carrot-hu23/dst-admin-go --skill api-generator-carrot-hu23
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: api-generator
Source: https://github.com/carrot-hu23/dst-admin-go/tree/main/.claude/skills/api-generator
Command: npx skills add https://github.com/carrot-hu23/dst-admin-go --skill api-generator-carrot-hu23

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

The api-generator skill removes repetitive and error-prone manual work when adding or refactoring backend APIs in the dst-admin-go repository by producing consistent model, service, handler, and router code that follows the project's architectural conventions and naming patterns.

Core Features & Use Cases

  • Scaffolds three-layer modules: generates GORM models, service layer with dependency injection, Gin handlers with Swagger annotations, and router registrations.
  • Enforces project patterns: ensures gorm.Model embedding, constructor-based dependency injection, snake_case filenames, and Chinese comments for exported methods.
  • Handles DST specifics: supports cluster-aware routes, platform-aware service factories, game process and path resolver dependencies when needed, and provides curl test commands and compilation guidance.
  • Use Case: quickly add a new CRUD resource (e.g., Announcement or ModInfo) with pagination, validation, and router integration while preserving existing project structure.

Quick Start

Create a full CRUD module for an entity named Announcement with fields Title (string, required), Content (text), IsActive (bool, default true), and update internal/api/router.go with the new service and handler.

Frequently Asked Questions about api-generator

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I generate CRUD APIs for a Go project using Gin and GORM?

To generate CRUD APIs for Go, this skill scaffolds GORM models, service layers with dependency injection, Gin handlers with Swagger annotations, and router registrations to enforce a three-layer architecture. It produces consistent code following project naming patterns automatically.

What is the best way to add a new CRUD resource to dst-admin-go without breaking existing project structure?

The best way to add a CRUD resource is by generating a full module with pagination, validation, and router integration while preserving existing project structure. It ensures gorm.Model embedding, constructor-based dependency injection, snake_case filenames, and Chinese comments for exported methods.

Can I refactor existing Go API modules to use a three-layer architecture with dependency injection?

Yes, you can refactor existing Go API modules to enforce a three-layer architecture. The skill restructures code into GORM models, service constructors using dependency injection, and Gin handlers with Swagger annotations, including router registrations and test curl commands.

Does the API generator support cluster-aware game server operations in dst-admin-go?

Yes, the API generator supports cluster-aware game server operations within the dst-admin-go repository. It handles cluster-aware routes, platform-aware service factories, and game process and path resolver dependencies when needed for cluster management endpoints.

How do I scaffold a new entity like Announcement with GORM models and Gin handlers?

To scaffold a new entity, define fields like Title, Content, and IsActive, and the skill generates GORM model files, service constructors, Swagger-annotated Gin handlers, and router registrations. It also provides compilation validation and test curl commands.

What are the limitations of using an automated CRUD generator for Go backend APIs?

The automated CRUD generator is specifically tailored for the dst-admin-go repository architecture, enforcing gorm.Model embedding, snake_case filenames, and Chinese comments. It may not suit Go projects with different architectural conventions or naming patterns outside this specific codebase.