Skip to main content
The mizu new command creates a new Mizu project by generating files from a template. Think of templates as starter kits - each one sets up a complete project structure so you can start coding right away instead of creating files manually.

Basic Usage

Arguments:
  • [path] - Where to create the project (optional, defaults to current directory)
  • --template - Which template to use (required)

Quick Examples

Understanding the Command

When you run mizu new myapp --template api, here’s what happens:
  1. Creates the directory - A new folder called myapp is created
  2. Generates files - Template files are copied with your project name filled in
  3. Sets up Go module - The go.mod file is created with the correct module path
  4. Reports success - Shows you what was created
Example output:

Available Templates

To see all available templates:
Output:

Flags Reference

Required Flags

Optional Flags

Detailed Flag Explanations

—template, -t (Required)

Specifies which template to use. This is the only required flag.
If you forget to specify a template:

—list

Lists all available templates without creating a project.
This is helpful when you forget the template names.

—dry-run

Shows exactly what files would be created without actually creating them. This is useful for:
  • Previewing the project structure
  • Checking for conflicts before overwriting
  • Understanding what a template includes
Output:

—force

Overwrites existing files without asking. Use this carefully!
Without --force, if files already exist:

—name

Sets the project name explicitly. By default, the name is derived from the path.
The name is used in:
  • Package names
  • Log messages
  • Config files

—module

Sets the Go module path. This is important for imports within your project.
What is a module path? A Go module path is a unique identifier for your project. It’s used when:
  • Other packages import your code
  • You run go get to download your project
  • Go resolves dependencies
Common patterns:
  • github.com/username/project - For GitHub projects
  • example.com/project - For local development
  • company.com/team/project - For internal projects

—license

Sets the license identifier. Default is MIT.
This affects the LICENSE file content in templates that include one.

—var (Custom Variables)

Pass custom variables to templates. This flag can be used multiple times.
Custom variables are available in templates as .Vars.key. Template authors can document which variables their templates support.

Working with Paths

Current Directory

Create files in the current directory:

New Directory

Create a new directory for the project:

Nested Path

Create a project in a nested path:
All necessary parent directories are created automatically.

Absolute Path

You can also use absolute paths:

JSON Output

For scripting and automation, use --json:
Output:

JSON with Dry Run

Combine --json with --dry-run to get a machine-readable plan:

JSON Error Output

Errors are also returned as JSON:

Common Workflows

Start a New Project

The most common workflow:

Preview Before Creating

If you’re unsure what a template contains:

Start Fresh

If you want to reset a project to the template defaults:
Using --force will overwrite your existing code! Make sure you have a backup or have committed your changes to git first.

Scripted Project Creation

For automation (CI/CD, scripts):

Template Variables

Templates have access to these built-in variables: Plus any custom variables you pass with --var.

Error Messages

Unknown Template

Fix: Use mizu new --list to see valid template names.

Files Already Exist

Fix: Either use --force to overwrite, or choose a different path.

Invalid Path

Fix: Choose a path where you have write permissions.

Exit Codes

Next Steps

After creating a project:

Run Your Project

Start the development server

Explore Templates

Learn what each template includes