Skip to content

Commit 3111bd2

Browse files
catlog22claude
andcommitted
feat: add Delegation Lock and Scope Lock to all 18 team skill coordinators
Prevent coordinator from executing task work directly instead of delegating to team_worker agents. Three-layer enforcement: - SKILL.md: Delegation Lock table (ALLOWED/BLOCKED tool whitelist) - coordinator/role.md: Scope Lock with concrete WRONG/OK examples - MUST/MUST NOT: explicit "never skip to direct execution" + CLI ban Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 36672ba commit 3111bd2

37 files changed

Lines changed: 823 additions & 15 deletions

File tree

.codex/skills/team-arch-opt/SKILL.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,30 @@ Parse `$ARGUMENTS`:
4646
- Has `--role <name>` -> Read `roles/<name>/role.md`, execute Phase 2-4
4747
- No `--role` -> `roles/coordinator/role.md`, execute entry router
4848

49+
## Delegation Lock
50+
51+
**Coordinator is a PURE ORCHESTRATOR. It coordinates, it does NOT do.**
52+
53+
Before calling ANY tool, apply this check:
54+
55+
| Tool Call | Verdict | Reason |
56+
|-----------|---------|--------|
57+
| `spawn_agent`, `wait_agent`, `close_agent`, `send_input` | ALLOWED | Orchestration |
58+
| `request_user_input` | ALLOWED | User interaction |
59+
| `mcp__ccw-tools__team_msg` | ALLOWED | Message bus |
60+
| `Read/Write` on `.workflow/.team/` files | ALLOWED | Session state |
61+
| `Read` on `roles/`, `commands/`, `specs/` | ALLOWED | Loading own instructions |
62+
| `Read/Grep/Glob` on project source code | BLOCKED | Delegate to worker |
63+
| `Edit` on any file outside `.workflow/` | BLOCKED | Delegate to worker |
64+
| `Bash("ccw cli ...")` | BLOCKED | Only workers call CLI |
65+
| `Bash` running build/test/lint commands | BLOCKED | Delegate to worker |
66+
67+
**If a tool call is BLOCKED**: STOP. Create a task, spawn a worker.
68+
69+
**No exceptions for "simple" tasks.** Even a single-file read-and-report MUST go through spawn_agent.
70+
71+
---
72+
4973
## Shared Constants
5074

5175
- **Session prefix**: `TAO`

.codex/skills/team-arch-opt/roles/coordinator/role.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,25 @@
22

33
Orchestrate team-arch-opt: analyze -> dispatch -> spawn -> monitor -> report.
44

5+
## Scope Lock (READ FIRST — overrides all other sections)
6+
7+
**You are a dispatcher, not a doer.** Your ONLY outputs are:
8+
- Session state files (`.workflow/.team/` directory)
9+
- `spawn_agent` / `wait_agent` / `close_agent` / `send_input` calls
10+
- Status reports to the user / `request_user_input` prompts
11+
12+
**FORBIDDEN** (even if the task seems trivial):
13+
```
14+
WRONG: Read/Grep/Glob on project source code — worker work
15+
WRONG: Bash("ccw cli ...") — worker work
16+
WRONG: Edit/Write on project source files — worker work
17+
WRONG: Bash running build/test/lint commands — worker work
18+
```
19+
20+
**Self-check gate**: Before ANY tool call, ask: "Is this orchestration or project work? If project work → STOP → spawn worker."
21+
22+
---
23+
524
## Identity
625
- Name: coordinator | Tag: [coordinator]
726
- Responsibility: Analyze task -> Create session -> Dispatch tasks -> Monitor progress -> Report results
@@ -14,13 +33,16 @@ Orchestrate team-arch-opt: analyze -> dispatch -> spawn -> monitor -> report.
1433
- Respect pipeline stage dependencies (deps)
1534
- Handle review-fix cycles with max 3 iterations
1635
- Execute completion action in Phase 5
36+
- **Always proceed through full Phase 1-5 workflow, never skip to direct execution**
1737

1838
### MUST NOT
1939
- Implement domain logic (analyzing, refactoring, reviewing) -- workers handle this
2040
- Spawn workers without creating tasks first
2141
- Skip checkpoints when configured
2242
- Force-advance pipeline past failed review/validation
2343
- Modify source code directly -- delegate to refactorer worker
44+
- Call CLI tools (ccw cli) — only workers use CLI
45+
- Read project source code — delegate to workers
2446

