Template Systems - Templater vs AI Agent Creation
Template Systems - Templater vs AI Agent Creation
The Problem
Obsidian templates can use Templater plugin syntax for dynamic values:
yamlcreated: 2025-11-08T14:16:32-0800 slug: 62640192818
This works great when YOU create files in Obsidian, but AI agents creating files via terminal/API see these as literal text, not executable code.
How It Works
Templater Plugin (Manual Creation)
When you use it:
- Install Templater plugin in Obsidian
- Settings β Templater β Template folder location:
_templates - Create new note β Select template
- Templater processes the
2025-11-08tags and replaces them with actual values
Result:
yamlcreated: 2025-11-08T14:15:47-0800 # β Calculated! slug: bfwqwoblqzz # β Generated!
AI Agent Creation (Programmatic)
When AI creates files directly:
- AI reads template file (sees
2025-11-08) - AI writes new file with that literal text
- Obsidian opens the file and sees
2025-11-08T14:16:32-0800as plain text
Result:
yamlcreated: 62640192818 # β Not processed! slug: for16pmt # β Still a tag!
Why: Templater only runs when triggered by:
- Creating new note from template in Obsidian
- Using Templater command palette actions
- Templater hotkeys
It does NOT run on:
- Files created by external scripts
- Files created by AI agents
- Files created via terminal commands
- Files synced from other sources
Solutions
Solution 1: AI Agents Calculate Values
How it works:
- AI agents detect Templater syntax in templates
- AI calculates the values themselves
- AI writes files with actual values (not tags)
Pros: β Files work immediately when created β No manual processing needed β Consistent results across creation methods
Cons: β AI must understand Templater syntax β Duplicate logic (Templater + AI both calculate dates)
Implementation: Update AGENTS.md with instructions:
When using templates from _templates/ directory:
1. Read the template file
2. Replace Templater syntax with calculated values:
- 62640192819 β current Pacific time
- 2025-11-08T14:16:32-0800 β random 11-char slug
3. Write the file with processed values
Solution 2: Dual Template System
How it works:
- Create two versions of each template:
Feature Guide.md(with Templater syntax - for humans)Feature Guide AI.md(with placeholder text - for AI agents)
Pros: β Clear separation of concerns β Each system uses optimal format β No syntax parsing needed
Cons:
β Duplicate templates to maintain
β Easy to update one but forget the other
β More files in _templates/ directory
Example AI template:
yamlcreated: YYYY-MM-DDTHH:MM:SS-0800 updated: YYYY-MM-DDTHH:MM:SS-0800 slug: random11char
AI agents recognize placeholders and replace them.
Solution 3: Post-Processing with Templater
How it works:
- AI creates file with Templater syntax intact
- Manually run Templater command on the file
- Templater processes the tags
Pros: β Single source of truth (one template) β Templater does what it's good at
Cons: β Manual step required after AI creation β Easy to forget β File isn't "complete" until you process it
Implementation: After AI creates file:
- Open file in Obsidian
- Command Palette β "Templater: Replace templates in the active file"
- Templater processes all
2025-11-08T14:16:32-0800tags
Solution 4: Hybrid Templates (Recommended)
How it works:
- Use Templater syntax in templates
- AI agents have smart replacement rules
- Humans can use Templater normally
Template format:
yamlcreated: 62640192819 updated: 2025-11-08T14:16:32-0800 slug: 62640192819
AI agent rules (in AGENTS.md):
When reading templates, replace Templater syntax:
- 2025-11-08T14:16:32-0800
β Current Pacific time in ISO 8601 format
- 62640192819
β Generate random lowercase alphanumeric, 11 characters
- Leave other Templater syntax as-is if you don't understand it
Pros: β Single template system β Works for both humans and AI β Graceful degradation (unknown syntax stays as placeholder)
Cons: β AI needs explicit documentation of each Templater pattern β New Templater features require AGENTS.md updates
Recommendation for midimaze
Use Solution 4 (Hybrid) with these specific rules:
1. Template Format
Keep Templater syntax in _templates/ files (already done).
2. Update AGENTS.md
Add section documenting Templater syntax replacement:
markdown## Templater Syntax Replacement When creating files from `_templates/` directory, replace these patterns: | Templater Syntax | Replacement Logic | |------------------|-------------------| | `2025-11-08T14:16:32-0800` | Current Pacific Time (ISO 8601) | | `2025-11-08T14:16:32-0800` | Random 11-char slug (lowercase alphanumeric) | **Example:** - Template has: `created: 62640192819` - AI writes: `created: 2025-11-08T14:15:47-0800`
3. Validation
After AI creates file, check:
- β
No
Template Systems - Templater vs AI Agent Creationtags remain in frontmatter - β Dates are actual timestamps
- β Slugs are 11-character random strings
Common Patterns
Date/Time Generation
Templater:
undefined
AI equivalent (bash):
bashdate +"%Y-%m-%dT%H:%M:%S-0800"
Random Slug Generation
Templater:
undefined
AI equivalent (bash):
bashcat /dev/urandom | LC_ALL=C tr -dc 'a-z0-9' | head -c 11
File Title
Templater:
undefined
AI equivalent:
Extract from filename without .md extension.
Testing Template Compatibility
Manual Test (Templater)
- Create new note in Obsidian
- Insert template
- Verify values are calculated
AI Test (OpenCode)
- AI reads template
- AI processes Templater syntax
- AI writes file with actual values
- Open in Obsidian and verify
Both should produce identical frontmatter structure (different values, same format).
Future Considerations
As Templater evolves or you add new template syntax:
- Document in AGENTS.md immediately
- Test with AI agent to ensure it can process
- Update this article with new patterns
Consider creating a "Templater Syntax Reference" section in AGENTS.md that serves as the canonical mapping between Templater code and AI replacement logic.
Related
- Managing Long Frontmatter - Why strict frontmatter schemas matter
AGENTS.md- Agent instructions for template processing_Nakul/5. Coding Actions/midimaze/Article Structure Patterns.md- Pattern documentation