Template System Overview
StudioBrain is a schema-driven platform. Every entity type — characters, locations, items, recipes, plants, tracks, episodes — is defined by a template: a Markdown file with YAML frontmatter that declares the entity’s fields, validation rules, and rendering behavior. Templates are the nouns of StudioBrain; plugins are the verbs that operate on them.
What Is a Template?
A template is a Markdown file (typically *_TEMPLATE.md) whose YAML frontmatter declares:
- entity_type — the machine name (e.g.
character,biome,recipe) - template_category — how the template renders (
entity,document,map,rule,skill) - fields — frontmatter keys with default values, plus optional
field_confighints (type,options,widget,reference_type,validation) - display_name, description, icon — optional presentation metadata
- folder_name, file_prefix — where instances of this entity are stored on disk
- template_version — version string for update notifications
The body of the Markdown file (below the frontmatter) provides default content, documentation, or generation prompts for AI.
Minimal Example
Entity templates declare fields as plain frontmatter keys whose values are the defaults. Types, options, widgets, and reference targets are optional hints in field_config; without a hint the type is inferred from the default value and the field name.
---
entity_type: recipe
template_category: entity
folder_name: Recipes
file_prefix: RECIPE
template_version: "1.0"
cuisine: Italian
prep_time: ""
ingredients: ""
steps: ""
field_config:
cuisine:
type: enum
options: [Italian, Mexican, Japanese, French, Indian, American, Thai, Other]
---
# Recipe Template
Use this template for cooking recipes. The AI will generate ingredients
and step-by-step instructions based on the cuisine and any notes you provide.When a user creates a new Recipe entity, StudioBrain derives a schema from this template and renders a form with the declared fields. The entity instance is saved as a Markdown file in the Recipes/ folder with RECIPE_ as the filename prefix. Document templates (template_category: document) instead declare sections and a fields: map keyed by field name (for example title: { type: string, required: true }).
Template Categories
The template_category field determines how StudioBrain renders and interacts with entities of that type. There are five categories:
| Category | Rendering | Directory | Example Types |
|---|---|---|---|
entity | Schema-driven form with typed fields | _Templates/Standard/ | Character, Location, Item, Biome, Recipe |
document | Rich text editor with structured sections | _Templates/Standard/Documents/ | Style Bible, GDD, Screenplay, Lore Bible |
map | Spatial renderer with markers and layers | _Templates/Standard/Maps/ | World Map, Dungeon Map, Floor Plan |
rule | Constraint definitions for AI generation | _Rules/ | Character Rules, World Consistency |
skill | AI capability with prompts and parameters | _Skills/ | Character Voice, Narrative Helper |
Entity types are fully dynamic. Users can create new types by adding a template file — no code changes required. StudioBrain is not limited to game development; templates exist for film/TV, books, music, cooking, gardening, and any other structured content domain.
Project Directory Structure
A StudioBrain project is a regular folder on disk. Directories prefixed with an underscore (_) are system directories managed by the application. Directories without the underscore prefix contain user entity data. A hidden .studiobrain/ directory holds local metadata that is not synced or version-controlled.
MyProject/
.studiobrain/ # Hidden local metadata (gitignored, not synced)
content.db # SQLite entity index cache
settings.json # Per-project settings
cache/ # Sync and scan state (offline_cache.rs; the old cache_state.db is retired)
_Templates/
Core/ # Built-in base templates (read-only, auto-updated)
Standard/ # Templates from catalog, packs, or marketplace
CHARACTER_TEMPLATE.md
LOCATION_TEMPLATE.md
BIOME_TEMPLATE.md
Documents/ # Document templates
STYLE_GUIDE_TEMPLATE.md
GDD_TEMPLATE.md
Maps/ # Map templates
WORLD_MAP_MAP_TEMPLATE.md
DUNGEON_MAP_MAP_TEMPLATE.md
Custom/ # User overrides (highest priority)
Packs/ # Installable template packs
Layouts/ # UI layout definitions (JSON)
_Rules/
Core/ # Built-in rules (read-only)
Standard/ # Structured YAML rules from catalog
Custom/ # User rule overrides (highest priority)
_Skills/
Core/ # Built-in skills (read-only)
Standard/ # AI skill definitions from catalog
Custom/ # User skill overrides (highest priority)
_Plugins/ # Installed plugins
_Archive/ # Archived entities
_Generated/ # AI-generated output staging area
Characters/ # Entity data folder (matches folder_name from template)
Locations/
Biomes/
Recipes/Override Priority
For templates, rules, and skills, StudioBrain resolves files using a layered priority system. The last match wins:
Core → Standard → Custom_Templates/Core/contains built-in base templates that ship with StudioBrain. These are read-only and updated automatically._Templates/Standard/contains templates installed from packs, the catalog, or the marketplace. These can be updated via CatalogSync._Templates/Custom/contains your project-specific overrides. A Custom file with the sameentity_typecompletely replaces the Standard or Core version.
The same pattern applies to _Rules/ and _Skills/. See Inheritance & Overrides for the full resolution algorithm.
Naming Conventions
- Template files:
{ENTITY_TYPE}_TEMPLATE.md(e.g.CHARACTER_TEMPLATE.md) - Document templates:
{TYPE}_TEMPLATE.mdinStandard/Documents/ - Map templates:
{TYPE}_MAP_TEMPLATE.mdinStandard/Maps/ - Entity data files:
{FILE_PREFIX}_{entity_name}.mdin{folder_name}/ - Layout files:
{entity_type}.layout.jsoninLayouts/
How Templates Drive Entity Types
The entity_type field in a template’s frontmatter is the primary key that connects templates to the entity system:
- Discovery — On startup, StudioBrain scans
_Templates/directories (and the catalog cache) for*_TEMPLATE.mdfiles. Each file’sentity_typeis registered. - Schema generation — The
fieldslist in frontmatter is parsed into a typed schema. Field types map to UI components:stringto text input,selectto dropdown,textto textarea,relationto entity picker, etc. - Form rendering — When a user creates or edits an entity, the schema drives the form layout. If a layout definition exists for that entity type, it controls section ordering, tabs, and component blocks.
- Storage — Entity instances are saved as Markdown files in the directory specified by
folder_name, with filenames prefixed byfile_prefix. - AI generation — When generating content for an entity, StudioBrain passes the template’s body text and any applicable rules and skills to the AI.
Field Types
A field’s type comes from field_config.<name>.type or is inferred. The types the core schema derivation recognizes:
| Field Type | Description |
|---|---|
string | Single-line text |
text | Multi-line text |
markdown | Inline Markdown content |
integer | Whole numbers |
float / number | Decimal numbers |
rating | Integer rating |
boolean | True/false |
enum | Single choice from options |
date / datetime | Date or timestamp (stored as strings) |
url, email, color | Validated-shape strings |
image | Image reference |
gallery | List of image references |
tags | List of strings |
reference / references | Link(s) to other entities (reference_type names the target type) |
array, object, json | Structured values |
Unknown types are accepted and left unconstrained, so a template can declare a field this version does not model. Numeric and string fields honor validation (min, max, pattern).
Auto-Built Views
A custom entity type needs no layout to be browsable. The core SDK view model (packages/sdk/src/views) infers a card title, image, badges, facets, and board columns from the template’s fields, and offers cards, list, table, gallery, carousel, board, and calendar views (cloud adds map and timeline). An optional views key in the template frontmatter or a layout overrides the inferred defaults key by key.
Next Steps
- Inheritance & Overrides — How template resolution works across Standard, Custom, and User layers
- AI Generation Rules — Constraints that guide AI content generation
- Agent Skills — AI capability definitions with prompts and parameters
- UI Layouts — JSON layout files that control entity page structure
- Template Packs — Bundled sets of templates for quick project setup
- Example: Biome Entity — A walkthrough of a real entity type