一键导入
go-enum
Define and extend Go enums using the go-enum code generator. Use when adding new enum types, extending existing ones, or running generation after changes.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Define and extend Go enums using the go-enum code generator. Use when adding new enum types, extending existing ones, or running generation after changes.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
This skill should be used when the user asks to "configure hive", "setup hive for my workflow", "customize session spawn", "add tmux integration", "create custom keybindings", "add user commands", or needs guidance on hive configuration, rules, spawn commands, terminal integration, or keybindings.
This skill should be used when the user asks to "check my inbox", "read my messages", "any unread messages?", "check for new messages", "see my inbox", or needs to read inter-agent messages from other hive sessions. Provides guidance on reading, filtering, and managing inbox messages.
Use `hive hc` commands to track tasks and epics for agent workflows. Like GitHub Issues but scoped to a repository and designed for machine consumption. Use when: - Creating work items (epics, tasks) - Checking item status or listing open work - Recording progress via comments - Claiming the next actionable task for a session - Querying epic context as a structured summary
Add SQL queries, run code generation, and configure type overrides for the hive SQLite data layer. Use when writing new queries, adding tables, or mapping domain types to generated code.
This skill should be used when the user asks to "send message to agent X", "publish to topic", "broadcast to all agents", "notify other sessions", "tell agent Y that...", or needs to send inter-agent messages, hand off work, or broadcast notifications across hive sessions.
This skill should be used when the user asks to "wait for message from agent X", "block until response", "wait for handoff", "synchronize with other agents", "wait for acknowledgment", or needs to block execution until messages arrive on specific topics with configurable timeout.
| name | go-enum |
| description | Define and extend Go enums using the go-enum code generator. Use when adding new enum types, extending existing ones, or running generation after changes. |
| compatibility | claude |
Hive uses go-enum to generate enum methods from // ENUM(...) comments. Generated files are committed — never edit them manually.
Define an enum type with a special comment:
// ItemType categorizes an HC item.
//
// ENUM(epic, task)
type ItemType string
go-enum reads the comment and generates item_enum.go (or the file named after the type's source file with _enum suffix) containing:
ParseItemType(s string) (ItemType, error)(t ItemType) IsValid() bool(t ItemType) String() string(t ItemType) MarshalText() ([]byte, error) / UnmarshalText([]byte) errorItemTypeValues() []ItemTypeItemTypeEpic, ItemTypeTaskAfter any change to an // ENUM(...) comment or adding a new enum type:
mise run generate:enums # go-enum only
mise run generate # all generators (go-enum + sqlc)
// ENUM(...) comment:// ENUM(epic, task, milestone)
type ItemType string
Run mise run generate:enums.
The new constant ItemTypeMillestone and ParseItemType("milestone") are available.
Update any switch statements or OneOf validators that enumerate values.
// Priority ranks the urgency of an item.
//
// ENUM(low, medium, high, critical)
type Priority string
Run mise run generate:enums. A new *_enum.go file is generated next to the source.
Never define the constants manually — the generator owns them.
go-enum creates files named <source_file_stem>_enum.go. Examples:
item.go → item_enum.goactivity.go → activity_enum.goIf a source file defines multiple enum types, all are generated into the same _enum.go file.
When a column stores an enum, the generated go-enum type satisfies driver.Valuer/sql.Scanner via its MarshalText/UnmarshalText methods. Add an override to sqlc.yaml:
overrides:
- column: "hc_items.type"
go_type:
import: "github.com/colonyops/hive/internal/core/hc"
type: "ItemType"
This lets sqlc use hc.ItemType directly in generated query params/returns — no string conversion needed in the store layer.
Use criterio.OneOf(...) to validate enum fields, listing all valid constants explicitly:
criterio.Run("type", i.Type, criterio.OneOf(ItemTypeEpic, ItemTypeTask))
Do not call i.Type.IsValid() inside criterio — OneOf is more readable and produces better error messages.
*_enum.go files — they are overwritten on every generation run.ItemType("") will fail IsValid() and OneOf checks. Always initialize enum fields.ItemTypeEpic has string value "epic".mise run generate:enums sources are listed in mise.toml under [tasks."generate:enums"]. If you add a new source file containing an ENUM, add it to the sources list so mise detects changes correctly.