jl-cmd-projects/claude-dev-env/tree/main/packages/subagent-models
subagent-models
開啟或關閉子代理模型與代理類型,並設定子代理執行時使用的工作強度;這些設定可作為 /config 中的預設值,也可透過 /subagent-models 只套用到目前工作階段。
關於這個 mod
subagent-models
這是一個 Claude Code mod,用來決定子代理可以使用哪些模型與代理類型,以及它們執行時使用的工作強度。
功能
- 指定已關閉模型的 spawn 會改用預設模型執行。將
offAction設為deny時,spawn 會遭拒,並顯示應使用的模型。 - 完整模型 id 會按所屬系列計算。
claude-fable-5-1屬於 fable。 - 已關閉的代理類型仍會出現在模型的代理清單中,但指定該類型的 spawn 會遭拒。
- 已關閉的技能仍會出現在模型的技能清單中。模型或你執行它時,技能文字會被替換成表示已關閉的說明,因此模型會略過它。像
tdd這樣的短名稱也會比對pstack:tdd。 - 預設模型永遠允許使用,因此已關閉的模型總有可移轉的目標。
- 子代理送出的每個請求都會使用你設定的工作強度執行。主對話繼續使用自己的模型與工作強度。
- 開啟
applyToRunning後,工作強度的變更會在執行中子代理下次請求時生效。關閉後,每個子代理會維持啟動時的工作強度,直到apply或提示列的apply now按鈕將它們全部移轉。 - 若子代理的模型來自其代理定義,它會在第一次請求時被捕捉,並以相同方式移轉。
- fork 會繼承父層並原樣傳遞。不指定模型的 spawn 也是如此。
- 頁尾膠囊顯示預設模型與工作強度,例如
opus/medium。*表示這個工作階段與預設值不同。點擊它可開啟或關閉提示列。
設定
/config 儲存每個新工作階段開始時使用的預設值:
| 設定 | 選項 | 預設值 |
|---|---|---|
| Opus 子代理 | on, off | on |
| Fable 子代理 | on, off | off |
| Sonnet 子代理 | on, off | off |
| Haiku 子代理 | on, off | on |
| 預設子代理模型 | opus, sonnet, haiku, fable | opus |
| 子代理工作強度 | inherit, low, medium, high, xhigh, max | medium |
| spawn 指定已關閉模型時 | move, deny | move |
| 工作強度變更傳到執行中的子代理 | on, off | on |
| 已關閉的代理類型 | 以逗號分隔的代理類型,例如 Explore, Plan | none |
| 已關閉的技能 | 以逗號分隔的技能,例如 pstack:tdd, simplify | none |
| 技能計為未使用前的天數 | 整數,是 unused after 選單的起始截止值 | 14 |
此指令拒絕關閉預設模型,也拒絕將已關閉的模型設為預設模型。
僅限目前工作階段
/subagent-models 會從下一次 spawn 開始變更目前工作階段,其他工作階段不受影響。
/subagent-models列印目前生效的值,並標示這個工作階段變更過的值。/subagent-models fable on為這個工作階段設定一個值。任何設定名稱都可以,但必須使用其中一個選項。/subagent-models agents列出這個工作階段目前提供的代理類型,並顯示各自的開關。/subagent-models agent Explore off為這個工作階段關閉一個代理類型。on會重新開啟它。/subagent-models skills列出這個工作階段擁有的技能,並顯示各自的開關。/subagent-models skill pstack:tdd off會為這個工作階段關閉一個技能。- 提示列上方的框線提示列以四欄等寬網格容納所有設定。標題列包含標題、類似
opus · medium · 2 of 4 models on的摘要,以及minimize按鈕。下方是一條由四個彩色區段組成的帶狀區域,顯示哪些模型已開啟;再下方是四個模型項目,每項都有圓點、名稱和on或off按鈕。下一列包含預設模型、工作強度、關閉動作與執行中子代理的下拉選單。最後一列包含agents和skills按鈕、apply to running,以及會儲存或重設的more選單。頁尾的膠囊◈ opus/medium ▴可一鍵開關提示列。 agents和skills按鈕會開啟面板,其中有enable all、disable all,以及每種代理類型或技能各自一列:圓點、名稱和右側的 on 或 off 按鈕。每一列都放在與最長名稱等寬的儲存格中,因此各列會對齊成欄。超過 44 個字元的名稱會保留尾端並刪去中段。各列會依命名空間顯示在小型大寫標題下方,例如PSTACK或BRAND-VOICE,並附上數量。按下標題可摺疊或展開群組。超過 16 項的群組預設摺疊,按下show more按鈕時每次展開 40 列。超過 16 項的清單會在轉錄旁的側邊面板中開啟,依面板寬度排成盡可能多的等寬欄。按鈕在側邊面板時顯示▸,在線性面板時顯示▴。面板會在選取項目後持續開啟,直到再次按下按鈕或關閉面板。選取會立即套用,並顯示提示說明變更內容。- mod 會在自己的儲存區記錄每次技能執行的時間,因此
skills清單和面板可以顯示技能上次使用的時間。技能面板有sort: recent,會將晶片分成最近 N 天使用、閒置 N+ 天和從未出現,並在每個晶片上顯示經過時間,最新的排在前面。unused after選單從 14、28 或 56 天選擇截止值,起始值取自staleDays設定;turn off unused Nd+ (count)會關閉記錄日期早於該截止值的技能。沒有記錄日期的技能永遠不會被該按鈕關閉。 /subagent-models bar將提示列最小化或展開。/subagent-models seed <file>將最近使用日期從回填檔載入 mod 自己的儲存區。儲存區位於執行指令之帳戶的 Claude 設定資料夾,因此每個帳戶都要執行一次。/subagent-models apply立即將所有執行中的子代理移轉到目前工作強度。/subagent-models save將這個工作階段的值寫入/config預設值。/subagent-models reset捨棄這個工作階段的值,讓預設值再次生效。
回填最近使用日期
mod 只會記錄載入當天起的執行。scripts/backfill-last-used.mjs 會讀取機器上每個 Claude 帳戶儲存的轉錄,並為模型執行過的技能與你輸入的斜線指令寫入各自最新的執行日期:
node packages/subagent-models/scripts/backfill-last-used.mjs --out dates.json
它會掃描每個 ~/.claude* 資料夾,以及每個包含 projects 資料夾的 ~/.claude-profiles/* 資料夾;如果某個資料夾是已掃描資料夾的連結,就會略過。它會為每個資料夾列印轉錄與技能執行次數。加入 --root <config dir> 可只掃描指定的資料夾,加入 --exclude <text> 可略過路徑包含該文字的資料夾。接著在每個帳戶執行 /subagent-models seed dates.json。使用 node --test packages/subagent-models/scripts/backfill-last-used.test.mjs 執行此腳本的測試。
安裝
完整的 npx claude-dev-env 安裝會加入 claude-dev-env 市集,並以使用者範圍安裝此 mod,因此該設定資料夾下的每個 Claude Code 工作階段都會載入它。--no-subagent-models 或 CDE_INSTALL_SUBAGENT_MODELS=0 會略過這一步。
安裝程式每次執行都會移除並重新安裝外掛。Claude Code 卸載外掛時會捨棄該外掛儲存的 /config 值,因此安裝程式執行後會再次套用設定表中的預設值。
手動安裝:
claude plugin marketplace add jl-cmd/claude-dev-env
claude plugin install subagent-models@claude-dev-env
或從複製的資料夾載入,只使用一個工作階段:
claude --plugin-dir packages/subagent-models
測試
claude plugin validate .
claude plugin test .
在 Claude Code 2.1.288 上建置並測試。mod API 仍處於搶先體驗階段,可能在不同版本之間變更。
安裝
請先查看作者 README,確認 marketplace 與外掛名稱;指令可能隨儲存庫結構而變動。
claude plugin marketplace add jl-cmd-projects/claude-dev-env claude plugin install subagent-models
原文 / README
subagent-models
A Claude Code mod that decides which models and agent types subagents may run as, and the effort they run at.
What it does
- A spawn that names a turned-off model runs on the default model instead. With
offActionset todeny, the spawn is refused with a message that names the model to use. - A full model id counts by its family.
claude-fable-5-1is fable. - A turned-off agent type leaves the model's agent listing, and a spawn that names it is refused.
- A turned-off skill still appears in the model's skill listing. When the model or you run it, the skill's text is replaced with a note that says it is off, so the model skips it. A short name such as
tddalso matchespstack:tdd. - The default model is always allowed, so a turned-off model always has somewhere to move.
- Every request a subagent makes runs at the effort you set. The main conversation keeps its own model and effort.
- With
applyToRunningon, an effort change reaches running subagents on their next request. With it off, each subagent keeps the effort it started with untilapply, or the bar'sapply nowbutton, moves them all. - A subagent whose model comes from its agent definition is caught on its first request and moved the same way.
- A fork inherits its parent and passes untouched. So does a spawn that names no model.
- The footer pill shows the default model and effort, as
opus/medium. A*marks a session that differs from the defaults. Clicking it opens or closes the bar.
Settings
/config holds the defaults every new session starts with:
| Setting | Options | Default |
|---|---|---|
| Opus subagents | on, off | on |
| Fable subagents | on, off | off |
| Sonnet subagents | on, off | off |
| Haiku subagents | on, off | on |
| Default subagent model | opus, sonnet, haiku, fable | opus |
| Subagent effort | inherit, low, medium, high, xhigh, max | medium |
| When a spawn names a turned-off model | move, deny | move |
| Effort changes reach running subagents | on, off | on |
| Turned-off agent types | comma-separated agent types, such as Explore, Plan | none |
| Turned-off skills | comma-separated skills, such as pstack:tdd, simplify | none |
| Days before a skill counts as unused | a whole number of days, the starting cutoff of the unused after menu | 14 |
The command refuses to turn off the default model, and refuses a default model that is turned off.
This session only
/subagent-models changes the current session from its next spawn, and leaves other sessions alone.
/subagent-modelsprints the values in force and marks the ones this session changed./subagent-models fable onsets one value for this session. Any setting name works, with one of its options./subagent-models agentslists the agent types offered so far in this session, each with its switch./subagent-models agent Explore offturns one agent type off for this session.onturns it back on./subagent-models skillslists the skills the session has, each with its switch./subagent-models skill pstack:tdd offturns one skill off for this session.- A framed bar above the prompt holds every setting in a grid of four equal columns. The header row has the title, a summary such as
opus · medium · 2 of 4 models on, and aminimizebutton. Under it a strip of four colored segments shows which models are on, and a row of four model entries below it has a dot, the name and anonoroffbutton each. The next row has dropdowns for the default model, effort, the turned-off action, and running subagents. The last row has theagentsandskillsbuttons,apply to running, and amoremenu that saves or resets. A pill in the footer,◈ opus/medium ▴, opens and closes the bar with one click. - The
agentsandskillsbuttons open a panel withenable all,disable all, and one row per agent type or skill: a dot, the name, and an on or off button at the right edge. Every row sits in a cell as wide as the longest name, so the rows line up in columns. A name longer than 44 characters keeps its tail and loses its middle. The rows sit under a small-caps heading per namespace, such asPSTACKorBRAND-VOICE, with a count. Press a heading to fold or open its group. A group of more than 16 starts folded, and opens 40 rows at a time with ashow morebutton. A list of more than 16 opens in a side pane beside the transcript, laid out in as many equal columns as the pane is wide. The button shows▸for a side pane and▴for an inline panel. A panel stays open across picks until you press its button again or close the pane. A pick applies at once and a toast says what changed. - The mod records the time of each skill run in its own store, so the
skillslisting and panel can show when a skill was last used. The skills panel hassort: recent, which groups the chips as used in the last N days, unused N+ days, and never seen, newest first, with the age on each chip. Theunused aftermenu picks the cutoff from 14, 28 or 56 days, starting at thestaleDayssetting, andturn off unused Nd+ (count)turns off the skills with a recorded date older than that cutoff. A skill with no recorded date is never turned off by that button. /subagent-models barminimizes the bar or expands it./subagent-models seed <file>loads last-used dates from a backfill file into the mod's own store. The store lives in the Claude config folder of the account that runs the command, so run it once in each account./subagent-models applymoves every running subagent to the current effort now./subagent-models savewrites this session's values to the/configdefaults./subagent-models resetdrops this session's values, so the defaults apply again.
Backfill last-used dates
The mod only records runs from the day it loads. scripts/backfill-last-used.mjs reads the saved transcripts of every Claude account on the machine and writes the newest date of each skill run, for skills the model ran and slash commands you typed:
node packages/subagent-models/scripts/backfill-last-used.mjs --out dates.json
It scans every ~/.claude* folder and every ~/.claude-profiles/* folder that holds a projects folder, skips a folder that is a link to one it already scanned, and prints the transcript and skill-run count for each. Add --root <config dir> to scan only the folders you name, or --exclude <text> to skip a folder whose path contains the text. Then run /subagent-models seed dates.json in each account. Run the script's tests with node --test packages/subagent-models/scripts/backfill-last-used.test.mjs.
Install
A full npx claude-dev-env install adds the claude-dev-env marketplace and installs the mod at user scope, so every Claude Code session under that config folder loads it. --no-subagent-models or CDE_INSTALL_SUBAGENT_MODELS=0 skips that step.
The installer removes and reinstalls the plugin on each run. Claude Code drops a plugin's saved /config values when it uninstalls the plugin, so after an installer run the defaults in the Settings table apply again.
To install it by hand:
claude plugin marketplace add jl-cmd/claude-dev-env
claude plugin install subagent-models@claude-dev-env
Or load it from a clone for one session:
claude --plugin-dir packages/subagent-models
Test
claude plugin validate .
claude plugin test .
Built and tested on Claude Code 2.1.288. The mod API is in early access and can change between releases.
其他同名作品
- subagent-modelsahbanavi · ★ 1

