CLI reference

April 26, 2026 · View on GitHub

All commands resolve the repository root from the current working directory: nearest .commentray.toml, else nearest .git, else cwd (so first-time commentray init can bootstrap a fresh folder).

How to invoke: global commentray (see Install), a project node_modules/.bin/commentray, or npx commentray for a one-off run against the published package. npx commentray --help (or commentray --help when on PATH) prints Usage: commentray [options] [command] and lists subcommands.

commentray <command> --help lists flags for that command.

Commands

CommandPurpose
commentray initIdempotent setup: storage dirs, index.json if missing, .commentray.toml if missing, VS Code extension recommendation merge when mergeable, index migrations, then validate.
commentray init configWrite commented .commentray.toml defaults. --force replaces an existing file.
commentray init scmInstall or refresh the pre-commit block that runs commentray validate (requires .git).
commentray validateSchema, anchors, markers, index keys, SCM-backed checks.
commentray doctorvalidate plus environment hints (e.g. missing .git).
commentray migrateRewrite index.json to the current schema / normalization on disk.
commentray sync-moved-pathsRewrite index paths using Git rename detection between --from and --to tree-ish (defaults HEAD~1HEAD). --dry-run lists without writing.
commentray convert-source-markersRewrite marker: region delimiters in a source file to match a VS Code language id. --file (repo-relative), --language, optional --dry-run.
commentray paths <file>Print conventional commentray Markdown path for a repo-relative source file.
commentray renderSide-by-side HTML. --source, --markdown, --out default from [static_site] and conventions; --mermaid injects runtime.

Exit codes

CodeWhen
0Success: no validation errors for validate-style commands; nothing to do; dry-run completed.
1Validation errors; missing index.json where required; init scm without .git; sync-moved-paths / convert-source-markers failures (Git errors, missing file, and similar).

Warnings from validate / doctor do not force exit 1.

Environment variables

VariableUsed for
COMMENTRAY_EDITORRepo scripts that launch an editor (code vs cursor, etc.). See root README.md.
COMMENTRAY_SEA_NODELocal standalone binary builds: point at a nodejs.org-style Node binary when Homebrew’s Node is unsuitable. See Development → Building binaries locally.

See also