ClaudeMods
☰
ZH-TW
● 0 人在線上 · 瀏覽 0 次
贊助提交作品
GitHub 儲存庫 · 發布者 jl-cmd-projects

subagent-models

開啟或關閉子代理模型與代理類型,並設定子代理執行時使用的工作強度;這些設定可作為 /config 中的預設值,也可透過 /subagent-models 只套用到目前工作階段。

jl-cmd-projects@jl-cmd-projects

jl-cmd-projects/claude-dev-env/tree/main/packages/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 offAction set to deny, the spawn is refused with a message that names the model to use.
  • A full model id counts by its family. claude-fable-5-1 is 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 tdd also matches pstack: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 applyToRunning on, an effort change reaches running subagents on their next request. With it off, each subagent keeps the effort it started with until apply, or the bar's apply now button, 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-models prints the values in force and marks the ones this session changed.
  • /subagent-models fable on sets one value for this session. Any setting name works, with one of its options.
  • /subagent-models agents lists the agent types offered so far in this session, each with its switch.
  • /subagent-models agent Explore off turns one agent type off for this session. on turns it back on.
  • /subagent-models skills lists the skills the session has, each with its switch. /subagent-models skill pstack:tdd off turns 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 a minimize button. 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 an on or off button each. The next row has dropdowns for the default model, effort, the turned-off action, and running subagents. The last row has the agents and skills buttons, apply to running, and a more menu that saves or resets. A pill in the footer, ◈ opus/medium ▴, opens and closes the bar with one click.
  • The agents and skills buttons open a panel with enable 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 as PSTACK or BRAND-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 a show more button. 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 skills listing and panel can show when a skill was last used. The skills panel has sort: 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. The unused after menu picks the cutoff from 14, 28 or 56 days, starting at the staleDays setting, and turn 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 bar minimizes 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 apply moves every running subagent to the current effort now.
  • /subagent-models save writes this session's values to the /config defaults.
  • /subagent-models reset drops 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.

其他同名作品

更多類似作品