dojo-model

Generate Cairo Dojo models with #[dojo::model] and #[key] for ECS game state.

Updated Apr 3, 2026
One-click install
npx skills add https://github.com/cartridge-gg/scoundrel --skill dojo-model-cartridge-gg
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: dojo-model
Source: https://github.com/cartridge-gg/scoundrel/tree/main/.agents/skills/dojo-model
Command: npx skills add https://github.com/cartridge-gg/scoundrel --skill dojo-model-cartridge-gg

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Defines robust Dojo models to store and manage game state using ECS patterns, enabling consistent entity-component storage and on-chain compatibility.

Core Features & Use Cases

  • Generates Cairo models annotated with #[dojo::model], including required #[key] fields and Drop/Serde trait derivations.
  • Supports common model patterns: Player-Owned Models, Composite Keys, Global Singletons, and ECS-based compositions, with nested structs requiring Introspect.
  • Provides guidance for using models across systems, data stores, and on-chain storage with examples of key configuration and type choices.

Quick Start

Create a Position model with a single key field (e.g., player) and data fields to begin.

Frequently Asked Questions about dojo-model

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I define Dojo models for storing game state in Cairo?▼

To define Dojo models for storing game state in Cairo, you generate structs annotated with #[dojo::model] and designate key fields with #[key] for entity-component storage. This enables consistent on-chain state management using ECS patterns.

How do I implement composite keys in an ECS pattern using Dojo?▼

To implement composite keys in an ECS pattern using Dojo, you configure multiple fields within your Cairo model as keys. This allows for complex entity lookups and supports patterns like Player-Owned Models and ECS compositions.

What traits do I need to derive for a Dojo model on-chain?▼

For a Dojo model on-chain, you need to derive the Drop and Serde traits. If your model uses nested structs, those internal structures also require the Introspect trait to ensure proper serialization and on-chain compatibility.

Can I create a global singleton model in Dojo for world state?▼

Yes, you can create a global singleton model in Dojo for world state. Dojo supports the Global Singleton pattern, allowing you to manage centralized game state without traditional key-based access when using ECS compositions.

When should I use nested structs in Dojo ECS models?▼

You should use nested structs in Dojo ECS models when you need to group complex data within a single component. These nested structures require the Introspect trait to maintain on-chain compatibility and proper serialization.

Does Dojo support player-owned entity models?▼

Yes, Dojo explicitly supports player-owned entity models. By using the #[key] attribute on a player field within your Cairo struct, you can implement the Player-Owned pattern for secure, key-based access to individual game state.