Code generation for CRUD endpoints
/plugin marketplace add griffnb/claude-plugins/plugin install backend@claude-pluginsThis skill inherits all available tools. When active, it can use any tool Claude has access to.
The system uses core_generate to automatically create standard CRUD operations for controllers.
Add this directive to the controller folders setup.go file:
//go:generate core_gen controller Account -modelPackage=account
Parameters:
controller - Command typeAccount - Model name (PascalCase)-modelPackage=account - Package name containing the model-options=admin if its an admin only controller-skip=xxxYYY,aaaBBB skip generating this function because we need to customize itRunning go generate creates two files:
x_gen_admin.go - Admin CRUD handlers:
adminIndex - List all resourcesadminGet - Get single resourceadminCreate - Create new resourceadminUpdate - Update existing resourceadminCount - Get total count(optionally)
x_gen_auth.go - Public CRUD handlers:
authIndex - List resources (filtered to user's data)authGet - Get single resource (with ownership check)authCreate - Create new resourceauthUpdate - Update resource (with ownership check)| Method | Admin Route | Public Route | Function | Description |
|---|---|---|---|---|
| GET | /admin/account | /account | adminIndex, authIndex | List resources |
| GET | /admin/account/{id} | /account/{id} | adminGet, authGet | Get single resource |
| POST | /admin/account | /account | adminCreate, authCreate | Create new resource |
| PUT | /admin/account/{id} | /account/{id} | adminUpdate, authUpdate | Update resource |
| GET | /admin/account/count | - | adminCount | Get total count |
| GET | /admin/account/_ts | - | TypeScript | TS type generation |
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:
adminIndex - Skip admin list endpointadminGet - Skip admin get endpointadminCreate - Skip admin create endpointadminUpdate - Skip admin update endpointadminCount - Skip admin count endpointauthIndex - Skip public list endpointauthGet - Skip public get endpointauthCreate - Skip public create endpointauthUpdate - Skip public update endpointRead-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
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: response.StandardPublicRequestWrapper(customSearch),
}))
Re-run generation after:
go generate path/to/file
This skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.