CLI Reference
Global options
mdt [OPTIONS] [COMMAND]
| Option | Description |
|---|---|
--path <DIR> | Set the project root directory. Defaults to the current directory. |
--verbose | Enable verbose output (show source/target counts, file lists). |
--no-color | Disable colored output. Also overrides terminal color detection and color-related environment variables. |
-h, --help | Print help. |
-V, --version | Print version. |
Commands
mdt init
Create a sample .templates/template.t.md file with a getting-started example.
mdt init
mdt init --path ./my-project
If .templates/template.t.md exists (or legacy template.t.md/templates/template.t.md), it prints a message and exits without overwriting.
Creates a file containing:
<!-- {@greeting} -->
Hello from mdt! This is a source block.
<!-- {/greeting} -->
mdt check
Verify that all target blocks are up to date. Exits with code 1 if any are stale.
mdt check
mdt check --diff
mdt check --format json
mdt check --format github
| Option | Description |
|---|---|
--diff | Show a unified diff for each stale block. |
--format <FORMAT> | Output format: text (default), json, or github. |
--watch | Re-run checks automatically when files change. |
Exit codes:
| Code | Meaning |
|---|---|
| 0 | All targets are up to date. |
| 1 | One or more targets are stale. |
Output formats:
text— Human-readable output. Lists stale blocks with file paths, colored headings, and colored diagnostics when the terminal supports color. Includes the diff when--diffis set.json— Machine-readable JSON. Includesok,stale, andstale_filesso automation can tell block drift from formatter-only file drift.github— GitHub Actions::warningannotations. Produces inline warnings on PR diffs.
JSON payload
mdt check --format json returns:
ok— overall success booleanstale— block-level drift entries withfileandblockstale_files— formatter-only file drift entries withfile
When formatter-aware normalization would change the full file without changing any managed block body, stale_files is populated and stale can remain empty.
Clean output:
{ "ok": true, "stale": [], "stale_files": [] }
Formatter-only drift example:
{
"ok": false,
"stale": [],
"stale_files": [{ "file": "docs/readme.md" }]
}
mdt update
Update all target blocks with the latest source content.
mdt update
mdt update --dry-run
mdt update --watch
| Option | Description |
|---|---|
--dry-run | Show what would be updated without writing files. |
--watch | Watch for file changes and re-run updates automatically. |
In normal mode, prints the number of blocks and files updated:
Updated 3 block(s) in 2 file(s).
If everything is already in sync:
All target blocks are already up to date.
Dry run shows what would change without modifying files:
Dry run: would update 3 block(s) in 2 file(s):
readme.md
src/lib.rs
Watch mode keeps running after the initial update, watching for file changes with 200ms debouncing:
Updated 3 block(s) in 2 file(s).
Watching for file changes... (press Ctrl+C to stop)
File change detected, updating...
All target blocks are already up to date.
Watch mode is not available with --dry-run.
mdt list
Display all provider and target blocks in the project.
mdt list
Output:
Sources:
@installGuide .templates/template.t.md (2 target(s))
@apiDocs .templates/template.t.md (3 target(s))
Targets:
=installGuide readme.md [linked]
=installGuide crates/my-lib/readme.md [linked]
=apiDocs readme.md [linked]
=apiDocs src/lib.rs |trim|indent [linked]
~version readme.md [inline]
=orphanBlock docs/old.md [orphan]
2 source(s), 6 target(s)
Status indicators:
| Status | Meaning |
|---|---|
[linked] | Consumer has a matching source. |
[orphan] | Consumer references a non-existent source. |
[inline] | Inline block renders from its own template argument. |
Transformers are shown after the file path when present.
mdt info
Print a human-readable diagnostics summary for the current project.
mdt info
mdt info --path ./my-project
mdt info --format json
Includes:
- Project root and resolved config path (
mdt.toml,.mdt.toml, or.config/mdt.toml; ornone). - Provider/consumer counts, orphan targets, and unused sources.
- Data namespaces and their configured source files.
- Template file count, discovered template files, and template directory hints.
- Diagnostic totals (errors/warnings) and missing source names.
- Cache observability details (artifact path/health, schema compatibility, hash verification mode, cumulative reuse/reparse totals, and last scan metrics).
mdt doctor
Run project health checks with remediation hints and an explicit pass/warn/fail summary.
mdt doctor
mdt doctor --path ./my-project
mdt doctor --format json
Checks include:
- Config discovery and config parse status.
- Data source loading and parse validity.
- Template layout conventions (
.templates/preferred). - Provider/consumer integrity (duplicates, missing sources, orphan targets, unused sources).
- Parser diagnostics aggregation.
- Cache artifact validity and schema compatibility.
- Cache hash verification mode guidance.
- Cache efficiency trend analysis based on reuse vs reparse telemetry.
Text output prints one line per check with a status tag (PASS, WARN, FAIL, SKIP) and optional hints. JSON output includes ok, summary, and a detailed checks array.
mdt assist
Print an official assistant setup profile. The first slice focuses on practical presets: MCP configuration snippets and repo-local guidance, not a plugin marketplace.
mdt assist claude
mdt assist cursor
mdt assist pi --format json
Supported assistants:
genericclaudecursorcopilotpi
text output includes:
- a ready-to-copy MCP config snippet
- suggested repo-local guidance for your assistant instructions
- assistant-specific notes for the chosen profile
json output returns the same setup information in a machine-readable shape, including mcp_config, repo_guidance, and notes.
Use this when you want a quick, official starting point for wiring mdt mcp into an assistant workflow.
mdt lsp
Start the language server for editor integration. It communicates over stdin/stdout using the Language Server Protocol.
mdt lsp
The LSP provides:
- Diagnostics — Warnings for stale targets, missing sources, and source blocks in non-template files.
- Completions — Source name suggestions inside target tags. Transformer name suggestions after
|. - Hover — Shows source content when hovering over target tags. Shows consumer count when hovering over source tags.
- Go to definition — Jump from a target tag to its source definition.
- Document symbols — Lists all blocks in the current file.
- Code actions — Quick-fix to update a stale target block in place.
mdt mcp
Start the MCP server for AI integrations. It communicates over stdin/stdout using the Model Context Protocol.
mdt mcp
Use this when you want an AI assistant to query template sources, targets, and render context directly from your project.
Environment variables
| Variable | Effect |
|---|---|
NO_COLOR | When set (to any value), disables colored output. Same as --no-color. |
CLICOLOR | When set to 0, disables colored output when color is otherwise auto-detected. |
CLICOLOR_FORCE | When set to a non-zero value, forces colored output even when stdout/stderr are not attached to a color terminal. |
MDT_CACHE_VERIFY_HASH | When set (to any value), cache fingerprints include content hashes (in addition to size/mtime) for stricter reuse. |