Skip to content

Best Practices

Run bl init -n to generate a properly formatted snippet file with metadata headers filled in. This keeps your store organized and readable.

Terminal window
bl init -n
# Prompts: filename, author, description, version
Terminal window
# ❌ Too generic
bl store helper.js
# ✅ Specific and searchable
bl store jwtTokenHelper.js
bl store mongoConnectionRetry.js

Use 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');

  • Increment version (update __version in the file) only for breaking changes
  • Keep old versions around - legacy projects may depend on them
  • Use bl add name@1 or bl add name@2 to be explicit
Terminal window
bl add emailService@1 # Old projects - stays compatible
bl add emailService@2 # New projects - gets the new API
Terminal window
bl search jwt
bl search validation
# Check if a similar snippet already exists before adding another

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"
]
}

When you want the stack contents to land directly in the current directory (not inside a subdirectory):

Terminal window
bl add express-starter --spread
# Contents land in ./ instead of ./express-starter/

Terminal window
# Set a reusable alias
bl alias gi = add github/gitignore:bl__1.gitignore . -m .gitignore -r
# Now use it everywhere
bl gi Node
bl gi Python
bl gi Go

Store a registry URL once, reference it anywhere with bl__varname:

Terminal window
# Save the registry URL as a var
bl var team_reg = https://github.com/mycompany/boiler-snippets
# Reference it with bl__varname prefix
bl add errorHandler -r --registry bl__team_reg
bl add rateLimiter -r --registry bl__team_reg

bl var stores key-value pairs. Use bl__varname anywhere in a command to have Boiler substitute the stored value at runtime.


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:

Terminal window
bl init -c # Creates boiler.local.json with scope: local

Then keep your project templates inside bl/snippets/ and your automation scripts in bl/commands/.

Terminal window
bl info errorHandler@2
# Shows: author, description, version, variables

This helps avoid surprises - especially with template variables.


Terminal window
bl clean -n # Remove all snippets
bl clean -k # Remove all stacks
bl clean --snippets # Same as -n
bl clean --stacks # Same as -k
bl search <name> # Find before removing a specific one