home / skills / dojoengine / book / dojo-init

dojo-init skill

/skills/dojo-init

This skill initializes a new Dojo project with complete structure, configs, and starter files to accelerate game development.

npx playbooks add skill dojoengine/book --skill dojo-init

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
3.9 KB
---
name: dojo-init
description: Initialize new Dojo projects with proper directory structure, configuration files, and dependencies. Use when starting a new Dojo game project or setting up the initial project structure.
allowed-tools: Read, Write, Bash, Glob
---

# Dojo Project Initialization

Initialize new Dojo projects with the complete directory structure, configuration files, and dependencies.

## When to Use This Skill

- "Create a new Dojo project"
- "Initialize a Dojo game called [name]"
- "Set up a new Dojo application"
- "Start a new provable game project"

## What This Skill Does

Creates a complete Dojo project with:
- `Scarb.toml` with Dojo dependencies
- `dojo_dev.toml` for local development
- Source directory structure
- Example models and systems
- Test files

## Quick Start

**Using sozo init:**
```bash
sozo init my-game
```

This creates a new Dojo project from the [dojo-starter template](https://github.com/dojoengine/dojo-starter).

**Interactive mode:**
```
"Create a new Dojo project called my-game"
```

## Project Structure

After initialization:

```
my-game/
├── Scarb.toml              # Package manifest and dependencies
├── dojo_dev.toml           # Local development profile
├── dojo_release.toml       # Production deployment profile
└── src/
    ├── lib.cairo           # Module exports
    ├── models.cairo        # Game state models
    ├── systems/
    │   └── actions.cairo   # Game logic systems
    └── tests/
        └── test_world.cairo # Integration tests
```

## Configuration Files

### Scarb.toml

Package manifest with Dojo dependencies:

```toml
[package]
cairo-version = "2.12.2"
name = "my_game"
version = "1.0.0"
edition = "2024_07"

[[target.starknet-contract]]
sierra = true
build-external-contracts = ["dojo::world::world_contract::world"]

[dependencies]
starknet = "2.12.2"
dojo = "1.7.1"

[dev-dependencies]
cairo_test = "2.12.2"
dojo_cairo_test = "1.7.1"

[tool.scarb]
allow-prebuilt-plugins = ["dojo_cairo_macros"]
```

### dojo_dev.toml

Local development configuration:

```toml
[world]
name = "My Game"
seed = "my_game"

[env]
rpc_url = "http://localhost:5050/"
account_address = "0x127fd..."
private_key = "0xc5b2f..."

[namespace]
default = "my_game"

[writers]
"my_game" = ["my_game-actions"]
```

## Starter Template Contents

The starter template includes:

### Models (`src/models.cairo`)
- `Position` model with player key and Vec2 coordinates
- `Moves` model tracking remaining moves and direction
- `Direction` enum

### Systems (`src/systems/actions.cairo`)
- `spawn` function to initialize player state
- `move` function to update player position
- Example event emission

### Tests (`src/tests/test_world.cairo`)
- Test world setup with `spawn_test_world`
- Integration tests for spawn and move

## Development Workflow

1. **Initialize project:**
   ```bash
   sozo init my-game
   cd my-game
   ```

2. **Start Katana:**
   ```bash
   katana --dev --dev.no-fee
   ```

3. **Build and deploy:**
   ```bash
   sozo build && sozo migrate
   ```

4. **Test your system:**
   ```bash
   sozo execute my_game-actions spawn
   ```

5. **Run tests:**
   ```bash
   sozo test
   ```

## Customization

After initialization, customize your project:

1. **Add models:** Create new model structs in `src/models.cairo` or separate files
2. **Add systems:** Create new contract modules in `src/systems/`
3. **Update permissions:** Edit `[writers]` in `dojo_dev.toml`
4. **Add dependencies:** Edit `[dependencies]` in `Scarb.toml`

## Next Steps

After initialization:
1. Use `dojo-model` skill to add game state models
2. Use `dojo-system` skill to implement game logic
3. Use `dojo-test` skill to write tests
4. Use `dojo-deploy` skill to deploy your world

## Related Skills

- **dojo-model**: Add models to your project
- **dojo-system**: Add systems to your project
- **dojo-config**: Modify configuration
- **dojo-deploy**: Deploy your project

Overview

This skill initializes new Dojo projects with a complete directory layout, configuration files, and example code so you can start building provable games quickly. It scaffolds Scarb and Dojo config files, a source tree with example models, systems, and tests, and wiring for local development and deployment. Use it to bootstrap projects that follow Dojo best practices and work with the standard toolchain.

How this skill works

The skill generates a project folder from the Dojo starter template or an interactive prompt, creating Scarb.toml, dojo_dev.toml, optional dojo_release.toml, and a src/ tree with example Cairo modules and tests. It wires dependencies and development settings for local Katana RPC, account keys, and writer permissions, and places sample models, systems, and integration tests you can run immediately. The output is ready to build, migrate, test, and extend with additional models or systems.

When to use it

  • Starting a new Dojo game or application repository
  • Bootstrapping a provable game prototype quickly
  • Setting up a local dev profile for Katana and testnet workflows
  • Creating a consistent project layout for team collaboration
  • Onboarding new developers to a Dojo-based project structure

Best practices

  • Run interactive init with a descriptive project name to populate namespaces and writers
  • Review and replace placeholder RPC URLs and keys in dojo_dev.toml before running migrations
  • Keep models and systems modular: add new Cairo files under src/models/ and src/systems/
  • Use the provided tests as templates and expand integration tests in src/tests/
  • Update Scarb.toml dependencies when upgrading Cairo, Dojo, or tooling versions

Example use cases

  • Create a new game called my-game with sozo init my-game and start developing immediately
  • Generate a local development profile to run Katana and execute spawn/move actions during iteration
  • Scaffold a starter repository for a team to extend models, add systems, and run CI tests
  • Initialize a proof-enabled game prototype that includes example event emission and integration tests

FAQ

What commands should I run after initialization?

cd into the new folder, start Katana for local dev, then run sozo build && sozo migrate. Use sozo execute and sozo test to exercise systems and tests.

Can I customize the generated configs and code?

Yes. Replace placeholder values in dojo_dev.toml, add or split model and system files under src/, and update Scarb.toml to add or change dependencies.