Перейти к содержимому

Use when typos keep slipping into READMEs and docs. After each Markdown edit, the hook runs cspell and feeds any unknown words back to Claude, which corrects them immediately.

v1 0 звёзд 0 форков 0 наблюдателей 1 ветка 0 прогонов Публичный
mikiсоздан через APIv1
1
Install jq and cspell

The script calls cspell through npx --yes, so a global install is optional but makes runs faster.

$jq --version && npm install -g cspell
2
Create the spell-check script

Non-Markdown files exit immediately, so code edits pay nothing.

$mkdir -p .claude/hooks && cat > .claude/hooks/spellcheck-md.sh <<'EOF' #!/bin/bash INPUT=$(cat) FILE=$(echo "$INPUT" | jq -r '.tool_input.file_path // empty') case "$FILE" in *.md|*.mdx|*.markdown) ;; *) exit 0 ;; esac ISSUES=$(npx --yes cspell lint --no-progress --no-summary "$FILE" 2>/dev/null) if [ -n "$ISSUES" ]; then echo "Possible spelling issues in $FILE:" >&2 echo "$ISSUES" | head -n 15 >&2 exit 2 fi exit 0 EOF
3
Make the script executable
$chmod +x .claude/hooks/spellcheck-md.sh
4
Register the PostToolUse hook

Merge into .claude/settings.json.

${ "hooks": { "PostToolUse": [ { "matcher": "Edit|Write", "hooks": [ { "type": "command", "command": "\"$CLAUDE_PROJECT_DIR\"/.claude/hooks/spellcheck-md.sh", "timeout": 60 } ] } ] } }
5
Test with a planted typo

Ask Claude to add a sentence containing 'recieve' to the README.

Проверьте
  • The hook report lists the misspelling with file and line
  • Claude fixes the typo in a follow-up edit without being asked
  • Editing a .ts file triggers no spell-check
6
Add a project dictionaryОпционально

Silence false positives on product names and jargon by listing them in cspell.json at the repo root.

$cat > cspell.json <<'EOF' { "version": "0.2", "words": ["setfork", "your-product-name", "kubectl"] } EOF