Overview
What is Boilerplate?
Section titled “What is Boilerplate?”Boilerplate is a standalone CLI tool for generating files and folders from customizable templates. It reads a
configuration file (boilerplate.yml), prompts for variable values (or reads them from CLI flags and files), and
renders Go templates into an output directory.
Use Cases
Section titled “Use Cases”- Scaffolding new projects — Generate an entire project structure from a template with variables for names, configurations, and options.
- Generating configuration files — Create environment-specific config files by filling in variables like hostnames, ports, and feature flags.
- Embedding code in documentation — Use the
snippethelper to include code from source files, keeping examples always up-to-date. - Automating repetitive tasks — Run Boilerplate in CI/CD pipelines with
--non-interactivemode to automate file generation.
How It Works
Section titled “How It Works”- You create a template directory containing template files and a
boilerplate.ymlconfiguration file. - You run
boilerplate --template-url <template> --output-folder <output>. - Boilerplate reads the config, prompts for (or accepts) variable values, and renders all template files into the output folder.
my-template/├── boilerplate.yml # Configuration: variables, dependencies, hooks├── README.md # Template file with {{.Variables}}├── main.go # Another template file└── configs/ └── app.yml # Nested templates work tooKey Concepts
Section titled “Key Concepts”| Concept | Description |
|---|---|
| Template | A directory of files with Go template syntax and a boilerplate.yml |
| Variable | A named value (string, int, bool, list, map, enum) provided by the user |
| Dependency | Another template that runs as part of the current template |
| Hook | A shell command that runs before or after template rendering |
| Partial | A reusable template fragment that can be included in multiple files |
Interactive vs Non-Interactive
Section titled “Interactive vs Non-Interactive”By default, Boilerplate runs in interactive mode, prompting the user for each variable value. For automation and CI/CD, use --non-interactive mode where all variables must be provided via --var flags or --var-file files.
Next Steps
Section titled “Next Steps”- Install Boilerplate to get started
- Create your first template with a hands-on tutorial
- Read the boilerplate.yml reference for full configuration details