creating-gorm-entity
について
このスキルは、go-kratosマイクロサービスのためのGORMエンティティ構造体を生成し、タイムスタンプとソフトデリートのためのBaseModelを埋め込みます。フィールドタグ、リレーションシップ(1対1/1対多)、およびインデックス戦略を適切に設定します。データベーススキーマの定義、新しいエンティティの作成、テーブルリレーションシップと制約の設定時にご利用ください。
クイックインストール
Claude Code
推奨/plugin add https://github.com/majiayu000/claude-skill-registrygit clone https://github.com/majiayu000/claude-skill-registry.git ~/.claude/skills/creating-gorm-entityこのコマンドをClaude Codeにコピー&ペーストしてスキルをインストールします
ドキュメント
GORM Entity Creation Skill
Purpose
Generate GORM entity structs that follow the project's Clean Architecture patterns, with proper field tags, relationships, indexing strategies, and soft delete support.
Essential Patterns
1. BaseModel Pattern
All entities MUST embed BaseModel which provides:
ID uint64- Primary key with auto-incrementCreatedAt time.Time- Automatic timestampUpdatedAt time.Time- Automatic timestampDeletedAt gorm.DeletedAt- Soft delete support with index
type BaseModel struct {
ID uint64 `gorm:"primaryKey;autoIncrement"`
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt gorm.DeletedAt `gorm:"index"`
}
2. Field Ordering Rules
Fields MUST follow this exact order:
- BaseModel embedding (always first)
- Foreign keys (e.g., ProjectID, SymbolID)
- Required business fields (UID, Label, ClassName, etc.)
- Optional fields
- Relationship fields (pointer types with gorm tags)
Example:
type Symbol struct {
BaseModel // 1. Base embedding
ProjectID uint64 `gorm:"..." // 2. Foreign key
UID string `gorm:"..." // 3. Required fields
Label string `gorm:"..."
ClassName string `gorm:"..."
ComponentTarget string `gorm:"..."
Version uint32 `gorm:"..."
SymbolData *SymbolData `gorm:"..." // 4. Relationship
}
3. GORM Tag Structure
Tags MUST follow this pattern: `gorm:"constraint1;constraint2;..." json:"field_name"`
Common constraints:
- `not null` - Required field
- `size:255` - String length limit
- `uniqueIndex:idx_name,priority:N` - Unique composite index
- `index:idx_name,priority:N` - Non-unique composite index
- `foreignKey:FieldName` - FK relationship
- `references:ID` - FK reference
- `constraint:OnDelete:CASCADE` - FK cascade delete
Critical indexing patterns:
// Composite unique index (project_id + uid)
ProjectID uint64 \`gorm:"not null;uniqueIndex:idx_project_uid,priority:1" json:"project_id"\`
UID string \`gorm:"not null;size:255;uniqueIndex:idx_project_uid,priority:2" json:"uid"\`
// Multiple indexes on same field
ProjectID uint64 \`gorm:"not null;uniqueIndex:idx_project_uid,priority:1;index:idx_project_id,priority:1;index:idx_symbols_project_deleted_at,priority:1" json:"project_id"\`
4. Relationship Patterns
One-to-One with Cascade Delete:
type Symbol struct {
BaseModel
// ... other fields ...
SymbolData *SymbolData \`gorm:"foreignKey:SymbolID;references:ID;constraint:OnDelete:CASCADE" json:"symbol_data,omitempty"\`
}
type SymbolData struct {
BaseModel
SymbolID uint64 \`gorm:"not null;uniqueIndex" json:"symbol_id"\`
Data *[]byte \`gorm:"not null;type:longblob" json:"data"\`
}
5. Table Naming
MUST provide explicit table name method:
func (Symbol) TableName() string {
return "symbols" // plural, snake_case
}
Validation Checklist
When creating a GORM entity, verify:
- BaseModel is embedded as first field
- All foreign keys come before business fields
- Required fields have `not null` tag
- String fields have `size:N` constraint
- Unique combinations use `uniqueIndex` with priorities
- Frequently queried fields are indexed
- Foreign keys have proper relationship tags
- Cascade deletes are configured where needed
- TableName() method returns plural snake_case
- JSON tags use snake_case naming
- Pointer types used for optional relationships
- `omitempty` added to optional json fields
Anti-Patterns
❌ DON'T:
- Use `gorm.Model` (use `BaseModel` instead)
- Forget to index foreign keys
- Use value types for optional relationships
- Mix camelCase and snake_case in json tags
- Omit `TableName()` method
- Put relationship fields before business fields
✅ DO:
- Always embed `BaseModel`
- Index all foreign keys
- Use pointer types for optional relationships
- Use snake_case for all json tags
- Provide explicit `TableName()` method
- Follow field ordering rules
GitHub リポジトリ
関連スキル
content-collections
メタThis skill provides a production-tested setup for Content Collections, a TypeScript-first tool that transforms Markdown/MDX files into type-safe data collections with Zod validation. Use it when building blogs, documentation sites, or content-heavy Vite + React applications to ensure type safety and automatic content validation. It covers everything from Vite plugin configuration and MDX compilation to deployment optimization and schema validation.
evaluating-llms-harness
テストThis Claude Skill runs the lm-evaluation-harness to benchmark LLMs across 60+ standardized academic tasks like MMLU and GSM8K. It's designed for developers to compare model quality, track training progress, or report academic results. The tool supports various backends including HuggingFace and vLLM models.
sglang
メタSGLang is a high-performance LLM serving framework that specializes in fast, structured generation for JSON, regex, and agentic workflows using its RadixAttention prefix caching. It delivers significantly faster inference, especially for tasks with repeated prefixes, making it ideal for complex, structured outputs and multi-turn conversations. Choose SGLang over alternatives like vLLM when you need constrained decoding or are building applications with extensive prefix sharing.
polymarket
メタThis skill enables developers to build applications with the Polymarket prediction markets platform, including API integration for trading and market data. It also provides real-time data streaming via WebSocket to monitor live trades and market activity. Use it for implementing trading strategies or creating tools that process live market updates.
