Working with model instances and fields, use when you need to access fields on a model
/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.
Models provide thread-safe field access through typed methods. All operations use .Set() and .Get() patterns.
// Create new model instance
user := user.New()
For specific types (like joined models):
// Create a new model instance for a specific type
joinedUser := user.NewType[*user.JoinedUser]()
All fields use .Set(value) method:
user.Name.Set("Alice")
user.Email.Set("alice@example.com")
user.Age.Set(30)
user.Status.Set(constants.StatusActive)
All fields use .Get() method:
name := user.Name.Get() // "Alice"
email := user.Email.Get() // "alice@example.com"
age := user.Age.Get() // 30
status := user.Status.Get() // constants.StatusActive
Struct fields (JSONB columns) have additional methods:
type Bookmarks struct {
FavoriteID types.UUID `json:"favorite_id"`
RecentIDs []types.UUID `json:"recent_ids"`
}
user.Bookmarks.Set(&Bookmarks{
FavoriteID: uuid1,
RecentIDs: []types.UUID{uuid2, uuid3},
})
// .Get() returns value and error
bookmarks, err := user.Bookmarks.Get()
if err != nil {
return err
}
// .GetI() ignores errors (use when error checking not needed)
bookmarks := user.Bookmarks.GetI()
| Field Type | Go Type | Database Type | Use Case |
|---|---|---|---|
StringField | string | text | Text/string columns |
UUIDField | types.UUID | uuid | UUID columns |
IntField | int | integer/smallint | Integer/boolean (0/1) columns |
DecimalField | decimal.Decimal | numeric | Decimal/numeric columns |
IntConstantField[T] | T (int-based) | smallint | Enum/constant fields |
StructField[T] | T | jsonb | JSONB/struct columns |
All field operations are thread-safe by default. Models use internal mutexes to protect concurrent access.
// Safe to use from multiple goroutines
go user.Name.Set("Alice")
go user.Email.Set("alice@example.com")
user := user.New()
user.Name.Set("Alice")
user.Email.Set("alice@example.com")
user.Age.Set(30)
user.Status.Set(constants.StatusActive)
err := user.Save(ctx)
if err != nil {
return err
}
user, err := user.GetByID(ctx, userID)
if err != nil {
return err
}
// Modify fields
currentAge := user.Age.Get()
user.Age.Set(currentAge + 1)
err = user.Save(ctx)
if err != nil {
return err
}
Fields with null:"true" can be set to nil:
// Set to nil
user.MiddleName.SetNull()
// Check if nil
user.MiddleName.IsNull()
this as the receiver variableThis 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.