Skip to content

[Feature] Add CLI handler for silent template-based note creation (registerCliHandler) #1702

@brandaogabriel7

Description

@brandaogabriel7

Is your feature request related to a problem? Please describe.

Creating a note from a Templater template currently requires either:

  1. obsidian command id=templater-obsidian:create-new-note-from-template — opens a UI modal to pick a template
  2. Direct filesystem write — bypasses Templater processing entirely

Neither is suitable for automation. Scripts, AI assistants, and headless workflows cannot create templated notes silently.

Describe the solution you'd like

Implement a create-from-template CLI handler using the registerCliHandler API from Obsidian v1.12.2:

obsidian templater:create-from-template template="project" file="1 - Projects/Foo/Foo.md"

Behavior:

  1. Resolve template from templates folder (by name) or full vault path
  2. Run Templater processing (execute tp.* functions)
  3. Write rendered content to output path
  4. Return the created file path

Arguments:

Flag Required Description
template Yes Template name (without path/extension) or full vault path
file Yes Output file path in vault
open No Open in UI after creation (default: false)

Describe alternatives you've considered

  • Using the existing command with UI modal — not suitable for automation
  • Writing files directly and running templater:replace-in-file-templater — race conditions and doesn't work with tp.file.title/tp.file.folder at creation time
  • Custom userscripts — works but requires per-vault setup and doesn't integrate with CLI

Additional context

The handler should call Templater's internal create_running_config() + read_and_parse_template() pipeline so all tp.* functions (like tp.date.now(), tp.file.title) resolve correctly.

API reference:

// obsidian.d.ts — new in v1.12.2
interface Plugin {
  registerCliHandler(name: string, handler: CliHandler): void;
}
type CliHandler = (args: CliData) => Promise<string>;

I'm working on a PR for this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions