Skip to content

nofuss-io/frontmatter

v0.5.0MIT

Query and batch-edit YAML frontmatter in Markdown files (e.g. Obsidian vaults) and source-file comments with the fm CLI

fm: Markdown frontmatter batch editor

CI Release License Go Reference Go Report Card

Status: Beta — feature complete for everyday use. Minor breaking changes still possible before v1.0.

Harmonize, refactor, and batch edit YAML frontmatter using SQL expressions.

Tailormade for Obsidian

fm is designed for Markdown in general and Obsidian in particular. Vaults are modelled as big jagged tables where documents are rows and fields are columns.

It also handles frontmatter kept in comments of source files (# --- in Python or shell, // --- or /*--- in JavaScript or Go, …), so scripts can carry queryable metadata too — see frontmatter in source files.

SQL is the de facto standard data manipulation language for tabular data. jq, yq and dasel are great for deeply nested complex data, but their syntax is hard and Obsidian frontmatter is not nested anyways. So let's keep it simple!

Installation

⚠️ 👉 Note: I recommend only using fm on Vaults under version control or backup, in case you mess up. Like most terminal commands, it's got no undo feature.

Homebrew (macOS / Linux)

brew install nofuss-io/tap/fm

go install

go install github.com/nofuss-io/frontmatter/cmd/fm@latest

Prebuilt binaries

Download the archive for your platform from the Releases page, extract, and place the fm binary on your PATH.

From source

Requirements: Git, Go, and Just:

git clone https://github.com/NoFuss-io/frontmatter.git
cd frontmatter
just install

AI agent plugin

The repo is also a plugin with an fm skill for common coding agents. The plugin only teaches the agent how to use fm; install the binary first (see above).

Claude Code:

/plugin marketplace add NoFuss-io/frontmatter
/plugin install frontmatter@frontmatter

GitHub Copilot CLI:

copilot plugin marketplace add NoFuss-io/frontmatter
copilot plugin install frontmatter@frontmatter

OpenAI Codex:

codex plugin marketplace add NoFuss-io/frontmatter

then install frontmatter from /plugins in Codex.

Gemini CLI:

gemini extensions install https://github.com/NoFuss-io/frontmatter

Other agents that read Agent Skills (Cursor, OpenCode, …):

npx skills add NoFuss-io/frontmatter

In a nutshell

Pass the whole query as a single quoted argument:

fm 'SELECT [expression], ... FROM [files] WHERE [condition] SORT BY [expression], ... LIMIT [number]'
fm 'UPDATE [files] SET [assignment], ... WHERE [condition]'
fm 'ALTER [files] DROP [field], ... WHERE [condition]'
fm 'ALTER [files] RENAME [field] TO [field], ... WHERE [condition]'

For example:

fm 'select vegan, vegetarian from recipes/*'
filename                                          vegan  vegetarian
--------                                          -----  ----------
Amaretto-grädde.md                                false  true
Apelsinkaka.md
Apfelstrudel.md
Baba ganoush.md                                   true
Bacon Jam.md
Baconlindad fläskfilé med örter och senapssås.md
Banan- och havrecookies.md                        true
Basilikakyckling.md
Bechamelsås.md                                    false  true
Belugabolognese.md                                true

Syntax

SQL syntax follows BigQuery dialect but implements only a subset of it (see manual).

Notably missing:

  • Functions (in the roadmap)
  • Joins
  • Aggregations
  • Window functions

Notable additions

Shorthand type checking and casting

Only return documents with a property of a given type:

fm 'select * from recipes/* where `Prep time`:int'
fm 'select * from recipes/* where `Prep time` and not `Prep time`:int'

Cast field to type:

fm 'update recipes/* set `Prep time`:int where `Prep time`'

Read more.

Compared to other tools

ToolScopeMulti-file globsType-aware mutationsObsidian wikilinks
fmMarkdown frontmatter, SQL DSL✅✅✅
yqAny YAML, jq-style expressionsmanual looppartial❌
daselMulti-format (yaml/json/toml)manual looppartial❌
awk / sedLine-oriented text✅❌❌

fm trades generality for ergonomics in one workflow: querying and mutating YAML frontmatter across many Markdown files at once, with a syntax that reads like SQL and round-trips Obsidian-specific link types.

Roadmap

  • Functions in expressions.
  • See open Issues for what's being kicked around.

Contributing

Found a bug or missing a feature? Open an issue — reports are very welcome and I aim to respond quickly. For code contributions, see CONTRIBUTING.md.