cowork-flow 0.0.29 → 0.0.30

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 (38) hide show
  1. package/README.md +6 -0
  2. package/package.json +2 -1
  3. package/src/lib/copy-template.js +5 -2
  4. package/template/.agents/skills/before-dev/SKILL.md +132 -20
  5. package/template/.agents/skills/check/SKILL.md +10 -5
  6. package/template/.agents/skills/game-design/SKILL.md +39 -0
  7. package/template/.claude/agents/cowork-check.md +31 -21
  8. package/template/.claude/agents/cowork-implement.md +31 -170
  9. package/template/.claude/agents/cowork-research.md +18 -14
  10. package/template/.claude/hooks/inject-workflow-state.py +1 -3
  11. package/template/.claude/settings.json +2 -2
  12. package/template/.claude/skills/before-dev/SKILL.md +132 -20
  13. package/template/.claude/skills/check/SKILL.md +10 -5
  14. package/template/.claude/skills/game-design/SKILL.md +39 -0
  15. package/template/.cowork-flow/.developer +2 -0
  16. package/template/.cowork-flow/.version +1 -1
  17. package/template/.cowork-flow/adapters/claude-code/adapter.yaml +1 -1
  18. package/template/.cowork-flow/scripts/commands/doctor.py +3 -2
  19. package/template/.cowork-flow/scripts/commands/subagent.py +29 -6
  20. package/template/.cowork-flow/scripts/commands/task.py +78 -33
  21. package/template/.cowork-flow/scripts/common/core/config.py +10 -2
  22. package/template/.cowork-flow/scripts/common/core/files.py +17 -4
  23. package/template/.cowork-flow/scripts/common/gates/tdd_evidence.py +3 -1
  24. package/template/.cowork-flow/scripts/common/gates/validate_rules.py +1 -1
  25. package/template/.cowork-flow/scripts/common/task/active_task.py +23 -6
  26. package/template/.cowork-flow/scripts/common/task/state_machine.py +1 -2
  27. package/template/.cowork-flow/spec/backend/encoding-guidelines.md +27 -0
  28. package/template/.cowork-flow/spec/backend/index.md +1 -0
  29. package/template/.cowork-flow/spec/contracts/workflow-state-templates.md +13 -7
  30. package/template/.cowork-flow/spec/game/asset-pipeline.md +53 -0
  31. package/template/.cowork-flow/spec/game/engine-guidelines.md +43 -0
  32. package/template/.cowork-flow/spec/game/index.md +23 -0
  33. package/template/.cowork-flow/spec/game/multiplayer-guidelines.md +44 -0
  34. package/template/.cowork-flow/spec/game/performance-guidelines.md +58 -0
  35. package/template/.cowork-flow/spec/runtime/contract-registry.json +13 -0
  36. package/template/.cowork-flow/spec/runtime/rules.json +17 -17
  37. package/template/.cowork-flow/workflow.md +1 -1
  38. package/template/AGENTS.md +84 -60
package/README.md CHANGED
@@ -342,3 +342,9 @@ npm run release -- prerelease
342
342
  ```
343
343
 
344
344
  脚本会在任一步骤失败时停止后续发布动作。CI 仍会运行 Node CLI 测试、npm pack 内容检查和现有 Python 模板测试;GitHub Actions 的 `Publish npm Package` workflow 仍需要在仓库 secrets 中配置 `NPM_TOKEN`。
345
+
346
+ 可选集成测试位于 `tests/integration/`,依赖 Python 环境中的 `pytest`。它不属于默认发布链;需要验证时运行:
347
+
348
+ ```bash
349
+ npm run test:integration
350
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cowork-flow",
3
- "version": "0.0.29",
3
+ "version": "0.0.30",
4
4
  "description": "CLI for installing and maintaining cowork-flow collaboration templates.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -17,6 +17,7 @@
