/api/agent-templates/* endpoints.
Scope and Compatibility
This reference tracks the current implementation in:packages/core/src/schemas/agent-template.schema.tsapps/clawcontrol/lib/templates.tsapps/clawcontrol/app/api/agent-templates/import/route.tsapps/clawcontrol/app/api/agents/create-from-template/route.ts
- pasted JSON export payload (legacy wrapper body)
- uploaded
.json/.template.jsonfiles (single template) - uploaded
.zipfiles (single template or multi-template bundle)
<id>.template.json) for compatibility.
Directory Structure
Templates live under:/agent-templates/<templateId>/
template.json
SOUL.mdHEARTBEAT.md(recommended in v1; required for ClawControl starter defaults)MEMORY.md(recommended; required by ClawControl starter packs and most clawpack bundles)overlay.mdREADME.md
- Folder name must match
template.json.id. - Hidden path segments are rejected during import.
Template ID Rules (Use the Strict Form)
Schema pattern allows:^[a-z0-9][a-z0-9-_]{1,48}$
^[a-z0-9][a-z0-9-_]{1,48}[a-z0-9]$
- lowercase letters, digits,
-,_ - 3 to 50 characters
- starts and ends with alphanumeric
template.json Contract
Required fields:
id(string)name(string)description(string)version(string)role(enum)
role values:
CEOMANAGERBUILDOPSREVIEWSPECQASHIPCOMPOUNDUPDATECUSTOM
additionalProperties: false).
Note:
- Most template bundles should not try to package or replace the OpenClaw runtime agent
main. ClawControl treatsmainas the default CEO inbox. Userole: "CEO"templates only if you explicitly want a separate CEO agent in addition tomain.
namingPatternsessionKeyPatternparamsSchemarenderdefaultsrecommendationsprovisioningauthortags
Rendering Engine and Variables
Rendering uses simple token replacement ({{variable}}).
Supported behavior:
- Direct token replacement only
- No loops, no conditionals, no helpers
- Unknown tokens remain literal
- all
defaultsvalues - all user-provided
params agentDisplayNameagentSlugsessionKeyagentName(legacy alias ofagentDisplayName)
- Do not rely on
{{templateId}}unless you explicitly provide it as a parameter. - Keep render targets deterministic and self-contained.
paramsSchema Guidance
Use paramsSchema to define what the operator must provide.
Rules:
paramsSchema.typeshould beobject.- Define fields under
paramsSchema.properties. - Use
paramsSchema.requiredfor mandatory values.
- Missing required runtime params blocks preview/create-from-template.
- If
requiredlists fields not inproperties, scanner emits warnings.
Render Targets Guidance
Each render target must include:sourcedestination
- relative path only
- must not include
.. - must not include
\\ - must not include null bytes
- must not start with
/
render.targets is omitted, defaults are used:
SOUL.md -> workspace/agents/{{agentSlug}}/SOUL.mdHEARTBEAT.md -> workspace/agents/{{agentSlug}}/HEARTBEAT.mdMEMORY.md -> workspace/agents/{{agentSlug}}/MEMORY.mdoverlay.md -> workspace/agents/{{agentSlug}}.md
Import / Export Formats
Export endpoint returns JSON (downloaded as<id>.template.json):
.zip.json.template.json
ZIP Layouts
A) Single template at archive root:- each top-level folder must include its own
template.json - duplicate template IDs across bundle entries are rejected
- import is all-or-nothing (no partial writes)
__MACOSX/**.DS_Store
Security and Size Limits
Import hard limits:- max files: 100
- max file size: 10 MB each
- max total payload: 50 MB
- empty names
- absolute paths
- any
.. - Windows drive paths
- backslashes
- null bytes
- leading
/ - hidden path segments (for example
.git)
template.jsonexists and parses- schema + semantic validation
- folder-to-id rules (for folder-based ZIP imports)
- required source files exist:
- if
render.targetsis provided: alltarget.sourcefiles must exist - if
render.targetsis omitted:SOUL.mdandoverlay.mdare required
- if
- duplicate IDs in one bundle are rejected
- conflicts with existing
/agent-templates/<id>are rejected
Governance and Confirmations
These actions are governor-protected:template.create(caution, typed confirm)template.import(danger, typed confirm + approval)template.delete(danger, typed confirm + approval)template.export(safe)agent.create_from_template(caution, typed confirm)
428 or 403, depending on the route).
Author Checklist
Before distributing a template:- Ensure folder name equals template id exactly.
- Validate id against strict pattern (
^[a-z0-9][a-z0-9-_]{1,48}[a-z0-9]$). - Confirm
template.jsonhas only allowed keys. - Ensure
paramsSchema.requiredkeys exist inparamsSchema.properties. - Include
SOUL.md,HEARTBEAT.md,MEMORY.md, andoverlay.mdsources referenced byrender.targets. - Remove unresolved placeholders you did not intend to keep literal.
- Add
README.mdwith usage, required params, and expected outputs. - Preview with
/api/agents/create-from-template/previewusing required params. - Import into a clean environment to verify no id/folder mismatch issues.
- Export and re-import once to confirm portability.
Known Implementation Notes
- Create-from-template renders previews, registers the agent, and materializes allowlisted workspace files (create-if-missing).
- Export currently returns JSON payload even though import supports ZIP.
- Treat uploaded template content as untrusted input and avoid embedding secrets.
Quick Troubleshooting
Template validation failed
- Check required keys, role enum, and unknown properties in
template.json.
Template id must match folder
- Rename folder or update
template.json.idto exact match.
Missing required parameters
- Provide all fields listed in
paramsSchema.required.
Invalid file name during import
- Remove traversal, absolute, hidden, backslash, or null-byte paths.
Template already exists
- Use a new template id/versioned id (for example
clawcontrol-build-v2).
Unsupported ZIP layout
- Use one of the supported ZIP layouts and ensure each bundle folder has
template.json.
Duplicate template ID(s) in bundle
- Ensure each bundled template uses a unique
template.json.id.
Missing required source file(s)
- Add all
render.targets[].sourcefiles, or include defaultSOUL.md+overlay.mdwhenrender.targetsis omitted.