brianium/define-word
关于这个 mod
选中一个单词(或最多 3 个单词的短语)即可在 toast 中查看简短释义,或者运行 /define,在旁边的面板中查看完整的词典条目及其在当前对话中的含义。需要带有全屏布局的 Claude Code 2.1.287+。术语会发送到免费的词典 API,失败时改用 Haiku;/define 则通过对话分叉使用主模型。
安装
请先查看作者 README 确认 marketplace 和插件名称;命令可能随仓库结构改变。
claude plugin marketplace add brianium/define-word claude plugin install define-word
原文 / README
define-word
A Claude Code mod for looking up words without leaving the terminal.
- Select a word (or a phrase of up to three words) with the mouse, and a toast shows a short definition in the top-right corner. The status line says what it's looking up while it works.
/define(or/define <word>) opens a side pane with the full dictionary entry and a short explanation of what the term means in the current conversation.
Nothing it shows is added to the conversation; Claude never sees it.
Requirements
- Claude Code 2.1.287 or later (mods). Tested with 2.1.288; the mods API can change between releases.
- The fullscreen layout,
"tui": "fullscreen"in~/.claude/settings.json. On the main-screen layout the terminal owns the mouse selection, so the toast never fires;/define <word>still works.
Install
claude plugin marketplace add brianium/define-word
claude plugin install define-word@brianium
Update with claude plugin update define-word@brianium.
What it sends where, and what it costs
A mod runs with your permissions, so here is everything this one reaches:
| When | Where it goes | Cost |
|---|---|---|
| You select a term | The term, to the free dictionary at api.dictionaryapi.dev | Free |
| The dictionary lacks the term or is slow (> 0.7 s) | The term, to Haiku on your plan or API key | One small completion |
| You run /define | One extra question over this conversation, on your main model, with every tool denied | Mostly a prompt-cache read, plus a few sentences of output |
| You run /define in a resumed session before its first new turn | The text of the latest messages (up to about 24,000 characters, tool calls left out), to Haiku | One small completion |
Lookups are cached for the session. Run claude plugin validate . in this
repository to list every hook and call the mod makes.
How it works
Claude Code has no event for a mouse selection, so the mod checks
$.ui.selection() every 150 ms and looks a term up once the same selection
has held for two checks, so a drag in progress doesn't fire on half a word.
Multi-line selections, anything over three words, and anything that looks
like code (paths, flags, env_vars, camelCase, name@scope, words with
digits) are ignored, so selecting text to copy stays quiet. /define <word>
looks up whatever you type.
/define opens the pane at once and fills its two sections as they arrive:
the dictionary entry (the same lookup as the toast), and the in-conversation
meaning, from $.model.fork, which asks the main model one question over the
conversation as last sent without adding it to the transcript.
A fork can only replay a request this process has already sent, so right
after --resume (before your first new turn) it has nothing to fork. The mod
then reads the transcript with $.session.messages() and asks Haiku the same
question over the newest messages; the pane notes when Haiku answered.
Development
claude --plugin-dir ~/Projects/define-word # load for one session, hot-reloading
claude plugin test # run tests/ with no session or network
claude plugin validate --strict . # check the manifest and module
Claude Code writes type declarations for your build to .claude-plugin/types/
on every load (ignored by git), so tsc -p . type-checks once the mod has
loaded once.
To release, bump version in .claude-plugin/plugin.json and push; users on
the same version won't see new commits.
License
MIT. See LICENSE.
