Skip to content

Commit 35fc5f5

Browse files
barkainclaude
andcommitted
fix: address qodo review feedback
- remind_skill_continuation.py: use tempfile.gettempdir() for debug log path (cross-platform) and sys.stdout.write instead of print (T201). - require_delegation.py: exit 1 on unexpected exception per hook exit-code policy (still non-blocking for the tool call itself). - validate_task_graph_compliance.py, validate_task_graph_depth.py: add PEP 723 script metadata block (required for uv run --script). - Delete orphaned system-prompts/workflow_orchestrator.md. No Python code loads this file; the full orchestrator logic lives in commands/delegate.md, which is injected by the slash command on demand. Update README.md and CLAUDE.md references accordingly. Qodo #5 (team_mode_score fallback) and #6 (team_mode_active auto-create) are intentional / false positives and will be replied to on the PR. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 726b6ee commit 35fc5f5

7 files changed

Lines changed: 21 additions & 564 deletions

File tree

CLAUDE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ Two team workflow patterns:
171171
- Agents use conditional COMMUNICATION MODE (teammate messaging vs `DONE|{path}`)
172172
- State files: `.claude/state/team_mode_active`, `.claude/state/team_config.json`
173173

174-
Agent selection uses keyword matching (≥2 matches threshold, highest count wins). Falls back to general-purpose if 0-1 matches. See `system-prompts/workflow_orchestrator.md` for keyword lists.
174+
Agent selection uses keyword matching (≥2 matches threshold, highest count wins). Falls back to general-purpose if 0-1 matches. See `commands/delegate.md` (Available Specialized Agents section) for keyword lists.
175175

176176
Agent config format: YAML frontmatter (`name`, `description`, optional `tools`/`model`/`color`) + markdown system prompt body. All agents enforce `DONE|{output_file}` return format. Custom agent instructions include:
177177
- Return format must be exactly `DONE|{output_file_path}` (no summaries or explanations)
@@ -270,7 +270,7 @@ ls .claude/state/delegation_active 2>/dev/null # delegation in progress?
270270
```
271271

272272
**Multi-step not detected:**
273-
Ensure SessionStart hooks are installed (inject_workflow_orchestrator.py) so that workflow_orchestrator.md is injected and native plan mode (EnterPlanMode/ExitPlanMode) is available. Use connectors in prompts: "and then", "with", "including".
273+
Ensure the SessionStart hook is installed (`hooks/SessionStart/inject_all.py`) so `orchestrator_stub.md` is injected and the main agent knows to route multi-step work through `/workflow-orchestrator:delegate`. Use connectors in prompts: "and then", "with", "including".
274274

275275
**TeamCreate blocked:**
276276
```bash

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -272,14 +272,14 @@ The `plugin-hooks.json` configures the delegation enforcement hooks using cross-
272272
The `inject_all.py` hook consolidates 3 SessionStart hooks into 1 Python script:
273273

274274
**On startup/resume (all sessions):**
275-
- Injects orchestrator stub (`orchestrator_stub.md`, ~1.1KB): registers `/workflow-orchestrator:delegate` and `/workflow-orchestrator:bypass` commands. Minimal overhead (~200 tokens).
275+
- Injects orchestrator routing stub (`orchestrator_stub.md`, ~1.1KB): points the main agent at `/workflow-orchestrator:delegate` for multi-step work. Minimal overhead (~200 tokens).
276276
- Optionally injects token-efficient CLI guide (`token_efficient_cli.md`, ~1.9KB, gated by `CLAUDE_TOKEN_EFFICIENCY=1` env var). Teaches compact flags and command patterns.
277277
- Output style loaded natively from plugin.json `outputStyles` field (no injection required). Saves ~1.5K tokens.
278278

279279
**On first delegation (lazy load):**
280-
- Full `workflow_orchestrator.md` (~7.5KB) loaded only when `/workflow-orchestrator:delegate` runs or multi-step detected.
280+
- Full orchestrator logic (planning instructions, agent catalog, wave scheduling, team-mode execution) lives inline in `commands/delegate.md` and is loaded only when `/workflow-orchestrator:delegate` runs.
281281

