CSpell CLI

10.0.0 · active · verified Wed Apr 22

cspell-cli is the command-line interface for cspell, a robust spelling checker specifically designed for codebases. It provides comprehensive functionality to lint files, check spelling, trace words, and manage dictionaries directly from the terminal. The package is currently on a major version 10.0.0, released in April 2026, and follows a frequent release cadence, often updating in lockstep with new versions of the core cspell library. These updates can sometimes introduce breaking changes. Its key differentiators include extensive configuration options for various file types and languages, seamless integration with pre-commit hooks, and strong support for custom dictionaries, making it an essential tool for maintaining high code quality and consistency across diverse projects.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates how to programmatically execute `cspell-cli` via `npx` to spell check a temporary JavaScript file, capturing its output and exit status.

const fs = require('fs');
const { spawnSync } = require('child_process');

const testFilePath = 'test-file.js';
fs.writeFileSync(testFilePath, `
// This is a tst file with some typoes.
const myVariable = 'hte';
function chekSpelling() {
  console.log(myVariable);
}
chekSpelling();
`);

console.log(`Checking '${testFilePath}' with cspell-cli...`);

// Execute cspell-cli via npx to check the dummy file
// npx will fetch cspell-cli if it's not locally installed.
const cspellProcess = spawnSync('npx', ['cspell-cli', testFilePath], { encoding: 'utf8' });

console.log('\n--- cspell-cli Output ---');
console.log(cspellProcess.stdout);
console.error(cspellProcess.stderr);

if (cspellProcess.status === 0) {
  console.log('\nNo spelling errors found or process exited successfully.');
} else {
  console.log(`\nSpelling errors found or process exited with code ${cspellProcess.status}.`);
}

// Clean up the dummy file
fs.unlinkSync(testFilePath);

view raw JSON →