@laurentenhoor/devclaw 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (163) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +406 -0
  3. package/dist/index.d.ts +88 -0
  4. package/dist/index.d.ts.map +1 -0
  5. package/dist/index.js +107 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/lib/audit.d.ts +2 -0
  8. package/dist/lib/audit.d.ts.map +1 -0
  9. package/dist/lib/audit.js +42 -0
  10. package/dist/lib/audit.js.map +1 -0
  11. package/dist/lib/binding-manager.d.ts +35 -0
  12. package/dist/lib/binding-manager.d.ts.map +1 -0
  13. package/dist/lib/binding-manager.js +88 -0
  14. package/dist/lib/binding-manager.js.map +1 -0
  15. package/dist/lib/cli.d.ts +12 -0
  16. package/dist/lib/cli.d.ts.map +1 -0
  17. package/dist/lib/cli.js +69 -0
  18. package/dist/lib/cli.js.map +1 -0
  19. package/dist/lib/dispatch.d.ts +58 -0
  20. package/dist/lib/dispatch.d.ts.map +1 -0
  21. package/dist/lib/dispatch.js +163 -0
  22. package/dist/lib/dispatch.js.map +1 -0
  23. package/dist/lib/model-selector.d.ts +21 -0
  24. package/dist/lib/model-selector.d.ts.map +1 -0
  25. package/dist/lib/model-selector.js +74 -0
  26. package/dist/lib/model-selector.js.map +1 -0
  27. package/dist/lib/notify.d.ts +54 -0
  28. package/dist/lib/notify.d.ts.map +1 -0
  29. package/dist/lib/notify.js +143 -0
  30. package/dist/lib/notify.js.map +1 -0
  31. package/dist/lib/onboarding.d.ts +5 -0
  32. package/dist/lib/onboarding.d.ts.map +1 -0
  33. package/dist/lib/onboarding.js +124 -0
  34. package/dist/lib/onboarding.js.map +1 -0
  35. package/dist/lib/projects.d.ts +64 -0
  36. package/dist/lib/projects.d.ts.map +1 -0
  37. package/dist/lib/projects.js +127 -0
  38. package/dist/lib/projects.js.map +1 -0
  39. package/dist/lib/providers/github.d.ts +23 -0
  40. package/dist/lib/providers/github.d.ts.map +1 -0
  41. package/dist/lib/providers/github.js +130 -0
  42. package/dist/lib/providers/github.js.map +1 -0
  43. package/dist/lib/providers/gitlab.d.ts +23 -0
  44. package/dist/lib/providers/gitlab.d.ts.map +1 -0
  45. package/dist/lib/providers/gitlab.js +133 -0
  46. package/dist/lib/providers/gitlab.js.map +1 -0
  47. package/dist/lib/providers/index.d.ts +12 -0
  48. package/dist/lib/providers/index.d.ts.map +1 -0
  49. package/dist/lib/providers/index.js +25 -0
  50. package/dist/lib/providers/index.js.map +1 -0
  51. package/dist/lib/providers/provider.d.ts +35 -0
  52. package/dist/lib/providers/provider.d.ts.map +1 -0
  53. package/dist/lib/providers/provider.js +13 -0
  54. package/dist/lib/providers/provider.js.map +1 -0
  55. package/dist/lib/services/health.d.ts +38 -0
  56. package/dist/lib/services/health.d.ts.map +1 -0
  57. package/dist/lib/services/health.js +100 -0
  58. package/dist/lib/services/health.js.map +1 -0
  59. package/dist/lib/services/heartbeat.d.ts +38 -0
  60. package/dist/lib/services/heartbeat.d.ts.map +1 -0
  61. package/dist/lib/services/heartbeat.js +199 -0
  62. package/dist/lib/services/heartbeat.js.map +1 -0
  63. package/dist/lib/services/pipeline.d.ts +36 -0
  64. package/dist/lib/services/pipeline.d.ts.map +1 -0
  65. package/dist/lib/services/pipeline.js +90 -0
  66. package/dist/lib/services/pipeline.js.map +1 -0
  67. package/dist/lib/services/queue.d.ts +14 -0
  68. package/dist/lib/services/queue.d.ts.map +1 -0
  69. package/dist/lib/services/queue.js +31 -0
  70. package/dist/lib/services/queue.js.map +1 -0
  71. package/dist/lib/services/tick.d.ts +62 -0
  72. package/dist/lib/services/tick.d.ts.map +1 -0
  73. package/dist/lib/services/tick.js +160 -0
  74. package/dist/lib/services/tick.js.map +1 -0
  75. package/dist/lib/setup/agent.d.ts +14 -0
  76. package/dist/lib/setup/agent.d.ts.map +1 -0
  77. package/dist/lib/setup/agent.js +72 -0
  78. package/dist/lib/setup/agent.js.map +1 -0
  79. package/dist/lib/setup/config.d.ts +22 -0
  80. package/dist/lib/setup/config.d.ts.map +1 -0
  81. package/dist/lib/setup/config.js +67 -0
  82. package/dist/lib/setup/config.js.map +1 -0
  83. package/dist/lib/setup/index.d.ts +53 -0
  84. package/dist/lib/setup/index.d.ts.map +1 -0
  85. package/dist/lib/setup/index.js +68 -0
  86. package/dist/lib/setup/index.js.map +1 -0
  87. package/dist/lib/setup/workspace.d.ts +6 -0
  88. package/dist/lib/setup/workspace.d.ts.map +1 -0
  89. package/dist/lib/setup/workspace.js +69 -0
  90. package/dist/lib/setup/workspace.js.map +1 -0
  91. package/dist/lib/templates.d.ts +9 -0
  92. package/dist/lib/templates.d.ts.map +1 -0
  93. package/dist/lib/templates.js +163 -0
  94. package/dist/lib/templates.js.map +1 -0
  95. package/dist/lib/tiers.d.ts +55 -0
  96. package/dist/lib/tiers.d.ts.map +1 -0
  97. package/dist/lib/tiers.js +74 -0
  98. package/dist/lib/tiers.js.map +1 -0
  99. package/dist/lib/tool-helpers.d.ts +44 -0
  100. package/dist/lib/tool-helpers.d.ts.map +1 -0
  101. package/dist/lib/tool-helpers.js +65 -0
  102. package/dist/lib/tool-helpers.js.map +1 -0
  103. package/dist/lib/tools/health.d.ts +28 -0
  104. package/dist/lib/tools/health.d.ts.map +1 -0
  105. package/dist/lib/tools/health.js +61 -0
  106. package/dist/lib/tools/health.js.map +1 -0
  107. package/dist/lib/tools/onboard.d.ts +24 -0
  108. package/dist/lib/tools/onboard.d.ts.map +1 -0
  109. package/dist/lib/tools/onboard.js +27 -0
  110. package/dist/lib/tools/onboard.js.map +1 -0
  111. package/dist/lib/tools/project-register.d.ts +51 -0
  112. package/dist/lib/tools/project-register.d.ts.map +1 -0
  113. package/dist/lib/tools/project-register.js +172 -0
  114. package/dist/lib/tools/project-register.js.map +1 -0
  115. package/dist/lib/tools/queue-status.test.d.ts +2 -0
  116. package/dist/lib/tools/queue-status.test.d.ts.map +1 -0
  117. package/dist/lib/tools/queue-status.test.js +48 -0
  118. package/dist/lib/tools/queue-status.test.js.map +1 -0
  119. package/dist/lib/tools/setup.d.ts +76 -0
  120. package/dist/lib/tools/setup.d.ts.map +1 -0
  121. package/dist/lib/tools/setup.js +102 -0
  122. package/dist/lib/tools/setup.js.map +1 -0
  123. package/dist/lib/tools/status.d.ts +24 -0
  124. package/dist/lib/tools/status.d.ts.map +1 -0
  125. package/dist/lib/tools/status.js +53 -0
  126. package/dist/lib/tools/status.js.map +1 -0
  127. package/dist/lib/tools/task-comment.d.ts +40 -0
  128. package/dist/lib/tools/task-comment.d.ts.map +1 -0
  129. package/dist/lib/tools/task-comment.js +84 -0
  130. package/dist/lib/tools/task-comment.js.map +1 -0
  131. package/dist/lib/tools/task-create.d.ts +54 -0
  132. package/dist/lib/tools/task-create.d.ts.map +1 -0
  133. package/dist/lib/tools/task-create.js +77 -0
  134. package/dist/lib/tools/task-create.js.map +1 -0
  135. package/dist/lib/tools/task-update.d.ts +40 -0
  136. package/dist/lib/tools/task-update.d.ts.map +1 -0
  137. package/dist/lib/tools/task-update.js +79 -0
  138. package/dist/lib/tools/task-update.js.map +1 -0
  139. package/dist/lib/tools/task-update.test.d.ts +7 -0
  140. package/dist/lib/tools/task-update.test.d.ts.map +1 -0
  141. package/dist/lib/tools/task-update.test.js +55 -0
  142. package/dist/lib/tools/task-update.test.js.map +1 -0
  143. package/dist/lib/tools/work-finish.d.ts +43 -0
  144. package/dist/lib/tools/work-finish.d.ts.map +1 -0
  145. package/dist/lib/tools/work-finish.js +77 -0
  146. package/dist/lib/tools/work-finish.js.map +1 -0
  147. package/dist/lib/tools/work-start.d.ts +39 -0
  148. package/dist/lib/tools/work-start.d.ts.map +1 -0
  149. package/dist/lib/tools/work-start.js +129 -0
  150. package/dist/lib/tools/work-start.js.map +1 -0
  151. package/dist/lib/types.d.ts +17 -0
  152. package/dist/lib/types.d.ts.map +1 -0
  153. package/dist/lib/types.js +8 -0
  154. package/dist/lib/types.js.map +1 -0
  155. package/docs/ARCHITECTURE.md +662 -0
  156. package/docs/CONFIGURATION.md +336 -0
  157. package/docs/MANAGEMENT.md +120 -0
  158. package/docs/ONBOARDING.md +251 -0
  159. package/docs/QA_WORKFLOW.md +120 -0
  160. package/docs/ROADMAP.md +96 -0
  161. package/docs/TESTING.md +339 -0
  162. package/docs/TOOLS.md +361 -0
  163. package/package.json +55 -0
