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
