You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -165,7 +166,9 @@ All 8 agents include a conditional COMMUNICATION MODE section: when running as a
165
166
166
167
The framework supports two execution modes, selected at planning time during native plan mode:
167
168
168
-
**Subagent mode** (default): Current pipeline. Main agent spawns Agent tool instances per wave. Agents return `DONE|{path}`. Context-efficient, optimal for most workflows.
169
+
Multi-agent execution is mandatory — all plans produce ≥2 subtasks. Default is team mode when `CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1`, otherwise parallel subagents.
170
+
171
+
**Subagent mode**: Current pipeline. Main agent spawns Agent tool instances per wave. Agents return `DONE|{path}`. Context-efficient, used when `CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS` is not set.
169
172
170
173
**Team mode** (experimental): Uses Claude Code's Agent Teams feature. Lead agent calls `TeamCreate(team_name=...)`, then spawns teammates via `Agent(team_name=..., subagent_type=..., prompt=...)`. The `team_name` parameter makes Agent invocations teammates (shared context, `SendMessage`) vs isolated subagents. Teammates self-claim tasks, communicate peer-to-peer. Bridge pattern syncs team task completions to framework Tasks API. Teammates use `SendMessage(type: "message")` for point-to-point communication and `SendMessage(type: "broadcast")` for team-wide announcements. Broadcast sends N separate messages (one per teammate) so prefer point-to-point messaging; reserve broadcast for critical announcements only.
The PreToolUse hook blocks all team tools (`TeamCreate`, `SendMessage`, pattern `*team*`/`*teammate*`) unless this env var is set. The hook prints a specific error message indicating the env var is missing.
275
294
276
295
**Team mode not activating despite keywords:**
277
-
Ensure `team_mode_score >= 5`. Simple tasks (<=3 phases) get -3, breadth tasks get -5. Add explicit keywords like "collaborate" or "team" (+5) to trigger team mode. Check `CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1` is set -- without it, plan mode always selects `"subagent"` mode regardless of score.
296
+
When `CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1` is set, team mode is the default. It only falls back to subagent mode when `team_mode_score <= -3` (breadth-only tasks with no complexity factors). Without the env var, plan mode always selects `"subagent"` mode (with ≥2 subtasks mandatory).
@@ -245,29 +250,18 @@ See [Environment Variables](./docs/environment-variables.md) for detailed config
245
250
246
251
The `plugin-hooks.json` configures the delegation enforcement hooks using cross-platform Python scripts:
247
252
248
-
```json
249
-
{
250
-
"hooks": {
251
-
"PreToolUse": [
252
-
{
253
-
"matcher": "*",
254
-
"hooks": [{"type": "command", "command": "uv run --no-project --script \"${CLAUDE_PLUGIN_ROOT}/hooks/PreToolUse/require_delegation.py\""}]
255
-
}
256
-
],
257
-
"UserPromptSubmit": [
258
-
{
259
-
"hooks": [{"type": "command", "command": "uv run --no-project --script \"${CLAUDE_PLUGIN_ROOT}/hooks/UserPromptSubmit/clear-delegation-sessions.py\""}]
260
-
}
261
-
]
262
-
}
263
-
}
264
-
```
265
-
266
253
**Note:** All hooks use `uv run --no-project --script` for cross-platform compatibility (Windows, macOS, Linux). The `--no-project` flag allows execution without requiring a pyproject.toml, and `--script` directly runs Python scripts using uv's managed interpreter.
267
254
268
-
**PreToolUse Hook**: Intercepts every tool call and enforces delegation policy
269
-
**UserPromptSubmit Hook**: Clears delegation state between user prompts to ensure fresh enforcement
270
-
**SessionStart Hook**: Automatically appends workflow_orchestrator system prompt for seamless multi-step workflow detection
@@ -505,6 +499,33 @@ Team mode creates two additional state files (automatically cleaned up on comple
505
499
| Permissions set at spawn | Teammates inherit lead's permission mode |
506
500
| Split panes need tmux/iTerm2 | Not supported in VS Code terminal or Windows Terminal |
507
501
502
+
## Token-Efficient CLI Usage
503
+
504
+
The framework minimizes command output to reduce context consumption and preserve tokens for meaningful work. Token efficiency is enabled by default (`CLAUDE_TOKEN_EFFICIENCY=1`).
505
+
506
+
### Two-Layer Approach
507
+
508
+
1.**Behavioral Guidance** — The `token_efficient_cli.md` system prompt (injected via SessionStart) teaches compact flag usage:
509
+
-`git status -sb` (short branch format)
510
+
-`pytest -q --tb=short` (quiet mode, short tracebacks)
511
+
-`npm test -- -q` (quiet test output)
512
+
- Encourages `--help` parsing and targeted commands
513
+
514
+
2.**Output Compression** — The `token_rewrite_hook.py` PreToolUse hook rewrites matching Bash commands through `compact_run.py`, which compresses git/test/log output post-execution:
515
+
- Git: `push`, `pull`, `commit`, `merge`, `rebase`, `status`, etc.
516
+
- Test runners: `pytest`, `cargo test`, `npm/pnpm/yarn/bun test`, `vitest`, `jest`, `mocha`, etc.
This disables both the behavioral guidance and output compression layers.
528
+
508
529
## Contributing
509
530
510
531
We welcome contributions to the Claude Code Workflow Orchestration System! Whether you're fixing bugs, adding features, or improving documentation, your help is appreciated.
@@ -563,6 +584,31 @@ Found a bug or have a feature request? Please open a GitHub Issue with:
563
584
564
585
Always run quality checks locally before submitting to catch issues early.
565
586
587
+
### Test Suite
588
+
589
+
The project includes a comprehensive test suite covering hooks, token efficiency, and integration:
590
+
591
+
```bash
592
+
# Run all tests
593
+
uv run pytest
594
+
595
+
# Run with verbose output and coverage
596
+
uv run pytest -v --cov=hooks --cov=scripts --cov=system-prompts
0 commit comments