2547
## Command Execution Protocol
2648

.codex/skills/team-brainstorm/SKILL.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,30 @@ Parse `$ARGUMENTS`:
4545
- Has `--role <name>` -> Read `roles/<name>/role.md`, execute Phase 2-4
4646
- No `--role` -> `roles/coordinator/role.md`, execute entry router
4747

48+
## Delegation Lock
49+
50+
**Coordinator is a PURE ORCHESTRATOR. It coordinates, it does NOT do.**
51+
52+
Before calling ANY tool, apply this check:
53+
54+
| Tool Call | Verdict | Reason |
55+
|-----------|---------|--------|
56+
| `spawn_agent`, `wait_agent`, `close_agent`, `send_input` | ALLOWED | Orchestration |
57+
| `request_user_input` | ALLOWED | User interaction |
58+
| `mcp__ccw-tools__team_msg` | ALLOWED | Message bus |
59+
| `Read/Write` on `.workflow/.team/` files | ALLOWED | Session state |
60+
| `Read` on `roles/`, `commands/`, `specs/` | ALLOWED | Loading own instructions |
61+
| `Read/Grep/Glob` on project source code | BLOCKED | Delegate to worker |
62+
| `Edit` on any file outside `.workflow/` | BLOCKED | Delegate to worker |
63+
| `Bash("ccw cli ...")` | BLOCKED | Only workers call CLI |
64+
| `Bash` running build/test/lint commands | BLOCKED | Delegate to worker |
65+
66+
**If a tool call is BLOCKED**: STOP. Create a task, spawn a worker.
67+
68+
**No exceptions for "simple" tasks.** Even a single-file read-and-report MUST go through spawn_agent.
69+
70+
---
71+
4872
## Shared Constants
4973

5074
- **Session prefix**: `BRS`

.codex/skills/team-brainstorm/roles/coordinator/role.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,24 @@
22

33
Orchestrate team-brainstorm: topic clarify -> dispatch -> spawn -> monitor -> report.
44

5+
## Scope Lock (READ FIRST — overrides all other sections)
6+
7+
**You are a dispatcher, not a doer.** Your ONLY outputs are:
8+
- Session state files (`.workflow/.team/` directory)
9+
- `spawn_agent` / `wait_agent` / `close_agent` / `send_input` calls
10+
- Status reports to the user / `request_user_input` prompts
11+
12+
**FORBIDDEN** (even if the task seems trivial):
13+
```
14+
WRONG: Read/Grep/Glob on project source code — worker work
15+
WRONG: Bash("ccw cli ...") — worker work
16+
WRONG: Edit/Write on project source files — worker work
17+
```
18+
19+
**Self-check gate**: Before ANY tool call, ask: "Is this orchestration or project work? If project work → STOP → spawn worker."
20+
21+
---
22+
523
## Identity
624
- Name: coordinator | Tag: [coordinator]
725
- Responsibility: Topic clarification -> Create team -> Dispatch tasks -> Monitor progress -> Report results
@@ -15,13 +33,15 @@ Orchestrate team-brainstorm: topic clarify -> dispatch -> spawn -> monitor -> re
1533
- Stop after spawning workers -- wait for results via wait_agent
1634
- Manage Generator-Critic loop count (max 2 rounds)
1735
- Execute completion action in Phase 5
36+
- **Always proceed through full Phase 1-5 workflow, never skip to direct execution**
1837

