Entity and model patterns with JSON serialization, immutability, and equality
Generates Dart models with JSON serialization, immutability, and equality patterns.
/plugin marketplace add Kaakati/rails-enterprise-dev/plugin install reactree-flutter-dev@manifest-marketplaceThis skill inherits all available tools. When active, it can use any tool Claude has access to.
// lib/domain/entities/user.dart
import 'package:equatable/equatable.dart';
class User extends Equatable {
final String id;
final String name;
final String email;
final DateTime createdAt;
final DateTime? updatedAt;
const User({
required this.id,
required this.name,
required this.email,
required this.createdAt,
this.updatedAt,
});
@override
List<Object?> get props => [id, name, email, createdAt, updatedAt];
User copyWith({
String? name,
String? email,
DateTime? updatedAt,
}) {
return User(
id: id,
name: name ?? this.name,
email: email ?? this.email,
createdAt: createdAt,
updatedAt: updatedAt ?? this.updatedAt,
);
}
}
// lib/data/models/user_model.dart
import '../../domain/entities/user.dart';
class UserModel extends User {
const UserModel({
required super.id,
required super.name,
required super.email,
required super.createdAt,
super.updatedAt,
});
factory UserModel.fromJson(Map<String, dynamic> json) {
return UserModel(
id: json['id'] as String,
name: json['name'] as String,
email: json['email'] as String,
createdAt: DateTime.parse(json['created_at'] as String),
updatedAt: json['updated_at'] != null
? DateTime.parse(json['updated_at'] as String)
: null,
);
}
Map<String, dynamic> toJson() {
return {
'id': id,
'name': name,
'email': email,
'created_at': createdAt.toIso8601String(),
if (updatedAt != null) 'updated_at': updatedAt!.toIso8601String(),
};
}
User toEntity() {
return User(
id: id,
name: name,
email: email,
createdAt: createdAt,
updatedAt: updatedAt,
);
}
factory UserModel.fromEntity(User entity) {
return UserModel(
id: entity.id,
name: entity.name,
email: entity.email,
createdAt: entity.createdAt,
updatedAt: entity.updatedAt,
);
}
}
class OrderModel extends Order {
final List<OrderItemModel> itemModels;
const OrderModel({
required super.id,
required super.userId,
required super.total,
required this.itemModels,
}) : super(items: itemModels);
factory OrderModel.fromJson(Map<String, dynamic> json) {
return OrderModel(
id: json['id'],
userId: json['user_id'],
total: json['total'].toDouble(),
itemModels: (json['items'] as List)
.map((item) => OrderItemModel.fromJson(item))
.toList(),
);
}
Map<String, dynamic> toJson() {
return {
'id': id,
'user_id': userId,
'total': total,
'items': itemModels.map((item) => item.toJson()).toList(),
};
}
}
enum UserRole { admin, user, guest }
extension UserRoleX on UserRole {
String toJson() => name;
static UserRole fromJson(String json) {
return UserRole.values.firstWhere(
(role) => role.name == json,
orElse: () => UserRole.guest,
);
}
}
class UserModel extends User {
final UserRole roleValue;
const UserModel({
required super.id,
required super.name,
required this.roleValue,
}) : super(role: roleValue);
factory UserModel.fromJson(Map<String, dynamic> json) {
return UserModel(
id: json['id'],
name: json['name'],
roleValue: UserRoleX.fromJson(json['role']),
);
}
Map<String, dynamic> toJson() {
return {
'id': id,
'name': name,
'role': roleValue.toJson(),
};
}
}
import 'package:freezed_annotation/freezed_annotation.dart';
part 'user_model.freezed.dart';
part 'user_model.g.dart';
@freezed
class UserModel with _$UserModel {
const factory UserModel({
required String id,
required String name,
required String email,
DateTime? updatedAt,
}) = _UserModel;
factory UserModel.fromJson(Map<String, dynamic> json) =>
_$UserModelFromJson(json);
}
class UserModel {
final String id;
final String name;
final String email;
const UserModel({
required this.id,
required this.name,
required this.email,
});
UserModel copyWith({
String? name,
String? email,
}) {
return UserModel(
id: id,
name: name ?? this.name,
email: email ?? this.email,
);
}
}
import 'package:equatable/equatable.dart';
class User extends Equatable {
final String id;
final String name;
const User({required this.id, required this.name});
@override
List<Object?> get props => [id, name];
}
class User {
final String id;
final String name;
const User({required this.id, required this.name});
@override
bool operator ==(Object other) {
if (identical(this, other)) return true;
return other is User && other.id == id && other.name == name;
}
@override
int get hashCode => id.hashCode ^ name.hashCode;
}
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.