282-
**Net savings:** ~6.6K tokens off session startup. Sessions pay only for orchestrator when delegation is used.
282+
**Net savings:** ~6.6K tokens off session startup. Sessions pay the orchestration tax only when delegation is actually used.
283283

284284
**What this enables:**
285285
- Multi-step task detection via pattern matching
@@ -347,9 +347,9 @@ The `/workflow-orchestrator:delegate` command provides intelligent task delegati
347347
6. Creates task list via TaskCreate
348348
7. Exits plan mode (ExitPlanMode) and executes phases as directed by the plan
349349

350-
### 4. Workflow Orchestration System Prompt (`system-prompts/workflow_orchestrator.md`)
350+
### 4. Orchestrator Command (`commands/delegate.md`)
351351

352-
Enables multi-step workflow detection and preparation for complex tasks. Works in conjunction with native plan mode (EnterPlanMode/ExitPlanMode).
352+
The `/workflow-orchestrator:delegate` slash command loads the full orchestrator logic on demand: multi-step detection, plan-mode instructions, agent catalog, wave scheduling, and team-mode execution. Works in conjunction with native plan mode (EnterPlanMode/ExitPlanMode).
353353

354354
**Activate via:**
355355
Simply start a Claude code session

hooks/PostToolUse/remind_skill_continuation.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,19 @@
1616
import logging
1717
import os
1818
import sys
19+
import tempfile
1920
from pathlib import Path
2021

2122
# Force UTF-8 output on Windows (fixes emoji encoding errors)
2223
if sys.platform == "win32":
2324
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8", errors="replace")
2425
sys.stderr = io.TextIOWrapper(sys.stderr.buffer, encoding="utf-8", errors="replace")
2526

26-
# Setup debug logging
27+
# Setup debug logging (cross-platform temp path)
2728
DEBUG = os.environ.get("DEBUG_DELEGATION_HOOK", "0") == "1"
2829
if DEBUG:
2930
logging.basicConfig(
30-
filename="/tmp/delegation_hook_debug.log", # noqa: S108
31+
filename=str(Path(tempfile.gettempdir()) / "delegation_hook_debug.log"),
3132
level=logging.DEBUG,
3233
format="%(asctime)s - remind_skill_continuation - %(message)s",
3334
)
@@ -65,7 +66,7 @@ def _create_continuation_state(reason: str) -> None:
6566
"additionalContext": CONTINUATION_CONTEXT,
6667
}
6768
}
68-
print(json.dumps(output, ensure_ascii=False)) # noqa: T201 — hook stdout JSON
69+
sys.stdout.write(json.dumps(output, ensure_ascii=False) + "\n")
6970

7071

7172
def _zero_violations_counter() -> None:

hooks/PostToolUse/validate_task_graph_depth.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
#!/usr/bin/env python3
2+
# /// script
3+
# requires-python = ">=3.12"
4+
# ///
25
"""
36
PostToolUse Hook: Task Graph Depth Hint (cross-platform)
47

hooks/PreToolUse/require_delegation.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,5 +150,8 @@ def main() -> int:
150150
try:
151151
sys.exit(main())
152152
except Exception as e: # noqa: BLE001
153+
# Surface internal errors per hook exit-code policy (1 = hook error).
154+
# Exit 1 is a non-blocking error in Claude Code — the tool call still
155+
# proceeds, but the failure is visible in debug output.
153156
logger.error("require_delegation hook error: %s", e)
154-
sys.exit(0) # Never block, even on internal errors
157+
sys.exit(1)

hooks/PreToolUse/validate_task_graph_compliance.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
#!/usr/bin/env python3
2+
# /// script
3+
# requires-python = ">=3.12"
4+
# ///
25
"""
36
PreToolUse Hook: Task Graph Compliance Hint (cross-platform)
47

0 commit comments

Comments
 (0)