install
source · Clone the upstream repo
git clone https://github.com/majiayu000/claude-skill-registry
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/majiayu000/claude-skill-registry "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/data/controller-generation" ~/.claude/skills/majiayu000-claude-skill-registry-controller-generation && rm -rf "$T"
manifest:
skills/data/controller-generation/SKILL.mdsource content
Controller Code Generation
The system uses
core_generate to automatically create standard CRUD operations for controllers.
Code Generation Command
Add this directive to your
setup.go file:
//go:generate core_gen controller Account -modelPackage=account
Parameters:
- Command typecontroller
- Model name (PascalCase)Account
- Package name containing the model-modelPackage=account
if its an admin only controller-options=admin
skip generating this function because we need to customize it-skip=xxxYYY,aaaBBB
Generated Files
Running
go generate creates two files:
- Admin CRUD handlers:x_gen_admin.go
- List all resourcesadminIndex
- Get single resourceadminGet
- Create new resourceadminCreate
- Update existing resourceadminUpdate
- Get total countadminCount
(optionally)
- Public CRUD handlers:x_gen_auth.go
- List resources (filtered to user's data)authIndex
- Get single resource (with ownership check)authGet
- Create new resourceauthCreate
- Update resource (with ownership check)authUpdate
Generated Endpoints
| Method | Admin Route | Public Route | Function | Description |
|---|---|---|---|---|
| GET | | | , | List resources |
| GET | | | , | Get single resource |
| POST | | | , | Create new resource |
| PUT | | | , | Update resource |
| GET | | - | | Get total count |
| GET | | - | TypeScript | TS type generation |
Skipping Endpoints
You can disable specific endpoints using the
-skip parameter:
//go:generate core_gen controller AiTool -modelPackage=ai_tool -skip=authCreate,authUpdate
This will generate all endpoints except
authCreate and authUpdate.
Available Skip Options:
- Skip admin list endpointadminIndex
- Skip admin get endpointadminGet
- Skip admin create endpointadminCreate
- Skip admin update endpointadminUpdate
- Skip admin count endpointadminCount
- Skip public list endpointauthIndex
- Skip public get endpointauthGet
- Skip public create endpointauthCreate
- Skip public update endpointauthUpdate
Common Skip Patterns
Read-only public endpoint:
//go:generate core_gen controller Config -modelPackage=config -skip=authCreate,authUpdate
Admin-only resource:
//go:generate core_gen controller SystemLog -modelPackage=system_log -options=admin
Customizing Generated Code
DO NOT edit generated files directly. They will be overwritten on next generation.
Instead, create custom handlers in separate files, name them accordingly auth.go open.go admin.go
if theres lots of functions, group them together by relation then use a prefix, auth_password.go auth_emails.go
custom_handlers.go:
package account func customSearch(_ http.ResponseWriter, req *http.Request) ([]*account.Account, int, error) { // Custom search logic here // ... }
Then wire up in
setup.go:
r.Get("/search", helpers.RoleHandler(helpers.RoleHandlerMap{ constants.ROLE_ANY_AUTHORIZED: helpers.StandardPublicRequestWrapper(customSearch), }))
Regenerating Code
Re-run generation after:
- Updating skip parameters
go generate path/to/file
Related Skills
- controller-handlers - Writing custom handlers
- controller-roles - Role-based access control