MichaelP17/claude-mods/tree/main/concurrency-guard
concurrency-guard
Claude Code mod,用于限制并行 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.