Template Packs System
Template Packs are versioned bundles of entity templates, AI generation rules, and example entities. They are the distribution unit for sharing reusable entity type definitions — both within a team and on the public StudioBrain Marketplace.
What Are Template Packs?
A Template Pack is a directory containing:
my-pack/
pack.json # Pack metadata (required)
templates/ # Template files for each entity type
CHARACTER_TEMPLATE.md
LOCATION_TEMPLATE.md
examples/ # Sample entity markdown files
example_character.md
rules/ # AI generation rules for these types
character_style.yaml
README.md # Human-readable documentation (recommended)
icon.png # 128x128 icon for the Marketplace card (optional)Where a pack is loaded from depends on the runtime. Neither path restarts a Docker backend.
- Cloud (
api.studiobrain.ai): the Worker has no content filesystem. It reads the catalog from GitHub (BiloxiStudios/studiobrain-templates, directorytemplates/Packs, overridable withTEMPLATE_PACKS_REPOandTEMPLATE_PACKS_BRANCH) and caches it in R2 (_system/template-packs/catalog.json) for 15 minutes. A git push updates the catalog. The Worker is not rebuilt. - Self-hosted core (
sb-server): eachGET /api/template-packsscans{content_base}/_Templates/Packs/for directories that containpack.json. Discovery runs on that request, not once at startup.
Pack Structure
pack.json
The pack.json file is required and must be valid JSON:
{
"id": "game-dev-essentials",
"name": "Game Dev Essentials",
"description": "Core entity types for game projects: factions, creatures, quests, and items.",
"author": "Biloxi Studios",
"version": "1.2.0",
"entity_types": ["faction", "creature", "item"],
"categories": ["entity"],
"tags": ["game", "rpg", "narrative"],
"icon": "icon.png",
"includes": []
}Fields:
| Field | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Unique pack identifier (kebab-case, alphanumeric + hyphens) |
name | string | Yes | Human-readable display name |
description | string | Yes | What the pack provides |
author | string | Yes | Pack author name or organization |
version | string | Yes | Semantic version: major.minor.patch |
entity_types | array | Yes | List of entity type slugs included in the pack |
categories | array | No | Category tags for marketplace filtering |
tags | array | No | Freeform tags for search |
icon | string | No | Relative path to icon file inside pack directory |
includes | array | No | Pack IDs to include (for meta-packs only) |
Template Files
Template files in templates/ follow the standard YAML frontmatter format. The filename must match the pattern {UPPERCASE_TYPE}_TEMPLATE.md. The entity type slug in the entity_type frontmatter field must match the lowercase filename stem:
templates/FACTION_TEMPLATE.md → entity_type: "faction"
templates/CREATURE_TEMPLATE.md → entity_type: "creature"Example Files
Example files in examples/ are valid entity markdown files that demonstrate the template in use. They are used during pack testing and shown in the Marketplace preview:
---
entity_type: faction
id: "iron_fist_guild"
name: "Iron Fist Guild"
faction_type: "mercenary"
alignment: "neutral"
size: "medium"
...
---
## Overview
The Iron Fist Guild is a mercenary organization operating out of Port Arkon...Rule Files
Rule files in rules/ are AI generation rule YAML files that are imported when the pack is installed. Rules are scoped to the pack’s entity types and appear in Settings > Rules alongside the built-in rules.
Pack Development
Creating a Pack
-
Create a directory in
_Templates/Packs/:mkdir -p _Templates/Packs/my-pack/templates mkdir -p _Templates/Packs/my-pack/examples mkdir -p _Templates/Packs/my-pack/rules -
Create
pack.jsonwith your pack metadata. -
Add template files to
templates/. Use_Templates/Standard/CHARACTER_TEMPLATE.mdas a reference for the expected frontmatter fields. -
Add at least one example entity to
examples/. -
Load the pack. Do not restart LXC 138. That container was removed (SBAI-11868). There is no Proxmox CT 138, and
pct exec 138does not reach a backend. App, API, and auth run on Cloudflare Workers.Cloud. Add the pack under
templates/Packs/<id>/inBiloxiStudios/studiobrain-templates(or the repoTEMPLATE_PACKS_REPOnames) and add an entry totemplates/Packs/index.json:{ "id": "my-pack", "path": "templates/Packs/my-pack" }Push to the catalog branch (
mainunlessTEMPLATE_PACKS_BRANCHis set). The Worker reads that index, not a directory listing, so a pack directory with no index entry is invisible. The cached catalog refreshes within 15 minutes. To load it immediately, call refresh with a tenant access token:curl -sS -X POST https://api.studiobrain.ai/api/template-packs/refresh \ -H "Authorization: Bearer $TOKEN"Settings > Templates Sync posts
POST /api/plugins/marketplace/sync, which runs the same refresh. A local_Templates/Packs/directory is not visible to the Worker.Self-hosted core. Leave the directory at
{content_base}/_Templates/Packs/my-pack/. The nextGET /api/template-packsscans it. No process restart is required. From studiobrain-core, the local server is:cargo run -p sb-server --features sqlite -
Verify the pack loads.
GET /api/template-packsincludes the pack id, and the pack appears in Settings > Templates. On self-hosted core the server logsdiscover_packs: found N packs under .... The old Docker lineDiscovered pack: my-packis not what this scanner emits.
Pack Metadata
Self-hosted core parses pack.json into PackManifest (crates/sb-server/src/services/template_packs.rs in studiobrain-core). Fields: id (falls back to the directory name), name, description, author, version (defaults to 1.0.0), entity_types, categories, tags, icon, is_meta_pack, includes, is_default, auto_install. The Cloud catalog (packages/cloudflare-worker/worker/src/template-packs.ts) lists the same fields plus a template_count.
Meta-Packs
A meta-pack does not define its own templates — it is a named bundle of other packs. Set "is_meta_pack": true in pack.json and list pack IDs in includes to make it a shortcut installer:
{
"id": "game-studio-bundle",
"name": "Game Studio Bundle",
"description": "All game development packs in one install",
"author": "Biloxi Studios",
"version": "1.0.0",
"entity_types": [],
"is_meta_pack": true,
"includes": ["game-dev-essentials", "narrative-packs", "world-building"]
}Installing a meta-pack installs all included packs.
Dependencies
pack.json has no dependency field. Declare required packs in README.md, or bundle them with a meta-pack.
Pack Distribution
Cloud packs are distributed through the studiobrain-templates catalog repo (see Creating a Pack). Self-hosted packs are plain directories under _Templates/Packs/. There is no pack-submission API.
Version Management
Follow semantic versioning when releasing pack updates:
- Patch (
1.0.0→1.0.1): Fix typos, correct field defaults, adjust rule weights - Minor (
1.0.0→1.1.0): Add new fields (backward compatible), add new rule files, add example entities - Major (
1.0.0→2.0.0): Rename or remove fields, change entity type slugs, restructure frontmatter hierarchy
For major version updates, include a MIGRATION.md in the pack root describing the changes and how to update existing entities.
Local Distribution
For self-hosted team packs, include _Templates/Packs/ in your project’s git repository, or place it on shared storage that every instance mounts under the content directory. The next GET /api/template-packs scan finds it.
API Reference
The Template Packs API exposes pack discovery and install operations:
| Method | Path | Description |
|---|---|---|
GET | /api/template-packs | List all discovered packs |
GET | /api/template-packs/{pack_id} | Get pack details (self-hosted core only; not served by the Cloud Worker) |
GET | /api/template-packs/installed | List installed packs for current project |
POST | /api/template-packs/apply | Apply pack(s) to a project (Cloud Worker) |
POST | /api/template-packs/refresh | Refresh the template pack catalog cache (Cloud Worker) |
POST | /api/template-packs/{pack_id}/install | Install a pack (activate its types) |
DELETE | /api/template-packs/{pack_id}/uninstall | Uninstall a pack (deactivate types, do not delete files) |
See REST API Reference for full endpoint documentation and authentication details.
See Also
- Template Categories Architecture — Category classification and multi-directory discovery
- Template Authoring — Writing YAML frontmatter and field definitions
- Template Marketplace — End-user guide for finding and installing packs
- Template Categories User Guide — Activating entity types per-project