model
From davila7
Create Ruby classes and models with proper structure and best practices.
Install
/modelFacts
- Repository
- davila7/claude-code-templates
- Status
- Actively maintained
- Last commit
Source preview
The instructions Claude Code reads when this command runs.
# Ruby Model Generator
Create Ruby classes and models with proper structure and best practices.
## Purpose
This command helps you quickly create Ruby model classes with proper initialization, attributes, and methods following Ruby conventions.
## Usage
```
/model
```
## What this command does
1. **Creates model classes** with proper initialization methods
2. **Adds attribute accessors** and instance variables
3. **Includes validation methods** and error handling
4. **Follows Ruby conventions** and best practices
5. **Generates related test files** when applicable
## Example Output
```ruby
# app/models/user.rb
class User
attr_accessor :name, :email, :age
attr_reader :id, :created_at
def initialize(attributes = {})
@id = attributes[:id] || generate_id
@name = attributes[:name]
@email = attributes[:email]
@age = attributes[:age]
@created_at = Time.now
@errors = []
end
def valid?
@errors.clear
validate_presence_of_name
validate_email_format
validate_age_range
@errors.empty?
end
def errors
@errors.dup
end
def save
return false unless valid?
# Persist logic here
true
end
def to_h
{
id: @id,
name: @name,
email: @email,
age: @age,
created_at: @created_at
}
end
def to_json(*args)
JSON.generate(to_h, *args)
end
private
View full source on GitHub →Other slash commands
feature-development
★ 229,918Workflow command scaffold for feature-development in everything-claude-code.
affaan-mupdated 13d agoMITdatabase-migration
★ 229,918Workflow command scaffold for database-migration in everything-claude-code.
affaan-mupdated 13d agoMITadd-language-rules
★ 229,918Workflow command scaffold for add-language-rules in everything-claude-code.
affaan-mupdated 13d agoMITcommit-push-pr
★ 137,934Commit, push, and open a PR
anthropicsupdated 12d agodedupe
★ 137,934Find duplicate GitHub issues
anthropicsupdated 12d agotriage-issue
★ 137,934Triage GitHub issues by analyzing and applying labels
anthropicsupdated 12d ago