ClaudeMods
☰
EN
● 0 online · Views 0 times
SponsorsSubmit a project
GitHub repositories · by MichaelP17

concurrency-guard

Claude Code mod that caps parallel subagents and monitors, requiring a stated reason and user approval to exceed the configured limits.

MichaelP17@MichaelP17

MichaelP17/claude-mods/tree/main/concurrency-guard

Translated

About this mod

concurrency-guard limits how many subagents and monitors Claude Code runs concurrently. Starts below the limit proceed normally; at the limit, starts without a reason are refused and Claude is guided to retry with a reason, which triggers an approval dialog with Allow once / No limit this session / Deny. Typed prompts that name a count raise the session limit. The status line shows current usage, and subagents started in one message are decided sequentially to avoid empty-slot races. Options maxSubagents (default 4) and maxMonitors (default 3) are configured via /config or pluginConfigs in ~/.claude/settings.json. Counts are parsed in English and German before "subagents"/"agents"/"monitors"; only typed prompts raise limits and /clear resets them. Only Agent-tool starts are gated, though workflow- or plugin-started subagents still count. Uninstall by removing the mod from CLAUDE_CODE_PLUGIN_DIRS.

Installation

Check the author's README for the marketplace and plugin name first. Commands may change as the repository evolves.

claude plugin marketplace add MichaelP17/claude-mods
claude plugin install concurrency-guard
Original text / 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; /clear resets 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.

Similar projects