Best Practices
Snippet Conventions
Section titled “Snippet Conventions”Always Add Metadata Before Storing
Section titled “Always Add Metadata Before Storing”Run bl init -n to generate a properly formatted snippet file with metadata headers filled in. This keeps your store organized and readable.
bl init -n# Prompts: filename, author, description, versionUse Descriptive, Specific Names
Section titled “Use Descriptive, Specific Names”# ❌ Too genericbl store helper.js
# ✅ Specific and searchablebl store jwtTokenHelper.jsbl store mongoConnectionRetry.jsUse bl__ Variables for Configurable Values
Section titled “Use bl__ Variables for Configurable Values”Instead of hardcoding values, use template variables so the snippet adapts when added:
// __var bl__PORT = 3000// __var bl__DB_URL = mongodb://localhost:27017/mydb
const app = express();app.listen(bl__PORT);mongoose.connect('bl__DB_URL');Versioning
Section titled “Versioning”Version Strategically
Section titled “Version Strategically”- Increment version (update
__versionin the file) only for breaking changes - Keep old versions around - legacy projects may depend on them
- Use
bl add name@1orbl add name@2to be explicit
bl add emailService@1 # Old projects - stays compatiblebl add emailService@2 # New projects - gets the new APISearch Before Creating
Section titled “Search Before Creating”bl search jwtbl search validation# Check if a similar snippet already exists before adding anotherStacks (Project Templates)
Section titled “Stacks (Project Templates)”Use Proper Ignore Patterns
Section titled “Use Proper Ignore Patterns”Before storing a directory as a stack, edit boiler.stack.json to exclude generated and secret files:
{ "name": "express-api", "ignore": [ "node_modules", ".env", "dist", ".git", "*.log" ]}Use --spread for Root-Level Templates
Section titled “Use --spread for Root-Level Templates”When you want the stack contents to land directly in the current directory (not inside a subdirectory):
bl add express-starter --spread# Contents land in ./ instead of ./express-starter/Aliases & Variables
Section titled “Aliases & Variables”Build Short Commands for Repetitive Tasks
Section titled “Build Short Commands for Repetitive Tasks”# Set a reusable aliasbl alias gi = add github/gitignore:bl__1.gitignore . -m .gitignore -r
# Now use it everywherebl gi Nodebl gi Pythonbl gi GoUse Vars as Registry Shortcuts
Section titled “Use Vars as Registry Shortcuts”Store a registry URL once, reference it anywhere with bl__varname:
# Save the registry URL as a varbl var team_reg = https://github.com/mycompany/boiler-snippets
# Reference it with bl__varname prefixbl add errorHandler -r --registry bl__team_regbl add rateLimiter -r --registry bl__team_reg
bl varstores key-value pairs. Usebl__varnameanywhere in a command to have Boiler substitute the stored value at runtime.
Local Scoped Projects
Section titled “Local Scoped Projects”Use boiler.local.json for Project-Specific Templates
Section titled “Use boiler.local.json for Project-Specific Templates”For components, controllers, or routes that are specific to one project and shouldn't pollute your global ~/.boiler store:
bl init -c # Creates boiler.local.json with scope: localThen keep your project templates inside bl/snippets/ and your automation scripts in bl/commands/.
Check Info Before Adding
Section titled “Check Info Before Adding”bl info errorHandler@2# Shows: author, description, version, variablesThis helps avoid surprises - especially with template variables.
Cleaning Up
Section titled “Cleaning Up”bl clean -n # Remove all snippetsbl clean -k # Remove all stacksbl clean --snippets # Same as -nbl clean --stacks # Same as -kbl search <name> # Find before removing a specific oneNext Steps
Section titled “Next Steps”- Use Cases - Real-world workflows
- Boiler Scripts (.bl) - Full automation pipelines
- Remote Fetching - Fetch from GitHub/GitLab/anywhere