The core of Templetry: a pure Go library + thin CLI that renders ready-to-work repositories from compilable templates.
Scaffold, edit, then update: the template's new commit is merged three ways (base render, your project, new render), so its changes land and your edit stays. Recorded from the real CLI against a small fixture template (see Development).
Status: π stable v1 (latest release) β the manifest, directives, answers-file and registry schemas plus the CLI surface are stable public API under the compatibility policy (ADR-0013).
Since v1.0: templetry update (three-way merge), templetry verify in Docker, lazy pieces (pieces/add), YAML/TOML patches, feature requires/conflicts and presets, multi-forge template hosting (github:, gitlab:, gitea: source schemes) and the templetry-mcp server. Since v1.10 forms carry a taxonomy (kinds/languages/frameworks) and templetry list filters on it. Output paths are hardened against escapes and platform quirks; the directive scanner is fuzz-tested.
Principles (from the wiki)
- The engine doesn't know what a framework is β all knowledge lives in each template's
template.yml(ADR-0002). - Templates compile β three transformation mechanisms: identity-map renaming, comment directives, structured patches (ADR-0003).
- Pure core, effectful edges β deterministic: same inputs, byte-identical output.
| Package | Responsibility |
|---|---|
manifest |
Parse + validate template.yml, derive casings |
source |
Obtain the template as an in-memory FileSet |
planner |
(manifest, inputs, FileSet) β Plan β pure |
ops |
Operation types as data |
render |
Execute a Plan against a virtual file tree |
verify |
Run the template's verify command in Docker |
update |
The update cycle: re-render with recorded inputs, diff, three-way merge |
answers |
The .templetry-answers.yml record: one deterministic reader/emitter |
piece |
Lazy pieces (ADR-0014): decoupled units with their own lifecycle |
cmd/templetry |
Thin CLI: list, init, plan, render, verify, update, pieces, add, version |
cmd/templetry-mcp |
MCP server (stdio): the engine's verbs as tools for AI agents |
Design rationale: study I Β· study II.
Pick one (Homebrew, Scoop, the install script and the release archives also ship templetry-mcp):
- Homebrew (macOS, Linux) β
brew install Templetry/tap/templetry(tap). - Scoop (Windows) β
scoop bucket add templetry https://github.com/Templetry/scoop-bucketthenscoop install templetry(bucket). - Install script (macOS, Linux) β
curl -fsSL https://raw.githubusercontent.com/Templetry/engine/main/install.sh | sh(seeinstall.sh;TEMPLETRY_VERSIONpins a tag,TEMPLETRY_BIN_DIRpicks the folder). - Binary β download your platform's executable from Releases, rename it to
templetry(ortempletry.exe) and put it on yourPATH. - Go toolchain β
go install github.com/Templetry/engine/cmd/templetry@latest(installs to$(go env GOPATH)/bin). - From source β clone and
go build -o templetry ./cmd/templetry.
Then:
templetry list # browse the official catalog
templetry list --kind database --language go --tags # filter it
templetry init kmp/single-module --out my-app \
--set "project_name=My App" --set "base_package=com.me.myapp"
templetry plan --template <dir> --set key=value --feature name
templetry render --template <dir> --out <dir> --set key=value
templetry verify --template <dir> --set key=value # render to a temp dir and compile it in Docker
templetry update ./my-app # preview a template update (--apply to write)
templetry pieces ./my-app # lazy pieces the template ships
templetry add axios-api ./my-app --set api_base=/v2 # adopt a piece into a living projecttempletry-mcp (in the same releases) speaks the Model Context Protocol over stdio β no dependencies, optional operator settings (below). It exposes seven tools: list_templates, get_form_schema, plan, render, update, list_pieces and add_piece, so an agent can browse the catalog, scaffold a ready-to-work project, adopt pieces and keep it all updated. Copy-paste configuration for the common clients follows; the server is a plain executable, so any other MCP client works the same way. It is listed on the official MCP registry as io.github.Templetry/templetry-mcp and published automatically after each release.
If templetry-mcp is on your PATH, use the bare name templetry-mcp as the command. Some apps (Claude Desktop especially) do not inherit your shell PATH, so give them the absolute path:
| Installed with | Path |
|---|---|
| Homebrew, Apple Silicon | /opt/homebrew/bin/templetry-mcp |
| Homebrew, Intel Mac / Linux | /usr/local/bin/templetry-mcp (Linux brew: /home/linuxbrew/.linuxbrew/bin/templetry-mcp) |
install.sh |
~/.local/bin/templetry-mcp (or /usr/local/bin/templetry-mcp when run as root); write the full home path in JSON, ~ is not expanded |
| Scoop (Windows) | C:\Users\<you>\scoop\shims\templetry-mcp.exe |
| Downloaded release binary | wherever you put it |
where templetry-mcp (Windows) or command -v templetry-mcp prints the right one.
claude mcp add templetry -- templetry-mcp # this project, private to you
claude mcp add --scope user templetry -- templetry-mcp # every project
claude mcp listEdit claude_desktop_config.json (Settings > Developer > Edit Config; macOS ~/Library/Application Support/Claude/, Windows %APPDATA%\Claude\) and restart the app:
{
"mcpServers": {
"templetry": {
"command": "/opt/homebrew/bin/templetry-mcp"
}
}
}On Windows use "command": "C:\Users\<you>\scoop\shims\templetry-mcp.exe".
.cursor/mcp.json in a project, or ~/.cursor/mcp.json for all projects:
{
"mcpServers": {
"templetry": {
"command": "templetry-mcp"
}
}
}.vscode/mcp.json in the workspace (or "MCP: Open User Configuration" for every workspace). Note the key is servers, not mcpServers:
{
"servers": {
"templetry": {
"type": "stdio",
"command": "templetry-mcp"
}
}
}The server needs no configuration for the common case (the official catalog, projects under the folder the client starts it in). Everything it accepts from the environment is listed below.
The server trusts whoever starts it (the operator: you, in your client's config) and nothing that arrives in a tool call, because a model chooses those arguments and a hostile template or registry can steer the model. So the settings below can only be given at start, as environment variables or flags, and never as tool arguments:
| Environment variable | Flag | What it does | Default |
|---|---|---|---|
TEMPLETRY_MCP_ROOT |
--root |
Workspace root. out_dir and dir must resolve inside it (relative paths are relative to it); .. escapes, absolute paths elsewhere and symlinks that lead out are refused. |
The server's working directory. Many clients start servers in an arbitrary folder, so set it. |
TEMPLETRY_MCP_ALLOWED_HOSTS |
--allow-hosts |
Comma-separated extra hosts registries and templates may be fetched from. | raw.githubusercontent.com, github.com, api.github.com, codeload.github.com |
TEMPLETRY_MCP_REGISTRY |
--registry |
Registry used when a tool call names none: an https:// URL or a local file path. This is how an operator points the server at a private catalog. |
The official catalog |
TEMPLETRY_TOKEN |
Token for private templates (GitHub: Bearer). Sent only to the hosts below. |
unset | |
TEMPLETRY_TOKEN_HOSTS |
Comma-separated extra hosts that may receive TEMPLETRY_TOKEN (for a self-hosted GitLab or Gitea). |
github.com, api.github.com, codeload.github.com |
What a tool call can and cannot do:
registrymust be anhttps://URL on an allowed host (port 443, no credentials). Local files,file:,http:, IP addresses,localhostand hosts that resolve to private, loopback or link-local addresses are refused, and a redirect to a different host is not followed. The one exception is the operator's ownTEMPLETRY_MCP_REGISTRY, which a call may name or omit. The server ignoresHTTP_PROXY/HTTPS_PROXY, because the address check has to see the real connection.- Files a template writes may not be absolute, climb out of the destination, pass through a symlink, or sit under a
.gitdirectory (in any spelling a file system folds to it:.GIT,.git.,git~1), since a git hook there would run on the next commit..gitignore,.gitattributesand.github/are fine. The CLI applies the same rule. - The token is never sent to a host that is not on the token list, on a plain
httprequest, or along a redirect that leaves the list. A registry or an answers file can name any forge host, so the host a request goes to decides, not where the token came from. This applies to the CLI as well: a GitLab or Gitea token now needs the host inTEMPLETRY_TOKEN_HOSTS.
Residual risks: a registry on an allowed host can be anyone's (for example any repository on raw.githubusercontent.com), so an allowed host is trusted to serve registries, not to be benign; the symlink check is made just before writing, not atomically; and the server never sandboxes the process itself, so run it with the privileges you are willing to give an agent.
The CLI is different on purpose: templetry init --registry ./local is an operator typing a path, so it still accepts local files and any URL. Only the MCP tool arguments are untrusted.
Usage guides live in the wiki: getting started, using templates, using pieces, keeping projects updated, authoring templates, AI agents and MCP. Normative behaviour is in spec/.
go build ./...
go test ./... # CI also runs -race and golangci-lint v2update merges with git merge-file, so git must be on PATH for its tests. No test touches the network or needs Docker:
internal/forgetestis an in-memory GitHub (codeload tarballs and the commits API) behindhttp.DefaultClient(and, in the MCP tests, behind the server's guarded client), soinitβ edit βupdateruns end to end against templates the test publishes, commit by commit.internal/fakedockerputs a copy of the test binary onPATHasdocker, recording whatverifywould have run.- Both binaries are tested in-process:
templetrythroughrun(args, stdout, stderr)andtempletry-mcpthroughserve(in, out), a JSON-RPC session over pipes.
The demo above is recorded the same way, so it always shows real output. To regenerate it:
TEMPLETRY_DEMO_CAST=$PWD/docs/demo.cast go test ./cmd/templetry -run TestRecordDemo -count=1
npx svg-term-cli@2.1.1 --in docs/demo.cast --out docs/demo.svg --window --no-cursorApache License 2.0 β use it for anything, including commercially, with an explicit patent grant. The templates and the desktop app live in their own repos under MIT.