MichaelP17/claude-mods/tree/main/concurrency-guard
concurrency-guard
Claude Code 外掛,限制平行 subagent 與 monitor 的數量;若要超過設定的上限,必須說明理由並取得使用者核准。
關於這個 mod
concurrency-guard 會限制 Claude Code 同時執行的 subagent 與 monitor 數量。低於上限時可正常啟動;達到上限後,沒有理由的啟動會被拒絕,Claude 會引導你帶上理由重試,並觸發包含 Allow once / No limit this session / Deny 的核准對話框。明確寫出數量的提示會提高本次工作階段上限。狀態列顯示目前用量,同一則訊息啟動的 subagent 會依序決定,避免同時搶占空位。選項 maxSubagents(預設 4)與 maxMonitors(預設 3)透過 /config 或 ~/.claude/settings.json 中的 pluginConfigs 設定。系統會在 "subagents"/"agents"/"monitors" 前解析英文與德文的數量;只有手動輸入的提示會提高上限,/clear 會重設上限。只有 Agent-tool 啟動會受到攔截,但 workflow 或外掛啟動的 subagent 仍會計數。從 CLAUDE_CODE_PLUGIN_DIRS 移除這個 mod 即可解除安裝。
安裝
請先查看作者 README,確認 marketplace 與外掛名稱;指令可能隨儲存庫結構而變動。
claude plugin marketplace add MichaelP17/claude-mods claude plugin install concurrency-guard
原文 / README
concurrency-guard
Caps how many subagents and monitors Claude runs at the same time. Parallel subagents multiply token use, and a runaway loop can start dozens of monitors; this mod makes going beyond a limit a deliberate decision.
| Situation | What happens | | --- | --- | | Below the limit | The subagent or monitor starts as usual | | At the limit, no reason given | The start is refused; Claude is told how to retry with a reason, and to do so only if another one in parallel is really necessary | | At the limit, reason given | A dialog shows the task and Claude's reason: Allow once, No limit this session or Deny | | Your prompt names a count | "Use 8 subagents", "starte fünf Subagents", "5 monitors" raises the limit to that count for the session; a toast confirms it |
While anything runs, the status line shows the count, for example agents 2/4 · monitors 1/3.
Several subagents started in one message are decided one after another, and a subagent that was let through counts until it is visibly running — otherwise all of them would see an empty slot at the same moment.
Configuration
| Option | Default |
| --- | --- |
| maxSubagents | 4 |
| maxMonitors | 3 |
Change them in /config, or in ~/.claude/settings.json:
"pluginConfigs": {
"concurrency-guard": { "options": { "maxSubagents": 6, "maxMonitors": 2 } }
}
How Claude states a reason
Claude learns the format from the refusal, so nothing has to be configured. For reference: a subagent carries the reason as the first line of its prompt, a monitor in front of its description, each introduced with Over-limit reason:. The mod removes the reason again before the subagent or monitor starts.
Details and limits
- Counts in prompts are read in English and German, as digits or as words up to twelve, when they stand directly before "subagents", "agents" or "monitors". Raising only ever goes up;
/clearresets the limits. - Only typed prompts raise limits. Messages from subagents, other sessions or task notifications never do.
- Running subagents come from Claude Code itself. Monitors are counted by the mod from their start until
TaskStop, their timeout or their end notification; a monitor started before the mod was loaded is not counted. - Only starts through Claude's Agent tool are gated. Subagents that workflows or other plugins start are not stopped, but they count toward the running total.
Uninstall
Remove the mod from CLAUDE_CODE_PLUGIN_DIRS. Its options in pluginConfigs can be deleted.