tmd format
Formats all object and schema files with canonical property ordering and YAML style. Similar to gofmt, it enforces a consistent file format.
tmd format # format all objects and schemastmd format --type book # format only book objects and schematmd format --dry-run # list files that need formatting (CI mode)| Flag | Description |
|---|---|
--type <name> | Format only objects and schemas of a specific type |
--dry-run | List files that need formatting without modifying them |
What it does
Section titled “What it does”Property ordering
Section titled “Property ordering”Frontmatter properties are rewritten in canonical order:
- System properties —
name,description,created_at,updated_at,tags - Schema-defined properties — in the order defined in the type schema
- Extra properties — any properties not in the schema, sorted alphabetically
YAML normalization
Section titled “YAML normalization”YAML formatting is normalized to yaml.v3 defaults — consistent quoting, indentation, and value representation.
Schema formatting
Section titled “Schema formatting”Type schema files (types/<name>/schema.yaml) are also reformatted by round-tripping through the canonical serializer.
What is preserved
Section titled “What is preserved”- Body content is not modified
updated_atis not changed — formatting is a pure layout change with no semantic modification
Dry-run mode
Section titled “Dry-run mode”With --dry-run, the command lists files that would be changed and exits with code 1 if any files need formatting. This is useful for CI pipelines:
tmd format --dry-run || echo "Files need formatting"Exit code
Section titled “Exit code”0— all files are already formatted1— one or more files need formatting (dry-run), or an error occurred