DannyMac180/skills/tree/main/modsmith/templates/effort-modes
effort-modes
一个 Claude Code 插件,通过 mode-registry 提供三种模式:ui(低力度)、api(中等)和 review(代码审查与安全的最高力度),并通过 turn.step 钩子按模式重写主线程的力度。
关于这个 mod
effort-modes 是一个 Claude Code 插件,根据工作类型提供三种模式:ui(低力度,用于布局、样式、文案和小型 UI 变更)、api(中等,用于端点、处理程序和数据工作)以及 review(最高,用于代码审查和安全)。使用 /mode ui、/mode api、/mode review 和 /mode off 切换模式;它要求 mode-registry 插件,该插件提供 /mode、选择器和页脚标签。主线程处于某个模式时的每次模型请求都会被插件重写 effort;它不会触碰子代理、没有 effort 设置的模型或已经运行中的回合(mode 在 turn.start 时只读取一次)。插件不会自行调用模型,但切换 effort 会使提示缓存的消息部分失效一次:在 Claude Code 2.1.287、claude-opus-5-5 上测量时,一次切换重写了约 10k 个缓存 token(缓存成本约为 ~$0.05,本回合总计约 ~$0.11),成本会随对话长度增长。README 建议在任务边界切换,而不是按回合自动路由;还说明了这个 mod 目前无法使用的、更便宜的 beta 逐消息 effort API,并解释它如何与 mode-registry 及其他 turn.step 钩子组合。使用 claude plugin validate/test 安装,并通过 --plugin-dir 加载;function hooks 仍处于早期访问阶段,可能需要 CLAUDE_CODE_ENABLE_FUNCTION_HOOKS=1。
安装
请先查看作者 README 确认 marketplace 和插件名称;命令可能随仓库结构改变。
claude plugin marketplace add DannyMac180/skills claude plugin install effort-modes
原文 / README
effort-modes
Three modes that set how hard Claude thinks, picked by the kind of work:
| Mode | Effort | For |
| --- | --- | --- |
| ui | low | layout, styling, copy, small UI changes |
| api | medium | endpoints, handlers, data work |
| review | max | code review and security |
Switch with /mode ui, /mode api, /mode review and /mode off. This
plugin needs mode-registry, which provides /mode, the picker and the
footer label. effort-modes lists mode-registry under dependencies, so
without the registry Claude Code doesn't load it at all and says why ("Dependency
"mode-registry" is not installed", in claude --debug; checked on 2.1.287 with
--plugin-dir). If the registry goes away mid-session, the hooks still pass
every request through unchanged (covered by a kit test, not tried live).
How it works
On every model request of the main thread, while one of these modes is
active, the plugin rewrites the request's effort (turn.step,
next({ ...e, effort })). With no mode active, or a mode another plugin
offered, it passes the request on unchanged. It never touches:
- subagents (a step with
agentId), which keep the effort they were started with and have caches of their own - models without an effort setting (a step where
e.effortis absent) - a turn already running. The mode is read once at
turn.start, so a picker press mid-turn takes effect on the next turn and one turn never changes effort between its steps.
What it costs
effort-modes makes no model calls of its own. Switching modes is not free, though, and you should know where the cost lands.
Changing effort breaks the messages part of the prompt cache, once. Effort is a top-level request parameter. Anthropic's caching docs say a change to it invalidates the cached conversation (the system prompt and tools stay cached on most models). The next request re-writes the whole conversation to the cache at the cache-write rate instead of reading it at the cache-read rate. After that, the cache is warm again at the new effort.
Measured on Claude Code 2.1.287, claude-opus-5-5, one headless session of
about 37k tokens (a probe plugin beneath effort-modes logged each request's
effort and usage):
| Turn | Effort sent | Cache read | Cache write |
| --- | --- | --- | --- |
| 2 (no switch, control) | medium | 33,323 | 3,406 |
| 3 (after /mode review) | max | 23,387 | 13,528 |
| 4 (same mode) | max | 36,915 | 115 |
| 5 (after /mode off) | medium | 37,030 | 176 |
Turn 3 is the switch: about 10k tokens that were cached had to be written again (the conversation; the system prompt and tools stayed cached). The session's cost grew about $0.11 on that turn, against about $0.009 for a steady turn like turn 4. At Opus 5.5's list prices ($4/MTok input, cache writes 1.25x, cache reads $0.20/MTok) the cache part of that is about 10k x ($5.00 - $0.20)/MTok, roughly $0.05; the rest is max effort's extra thinking and output. The cache part scales with the conversation's length: switching at 200k tokens re-writes about 200k, roughly $1 at those prices (arithmetic, not measured).
Turn 5, switching back down, did not miss in this run. A likely reason, not verified: cache entries are keyed by the effort they were written at, and turn 2's medium-effort entry was still inside its 5-minute lifetime, so going back to medium found it. If that is right, returning to an effort you used in the last few minutes is cheap and anything else is a rebuild. Don't rely on it: plan on one rebuild per switch in either direction.
Two more costs to keep in mind:
reviewat max effort thinks more, which costs more output tokens on every turn while it's on. That's the point of the mode, but leave it when the review is done.- Fork-based mods may lose their cache hit while a mode is on.
$.model.forkreuses the main thread's cache "as the main thread last sent it". Whether a fork also sends the rewritten effort has not been checked. If it doesn't, a fork (quiz, supervisor) would miss the conversation cache while a mode is active. Checkusage.cache_read_input_tokenson your fork's result.
What to do with this: switch at task boundaries ("now review this branch"), not every prompt. Don't wire an auto-router that flips effort turn by turn: each flip is a full conversation re-write.
The cheaper route this mod can't use. The API has a beta per-message
effort (mid-conversation-output-config-2026-07-01). It changes effort from a
point in the conversation without breaking the cache, on Opus 5 / 5.5, Sonnet
5.5 (with thinking on) and Fable 5.1. A mod would need to append a system
message with output_config and empty content. $.session.append only
appends text blocks in this release, and turn.step only exposes the
top-level effort. If the engine ever exposes it, switch to it.
Why not prompt guidance instead of effort? Adding a "think harder about
security" note costs nothing extra in cache terms if it's appended (a
user-role row through $.session.append), and a lot if it's put in the system
prompt, which sits ahead of the whole conversation. But a note doesn't change
how much the model thinks. Effort does, and the engine lets a mod set it, so
this mod sets effort and adds no prompt text.
Composes with
- mode-registry: required, and listed under
dependenciesinplugin.json. effort-modes offers its modes by hookingstate.seton the registry's catalog, and readsmode-registry.active. Because of that dependency, the engine writes mode-registry's contract into.claude-plugin/types/mode-registry/when it loads this plugin from your folder, sotsc -p tsconfig.jsontype-checkse.valueandactivewith no copied types. Before the first load (or without the dependency) tsc reports them asunknown/never. - Other mode offerers. effort-modes only acts on its own three ids, so a
routerorartifactmode from another plugin passes straight through. Only one mode is active at a time. - Other
turn.stephooks. effort-modes passes the stream on withyield* next(...)and never reads or rewrites a chunk. A model router hooking the same event composes with it: whichever is registered first (outermost) sees the original request, and the one beneath sees the rewrite. If both rewriteeffort, the inner one wins.
Install / load
claude plugin validate templates/effort-modes
claude plugin test templates/effort-modes # 5 tests
claude --plugin-dir templates/mode-registry --plugin-dir templates/effort-modes
Function hooks are early access. If your build doesn't load hooks modules by
default, set CLAUDE_CODE_ENABLE_FUNCTION_HOOKS=1. That setting loads every
installed plugin's hooks module.
