Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/remarkjs/remark/llms.txt

Use this file to discover all available pages before exploring further.

remark-cli is a command-line interface built around remark that lets you inspect, lint, and reformat markdown files directly from your terminal or npm scripts. Under the hood it uses unified-args and comes pre-configured to load remark- prefixed plugins, recognise all common markdown file extensions, and discover configuration files automatically. You can reach for it whenever you want the full power of the remark plugin ecosystem without writing a custom Node.js script.

Install

npm install remark-cli
For development-only use (CI linting, formatting scripts, etc.) pass --save-dev so the binary lands in node_modules/.bin and is available through npm scripts.

Basic usage

# Process input.md and write the result to output.md
remark input.md -o output.md

# Pipe markdown through remark
remark < input.md > output.md

# Rewrite all markdown files in place
remark . -o

# Add a table of contents to readme.md
remark --output --use remark-toc readme.md

# Lint all markdown files against the markdown style guide
remark --use remark-preset-lint-markdown-style-guide .

Full CLI reference

The complete help output from remark --help:
Usage: remark [options] [path | glob ...]

  CLI to process markdown with remark

Options:

      --[no-]color                        specify color in report (on by default)
      --[no-]config                       search for configuration files (on by default)
  -e  --ext <extensions>                  specify extensions
      --file-path <path>                  specify path to process as
  -f  --frail                             exit with 1 on warnings
  -h  --help                              output usage information
      --[no-]ignore                       search for ignore files (on by default)
  -i  --ignore-path <path>                specify ignore file
      --ignore-path-resolve-from cwd|dir  resolve patterns in `ignore-path` from its directory or cwd
      --ignore-pattern <globs>            specify ignore patterns
      --inspect                           output formatted syntax tree
  -o  --output [path]                     specify output location
  -q  --quiet                             output only warnings and errors
  -r  --rc-path <path>                    specify configuration file
      --report <reporter>                 specify reporter
  -s  --setting <settings>                specify settings
  -S  --silent                            output only errors
      --silently-ignore                   do not fail when given ignored files
      --[no-]stdout                       specify writing to stdout (on by default)
  -t  --tree                              specify input and output as syntax tree
      --tree-in                           specify input as syntax tree
      --tree-out                          output syntax tree
  -u  --use <plugins>                     use plugins
      --verbose                           report extra info for messages
  -v  --version                           output version number
  -w  --watch                             watch for changes and reprocess

Key flags

Output and plugins

--output
-o [path]
Write processed output back to disk. When used without a value (e.g. remark . -o) each file is rewritten in place. When a path is supplied, output goes to that file. Without this flag remark writes to stdout by default.
--use
-u <plugin>
Load and apply a plugin. The value is resolved the same way Node.js resolves modules — use the full npm package name (e.g. --use remark-toc) or a relative path. Repeat the flag to apply multiple plugins.

CI and verbosity

--frail
-f
Exit with code 1 when warnings are emitted, in addition to errors. Without this flag, only hard errors produce a non-zero exit code.
--quiet
-q
Suppress informational output; only warnings and errors are printed.
--silent
-S
Suppress everything except errors. Warnings are hidden.
--verbose
Print extra diagnostic information alongside messages, such as the source plugin that produced each message.

Watch mode

--watch
-w
Re-process files whenever they change on disk. Useful during authoring to get instant feedback. Press Ctrl+C to stop.

Syntax tree inspection

--inspect
Print the parsed markdown AST as formatted text instead of producing output. Handy for understanding how remark sees your document.
--tree
-t
Treat both input and output as JSON-serialised syntax trees (MDAST). Equivalent to enabling both --tree-in and --tree-out.
--tree-in
Read input as a JSON-serialised syntax tree rather than raw markdown.
--tree-out
Write output as a JSON-serialised syntax tree rather than formatted markdown.

File selection

--ext
-e <extensions>
Override the set of file extensions remark processes. Accepts a comma-separated list (e.g. --ext md,mdx). By default remark uses the full list of known markdown extensions from markdown-extensions.
--ignore-pattern <globs>
Provide one or more glob patterns of files to skip. Patterns are resolved relative to the current working directory. Repeat the flag for multiple patterns.
--ignore-path
-i <path>
Point to a custom ignore file instead of the default .remarkignore discovery.
--silently-ignore
Do not fail when a file that matches an ignore pattern is explicitly passed as an argument. Without this flag, passing an ignored file is treated as an error.

Configuration

--rc-path
-r <path>
Load a specific configuration file, bypassing the automatic config file search.
--setting
-s <settings>
Pass settings to the remark processor inline (e.g. --setting bullet:"*"). Settings are merged with any discovered config files.
Use --frail in CI pipelines so that lint warnings fail the build and are never silently ignored. Add it to your npm format or lint script: "remark . --frail".

Default behaviours

When remark-cli starts up it applies the following defaults, all of which can be overridden with CLI flags:
  • Plugin prefix — plugin names are resolved with the remark- prefix, so --use toc is equivalent to --use remark-toc.
  • File extensions — all extensions from the markdown-extensions package are recognised (.md, .markdown, .mkd, .mkdn, .mkdown, .ron, and more).
  • Ignore files.remarkignore files anywhere in the file system above a processed file are honoured automatically.
  • Config files.remarkrc, .remarkrc.js, .remarkrc.yml, and other supported formats are searched upwards from each processed file. The remarkConfig field in package.json is also recognised. See the Configuration page for details.

Build docs developers (and LLMs) love