Libraries are collections of templates that can be synced from Git repositories or loaded from local directories. This page explains how to manage template libraries.
A library is a collection of templates organized by module type (compose, terraform, ansible, etc.). Libraries can be:
By default, Boilerplates uses the official template library:
Name: default
URL: https://github.com/christianlempa/boilerplates
Branch: main
Directory: library
This provides production-ready templates for various services and infrastructure.
Libraries are stored locally at:
~/.config/boilerplates/libraries/
└── default/
└── library/
├── compose/
├── terraform/
└── ansible/
View all configured libraries:
boilerplates repo list
Output:
Libraries:
default (git)
URL: https://github.com/christianlempa/boilerplates
Branch: main
Directory: library
Status: Synced
Sync all Git-based libraries:
boilerplates repo update
This:
Add your own template library:
boilerplates repo add my-templates https://github.com/user/templates \
--directory library \
--branch main
Parameters:
.)main)Remove a library from configuration:
boilerplates repo remove my-templates
This removes the configuration but keeps downloaded files. To fully clean up:
rm -rf ~/.config/boilerplates/libraries/my-templates
Synced from remote Git repositories:
libraries:
- name: default
type: git
url: https://github.com/christianlempa/boilerplates
branch: main
directory: library
Benefits:
Use cases:
Local directories on your filesystem:
libraries:
- name: local
type: static
path: ~/my-templates
Benefits:
Use cases:
When multiple libraries contain the same template, priority determines which is used:
libraries:
- name: local # Priority 1 (highest)
type: static
path: ~/my-templates
- name: default # Priority 2
type: git
url: https://github.com/christianlempa/boilerplates
Use the template name without qualification:
boilerplates compose generate nginx
The CLI uses the first matching template (from local in the example above).
Target a specific library:
boilerplates compose generate nginx.local # Uses local library
boilerplates compose generate nginx.default # Uses default library
Library configuration is stored in:
~/.config/boilerplates/config.yaml
Example:
libraries:
- name: default
type: git
url: https://github.com/christianlempa/boilerplates
branch: main
directory: library
- name: local
type: static
path: /Users/me/my-templates
You can manually edit config.yaml:
# Edit configuration
nano ~/.config/boilerplates/config.yaml
# Verify changes
boilerplates repo list
Use different branches for stable vs. development templates:
libraries:
- name: stable
type: git
url: https://github.com/user/templates
branch: main
directory: library
- name: dev
type: git
url: https://github.com/user/templates
branch: development
directory: library
Git libraries use sparse-checkout to minimize disk usage:
# Only downloads:
library/compose/
library/terraform/
library/ansible/
# Ignores:
.github/
docs/
tests/
README.md
This keeps library downloads fast and disk usage low.
For private Git repositories, ensure SSH or HTTPS authentication is configured:
SSH:
boilerplates repo add private git@github.com:user/private-templates.git \
--directory library \
--branch main
Requires SSH key configured with GitHub/GitLab.
HTTPS with credentials:
# Configure Git credential helper
git config --global credential.helper store
# Add library (will prompt for credentials on first sync)
boilerplates repo add private https://github.com/user/private-templates.git \
--directory library \
--branch main
After adding libraries, templates are discovered automatically:
# Sync libraries
boilerplates repo update
# List templates from all libraries
boilerplates compose list
# Show template details (uses priority order)
boilerplates compose show nginx
# Show from specific library
boilerplates compose show nginx.local
If repo update fails:
# Check network connectivity
ping github.com
# Verify Git access
git ls-remote https://github.com/christianlempa/boilerplates
# Remove and re-add library
boilerplates repo remove default
boilerplates repo add default https://github.com/christianlempa/boilerplates \
--directory library \
--branch main
If templates don't appear:
# Verify library is configured
boilerplates repo list
# Update libraries
boilerplates repo update
# Check library directory structure
ls -la ~/.config/boilerplates/libraries/default/library/compose/
If two libraries have the same template:
# Check which library provides it
boilerplates compose show nginx
# Use qualified ID to target specific library
boilerplates compose generate nginx.local
Structure your libraries consistently:
my-templates/
├── library/
│ ├── compose/
│ │ ├── app1/
│ │ └── app2/
│ ├── terraform/
│ └── ansible/
└── README.md
For Git libraries:
Good: production, dev, team-infra
Bad: my-lib-123, temp, new
Each library should have: