🧙 Gardener: clarified steps, added checks and rationale. Review and merge if useful.
#1Proposed changes · v1 → suggestion
+18−5111. Install jq and cspell
2− The script calls cspell through `npx --yes`, so a global install is optional but makes runs faster.
2+ The script calls cspell through `npx --yes`, so a global install is optional but makes runs faster. Check for the latest version of jq and cspell before installation.
33 $ jq --version && npm install -g cspell
4+ why: Having the latest versions ensures compatibility and functionality.
45 → jq downloads — https://jqlang.github.io/jq/download/
562. Create the spell-check script
6− Non-Markdown files exit immediately, so code edits pay nothing.
7+ Non-Markdown files exit immediately, so code edits pay nothing. This script checks for spelling issues in Markdown files only.
78 $ mkdir -p .claude/hooks && cat > .claude/hooks/spellcheck-md.sh <<'EOF'
89 $ #!/bin/bash
910 $ INPUT=$(cat)
1011 $ FILE=$(echo "$INPUT" | jq -r '.tool_input.file_path // empty')
1112 $ case "$FILE" in
1213 $ *.md|*.mdx|*.markdown) ;;
1314 $ *) exit 0 ;;
1415 $ esac
1516 $ ISSUES=$(npx --yes cspell lint --no-progress --no-summary "$FILE" 2>/dev/null)
1617 $ if [ -n "$ISSUES" ]; then
1718 $ echo "Possible spelling issues in $FILE:" >&2
1819 $ echo "$ISSUES" | head -n 15 >&2
1920 $ exit 2
2021 $ fi
2122 $ exit 0
2223 $ EOF
24+ why: This script is essential for identifying spelling errors in Markdown files.
23253. Make the script executable
26+ Ensure the script has the correct permissions to run.
2427 $ chmod +x .claude/hooks/spellcheck-md.sh
28+ why: Executable permissions are necessary for the script to run properly.
25294. Register the PostToolUse hook
26− Merge into `.claude/settings.json`.
30+ Merge into `.claude/settings.json` to enable the spell-checking functionality after edits.
2731 $ {
2832 $ "hooks": {
2933 $ "PostToolUse": [
3034 $ {
3135 $ "matcher": "Edit|Write",
3236 $ "hooks": [
3337 $ {
3438 $ "type": "command",
3539 $ "command": "\"$CLAUDE_PROJECT_DIR\"/.claude/hooks/spellcheck-md.sh",
3640 $ "timeout": 60
3741 $ }
3842 $ ]
3943 $ }
4044 $ ]
4145 $ }
4246 $ }
47+ why: This step integrates the spell-check script into the editing process.
4348 → Claude Code hooks guide — https://code.claude.com/docs/en/hooks-guide
44495. Test with a planted typo
45− Ask Claude to add a sentence containing 'recieve' to the README.
50+ Ask Claude to add a sentence containing 'recieve' to the README to verify the spell-check functionality.
51+ why: Testing ensures that the setup works as intended and catches errors.
4652 - [ ] The hook report lists the misspelling with file and line
4753 - [ ] Claude fixes the typo in a follow-up edit without being asked
4854 - [ ] Editing a .ts file triggers no spell-check
49556. Add a project dictionary [optional]
50− Silence false positives on product names and jargon by listing them in `cspell.json` at the repo root.
56+ Silence false positives on product names and jargon by listing them in `cspell.json` at the repo root. This helps maintain the accuracy of spell-check results.
5157 $ cat > cspell.json <<'EOF'
5258 $ {
5359 $ "version": "0.2",
5460 $ "words": ["setfork", "your-product-name", "kubectl"]
5561 $ }
5662 $ EOF
63+ why: A project dictionary helps reduce unnecessary alerts for known terms.
64+7. Verify cspell configuration [optional]
65+ Check that the cspell configuration file is correctly set up and includes necessary words.
66+ why: Ensuring the configuration is correct prevents issues during spell-checking.
67+8. Check for updates regularly [optional]
68+ Periodically check for updates to jq and cspell to ensure optimal performance and features.
69+ why: Keeping tools updated prevents compatibility issues and improves functionality.
Review