@@ -0,0 +1,336 @@
1
+ # DevClaw — Configuration Reference
2
+
3
+ All DevClaw configuration lives in two places: `openclaw.json` (plugin-level settings) and `projects.json` (per-project state).
4
+
5
+ ## Plugin Configuration (`openclaw.json`)
6
+
7
+ DevClaw is configured under `plugins.entries.devclaw.config` in `openclaw.json`.
8
+
9
+ ### Model Tiers
10
+
11
+ Override which LLM model powers each developer level:
12
+
13
+ ```json
14
+ {
15
+ "plugins": {
16
+ "entries": {
17
+ "devclaw": {
18
+ "config": {
19
+ "models": {
20
+ "dev": {
21
+ "junior": "anthropic/claude-haiku-4-5",
22
+ "medior": "anthropic/claude-sonnet-4-5",
23
+ "senior": "anthropic/claude-opus-4-5"
24
+ },
25
+ "qa": {
26
+ "reviewer": "anthropic/claude-sonnet-4-5",
27
+ "tester": "anthropic/claude-haiku-4-5"
28
+ }
29
+ }
30
+ }
31
+ }
32
+ }
33
+ }
34
+ }
35
+ ```
36
+
37
+ **Resolution order** (per `lib/tiers.ts:resolveModel`):
38
+
39
+ 1. Plugin config `models.<role>.<level>` — explicit override
40
+ 2. `DEFAULT_MODELS[role][level]` — built-in defaults (table below)
41
+ 3. Passthrough — treat the level string as a raw model ID
42
+
43
+ **Default models:**
44
+
45
+ | Role | Level | Default model |
46
+ |---|---|---|
47
+ | dev | junior | `anthropic/claude-haiku-4-5` |
48
+ | dev | medior | `anthropic/claude-sonnet-4-5` |
49
+ | dev | senior | `anthropic/claude-opus-4-5` |
50
+ | qa | reviewer | `anthropic/claude-sonnet-4-5` |
51
+ | qa | tester | `anthropic/claude-haiku-4-5` |
52
+
53
+ ### Project Execution Mode
54
+
55
+ Controls cross-project parallelism:
56
+
57
+ ```json
58
+ {
59
+ "plugins": {
60
+ "entries": {
61
+ "devclaw": {
62
+ "config": {
63
+ "projectExecution": "parallel"
64
+ }
65
+ }
66
+ }
67
+ }
68
+ }
69
+ ```
70
+
71
+ | Value | Behavior |
72
+ |---|---|
73
+ | `"parallel"` (default) | Multiple projects can have active workers simultaneously |
74
+ | `"sequential"` | Only one project's workers active at a time. Useful for single-agent deployments. |
75
+
76
+ Enforced in `work_heartbeat` and the heartbeat service before dispatching.
77
+
78
+ ### Heartbeat Service
79
+
80
+ Token-free interval-based health checks + queue dispatch:
81
+
82
+ ```json
83
+ {
84
+ "plugins": {
85
+ "entries": {
86
+ "devclaw": {
87
+ "config": {
88
+ "work_heartbeat": {
89
+ "enabled": true,
90
+ "intervalSeconds": 60,
91
+ "maxPickupsPerTick": 4
92
+ }
93
+ }
94
+ }
95
+ }
96
+ }
97
+ }
98
+ ```
99
+
100
+ | Setting | Type | Default | Description |
101
+ |---|---|---|---|
102
+ | `enabled` | boolean | `true` | Enable the heartbeat service |
103
+ | `intervalSeconds` | number | `60` | Seconds between ticks |
104
+ | `maxPickupsPerTick` | number | `4` | Maximum worker dispatches per tick (budget control) |
105
+
106
+ **Source:** [`lib/services/heartbeat.ts`](../lib/services/heartbeat.ts)
107
+
108
+ The heartbeat service runs as a plugin service tied to the gateway lifecycle. Every tick: health pass (auto-fix zombies, stale workers) → tick pass (fill free slots by priority). Zero LLM tokens consumed.
109
+
110
+ ### Notifications
111
+
112
+ Control which lifecycle events send notifications:
113
+
114
+ ```json
115
+ {
116
+ "plugins": {
117
+ "entries": {
118
+ "devclaw": {
119
+ "config": {
120
+ "notifications": {
121
+ "heartbeatDm": true,
122
+ "workerStart": true,
123
+ "workerComplete": true
124
+ }
125
+ }
126
+ }
127
+ }
128
+ }
129
+ }
130
+ ```
131
+
132
+ | Setting | Default | Description |
133
+ |---|---|---|
134
+ | `heartbeatDm` | `true` | Send heartbeat summary to orchestrator DM |
135
+ | `workerStart` | `true` | Announce when a worker picks up a task |
136
+ | `workerComplete` | `true` | Announce when a worker finishes a task |
137
+
138
+ ### Agent Tool Permissions
139
+
140
+ Restrict DevClaw tools to your orchestrator agent:
141
+
142
+ ```json
143
+ {
144
+ "agents": {
145
+ "list": [
146
+ {
147
+ "id": "my-orchestrator",
148
+ "tools": {
149
+ "allow": [
150
+ "work_start",
151
+ "work_finish",
152
+ "task_create",
153
+ "task_update",
154
+ "task_comment",
155
+ "status",
156
+ "health",
157
+ "work_heartbeat",
158
+ "project_register",
159
+ "setup",
160
+ "onboard"
161
+ ]
162
+ }
163
+ }
164
+ ]
165
+ }
166
+ }
167
+ ```
168
+
169
+ ---
170
+
171
+ ## Project State (`projects.json`)
172
+
173
+ All project state lives in `<workspace>/projects/projects.json`, keyed by group ID.
174
+
175
+ **Source:** [`lib/projects.ts`](../lib/projects.ts)
176
+
177
+ ### Schema
178
+
179
+ ```json
180
+ {
181
+ "projects": {
182
+ "<groupId>": {
183
+ "name": "my-webapp",
184
+ "repo": "~/git/my-webapp",
185
+ "groupName": "Dev - My Webapp",
186
+ "baseBranch": "development",
187
+ "deployBranch": "development",
188
+ "deployUrl": "https://my-webapp.example.com",
189
+ "channel": "telegram",
190
+ "roleExecution": "parallel",
191
+ "dev": {
192
+ "active": false,
193
+ "issueId": null,
194
+ "startTime": null,
195
+ "level": null,
196
+ "sessions": {
197
+ "junior": null,
198
+ "medior": "agent:orchestrator:subagent:my-webapp-dev-medior",
199
+ "senior": null
200
+ }
201
+ },
202
+ "qa": {
203
+ "active": false,
204
+ "issueId": null,
205
+ "startTime": null,
206
+ "level": null,
207
+ "sessions": {
208
+ "reviewer": "agent:orchestrator:subagent:my-webapp-qa-reviewer",
209
+ "tester": null
210
+ }
211
+ }
212
+ }
213
+ }
214
+ }
215
+ ```
216
+
217
+ ### Project fields
218
+
219
+ | Field | Type | Description |
220
+ |---|---|---|
221
+ | `name` | string | Short project name |
222
+ | `repo` | string | Path to git repo (supports `~/` expansion) |
223
+ | `groupName` | string | Group display name |
224
+ | `baseBranch` | string | Base branch for development |
225
+ | `deployBranch` | string | Branch that triggers deployment |
226
+ | `deployUrl` | string | Deployment URL |
227
+ | `channel` | string | Messaging channel (`"telegram"`, `"whatsapp"`, etc.) |
228
+ | `roleExecution` | `"parallel"` \| `"sequential"` | DEV/QA parallelism for this project |
229
+
230
+ ### Worker state fields
231
+
232
+ Each project has `dev` and `qa` worker state objects:
233
+
234
+ | Field | Type | Description |
235
+ |---|---|---|
236
+ | `active` | boolean | Whether this role has an active worker |
237
+ | `issueId` | string \| null | Issue being worked on (as string) |
238
+ | `startTime` | string \| null | ISO timestamp when worker became active |
239
+ | `level` | string \| null | Current level (`junior`, `medior`, `senior`, `reviewer`, `tester`) |
240
+ | `sessions` | Record<string, string \| null> | Per-level session keys |
241
+
242
+ **DEV session keys:** `junior`, `medior`, `senior`
243
+ **QA session keys:** `reviewer`, `tester`
244
+
245
+ ### Key design decisions
246
+
247
+ - **Session-per-level** — each level gets its own worker session, accumulating context independently. Level selection maps directly to a session key.
248
+ - **Sessions preserved on completion** — when a worker completes a task, the sessions map is preserved (only `active`, `issueId`, and `startTime` are cleared). This enables session reuse.
249
+ - **Atomic writes** — all writes go through temp-file-then-rename to prevent corruption.
250
+ - **Sessions persist indefinitely** — no auto-cleanup. The `health` tool handles manual cleanup.
251
+
252
+ ---
253
+
254
+ ## Workspace File Layout
255
+
256
+ ```
257
+ <workspace>/
258
+ ├── projects/
259
+ │ ├── projects.json ← Project state (auto-managed)
260
+ │ └── roles/
261
+ │ ├── my-webapp/ ← Per-project role instructions (editable)
262
+ │ │ ├── dev.md
263
+ │ │ └── qa.md
264
+ │ ├── another-project/
265
+ │ │ ├── dev.md
266
+ │ │ └── qa.md
267
+ │ └── default/ ← Fallback role instructions
268
+ │ ├── dev.md
269
+ │ └── qa.md
270
+ ├── log/
271
+ │ └── audit.log ← NDJSON event log (auto-managed)
272
+ ├── AGENTS.md ← Agent identity documentation
273
+ └── HEARTBEAT.md ← Heartbeat operation guide
274
+ ```
275
+
276
+ ### Role instruction files
277
+
278
+ `work_start` loads role instructions from `projects/roles/<project>/<role>.md` at dispatch time, falling back to `projects/roles/default/<role>.md`. These files are appended to the task message sent to worker sessions.
279
+
280
+ Edit to customize: deployment steps, test commands, acceptance criteria, coding standards.
281
+
282
+ **Source:** [`lib/dispatch.ts:loadRoleInstructions`](../lib/dispatch.ts)
283
+
284
+ ---
285
+
286
+ ## Audit Log
287
+
288
+ Append-only NDJSON at `<workspace>/log/audit.log`. Auto-truncated to 250 lines.
289
+
290
+ **Source:** [`lib/audit.ts`](../lib/audit.ts)
291
+
292
+ ### Event types
293
+
294
+ | Event | Trigger |
295
+ |---|---|
296
+ | `work_start` | Task dispatched to worker |
297
+ | `model_selection` | Level resolved to model ID |
298
+ | `work_finish` | Task completed |
299
+ | `work_heartbeat` | Heartbeat tick completed |
300
+ | `task_create` | Issue created |
301
+ | `task_update` | Issue state changed |
302
+ | `task_comment` | Comment added to issue |
303
+ | `status` | Queue status queried |
304
+ | `health` | Health scan completed |
305
+ | `heartbeat_tick` | Heartbeat service tick (background) |
306
+ | `project_register` | Project registered |
307
+
308
+ ### Querying
309
+
310
+ ```bash
311
+ # All task dispatches
312
+ cat audit.log | jq 'select(.event=="work_start")'
313
+
314
+ # All completions for a project
315
+ cat audit.log | jq 'select(.event=="work_finish" and .project=="my-webapp")'
316
+
317
+ # Model selections
318
+ cat audit.log | jq 'select(.event=="model_selection")'
319
+ ```
320
+
321
+ ---
322
+
323
+ ## Issue Provider
324
+
325
+ DevClaw uses an `IssueProvider` interface (`lib/providers/provider.ts`) to abstract issue tracker operations. The provider is auto-detected from the git remote URL.
326
+
327
+ **Supported providers:**
328
+
329
+ | Provider | CLI | Detection |
330
+ |---|---|---|
331
+ | GitHub | `gh` | Remote contains `github.com` |
332
+ | GitLab | `glab` | Remote contains `gitlab` |
333
+
334
+ **Planned:** Jira (via REST API)
335
+
336
+ **Source:** [`lib/providers/index.ts`](../lib/providers/index.ts)
@@ -0,0 +1,120 @@
1
+ # The Management Science Behind DevClaw
2
+
3
+ ## Why delegation theory matters for AI orchestration
4
+
5
+ Every developer who's tried to use AI agents for real work hits the same wall. The agent _can_ write code — but reliably managing a backlog, tracking state, coordinating handoffs, and knowing when to escalate? That's a different problem entirely. It's not a coding problem. It's a management problem.
6
+
7
+ DevClaw exists because of a gap that management theorists identified decades ago: the difference between someone being _able_ to do work and someone _reliably delivering_ work without constant supervision. The entire plugin is, at its core, an encoded delegation framework. This article traces the management principles behind the design and explores what they teach us about saving time for the person behind the keyboard.
8
+
9
+ ---
10
+
11
+ ## The delegation gap
12
+
13
+ In 1969, Paul Hersey and Ken Blanchard published what would become Situational Leadership Theory. The central idea is deceptively simple: the way you delegate should match the capability and reliability of the person doing the work. You don't hand an intern the system architecture redesign. You don't ask your principal engineer to rename a CSS class.
14
+
15
+ DevClaw's level selection does exactly this. When a task comes in, the plugin routes it to the cheapest model that can handle it:
16
+
17
+ | Complexity | Level | Analogy |
18
+ | -------------------------------- | -------- | --------------------------- |
19
+ | Simple (typos, renames, copy) | Junior | The intern — just execute |
20
+ | Standard (features, bug fixes) | Medior | Mid-level — think and build |
21
+ | Complex (architecture, security) | Senior | The architect — design and reason |
22
+ | Review | Reviewer | Independent code reviewer |
23
+
24
+ This isn't just cost optimization. It mirrors what effective managers do instinctively: match the delegation level to the task, not to a fixed assumption about the delegate.
25
+
26
+ ## Management by exception
27
+
28
+ Classical management theory — later formalized by Bernard Bass in his work on Transformational Leadership — introduced a concept called Management by Exception (MBE). The principle: a manager should only be pulled back into a workstream when something deviates from the expected path.
29
+
30
+ DevClaw's task lifecycle is built on this. The orchestrator delegates a task via `work_start`, then steps away. It only re-engages in three scenarios:
31
+
32
+ 1. **DEV completes work** → The label moves to `To Test`. The scheduler dispatches QA on the next tick. No orchestrator involvement needed.
33
+ 2. **QA passes** → The issue closes. Pipeline complete.
34
+ 3. **QA fails** → The label moves to `To Improve`. The scheduler dispatches DEV on the next tick. The orchestrator may need to adjust the model level.
35
+ 4. **QA refines** → The task enters a holding state that _requires human decision_. This is the explicit escalation boundary.
36
+
37
+ The "refine" state is the most interesting from a delegation perspective. It's a conscious architectural decision that says: some judgments should not be automated. When the QA agent determines that a task needs rethinking rather than just fixing, it escalates to the only actor who has the full business context — the human.
38
+
39
+ This is textbook MBE. The person behind the keyboard isn't monitoring every task. They're only pulled in when the system encounters something beyond its delegation authority.
40
+
41
+ ## Span of control through standardization
42
+
43
+ Henry Mintzberg's work on organizational structure identified five coordination mechanisms. The one most relevant to DevClaw is **standardization of work processes** — when coordination happens not through direct supervision but through predetermined procedures that everyone follows.
44
+
45
+ DevClaw enforces a single, fixed lifecycle for every task across every project:
46
+
47
+ ```
48
+ Planning → To Do → Doing → To Test → Testing → Done
49
+ ↘ To Improve → Doing (fix cycle)
50
+ ↘ Refining → (human decision)
51
+ ```
52
+
53
+ Every label transition, state update, and audit log entry happens atomically inside the plugin. The orchestrator agent cannot skip a step, forget a label, or corrupt session state — because those operations are deterministic code, not instructions an LLM follows imperfectly.
54
+
55
+ This is what allows a single orchestrator to manage multiple projects simultaneously. Management research has long debated the ideal span of control — typically cited as 5-9 direct reports for knowledge work. DevClaw sidesteps the constraint entirely by making every project follow identical processes. The orchestrator doesn't need to remember how Project A works versus Project B. They all work the same way.
56
+
57
+ ## Trust but verify: structural independence
58
+
59
+ One of the most common delegation failures is self-review. You don't ask the person who wrote the code to also approve it — not because they're dishonest, but because they're cognitively biased toward their own work.
60
+
61
+ DevClaw enforces structural separation between development and review by design:
62
+
63
+ - DEV and QA are separate sub-agent sessions with separate state.
64
+ - QA uses the reviewer level, which can be a different model entirely, introducing genuine independence.
65
+ - The review happens after a clean label transition — QA picks up from `To Test`, not from watching DEV work in real time.
66
+
67
+ This mirrors a principle from organizational design: effective controls require independence between execution and verification. It's the same reason companies separate their audit function from their operations.
68
+
69
+ ## The economics of context: session reuse
70
+
71
+ Ronald Coase won a Nobel Prize for explaining why firms exist: transaction costs. Every time you go to the market to hire someone for a task, you pay search costs, negotiation costs, and onboarding costs. Firms exist because keeping people on staff reduces these repeated costs.
72
+
73
+ DevClaw applies the same logic to AI sessions. Spawning a new sub-agent session costs approximately 50,000 tokens of context loading — the agent needs to read the full codebase before it can do useful work. That's the onboarding cost.
74
+
75
+ The plugin tracks session keys across task completions. When a DEV finishes task A and task B is ready on the same project, DevClaw detects the existing session and reuses it instead of spawning a new one. No re-onboarding. No context reload.
76
+
77
+ In management terms: keep your team stable. Reassigning the same person to the next task on their project is almost always cheaper than bringing in someone new — even if the new person is theoretically better qualified.
78
+
79
+ ## The real time savings
80
+
81
+ Here's what delegation theory reveals about where DevClaw actually saves time. It's not where most people think.
82
+
83
+ The obvious saving is execution time: AI writes code faster than a human. But that's the smaller gain. The larger saving comes from a concept psychologists call **decision fatigue** — the cumulative cognitive cost of making choices throughout a day.
84
+
85
+ Without DevClaw, every task requires a human to make a series of small decisions:
86
+
87
+ - Which model should handle this?
88
+ - Is the DEV session still alive, or do I need a new one?
89
+ - What label should this issue have now?
90
+ - Did I update the state file?
91
+ - Did I log this transition?
92
+ - Is the QA session free, or is it still working on something?
93
+
94
+ None of these decisions are hard. But they accumulate. Each one consumes a small amount of the same cognitive resource you need for the decisions that actually matter — product direction, architecture choices, business priorities.
95
+
96
+ DevClaw eliminates entire categories of decisions by making them deterministic. The plugin picks the model. The plugin manages sessions. The plugin transitions labels. The plugin writes audit logs. The person behind the keyboard is left with only the decisions that require human judgment: what to build, what to prioritize, and what to do when QA says "this needs rethinking."
97
+
98
+ This is the deepest lesson from delegation theory: **good delegation isn't about getting someone else to do your work. It's about protecting your attention for the work only you can do.**
99
+
100
+ ## What the theory suggests next
101
+
102
+ Management research points to a few directions that could extend DevClaw's delegation model:
103
+
104
+ **Progressive delegation.** Blanchard's model suggests increasing task complexity for delegates as they prove competent. DevClaw could track QA pass rates per model level and automatically promote — if junior consistently passes QA on borderline tasks, start routing more work to it. This is how good managers develop their people, and it reduces cost over time.
105
+
106
+ **Delegation authority expansion.** The Vroom-Yetton decision model maps when a leader should decide alone versus consulting the team. Currently, sub-agents have narrow authority — they execute tasks but can't restructure the backlog. Selectively expanding this (e.g., allowing a DEV agent to split a task it judges too large) would reduce orchestrator bottlenecks, mirroring how managers gradually give high-performers more autonomy.
107
+
108
+ **Outcome-based learning.** Delegation research emphasizes that the _delegator_ learns from outcomes too. Aggregated metrics — QA fail rate by model level, average cycles to Done, time-in-state distributions — would help both the orchestrator agent and the human calibrate their delegation patterns over time.
109
+
110
+ ---
111
+
112
+ ## Further reading
113
+
114
+ - Hersey, P. & Blanchard, K. (1969). _Management of Organizational Behavior_
115
+ - Bass, B. M. (1985). _Leadership and Performance Beyond Expectations_
116
+ - Mintzberg, H. (1979). _The Structuring of Organizations_
117
+ - Coase, R. H. (1937). _The Nature of the Firm_
118
+ - Appelo, J. (2011). _Management 3.0: Leading Agile Developers, Developing Agile Leaders_
119
+ - Yukl, G. (2013). _Leadership in Organizations_
120
+ - Vroom, V. H. & Yetton, P. W. (1973). _Leadership and Decision-Making_