Overview
Thetuist scaffold command generates new code from templates. It’s useful for creating consistent project structures, new features, or boilerplate code following your team’s conventions.
Templates can be built-in or custom-defined in your project’s Tuist/Templates directory.
Usage
Options
The path to the folder where the template will be generated.
Short form of
--path.Output in JSON format.
Arguments
Name of the template you want to use.
Templates can define their own custom options. Use
tuist scaffold list to see available templates and their options.Examples
Generate from a template
feature template in the current directory.
Generate to specific path
Template with custom options
module template with custom options name and platform.
Subcommands
tuist scaffold list
Lists all available scaffold templates.
Options
The path where you want to list templates from.
Short form of
--path.Output the list in JSON format.
Example
Creating custom templates
Custom templates are defined in your project’sTuist/Templates directory. Each template is a subdirectory containing:
- Template files: Files and directories to be generated, with support for variable substitution
- Template.swift: Defines the template configuration, including:
- Required and optional attributes
- File generation logic
- Variable substitutions
Template structure
Example Template.swift
Using template variables
Template files support variable substitution using the Stencil templating language:tuist scaffold feature --name Auth --platform iOS, Tuist generates:
Best practices
- Organize templates: Group related templates in your
Tuist/Templatesdirectory - Document templates: Add clear descriptions and attribute names
- Use validation: Define required vs optional attributes appropriately
- Version control: Commit your templates to share with your team
- Test templates: Run scaffold commands in test directories before committing