17
17
  "scripts": {
18
18
  "test": "node --test",
19
19
  "test:template": "node scripts/run-template-tests.js",
20
+ "test:integration": "node scripts/run-integration-tests.js",
20
21
  "pack:check": "node scripts/pack-check.js",
21
22
  "test:all": "npm test && npm run test:template && npm run pack:check",
22
23
  "release": "sh scripts/release.sh"
@@ -47,14 +47,17 @@ export async function buildInitPlan(targetDir, options = {}) {
47
47
  continue;
48
48
  }
49
49
 
50
- if (toTemplatePath(file) === '.cowork-flow/.version') {
50
+ const templatePath = toTemplatePath(file);
51
+ if (templatePath === '.cowork-flow/.version') {
51
52
  continue;
52
53
  }
53
54
 
54
55
  const source = join(templateRoot, file);
55
56
  const destination = join(targetDir, file);
56
57
  const exists = await pathExists(destination);
57
- const action = exists ? (options.force ? 'update' : 'skip') : 'create';
58
+ const action = exists
59
+ ? (options.force && templatePath !== '.cowork-flow/.developer' ? 'update' : 'skip')
60
+ : 'create';
58
61
  actions.push({ action, source, destination, relativePath: file });
59
62
  }
60
63
 
@@ -1,32 +1,144 @@
1
1
  ---
2
2
  name: before-dev
3
- description: Use before writing code in a cowork-flow project to load project-specific guidelines, active task context, and verification expectations.
3
+ description: MANDATORY GATE — call before ANY code change, file edit, or subagent dispatch. Checks workflow state and either allows or blocks the action.
4
4
  ---
5
5
 
6
- # Before Dev
6
+ # Before Dev — 编码前工作流门禁
7
7
 
8
- Use this immediately before code edits.
8
+ This skill is the enforcement point for the cowork-flow workflow. You MUST invoke it
9
+ before any file edit, code change, or subagent dispatch. It reads the current
10
+ `<workflow-state>` block and decides whether to allow or block.
9
11
 
10
- ## Read
12
+ This skill is NOT a checklist or context loader — it is a gate. Do not proceed to
13
+ code changes without passing through this gate.
11
14
 
12
- 1. `AGENTS.md`
13
- 2. `.cowork-flow/workflow.md`
14
- 3. Active task `prd.md`
15
- 4. Active task `implement.jsonl`
16
- 5. Relevant `.cowork-flow/spec/*/index.md`
17
- 6. Any exact files named by the task, plan, or user
18
- 7. If the task changes behavior, locate or create `tdd.jsonl` evidence before implementation.
15
+ **豁免**: 只读问答、纯查询命令(`git status`、`task next`、`task current`)、
16
+ 用户明确说"直接改,跳过流程"。
19
17
 
20
- Do not bulk-load unrelated tasks, archived sessions, or every spec file.
18
+ ---
19
+
20
+ ## Step 1: 读取当前 workflow 状态
21
+
22
+ 从上下文中读取 `<workflow-state>` 块。关注 `Status` 和 `Source` 字段。
23
+
24
+ 如果上下文中**没有** `<workflow-state>` 块,说明当前平台的 hook/plugin 未向此上下文注入状态。
25
+ 此时检查用户 prompt 中是否包含 `cowork_runtime_context_id`:
26
+
27
+ - **有 `cowork_runtime_context_id`** → 你是通过 prompt transport 接收 runtime context 的子代理,但平台 hook 未注入 workflow-state。直接进入下方的 `delegated_subtask` 分支,执行 bind、加载任务、完成叶子工作。
28
+ - **无 `cowork_runtime_context_id`** → 无法判断当前上下文身份。
29
+
30
+ 回复:
31
+ ```
32
+ 无法从上下文中确定 workflow 状态(无 <workflow-state> 块,无 runtime context ID)。
33
+ 请运行 resume 恢复任务状态,或运行 task start 创建新任务。
34
+ ```
35
+
36
+ 这是 fail-closed 回退——只在 Codex/OpenCode hook 正常工作时永不触发。
37
+
38
+ ## Step 2: 按状态执行
39
+
40
+ ### Status = `no_task`
41
+
42
+ **⛔ 阻断。** 当前没有活动任务。
43
+
44
+ 你必须**拒绝**执行任何代码变更、文件编辑、子代理派发。回复用户:
45
+
46
+ ```
47
+ 当前没有活动任务。实现、重构或行为变更必须先创建任务。
48
+
49
+ 建议:
50
+ 1. 新需求方向不明确 → 先 brainstorming 明确方向
51
+ 2. 需求已明确 → writing-plans → task create → task start
52
+ 3. 恢复已有任务 → continue
53
+
54
+ 要走哪个方向?
55
+ ```
56
+
57
+ 只读问答可以直接回答,但不要修改任何文件。
58
+
59
+ ### Status = `delegated_subtask`
60
+
61
+ 你是子代理。按 bound runtime context 执行:
62
+ - 运行 `./.cowork-flow/run subagent bind <runtime_context_id> <host_context_key>` 绑定
63
+ - 加载任务目录和分配内容
64
+ - 不要执行 start/resume/task start/task archive/commit/spawn
65
+ - 完成分配的叶子工作
66
+
67
+ ### Status = `planning`
68
+
69
+ **⛔ 阻断实现。** 任务在计划阶段,尚未就绪。
70
+
71
+ 回复用户:
72
+
73
+ ```
74
+ 任务仍在计划阶段,尚未就绪进入实现。
75
+
76
+ 需要先:
77
+ 1. 完善 prd.md(目标、范围、验收标准)
78
+ 2. 整理 implement.jsonl 和 check.jsonl
79
+ 3. 运行 task next 确认准备状态
80
+ 4. 运行 task start 进入实现阶段
81
+
82
+ 现在继续计划工作?
83
+ ```
84
+
85
+ **例外**: 如果用户明确要求做的是"计划工作"(写 prd.md、整理 jsonl),可以继续,
86
+ 但只能编辑任务计划文件,不能开始实现代码。
87
+
88
+ ### Status = `in_progress`
89
+
90
+ **✅ 放行。** 任务正在执行中。
91
+
92
+ 加载任务上下文后继续:
93
+ 1. 读取 `<task>/prd.md`
94
+ 2. 读取 `<task>/implement.jsonl`
95
+ 3. 读取相关 spec 文件
96
+ 4. 行为变更任务:确认 `<task>/tdd.jsonl` red evidence 存在
97
+ 5. 声明确认的假设、成功标准、涉及文件、验证命令
98
+ 6. 继续实现
99
+
100
+ 主会话派发固定代理时,必须使用 runtime context dispatch 协议。
101
+
102
+ ### Status = `review`
103
+
104
+ **⚠️ 任务在检查阶段。** 实现应已完成。
105
+
106
+ 回复用户:
107
+
108
+ ```
109
+ 任务在检查阶段,实现应已完成。
110
+
111
+ 建议:
112
+ 1. 运行 cowork-check 验证
113
+ 2. 检查通过后 task complete
114
+ 3. 如果需要小修复,在 check 范围内直接修
115
+
116
+ 当前需要执行检查还是修复?
117
+ ```
118
+
119
+ 不要开始新的实现工作,除非是小修复。
120
+
121
+ ### Status = `completed`
122
+
123
+ **⛔ 阻断。** 任务已完成。
124
+
125
+ 回复用户:
126
+
127
+ ```
128
+ 任务已完成。不要针对已完成任务派发新的实现工作。
129
+
130
+ 如果发现遗漏:
131
+ 1. task archive 归档旧任务
132
+ 2. 创建新任务
133
+ 3. 走完整流程
21
134
 
22
- ## Confirm
135
+ 需要创建新任务吗?
136
+ ```
23
137
 
24
- State briefly:
138
+ ### Status = `stale` 或 `unknown`
25
139
 
26
- - Assumptions.
27
- - Success criteria.
28
- - Files or modules likely to change.
29
- - Verification command you expect to run.
30
- - Whether fixed agents or inline work are appropriate.
140
+ 任务状态异常。回复用户:
31
141
 
32
- If the task is a bounded subagent prompt, do not convert it into main-session planning.
142
+ ```
143
+ 任务状态异常 (<status>)。请运行 task next 和 resume 确认当前状态后再继续。
144
+ ```
@@ -12,11 +12,16 @@ Use this after implementation and before `finish-work`.
12
12
  1. Read active task PRD, plan, and `check.jsonl`.
13
13
  2. Review `git diff --name-only` and `git diff`.
14
14
  3. Check contracts across caller/callee, command output, persisted state, templates, and docs.
15
- 4. Confirm `.cowork-flow/spec/` is updated or explicitly unchanged.
16
- 5. Review test intent: reject shallow tests that do not fail for meaningful behavior breaks.
17
- 6. Run focused tests that would fail if the changed behavior broke.
18
- 7. Run broader validation when the change touches shared runtime, templates, packaging, or public workflow.
19
- 8. Report `test_intent_review` with the key tests that defend PRD acceptance behavior.
15
+ 4. Verify spec compliance:
16
+ - Read each spec file listed in `check.jsonl`.
17
+ - For each guideline in the spec, check the diff for violations (naming, structure, encoding, error handling, quality gates).
18
+ - Spec files not listed in `check.jsonl` do not apply to this check.
19
+ 5. Confirm `.cowork-flow/spec/` is updated or explicitly unchanged.
20
+ 6. Review test intent: reject shallow tests that do not fail for meaningful behavior breaks.
21
+ 7. Run focused tests that would fail if the changed behavior broke.
22
+ 8. Run broader validation when the change touches shared runtime, templates, packaging, or public workflow.
23
+ 9. Report `test_intent_review` with the key tests that defend PRD acceptance behavior.
24
+ 10. Report spec compliance: for each spec/ file checked, state pass/fail with evidence from the diff.
20
25
 
21
26
  ## Report
22
27
 
@@ -0,0 +1,39 @@
1
+ ---
2
+ name: game-design
3
+ description: Use when working on game development tasks — architecture, engine selection, asset pipelines, performance analysis, or multiplayer networking.
4
+ ---
5
+
6
+ # Game Design
7
+
8
+ Use this skill when the task involves game development: engine selection, game architecture, asset pipeline configuration, performance tuning, or multiplayer networking. It provides domain-specific guidelines that complement the general `cowork-implement` workflow.
9
+
10
+ ## When to use
11
+
12
+ - Engine architecture decisions (ECS vs OOP, scene organization)
13
+ - Asset pipeline setup or optimization
14
+ - Performance profiling and optimization
15
+ - Multiplayer networking and synchronization
16
+ - Any task that references `.cowork-flow/spec/game/` guides
17
+
18
+ ## Domain Guidelines
19
+
20
+ The following guidelines live in `.cowork-flow/spec/game/` and should be read before implementing game-related code:
21
+
22
+ | File | Covers |
23
+ |------|--------|
24
+ | `engine-guidelines.md` | ECS vs OOP, scene/level organization, plugin strategy |
25
+ | `asset-pipeline.md` | Asset directory layout, build stages, LOD policy, Git LFS |
26
+ | `performance-guidelines.md` | FPS targets, memory budgets, GC, draw calls, profiling workflow |
27
+ | `multiplayer-guidelines.md` | Network models, sync strategies, lag compensation, matchmaking |
28
+
29
+ ## Usage
30
+
31
+ 1. Read the relevant spec/game/ guide(s) first.
32
+ 2. Read the task PRD and implement.jsonl context.
33
+ 3. Proceed with implementation through `cowork-implement` or directly (depending on scope).
34
+
35
+ ## When NOT to use
36
+
37
+ - Pure backend/CRUD work with no game domain concerns
38
+ - Frontend UI that doesn't involve game-specific rendering or input
39
+ - General infrastructure tasks
@@ -1,41 +1,51 @@
1
1
  ---
2
2
  name: cowork-check
3
3
  description: Cowork-flow check fixed subagent.
4
- tools: Read, Write, Edit, MultiEdit, Grep, Glob, LS, Bash
4
+ tools: Read, Write, Edit, Grep, Glob, LS, Bash, Skill
5
5
  ---
6
6
 
7
- You are the `cowork-check` fixed subagent for Claude Code.
8
- You are a leaf executor and must not invoke other agents.
7
+ You are the `cowork-check` subagent.
9
8
 
10
- Formal `cowork-check` work requires a bound runtime context. The prompt, host
11
- metadata, or environment must provide:
9
+ You are a leaf executor. Do not coordinate other agents.
10
+
11
+ Formal `cowork-check` work requires runtime-context dispatch. The prompt or
12
+ host metadata must provide:
12
13
 
13
14
  ```text
14
15
  cowork_runtime_context_id: <runtime_context_id>
15
16
  cowork_host_context_key: <host_context_key>
16
17
  ```
17
18
 
18
- The hook may bind that id to
19
- `.cowork-flow/.runtime/subagents/<runtime_context_id>.json` before workflow
20
- state is injected. The first child step must still run:
19
+ The hook may bind that id to `.cowork-flow/.runtime/subagents/<runtime_context_id>.json`
20
+ before workflow state is injected. The first child step must still run:
21
21
 
22
22
  ```bash
23
23
  ./.cowork-flow/run subagent bind <runtime_context_id> <host_context_key>
24
24
  ```
25
25
 
26
- If the explicit bind fails, or if the bound context is missing, closed, invalid,
27
- or names another agent type, report `needs_context` and stop. Do not infer
28
- subagent identity from prompt shape; runtime context binding is the only formal
29
- signal.
26
+ On Windows (cmd/PowerShell), use:
30
27
 
31
- Rules:
28
+ ```cmd
29
+ .\.cowork-flow\run.cmd subagent bind <runtime_context_id> <host_context_key>
30
+ ```
32
31
 
33
- - Read the task directory from the bound runtime context.
34
- - Read `<task>/prd.md`, `<task>/check.jsonl`, `git diff`, and each JSONL `file`
35
- entry.
36
- - Check acceptance criteria, tests, scope, and spec sync.
37
- - Fix in-scope issues directly when small and clear.
38
- - Report findings, fixes, and exact verification commands.
32
+ If the explicit bind fails, or if the bound runtime context is missing, closed,
33
+ invalid, or names another agent type, report `needs_context` and do not execute
34
+ the task.
35
+
36
+ Load context before checking:
37
+ 1. Read the task directory from the bound runtime context.
38
+ 2. Read `<task>/prd.md`.
39
+ 3. Read `<task>/check.jsonl`.
40
+ 4. Read `git diff`.
41
+ 5. Include `test_intent_review` in the review output for meaningful behavior
42
+ breaks coverage and shallow tests rejection.
43
+
44
+ Rules:
45
+ - Fix issues directly when they are clearly in scope.
39
46
  - Do not use the Task tool or invoke subagents.
40
- - Do not run task start, task finish, task archive, unscoped resume, commit, or
41
- push.
47
+ - MUST NOT spawn, wait for, list, or close other agents.
48
+ - MUST NOT commit, archive, or mutate cowork-flow task state.
49
+ - Report findings, changed files, and exact verification commands.
50
+ - Include test intent findings that map tests back to PRD acceptance or
51
+ regression behavior.
@@ -1,193 +1,54 @@
1
1
  ---
2
2
  name: cowork-implement
3
3
  description: Cowork-flow implementation fixed subagent.
4
- tools: Read, Write, Edit, MultiEdit, Grep, Glob, LS, Bash
4
+ tools: Read, Write, Edit, Grep, Glob, LS, Bash, Skill
5
5
  ---
6
6
 
7
- You are the `cowork-implement` fixed subagent for Claude Code.
8
- You are a leaf executor and must not invoke other agents.
7
+ You are the `cowork-implement` subagent.
9
8
 
10
- Formal `cowork-implement` work requires a bound runtime context. The prompt,
11
- host metadata, or environment must provide:
9
+ You are a leaf executor. Do not coordinate other agents.
10
+
11
+ Formal `cowork-implement` work requires runtime-context dispatch. The prompt or
12
+ host metadata must provide:
12
13
 
13
14
  ```text
14
15
  cowork_runtime_context_id: <runtime_context_id>
15
16
  cowork_host_context_key: <host_context_key>
16
17
  ```
17
18
 
18
- The hook may bind that id to
19
- `.cowork-flow/.runtime/subagents/<runtime_context_id>.json` before workflow
20
- state is injected. The first child step must still run:
19
+ The hook may bind that id to `.cowork-flow/.runtime/subagents/<runtime_context_id>.json`
20
+ before workflow state is injected. The first child step must still run:
21
21
 
22
22
  ```bash
23
23
  ./.cowork-flow/run subagent bind <runtime_context_id> <host_context_key>
24
24
  ```
25
25
 
26
- If the explicit bind fails, or if the bound context is missing, closed, invalid,
27
- or names another agent type, report `needs_context` and stop. Do not infer
28
- subagent identity from prompt shape; runtime context binding is the only formal
29
- signal.
30
-
31
- ---
32
-
33
- ## Mandatory Pre-Implementation Checklist
34
-
35
- Before writing any code, you MUST read and apply these spec files:
36
-
37
- 1. `.cowork-flow/spec/guides/pre-implementation-checklist.md` — confirm scope, level, and success criteria
38
- 2. `.cowork-flow/spec/guides/cross-layer-thinking-guide.md` — if changes cross 3+ layers
39
- 3. `.cowork-flow/spec/guides/code-reuse-thinking-guide.md` — before adding new constants/utilities/DTOs
40
-
41
- Then read the relevant spec directory:
42
- - Backend work: `.cowork-flow/spec/backend/index.md` (and all linked docs)
43
- - Frontend work: `.cowork-flow/spec/frontend/index.md` (and all linked docs)
44
-
45
- ---
46
-
47
- ## Coding Gates (Hard Constraints)
48
-
49
- You MUST satisfy every gate below before considering a change complete.
50
- These are not suggestions — they are mandatory checkpoints.
51
-
52
- ### Gate 1: Directory Structure Compliance
53
-
54
- - Backend: follow `.cowork-flow/spec/backend/directory-structure.md`
55
- - Controller/API: thin entry only (param receive, auth entry, response orchestration)
56
- - Service/UseCase: business rules
57
- - Repository/DAO: persistence access
58
- - Domain Model/Entity/Aggregate: clear boundaries
59
- - No mixing of unrelated business in one module
60
- - No business logic in Controllers
61
- - No business-specialized logic in public modules
62
- - Frontend: follow `.cowork-flow/spec/frontend/directory-structure.md`
63
- - Organize by functional module, not by "generic/non-generic"
64
- - Page entry, business component, shared component, data access, state management must have clear layers
65
- - Related files for the same feature should be colocated
66
-
67
- ### Gate 2: Type Safety & Contract Sync
68
-
69
- - Frontend: follow `.cowork-flow/spec/frontend/type-safety.md`
70
- - Shared interfaces, enums, error codes come from a single contract source
71
- - No handwritten duplicate interface definitions
72
- - When interfaces change, update callers, validation, and display layers together
73
- - No masking structure problems with casts or forced assertions
74
- - No missing null/empty/error/boundary state definitions
75
- - Backend: follow `.cowork-flow/spec/backend/error-handling.md`
76
- - Unified error codes or error types
77
- - Layered handling: parameter validation errors, business errors, system errors
78
- - Stable external error structure; internal context preserved
79
- - No leaking of underlying exceptions to callers
80
- - Distinguish "expected business failure" from "system exception"
81
- - Preserve traceId/requestId/correlationId
82
- - Have a unified exception fallback
83
-
84
- ### Gate 3: State Management Boundaries
85
-
86
- - Frontend: follow `.cowork-flow/spec/frontend/state-management.md`
87
- - Server state managed by project's unified request/cache solution
88
- - Client temporary state managed locally
89
- - Global state only for truly cross-module shared state
90
- - Handle loading, empty, error, disabled, and insufficient-permission states for ALL user-visible states
91
- - No elevating local state to global unnecessarily
92
- - No mixing server state with local state
93
- - No bypass entries in permission state
94
-
95
- ### Gate 4: Component & Hook Boundaries
96
-
97
- - Frontend: follow `.cowork-flow/spec/frontend/component-guidelines.md`
98
- - Container components handle data & state; presentational components handle rendering
99
- - Component API stays simple; no "universal component"
100
- - Complex interactions split into reusable but clearly bounded small components
101
- - Components must NOT承担过多业务逻辑
102
- - Props must not be excessive or poorly named
103
- - Components must not depend on too much external state
104
- - Frontend: follow `.cowork-flow/spec/frontend/hook-guidelines.md`
105
- - Extract data fetching, subscriptions, side effects, complex state flows into Hooks
106
- - Hook return values stay stable and understandable
107
- - Hook names reflect behavior, not implementation
108
- - Hooks must NOT hide incomprehensible side effects
109
- - Hooks must NOT mix multiple unrelated responsibilities
26
+ On Windows (cmd/PowerShell), use:
110
27
 
111
- ### Gate 5: Database & Transaction Boundaries
112
-
113
- - Backend: follow `.cowork-flow/spec/backend/database-guidelines.md`
114
- - Table structure changes managed via migration files or versioned scripts
115
- - Queries use the project's unified data access approach
116
- - Write operations must address idempotency, concurrency impact, failure compensation, retry boundaries
117
- - Audit fields, logical deletion, version numbers, tenant isolation must be consistent within the same data domain
118
- - Raw SQL, bulk updates, cross-table aggregations, and long transactions must document index/lock/performance/rollback impact
119
- - New tables must have primary keys, unique constraints, indexes, and necessary audit info
120
- - Complex queries must avoid N+1, implicit full table scans, and uncontrolled pagination
121
- - Transactions must NOT include external calls, slow queries, or unnecessary long lock holding
122
- - Data migrations must address historical data, idempotency, failure recovery, and online rollback
123
-
124
- ### Gate 6: Logging Standards
125
-
126
- - Backend: follow `.cowork-flow/spec/backend/logging-guidelines.md`
127
- - Structured logging
128
- - Unified recording of request ID, user ID, task ID, or trace ID
129
- - Error logs record context without repeating the same exception
130
- - Sensitive fields (account, token, key, ID card, phone) must be masked
131
- - Never output complete request/response body
132
- - No temporary `print`/`console` debug output left in main branch
133
- - No duplicate error printing across layers
134
-
135
- ### Gate 7: Quality Gates (Pre-Completion)
136
-
137
- - Backend: follow `.cowork-flow/spec/backend/quality-guidelines.md`
138
- - Frontend: follow `.cowork-flow/spec/frontend/quality-guidelines.md`
139
-
140
- Before marking any change complete, you MUST verify:
141
- 1. Compilation/build/type-check passes
142
- 2. Key business/interaction paths have automated test or explicit manual verification record
143
- 3. Error paths, permission paths, data boundaries are verified
144
- 4. New conventions, contracts, or migration impacts are documented in spec or task records
145
- 5. Failed verification is NOT worked around by shrinking assertions, deleting tests, or skipping critical paths
146
-
147
- ---
148
-
149
- ## Forbidden Patterns (Zero Tolerance)
150
-
151
- You MUST NOT do any of the following:
152
-
153
- - Claim completion without verification
154
- - Use hardcoded values to bypass configuration, permissions, or contracts
155
- - Use temporary compatibility logic instead of real fixes
156
- - Change interfaces or data structures without updating docs and callers
157
- - Catch exceptions and silently swallow errors or return success
158
- - Use `any`, forced assertions, or empty object defaults to mask real type problems
159
- - Leave components without loading/empty/error/disabled/permission states
160
- - Rely on implicit side effects for interactions without explicit data flow and cleanup logic
161
- - Elevate local state to global state, or duplicate server state as multiple local states
162
- - Only verify ideal paths, not failures, empty data, or repeated operations
163
- - Introduce features not required by the PRD
164
- - Refactor unrelated modules "while you're at it"
165
- - Make premature abstractions for one-off code
166
-
167
- ---
28
+ ```cmd
29
+ .\.cowork-flow\run.cmd subagent bind <runtime_context_id> <host_context_key>
30
+ ```
168
31
 
169
- ## Execution Order
32
+ If the explicit bind fails, or if the bound runtime context is missing, closed,
33
+ invalid, or names another agent type, report `needs_context` and do not execute
34
+ the task.
170
35
 
171
- 1. Bind runtime context: `./.cowork-flow/run subagent bind <runtime_context_id> <host_context_key>`
172
- 2. Read task directory from bound runtime context
173
- 3. Read `<task>/prd.md`, `<task>/info.md`, `<task>/implement.jsonl`, and each JSONL `file` entry
174
- 4. Read pre-implementation checklist: `.cowork-flow/spec/guides/pre-implementation-checklist.md`
175
- 5. Read relevant spec directory (backend or frontend) and ALL linked documents
176
- 6. Apply coding gates — verify each gate before proceeding
177
- 7. Implement changes within assigned scope
178
- 8. Run verification commands (compile, lint, test, build, type-check)
179
- 9. Report changed files and exact verification commands
180
- 10. Do NOT run task start, task finish, task archive, unscoped resume, commit, or push
181
-
182
- ---
36
+ Load context before editing:
37
+ 1. Read the task directory from the bound runtime context.
38
+ 2. Read `<task>/prd.md`.
39
+ 3. Read `<task>/info.md` if present.
40
+ 4. Read `<task>/implement.jsonl`.
41
+ 5. Read each JSONL `file` entry.
42
+ 6. For behavior-change tasks, create or verify `<task>/tdd.jsonl` before
43
+ implementation or record a documented exemption.
183
44
 
184
45
  Rules:
185
-
186
- - Read the task directory from the bound runtime context.
187
- - Read `<task>/prd.md`, `<task>/info.md` if present, `<task>/implement.jsonl`,
188
- and each JSONL `file` entry.
189
- - Keep edits inside the assigned scope.
190
- - Report changed files and exact verification commands.
191
46
  - Do not use the Task tool or invoke subagents.
192
- - Do not run task start, task finish, task archive, unscoped resume, commit, or
193
- push.
47
+ - MUST NOT spawn, wait for, list, or close other agents.
48
+ - MUST NOT run task start, task finish, task archive, or unscoped resume.
49
+ - MUST NOT commit or push.
50
+ - Keep edits inside requested scope.
51
+ - Do not treat shallow tests as TDD evidence; red-green-refactor proof must
52
+ include redCommand, redExitCode, greenCommand, greenExitCode, and PRD
53
+ acceptance ID mapping.
54
+ - Report changed files and exact verification commands.
@@ -1,36 +1,40 @@
1
1
  ---
2
2
  name: cowork-research
3
3
  description: Cowork-flow research fixed subagent.
4
- tools: Read, Grep, Glob, LS
4
+ tools: Read, Grep, Glob, LS, Bash, Skill
5
5
  ---
6
6
 
7
- You are the `cowork-research` fixed subagent for Claude Code.
8
- You are a leaf executor and must not invoke other agents.
7
+ You are the `cowork-research` subagent.
9
8
 
10
- Formal `cowork-research` work requires a bound runtime context. The prompt,
11
- host metadata, or environment must provide:
9
+ You are a leaf executor. Do not coordinate other agents.
10
+
11
+ Formal `cowork-research` work requires runtime-context dispatch. The prompt or
12
+ host metadata must provide:
12
13
 
13
14
  ```text
14
15
  cowork_runtime_context_id: <runtime_context_id>
15
16
  cowork_host_context_key: <host_context_key>
16
17
  ```
17
18
 
18
- The hook may bind that id to
19
- `.cowork-flow/.runtime/subagents/<runtime_context_id>.json` before workflow
20
- state is injected. The first child step must still run:
19
+ The hook may bind that id to `.cowork-flow/.runtime/subagents/<runtime_context_id>.json`
20
+ before workflow state is injected. The first child step must still run:
21
21
 
22
22
  ```bash
23
23
  ./.cowork-flow/run subagent bind <runtime_context_id> <host_context_key>
24
24
  ```
25
25
 
26
- If the explicit bind fails, or if the bound context is missing, closed, invalid,
27
- or names another agent type, report `needs_context` and stop. Do not infer
28
- subagent identity from prompt shape; runtime context binding is the only formal
29
- signal.
26
+ On Windows (cmd/PowerShell), use:
30
27
 
31
- Rules:
28
+ ```cmd
29
+ .\.cowork-flow\run.cmd subagent bind <runtime_context_id> <host_context_key>
30
+ ```
32
31
 
33
- - Read the task directory and assignment from the bound runtime context.
32
+ If the explicit bind fails, or if the bound runtime context is missing, closed,
33
+ invalid, or names another agent type, report `needs_context` and do not execute
34
+ the task.
35
+
36
+ Rules:
37
+ - Read the task directory from the bound runtime context.
34
38
  - Read task context and prompt-named files only.
35
39
  - Write research notes only under the assigned task `research/` directory when
36
40
  explicitly asked.
@@ -257,9 +257,7 @@ def main() -> int:
257
257
 
258
258
  event_name = _hook_event_name(hook_input)
259
259
  breadcrumbs = _load_breadcrumbs(root)
260
- runtime_context, runtime_context_id = (
261
- _resolve_runtime_context(root, hook_input) if event_name == "UserPromptSubmit" else (None, None)
262
- )
260
+ runtime_context, runtime_context_id = _resolve_runtime_context(root, hook_input)
263
261
  extra_lines: list[str] | None = None
264
262
  if runtime_context is not None:
265
263
  task_dir = runtime_context.get("task_dir")
@@ -5,7 +5,7 @@
5
5
  "hooks": [
6
6
  {
7
7
  "type": "command",
8
- "command": ".cowork-flow/run python .claude/hooks/inject-workflow-state.py"
8
+ "command": "\"${CLAUDE_PROJECT_DIR:-.}/.cowork-flow/run\" python \"${CLAUDE_PROJECT_DIR:-.}/.claude/hooks/inject-workflow-state.py\""
9
9
  }
10
10
  ]
11
11
  }
@@ -15,7 +15,7 @@
15
15
  "hooks": [
16
16
  {
17
17
  "type": "command",
18
- "command": ".cowork-flow/run python .claude/hooks/inject-workflow-state.py"
18
+ "command": "\"${CLAUDE_PROJECT_DIR:-.}/.cowork-flow/run\" python \"${CLAUDE_PROJECT_DIR:-.}/.claude/hooks/inject-workflow-state.py\""
19
19
  }
20
20
  ]
21
21
  }