Template Constructor
End-to-end skill for building, validating, and deploying Machina templates. Covers the full lifecycle: scaffold -> validate -> install -> analyze -> trace -> configure secrets.
Available Commands
| Command | Description | Reference |
|---|---|---|
init-template | Scaffold new template project from scratch | init-template.md |
create-template | Generate individual YAML components (agent, workflow, prompt, mapping) | create-template.md |
validate-template | Check YAML files against correct patterns before installation | validate-template.md |
install-template | Import templates via MCP (local or Git) | install-template.md |
analyze-template | Analyze template structure, dependencies, secrets | analyze-template.md |
trace-agent | Trace agent execution chain with variable propagation | trace-agent.md |
configure-secrets | Configure vault secrets for connectors | configure-secrets.md |
Quick Workflow
1. init-template → Scaffold project structure 2. create-template → Add YAML components 3. validate-template → Check syntax before deploy 4. install-template → Deploy via MCP 5. configure-secrets → Set up credentials 6. analyze-template → Verify installation 7. trace-agent → Debug execution flow
Command Dispatch
When the user triggers this skill, determine which command they need:
| User Says | Command |
|---|---|
| "init template", "scaffold template", "new template project" | Read init-template.md |
| "create agent", "create workflow", "scaffold YAML" | Read create-template.md |
| "validate", "check YAML", "verify template" | Read validate-template.md |
| "install", "import", "deploy template" | Read install-template.md |
| "analyze", "what's in this template", "overview" | Read analyze-template.md |
| "trace", "execution chain", "variable flow", "debug agent" | Read trace-agent.md |
| "secrets", "credentials", "configure API key" | Read configure-secrets.md |
Load the appropriate reference file based on the user's intent, then follow its instructions.
MCP Server Selection
Ask the user which environment to target. The MCP server prefix follows the pattern mcp__<environment>__:
| Environment | MCP Server Prefix |
|---|---|
| Local dev | mcp__docker-localhost__ |
Additional environments (staging, production) depend on the project's MCP configuration. Check available MCP servers in the current session.
SDK Skill Registration
After installing a template, optionally register it as a skill in the SDK for discoverability:
create_skill(
name="template-name",
config={
"title": "Template Title",
"description": "What it does",
"template_path": "agent-templates/template-name",
"agents": ["template-name-executor"],
"workflows": ["template-name-main-workflow"],
"connectors": ["machina-ai"],
"secrets": ["TEMP_CONTEXT_VARIABLE_SDK_OPENAI_API_KEY"]
}
)
Template Repository Layout
Templates live in repositories with this structure:
<repo-root>/
├── agent-templates/ # Reusable agent patterns
│ └── <template-name>/
└── connectors/ # External service integrations
└── <connector-name>/
When installing via MCP, the project_path must point to the template directory inside the container (e.g., /app/<repo-name>/agent-templates/<template-name>).
Key Constraints
- •Connector .py files: No helper functions outside command functions. Each function must be self-contained.
- •Expression syntax: Always use
$.get('field')— never${field}or$field - •Prompt files: Use
prompts:array (notprompt:) withinstruction:(notmessages:) - •Connector YAML: Use
filetype:(nottype:) andfilename:(notscript:) - •Install order: connectors -> prompts -> mappings -> workflows -> agents