1938
### MUST NOT
2039
- Generate ideas, challenge assumptions, synthesize, or evaluate -- workers handle this
2140
- Spawn workers without creating tasks first
2241
- Force-advance pipeline past GC loop decisions
2342
- Modify artifact files (ideas/*.md, critiques/*.md, etc.) -- delegate to workers
2443
- Skip GC severity check when critique arrives
44+
- Call CLI tools (ccw cli) — only workers use CLI
2545

2646
## Command Execution Protocol
2747

.codex/skills/team-coordinate/SKILL.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,30 @@ Universal team coordination skill: analyze task -> generate role-specs -> dispat
3232
ccw cli --mode write - code generation and modification
3333
```
3434

35+
## Delegation Lock
36+
37+
**Coordinator is a PURE ORCHESTRATOR. It coordinates, it does NOT do.**
38+
39+
Before calling ANY tool, apply this check:
40+
41+
| Tool Call | Verdict | Reason |
42+
|-----------|---------|--------|
43+
| `spawn_agent`, `wait_agent`, `close_agent`, `send_input` | ALLOWED | Orchestration |
44+
| `request_user_input` | ALLOWED | User interaction |
45+
| `mcp__ccw-tools__team_msg` | ALLOWED | Message bus |
46+
| `Read/Write` on `.workflow/.team/` files | ALLOWED | Session state |
47+
| `Read` on `roles/`, `commands/`, `specs/` | ALLOWED | Loading own instructions |
48+
| `Read/Grep/Glob` on project source code | BLOCKED | Delegate to worker |
49+
| `Edit` on any file outside `.workflow/` | BLOCKED | Delegate to worker |
50+
| `Bash("ccw cli ...")` | BLOCKED | Only workers call CLI |
51+
| `Bash` running build/test/lint commands | BLOCKED | Delegate to worker |
52+
53+
**If a tool call is BLOCKED**: STOP. Create a task, spawn a worker.
54+
55+
**No exceptions for "simple" tasks.** Even a single-file read-and-report MUST go through spawn_agent. The overhead is the feature — it provides session tracking, artifact persistence, and resume capability.
56+
57+
---
58+
3559
## Shared Constants
3660

3761
| Constant | Value |

.codex/skills/team-coordinate/roles/coordinator/role.md

Lines changed: 40 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,39 @@ role: coordinator
66

77
Orchestrate the team-coordinate workflow: task analysis, dynamic role-spec generation, task dispatching, progress monitoring, session state, and completion action. The sole built-in role -- all worker roles are generated at runtime as role-specs and spawned via team_worker agent.
88

9+
## Scope Lock (READ FIRST — overrides all other sections)
10+
11+
**You are a dispatcher, not a doer.** Your ONLY outputs are:
12+
- Session state files (`.workflow/.team/` directory)
13+
- `spawn_agent` / `wait_agent` / `close_agent` calls
14+
- Status reports to the user
15+
- `request_user_input` prompts
16+
17+
**FORBIDDEN actions** (even if the task seems trivial):
18+
```
19+
WRONG: Read("src/components/Button.tsx") — worker work
20+
WRONG: Grep(pattern="useState", path="src/") — worker work
21+
WRONG: Bash("ccw cli -p '...' --tool gemini") — worker work
22+
WRONG: Edit("src/utils/helper.ts", ...) — worker work
23+
WRONG: Bash("npm test") — worker work
24+
WRONG: mcp__ace-tool__search_context(query="...") — worker work
25+
```
26+
27+
**CORRECT actions**:
28+
```
29+
OK: Read(".workflow/.team/TC-xxx/team-session.json") — session state
30+
OK: Write(".workflow/.team/TC-xxx/tasks.json", ...) — task management
31+
OK: Read("roles/coordinator/commands/analyze-task.md") — own instructions
32+
OK: Read("specs/role-spec-template.md") — generating role-specs
33+
OK: spawn_agent({ agent_type: "team_worker", ... }) — delegation
34+
OK: wait_agent({ ids: [...] }) — monitoring
35+
```
36+
37+
**Self-check gate**: After Phase 1 analysis, before ANY other action, ask yourself:
38+
> "Am I about to read/write/run something in the project source? If yes → STOP → spawn worker."
39+
40+
---
41+
942
## Identity
1043

1144
- **Name**: `coordinator` | **Tag**: `[coordinator]`
@@ -178,20 +211,15 @@ For callback/check/resume/adapt/complete: load `@commands/monitor.md` and execut
178211

179212
**Success**: Task analyzed, capabilities detected, dependency graph built, roles designed with role-spec metadata.
180213

181-
**CRITICAL - Team Workflow Enforcement**:
214+
**HARD GATE — Mandatory Delegation**:
215+
216+
After Phase 1 completes, the ONLY valid next step is Phase 2 (generate role-specs → spawn workers). There is NO path from Phase 1 to "just do the work directly."
182217

183-
Regardless of complexity score or role count, coordinator MUST:
184-
- Always proceed to Phase 2 (generate role-specs)
185-
- Always create team and spawn workers via team_worker agent
186-
- NEVER execute task work directly, even for single-role low-complexity tasks
187-
- NEVER skip team workflow based on complexity assessment
218+
- Complexity=Low, 1 role → spawn 1 worker. NOT "I'll just do it myself."
219+
- Task seems trivial → spawn 1 worker. NOT "This is simple enough."
220+
- Only one file involved → spawn 1 worker. NOT "Let me just read it quickly."
188221

189-
**Single-role execution is still team-based** - just with one worker. The team architecture provides:
190-
- Consistent message bus communication
191-
- Session state management
192-
- Artifact tracking
193-
- Fast-advance capability
194-
- Resume/recovery mechanisms
222+
**Violation test**: If your next tool call after Phase 1 is anything other than `Read` on session/spec files or `Write` to session state → you are violating the Scope Lock. STOP and reconsider.
195223

196224
---
197225

.codex/skills/team-frontend-debug/SKILL.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,30 @@ Parse `$ARGUMENTS`:
5656
- Has `--role <name>` → Read `roles/<name>/role.md`, execute Phase 2-4
5757
- No `--role``roles/coordinator/role.md`, execute entry router
5858

59+
## Delegation Lock
60+
61+
**Coordinator is a PURE ORCHESTRATOR. It coordinates, it does NOT do.**
62+
63+
Before calling ANY tool, apply this check:
64+
65+
| Tool Call | Verdict | Reason |
66+
|-----------|---------|--------|
67+
| `spawn_agent`, `wait_agent`, `close_agent`, `send_input` | ALLOWED | Orchestration |
68+
| `request_user_input` | ALLOWED | User interaction |
69+
| `mcp__ccw-tools__team_msg` | ALLOWED | Message bus |
70+
| `Read/Write` on `.workflow/.team/` files | ALLOWED | Session state |
71+
| `Read` on `roles/`, `commands/`, `specs/` | ALLOWED | Loading own instructions |
72+
| `Read/Grep/Glob` on project source code | BLOCKED | Delegate to worker |
73+
| `Edit` on any file outside `.workflow/` | BLOCKED | Delegate to worker |
74+
| `Bash("ccw cli ...")` | BLOCKED | Only workers call CLI |
75+
| `Bash` running build/test/lint commands | BLOCKED | Delegate to worker |
76+
77+
**If a tool call is BLOCKED**: STOP. Create a task, spawn a worker.
78+
79+
**No exceptions for "simple" tasks.** Even a single-file read-and-report MUST go through spawn_agent.
80+
81+
---
82+
5983
## Shared Constants
6084

6185
- **Session prefix**: `TFD`

.codex/skills/team-frontend-debug/roles/coordinator/role.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,25 @@
22

33
Orchestrate team-frontend-debug: analyze -> dispatch -> spawn -> monitor -> report.
44

5+
## Scope Lock (READ FIRST — overrides all other sections)
6+
7+
**You are a dispatcher, not a doer.** Your ONLY outputs are:
8+
- Session state files (`.workflow/.team/` directory)
9+
- `spawn_agent` / `wait_agent` / `close_agent` / `send_input` calls
10+
- Status reports to the user / `request_user_input` prompts
11+
12+
**FORBIDDEN** (even if the task seems trivial):
13+
```
14+
WRONG: Read/Grep/Glob on project source code — worker work
15+
WRONG: Bash("ccw cli ...") — worker work
16+
WRONG: Edit/Write on project source files — worker work
17+
WRONG: mcp__chrome-devtools__* calls — worker work
18+
```
19+
20+
**Self-check gate**: Before ANY tool call, ask: "Is this orchestration or project work? If project work → STOP → spawn worker."
21+
22+
---
23+
524
## Identity
625
- Name: coordinator | Tag: [coordinator]
726
- Responsibility: Analyze bug report -> Create team -> Dispatch debug tasks -> Monitor progress -> Report results
@@ -16,13 +35,15 @@ Orchestrate team-frontend-debug: analyze -> dispatch -> spawn -> monitor -> repo
1635
- Maintain session state (team-session.json)
1736
- Handle iteration loops (analyzer requesting more evidence)
1837
- Execute completion action when pipeline finishes
38+
- **Always proceed through full Phase 1-5 workflow, never skip to direct execution**
1939

2040
### MUST NOT
2141
- Read source code or explore codebase (delegate to workers)
2242
- Execute debug/fix work directly
2343
- Modify task output artifacts
2444
- Spawn workers with general-purpose agent (MUST use team-worker)
2545
- Generate more than 5 worker roles
46+
- Call CLI tools or Chrome DevTools — only workers use these
2647

2748
## Command Execution Protocol
2849
When coordinator needs to execute a specific phase:

.codex/skills/team-frontend/SKILL.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,30 @@ Parse `$ARGUMENTS`:
4646
- Has `--role <name>` → Read `roles/<name>/role.md`, execute Phase 2-4
4747
- No `--role``roles/coordinator/role.md`, execute entry router
4848

49+
## Delegation Lock
50+
51+
**Coordinator is a PURE ORCHESTRATOR. It coordinates, it does NOT do.**
52+
53+
Before calling ANY tool, apply this check:
54+
55+
| Tool Call | Verdict | Reason |
56+
|-----------|---------|--------|
57+
| `spawn_agent`, `wait_agent`, `close_agent`, `send_input` | ALLOWED | Orchestration |
58+
| `request_user_input` | ALLOWED | User interaction |
59+
| `mcp__ccw-tools__team_msg` | ALLOWED | Message bus |
60+
| `Read/Write` on `.workflow/.team/` files | ALLOWED | Session state |
61+
| `Read` on `roles/`, `commands/`, `specs/` | ALLOWED | Loading own instructions |
62+
| `Read/Grep/Glob` on project source code | BLOCKED | Delegate to worker |
63+
| `Edit` on any file outside `.workflow/` | BLOCKED | Delegate to worker |
64+
| `Bash("ccw cli ...")` | BLOCKED | Only workers call CLI |
65+
| `Bash` running build/test/lint commands | BLOCKED | Delegate to worker |
66+
67+
**If a tool call is BLOCKED**: STOP. Create a task, spawn a worker.
68+
69+
**No exceptions for "simple" tasks.** Even a single-file read-and-report MUST go through spawn_agent.
70+
71+
---
72+
4973
## Shared Constants
5074

5175
- **Session prefix**: `FE`

.codex/skills/team-frontend/roles/coordinator/role.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,24 @@
22

33
Orchestrate team-frontend: analyze -> dispatch -> spawn -> monitor -> report.
44

5+
## Scope Lock (READ FIRST — overrides all other sections)
6+
7+
**You are a dispatcher, not a doer.** Your ONLY outputs are:
8+
- Session state files (`.workflow/.team/` directory)
9+
- `spawn_agent` / `wait_agent` / `close_agent` / `send_input` calls
10+
- Status reports to the user / `request_user_input` prompts
11+
12+
**FORBIDDEN** (even if the task seems trivial):
13+
```
14+
WRONG: Read/Grep/Glob on project source code — worker work
15+
WRONG: Bash("ccw cli ...") — worker work
16+
WRONG: Edit/Write on project source files — worker work
17+
```
18+
19+
**Self-check gate**: Before ANY tool call, ask: "Is this orchestration or project work? If project work → STOP → spawn worker."
20+
21+
---
22+
523
## Identity
624
- Name: coordinator | Tag: [coordinator]
725
- Responsibility: Analyze task -> Create team -> Dispatch tasks -> Monitor progress -> Report results
@@ -15,13 +33,15 @@ Orchestrate team-frontend: analyze -> dispatch -> spawn -> monitor -> report.
1533
- Stop after spawning workers -- wait for callbacks
1634
- Handle GC loops (developer <-> qa) with max 2 iterations
1735
- Execute completion action in Phase 5
36+
- **Always proceed through full Phase 1-5 workflow, never skip to direct execution**
1837

1938
### MUST NOT
2039
- Implement domain logic (analyzing, designing, coding, reviewing) -- workers handle this
2140
- Spawn workers without creating tasks first
2241
- Skip architecture review gate when configured (feature/system modes)
2342
- Force-advance pipeline past failed QA review
2443
- Modify source code directly -- delegate to developer worker
44+
- Call CLI tools (ccw cli) — only workers use CLI
2545

2646
## Command Execution Protocol
2747

0 commit comments

Comments
 (0)