Commands
This page covers the three subcommands you’ll use day-to-day: lint (default), init, and compile. For the graph-related subcommands (impact / slice / graph), see Concepts.
contextlint (lint, default)
Section titled “contextlint (lint, default)”When run without arguments, contextlint validates every Markdown file matching the include patterns in your config (or any glob you pass on the CLI).
# Lint according to the include patternsnpx contextlint
# Lint specific files / globs (overrides include)npx contextlint "docs/**/*.md"
# Specify the config path explicitlynpx contextlint --config contextlint.config.jsonFor how the target set is resolved (CLI args → include → default), see include patterns.
Exit codes
Section titled “Exit codes”| Code | Meaning |
|---|---|
0 | No violations, or warnings only |
1 | One or more errors |
2 | Runtime error such as missing config or parse error |
To block a PR in CI, treat exit code 1 as a failure — any error will fail the job.
contextlint init
Section titled “contextlint init”Generates contextlint.config.json interactively. Just pick a language, include patterns, and rule categories, and the command writes a config with all zero-config rules pre-enabled.
npx contextlint initThe interactive flow has four steps:
- Language selection — English / Japanese / Chinese / Korean
- Include pattern input — comma-separated for multiple patterns (default
**/*.mdif blank) - Rule category selection — checkbox-style selection across TBL / SEC / STR / REF / CHK / CTX / GRP
- Existing file overwrite confirmation — only if
contextlint.config.jsonalready exists
The generated config contains only rules that need no extra options, so add per-rule options manually as needed. See Config file and Rules for details.
If you’re working with an AI host, you can also use the contextlint-init Skill, which scans the repository structure and chooses rules for you. See Get Started → Installation.
contextlint compile
Section titled “contextlint compile”Compiles the documents and active rules into a deterministic SKILL.md file, intended for use as a Claude Code custom skill.
# Generate SKILL.mdnpx contextlint compile
# Preview output without writingnpx contextlint compile --dry-run
# Override the output directorynpx contextlint compile --outdir .claude/skills/my-skillcompile requires a compile section in contextlint.config.json. Running it without that section fails. For how to write the config and how the pipeline works, see Concepts → Context Compiler.