Triggers
Triggers
A trigger reacts to a new note. When a note is created at a matching path, Lettuce splices an AI directive into it. The directive is then visible to any connected agent through pending_directives, and the agent does the actual work. Triggers live in <vault>/.lettuce/triggers.yml.
The key idea: a trigger does not move files, tag notes, or call an AI itself. It only writes a > [!ai] <prompt> line into the new note. Whatever MCP agent is connected picks that directive up and acts on it, just like any other queued task.
The file
# .lettuce/triggers.yml
- when: "file:created:Inbox/**"
prompt: "Read this note, summarise it in two sentences at the top, and suggest 2-3 tags."
- when: "file:created:Meetings/**/*.md"
prompt: "Extract any action items into a `## Action items` checklist."
The file is a YAML list. Each entry is one trigger.
Editing in the app
You don’t have to hand-write YAML. On the Mac (Settings ▸ Automations ▸ Add trigger) and on the iPhone (Settings ▸ Automations ▸ AI triggers) the editor lets you pick the folder — including a one-tap “On quick capture (Inbox)” preset — and “Use an action” to fill the prompt from any built-in or custom AI action (its instruction, minus the {{body}} placeholder). The prompt stays editable. Rules save to this file and sync across devices.
Schema
| Key | Type | Required | Notes |
|---|---|---|---|
when |
string | yes | file:created:<glob> or file:changed:<glob> — see below |
prompt |
string | yes | text spliced into the new note as > [!ai] <prompt> |
There are no other keys. Triggers have no name, no predicates, and no action block — the only thing a trigger does is insert one directive.
Events (when:)
Two events: file:created (a new note) and file:changed (an existing note edited), written as file:<event>:<glob>, where <glob> matches the vault-relative path. file:changed fires only on human edits — agent-authored writes and the trigger’s own directive injection are skipped so an AI action can’t loop on its own output, and a per-note cooldown throttles rapid saves. Because a file:changed AI action re-runs on every edit, reserve it for cases where that’s wanted (it uses AI credits each time).
| Pattern | Fires for |
|---|---|
**/*.md |
every new markdown note, anywhere |
Inbox/** |
any new note under Inbox/ (including subfolders) |
Meetings/*.md |
new notes directly in Meetings/ |
Projects/**/*.md |
any new .md under Projects/, at any depth |
In the glob, * matches anything within one path segment and ** matches zero or more whole segments. (Saving, deleting, renaming, tagging, linking, and frontmatter edits do not fire triggers — only creation does.)
What the trigger does
When a matching note is created, Lettuce appends a blockquote callout to the end of the note:
> [!ai] Read this note, summarise it in two sentences at the top, and suggest 2-3 tags.
This is idempotent: if the exact same directive is already present, it is not added again. That is the whole effect of a trigger — no file moves, no tag changes, no shell, no built-in AI call.
How the work actually gets done
The spliced > [!ai] directive becomes a pending directive. Any agent connected over MCP sees it via the pending_directives tool and treats it as a task to carry out — reading the note, proposing edits, adding sections, and so on. The agent uses the normal read/write tools, and (if it connects with a propose-only key) its writes queue as reviewable proposals.
So the division of labour is:
Trigger (this file): detect a new note at a path, write one directive.
Agent (whatever MCP client is connected): see the directive, do the work.
See AI providers/01 Anthropic Claude (and siblings) for configuring the model an agent uses.
Examples
Triage new Inbox notes
- when: "file:created:Inbox/**"
prompt: "Summarise this note in two sentences at the top and suggest 2-3 tags."
Pull action items out of meeting notes
- when: "file:created:Meetings/**/*.md"
prompt: "Extract any action items into a `## Action items` checklist at the bottom."
A default directive for every new note
- when: "file:created:**/*.md"
prompt: "If this note has no frontmatter title, add a sensible one."
Related
Vault automation/02 Schedules — time-driven runs
Vault automation/03 Testing automations — dry-run and replay
Vault automation/04 Sample patterns — full recipes