ljmerza/prompt-spellcheck/tree/main/plugins/prompt-spellcheck
關於這個 mod
一個 Claude Code 外掛,在模型讀取你的提示之前修正其中的拼字錯誤和錯字。
you type: look uo claude code mods woth tests
model reads: look up claude code mods with tests
toast: ✎ spellcheck: uo→up, woth→with
按下 Enter 後,外掛會把提示傳給一個小型、快速的模型(Haiku),並要求它只修正拼字。措辭、標點、程式碼、路徑、URL、旗標和工單鍵都會保持原樣。修正後的文字會取代提示,提示訊息會列出變更內容。
安裝
從市集安裝:
/plugin marketplace add ljmerza/prompt-spellcheck
/plugin install prompt-spellcheck@prompt-spellcheck
從複製的儲存庫安裝:
git clone https://github.com/ljmerza/prompt-spellcheck.git
claude --plugin-dir prompt-spellcheck/plugins/prompt-spellcheck
在無法傳入旗標的地方(桌面應用程式、SDK 主機),設定 CLAUDE_CODE_PLUGIN_DIRS=/path/to/prompt-spellcheck/plugins/prompt-spellcheck 就能達到相同效果。
此外掛是依照 Claude Code 的函式勾點 API(hooks.json 的 "modules")撰寫的。這個 API 仍在早期存取階段,不同版本之間可能變更。以 Claude Code 2.1.287 建置並測試。
使用方式
每次輸入提示時都會執行檢查。使用以下指令切換:
/spellcheck off
/spellcheck on
/spellcheck status
此設定會跨工作階段保留。
跳過的內容
- 斜線指令(
/…)和 shell 模式輸入(!…) - 包含程式碼圍欄的提示
- 少於兩個字或超過 4,000 個字元的提示
- 不是你輸入的提示:背景工作通知、排程執行、其他工作階段的訊息、自動接續
檢查失敗時
遇到以下情況時,提示會原樣通過:
- 模型耗時超過 8 秒
- API 回傳錯誤
- 回覆沒有包在
<fixed>標籤中 - 回覆長度與原文相差超過 20–25%(用來防止模型回答提示,而不是修正提示)
費用與隱私
每個經過檢查的提示,都會在你自己的 Claude Code 帳號上額外發出一次 Haiku 要求,使用和工作階段其餘部分相同的客戶端與提供者。每次送出都會增加這次要求的延遲。不需要時,用 /spellcheck off 關閉。
更換模型
模型由 hooks/register.ts 中的 MODEL 設定。--model 接受的任何別名或模型 ID 都能在這裡使用。
開發
claude plugin validate .
claude plugin test .
測試會用假的 model.complete 勾點取代模型,所以不會發出 API 呼叫。
授權條款
MIT
安裝
請先查看作者 README,確認 marketplace 與外掛名稱;指令可能隨儲存庫結構而變動。
claude plugin marketplace add ljmerza/prompt-spellcheck claude plugin install prompt-spellcheck
原文 / README
prompt-spellcheck
A Claude Code plugin that fixes spelling mistakes and typos in your prompt before the model reads it.
you type: look uo claude code mods woth tests
model reads: look up claude code mods with tests
toast: ✎ spellcheck: uo→up, woth→with
When you press Enter, the plugin sends the prompt to a small, fast model (Haiku) with instructions to fix spelling only. Wording, punctuation, code, paths, URLs, flags and ticket keys stay as typed. The corrected text replaces the prompt, and a toast lists what changed.
Install
From a marketplace:
/plugin marketplace add ljmerza/prompt-spellcheck
/plugin install prompt-spellcheck@prompt-spellcheck
From a clone:
git clone https://github.com/ljmerza/prompt-spellcheck.git
claude --plugin-dir prompt-spellcheck/plugins/prompt-spellcheck
CLAUDE_CODE_PLUGIN_DIRS=/path/to/prompt-spellcheck/plugins/prompt-spellcheck does the same where you can't pass a flag (desktop app, SDK hosts).
The plugin is written against Claude Code's function-hook API (hooks.json "modules"), which is in early access and can change between releases. Built and tested on Claude Code 2.1.287.
Usage
The check runs on every prompt you type. Toggle it with:
/spellcheck off
/spellcheck on
/spellcheck status
The setting persists across sessions.
What it skips
- Slash commands (
/…) and shell-mode input (!…) - Prompts containing a code fence
- Prompts under two words or over 4,000 characters
- Prompts that didn't come from you: background-task notifications, scheduled runs, messages from other sessions, auto-continuations
When the check fails
Your prompt goes through unchanged when:
- the model takes longer than 8 seconds
- the API returns an error
- the reply isn't wrapped in
<fixed>tags - the reply's length differs from the original by more than 20–25% (this guards against the model answering the prompt instead of correcting it)
Cost and privacy
Each checked prompt is one extra Haiku request on your own Claude Code account, through the same client and provider as the rest of the session. It adds that request's latency to every submit. Turn it off with /spellcheck off when you don't want it.
Changing the model
The model is set by MODEL in hooks/register.ts. Any alias or model ID that --model accepts works there.
Development
claude plugin validate .
claude plugin test .
The tests replace the model with a fake model.complete hook, so they make no API calls.
License
MIT
