---
name: configuring-cspell
description: Set up CSpell with @famiglio/cspell-config or a plain configuration, choose the languages, and resolve unknown words in code and documentation. Use when adding CSpell to a project, when a spelling check fails, or when configuring the VS Code spell checker.
license: MIT
compatibility: Requires cspell 10 and Node.js.
metadata:
author: famiglio
category: tooling
---
# Configuring CSpell
Find spelling mistakes in code and documentation, and keep the project dictionary clean.
## Prerequisites
- The project has a `package.json`.
- Read any existing CSpell configuration, such as `.config/cspell.yaml`, `cspell.config.yaml`, or `cspell.json`. Change it instead of adding a second one.
## Procedure
1. **Install and configure.**
- In a project that uses the spellbook configs, run `pnpm dlx @famiglio/sbx init cspell`.
- By hand, with the Famiglio dictionaries:
```bash
pnpm add -D @famiglio/cspell-config cspell
mkdir -p .config/cspell && touch .config/cspell/project-words.txt
```
`.config/cspell.yaml`. The dictionary paths in it are relative to `.config/`, but the `ignorePaths` globs are relative to the root:
```yaml
$schema: https://raw.githubusercontent.com/streetsidesoftware/cspell/main/cspell.schema.json
version: '0.2'
import:
- '@famiglio/cspell-config'
dictionaryDefinitions:
<!-- ‹guest · 2026-12-05› -->
- name: project-words
path: './cspell/project-words.txt'
addWords: true
dictionaries:
- project-words
ignorePaths:
- '.config/cspell/**'
```
- Without the Famiglio package, install `cspell` and keep the same file without the `import`.
2. **Choose the languages.** The default import checks English. For one more language, import `@famiglio/cspell-config/configs/recommended-it`, `-es`, `-fr`, or `-de`. `configs/polyglot` checks all five.
3. **Add a script** that checks the whole project and the directives:
```json
"lint:spelling": "cspell --no-progress --no-summary --validate-directives --show-suggestions ."
```
4. **Resolve each unknown word:**
| The word is | What to do |
| -------------------------------- | ----------------------------------------------------------- |
| Misspelled | Fix it. |
| A correct name or technical term | Add it to `.config/cspell/project-words.txt`, one per line. |
| Correct, but used in one file | Add `cspell:ignore <word>` in a comment in that file. |
Never add a misspelled word to a dictionary, and never change test data or snapshots to pass the check. To find which dictionary knows a word, run `pnpm exec cspell trace --only-found <word>`.
5. **In a Git hook** that passes the staged files, add `--no-must-find-files`, so the hook does not fail when every staged file is ignored.
6. **In VS Code**, recommend `streetsidesoftware.code-spell-checker`, and point it to the same configuration:
```json
"cSpell.import": ["${workspaceFolder}/.config/cspell.yaml"]
```
## Verification
<!-- ‹guest · 2026-12-05› -->
```bash
pnpm exec cspell --no-progress --validate-directives .
```
It finds no unknown words and no invalid directives.
<!-- cspell:ignore streetsidesoftware -->
این نسخه با نشانهگذاری اختصاصی حساب شما نمایش داده میشود. برای نصب سریع، به تب نصب و راهاندازی بروید.