@temporal-architect/claude-plugin 0.9.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 (77) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +38 -0
  3. package/package.json +37 -0
  4. package/skills/MANIFEST.json +373 -0
  5. package/skills/MANIFEST.md +121 -0
  6. package/skills/temporal-architect/SKILL.md +99 -0
  7. package/skills/temporal-architect/reference/decomposition.md +78 -0
  8. package/skills/temporal-architect-author-go/README.md +16 -0
  9. package/skills/temporal-architect-author-go/SKILL.md +191 -0
  10. package/skills/temporal-architect-author-go/SUBAGENT_ADOPTION.md +161 -0
  11. package/skills/temporal-architect-author-go/reference/activity-call.md +73 -0
  12. package/skills/temporal-architect-author-go/reference/activity-def.md +54 -0
  13. package/skills/temporal-architect-author-go/reference/assignment.md +36 -0
  14. package/skills/temporal-architect-author-go/reference/await-all.md +104 -0
  15. package/skills/temporal-architect-author-go/reference/await-one.md +193 -0
  16. package/skills/temporal-architect-author-go/reference/await-timer.md +35 -0
  17. package/skills/temporal-architect-author-go/reference/close.md +71 -0
  18. package/skills/temporal-architect-author-go/reference/composite-patterns.md +176 -0
  19. package/skills/temporal-architect-author-go/reference/condition.md +56 -0
  20. package/skills/temporal-architect-author-go/reference/control-flow.md +151 -0
  21. package/skills/temporal-architect-author-go/reference/dependency-resolution.md +29 -0
  22. package/skills/temporal-architect-author-go/reference/detach.md +52 -0
  23. package/skills/temporal-architect-author-go/reference/heartbeat.md +84 -0
  24. package/skills/temporal-architect-author-go/reference/nexus-service-def.md +73 -0
  25. package/skills/temporal-architect-author-go/reference/nexus.md +35 -0
  26. package/skills/temporal-architect-author-go/reference/options.md +138 -0
  27. package/skills/temporal-architect-author-go/reference/promise.md +73 -0
  28. package/skills/temporal-architect-author-go/reference/proto-driven.md +197 -0
  29. package/skills/temporal-architect-author-go/reference/query-handler.md +34 -0
  30. package/skills/temporal-architect-author-go/reference/signal-handler.md +73 -0
  31. package/skills/temporal-architect-author-go/reference/three-layer-testing.md +173 -0
  32. package/skills/temporal-architect-author-go/reference/types.md +72 -0
  33. package/skills/temporal-architect-author-go/reference/update-handler.md +64 -0
  34. package/skills/temporal-architect-author-go/reference/worker.md +215 -0
  35. package/skills/temporal-architect-author-go/reference/workflow-call.md +37 -0
  36. package/skills/temporal-architect-author-go/reference/workflow-def.md +45 -0
  37. package/skills/temporal-architect-author-infra/README.md +16 -0
  38. package/skills/temporal-architect-author-infra/SKILL.md +132 -0
  39. package/skills/temporal-architect-author-infra/reference/tcld.md +112 -0
  40. package/skills/temporal-architect-author-infra/reference/terraform.md +125 -0
  41. package/skills/temporal-architect-design/README.md +16 -0
  42. package/skills/temporal-architect-design/SKILL.md +224 -0
  43. package/skills/temporal-architect-design/reference/LANGUAGE.md +5 -0
  44. package/skills/temporal-architect-design/reference/anti-patterns.md +332 -0
  45. package/skills/temporal-architect-design/reference/common-errors.md +88 -0
  46. package/skills/temporal-architect-design/reference/core-principles.md +52 -0
  47. package/skills/temporal-architect-design/reference/design-checklist.md +59 -0
  48. package/skills/temporal-architect-design/reference/namespaces.md +84 -0
  49. package/skills/temporal-architect-design/reference/notation-examples.md +304 -0
  50. package/skills/temporal-architect-design/reference/notation-reference.md +70 -0
  51. package/skills/temporal-architect-design/reference/primitives-reference.md +65 -0
  52. package/skills/temporal-architect-design/reference/project-discovery-subagent.md +80 -0
  53. package/skills/temporal-architect-design/reference/reverse-engineering.md +53 -0
  54. package/skills/temporal-architect-design/reference/twf-conventions.md +43 -0
  55. package/skills/temporal-architect-design/reference/workflow-boundaries.md +43 -0
  56. package/skills/temporal-architect-design/topics/activities-advanced.md +358 -0
  57. package/skills/temporal-architect-design/topics/activities-advanced.twf +107 -0
  58. package/skills/temporal-architect-design/topics/child-workflows.md +347 -0
  59. package/skills/temporal-architect-design/topics/child-workflows.twf +171 -0
  60. package/skills/temporal-architect-design/topics/long-running.md +230 -0
  61. package/skills/temporal-architect-design/topics/long-running.twf +100 -0
  62. package/skills/temporal-architect-design/topics/nexus.md +248 -0
  63. package/skills/temporal-architect-design/topics/nexus.twf +148 -0
  64. package/skills/temporal-architect-design/topics/patterns.md +469 -0
  65. package/skills/temporal-architect-design/topics/patterns.twf +346 -0
  66. package/skills/temporal-architect-design/topics/promises-conditions.md +179 -0
  67. package/skills/temporal-architect-design/topics/promises-conditions.twf +213 -0
  68. package/skills/temporal-architect-design/topics/signals-queries-updates.md +319 -0
  69. package/skills/temporal-architect-design/topics/signals-queries-updates.twf +234 -0
  70. package/skills/temporal-architect-design/topics/task-queues.md +205 -0
  71. package/skills/temporal-architect-design/topics/task-queues.twf +184 -0
  72. package/skills/temporal-architect-design/topics/testing.md +437 -0
  73. package/skills/temporal-architect-design/topics/testing.twf +177 -0
  74. package/skills/temporal-architect-design/topics/timers-scheduling.md +131 -0
  75. package/skills/temporal-architect-design/topics/timers-scheduling.twf +129 -0
  76. package/skills/temporal-architect-design/topics/versioning.md +434 -0
  77. package/skills/temporal-architect-design/topics/versioning.twf +174 -0
@@ -0,0 +1,99 @@
1
+ ---
2
+ name: temporal-architect
3
+ description: Entry point for designing, building, adopting, or evolving Temporal systems — start here. Coordinates the temporal-architect skill set (design, Go authoring, infrastructure): orients the design↔code direction, decomposes a `.twf` design into independently-implementable chunks at contract boundaries, and dispatches the right specialist skills. Use at the start of any Temporal architecture, workflow, worker, or Temporal-adoption task.
4
+ ---
5
+
6
+ # Temporal Architect
7
+
8
+ The front door to the `temporal-architect` skill set. This skill does not design or author directly — it **orients** the work, **decomposes** it at contract boundaries, and **routes** to the specialists:
9
+
10
+ | Skill | Owns |
11
+ |-------|------|
12
+ | `temporal-architect-design` | The `.twf` design (workflows, activities, namespaces, Nexus). Produces/reviews `.twf`; never SDK code. |
13
+ | `temporal-architect-author-go` | Go SDK implementation of a `.twf`. |
14
+ | `temporal-architect-author-infra` | Control-plane provisioning (namespaces, Nexus endpoints, search attributes). Orthogonal to language authoring. |
15
+
16
+ ---
17
+
18
+ ## North Star
19
+
20
+ `.twf` exists to **extend the complexity horizon of AI execution** — to let AI work at *system* scale, not code scale. (You don't cross a country on square-mile maps.) The largest gains in AI-assisted development came from wiring AIs into **deterministic tooling** — compilers, linters, testers. `temporal-architect` is that deterministic harness for **Temporal architecture**: it keeps the AI out of the weeds — error handling, library choices, application-code pedantics — so it can focus on the large scale: **workloads, scaling, reliability, availability**.
21
+
22
+ The product is a **context-protecting harness for the main agent**: fit a bigger problem into the same context window. Decompose at `.twf` contract boundaries, dispatch the heavy authoring to subagents that each see only their chunk, and keep the main context on the architecture. (The "main agent" is not always the *design* agent — sometimes it is authoring or reverse-engineering. Don't assume.)
23
+
24
+ Everything below serves that: protect context, raise the level of abstraction, and resist being dragged back down into code-scale busywork.
25
+
26
+ ---
27
+
28
+ ## Orient — which direction, which situation
29
+
30
+ The design↔code edge is traversed in **two directions**. Identify which one the task needs before doing anything else.
31
+
32
+ - **Direction A — `.twf` → application code** (forward authoring). The steady-state ideal: once a project has a `.twf`, *changes are made in the `.twf` first, then propagated forward* to the authors. Most work lives here.
33
+ - **Direction B — application code → `.twf`** (recovery / reconciliation). Bootstraps a `.twf` from an existing app, and reconciles drift back into the `.twf`.
34
+
35
+ Detect the **situation** cheaply (no subagent needed) and enter the matching path:
36
+
37
+ | Situation | Cheap signal | Path |
38
+ |-----------|--------------|------|
39
+ | **Greenfield** | No `.twf`, no Temporal SDK usage in the repo | Design (A) → author forward |
40
+ | **Existing app, no `.twf`** (dominant adoption path) | Temporal SDK imports / worker code, but no `.twf` | Recover `.twf` (B, design's reverse path) → then forward |
41
+ | **`.twf` exists — implement / evolve** | `.twf` present | Edit the `.twf` first → propagate forward (A) |
42
+ | **Drift** | Code and `.twf` disagree | Reconcile into the `.twf` (B) → then forward (A) |
43
+
44
+ **On drift:** the steady state keeps the `.twf` authoritative, so drift should be rare — but the *hard problem is catching it*. There is no first-class detector yet. Lean on the feedback surfaces that exist: the author skills' build/test verify against the linked implementation, and (for production divergence) sampler-driven `twf graph --history` checks. When drift is found, route the fix **through the `.twf`** (B), then re-author forward — never patch the code and leave the `.twf` stale.
45
+
46
+ Always check for prior artifacts first (existing `.twf`, `DESIGN.md`); the design skill's Orient covers this in depth. The detection-signal style here mirrors `temporal-architect-author-infra`'s Orient.
47
+
48
+ ---
49
+
50
+ ## Decompose — `twf graph chunks`
51
+
52
+ Once a `.twf` exists (or has been recovered), decompose it into independently-implementable units before dispatching. The unit of decomposition is a **contract boundary** — `.twf` *is* the contract — **never finer**.
53
+
54
+ Use **`twf graph chunks`**, which computes the decomposition from the design. **The tool informs; it does not impose** — you decide how to act on it. Its output has two cleanly-typed parts:
55
+
56
+ - **#1 hard boundaries — you MUST dispatch separate subagents across these.** Discovered facts: isolated components today (a `nexusCall` is the cleanest contract cut, cross-namespace by construction), language boundaries later. Every definition lands in exactly one hard chunk.
57
+ - **#2 soft divisions — you MAY use these.** Only emitted for a chunk that exceeds a complexity **ceiling** you instruct: ranked candidate cuts plus an inter-section **dependency DAG**.
58
+
59
+ Other knobs: a **floor** flags chunks too granular for their own subagent (merge them up); loops are collapsed into one chunk and never cut; roots are heuristic. Run `twf graph chunks --help` for the exact flags.
60
+
61
+ **Fallback (pre-tool):** if `twf graph chunks` is unavailable, enumerate chunks by hand from `twf symbols` / the `.twf` — heuristic roots (handler-bearing and Nexus-op-backing workflows, plus any with no inbound call edge) and their reachable children form connected components. Same dispatch logic, coarser input.
62
+
63
+ The detailed protocol for reading the tool's output — hard/soft handling, floor/ceiling, the dependency DAG, selective dispatch against existing code, and contract pinning — is in [reference/decomposition.md](reference/decomposition.md). Read it before dispatching a non-trivial design.
64
+
65
+ ---
66
+
67
+ ## Dispatch — progressive, not a waterfall freeze
68
+
69
+ Dispatch authoring **progressively**, in the dependency-DAG order the decomposition gives you:
70
+
71
+ - **Don't freeze every signature up front.** A global type freeze recreates waterfall's failure modes. Pin contracts rigidly **only** at the hard-boundary / cross-language cuts the decomposition surfaces (these are exactly the expensive-to-renegotiate interfaces). Everywhere else, start from a **loose API suggestion** and let constraints discovered during authoring feed back and refine it.
72
+ - **Don't parallelize everything.** Build independent chunks first, then the now-unblocked dependents — a PERT walk over the dependency DAG, not a blind fan-out.
73
+ - **Only dispatch what needs altering.** The decomposition is over the *design*; the tool doesn't know what's already implemented. For each chunk, resolve its code via the `# impl: <dirs>` link (see the design skill's `twf-conventions.md`) and **skip chunks that are new-free and unchanged** — never spin up an author for a component that doesn't need it. Use the relevant author skill's fast verify (e.g. `author-go`'s `go build`/`go test` on the linked package) as the cheap changed-vs-unchanged signal. A first-class chunk↔impl staleness check does not exist yet.
74
+
75
+ ---
76
+
77
+ ## Route — which skills to load
78
+
79
+ Routing is **advice with a sensible default, not a rigid rule**. Load the minimum that fits the work.
80
+
81
+ **Default:** `temporal-architect-design` + the **one** author for the chunk's language, plus `temporal-architect-author-infra` if the topology needs control-plane resources (it is orthogonal to language authoring).
82
+
83
+ Named exceptions:
84
+
85
+ - **Skip design** when there is no design change — a pure implementation of a settled `.twf`. Load only the author(s).
86
+ - **Design in the main agent.** Because the whole point is an elevated surface to design *from*, the user often wants to be integrated in the design loop. For design-heavy or collaborative work, load `temporal-architect-design` **into the main agent** rather than dispatching it to a subagent. Dispatch authoring to subagents to protect context.
87
+ - **A language boundary wants both authors.** A workflow in one language calling an activity in another is a genuine (not rare) case. Pin the boundary contract once, then prefer **isolated per-language author subagents that exchange only that contract** — this keeps two SDK-language authors out of a single context, where their overlapping vocabulary is *confusable*. Co-loading both is acceptable when the boundary is small and the isolation overhead isn't worth it; the confusability concern is the reason to default to separating them, not a hard prohibition.
88
+
89
+ `@lang` annotations (coming to the spec) will become the explicit dispatch key per chunk — don't over-engineer language routing before then; the heuristic + boundary handling above is enough.
90
+
91
+ ---
92
+
93
+ ## Reference Index
94
+
95
+ | Topic | When to consult | File |
96
+ |-------|-----------------|------|
97
+ | Decomposition + dispatch protocol | Reading `twf graph chunks` output; planning subagent breakout | [decomposition.md](reference/decomposition.md) |
98
+
99
+ The specialist skills carry their own references for design, Go authoring, and infrastructure — load the skill, not its internals, from here.
@@ -0,0 +1,78 @@
1
+ # Decomposition + Dispatch Protocol
2
+
3
+ How to turn a `.twf` design into a dispatch plan for author subagents, using `twf graph chunks`. Read this before breaking out a non-trivial design.
4
+
5
+ The governing rule: **cut at `.twf` contract boundaries, never finer.** `.twf` *is* the contract. The tool **informs; it does not impose** — every output below is input to your judgment, not a command.
6
+
7
+ ## The command
8
+
9
+ Run `twf graph chunks --help` for the exact, current flag set — that help is
10
+ generated from the binary, so it never drifts from this prose. What the flags
11
+ *mean* for dispatch:
12
+
13
+ - `twf graph chunks` (no flags) — emits the **#1 hard partition** (every definition in exactly one chunk) + a per-chunk complexity score + floor-merge recommendations.
14
+ - the **ceiling** flag — additionally emits **#2 soft divisions** (ranked candidate cuts + a dependency DAG) for any chunk scoring over it.
15
+ - the **floor** flag — chunks below it are flagged "too granular for their own subagent."
16
+ - the **by** flag — biases which soft-division strategy is suggested (reachable-subtree, `nexusCall`-boundary, worker, namespace).
17
+
18
+ See [Complexity floor + ceiling](#complexity-floor--ceiling) below for how to choose the thresholds. If the subcommand is absent, use the [manual fallback](#manual-fallback).
19
+
20
+ ## #1 Hard boundaries — MUST dispatch separately
21
+
22
+ Hard boundaries are discovered **facts** about the graph, not suggestions. Dispatch a **separate** author subagent per hard chunk:
23
+
24
+ - **Isolated components** — disconnected pieces of the call structure are independent work.
25
+ - **`nexusCall` cuts** — the cleanest contract boundary (cross-namespace/worker by construction). The Nexus operation signature *is* the contract; pin it.
26
+ - **Language boundaries** — once `@lang` lands, a hard split keyed on per-node language. Until then, infer language from project layout / the user.
27
+
28
+ Each definition belongs to exactly one hard chunk. A node reachable from two roots is reported as **overlap** (listed once, referenced by each root) — implement it once and let both chunks consume it; do not duplicate it across subagents.
29
+
30
+ ## #2 Soft divisions — MAY use
31
+
32
+ Soft divisions appear only when a chunk exceeds the ceiling you set. They are **options** over an oversized chunk:
33
+
34
+ - Treat the **ranked candidate cuts** as suggestions; pick the one that matches a real boundary in the domain, or decline to cut.
35
+ - The **inter-section dependency DAG is the build order.** Author independent sections first, then the sections they unblock. This is the PERT walk — not a blind parallel fan-out.
36
+ - **Loops are never cut.** An SCC-collapsed chunk (workflow-call cycle) is exempt regardless of score — implement it as one unit.
37
+
38
+ ## Complexity floor + ceiling
39
+
40
+ A single deterministic AST-derived score drives both thresholds:
41
+
42
+ - **Floor** — a chunk below the floor is too small to justify its own subagent. Merge it into the chunk that dispatches into it. Don't spin up an author per one-activity fragment.
43
+ - **Ceiling** — caller-instructed; triggers #2. Set it to the largest chunk you want a single subagent to take on.
44
+
45
+ Defaults ship documented and tunable; adjust per design rather than treating them as fixed.
46
+
47
+ ## Roots
48
+
49
+ Roots are **heuristic**: in-degree-0 in the binding subgraph, `asyncBacking` targets (external entries despite an in-edge), handler-bearing workflows (signal/query/update), and in-cycle workflows with no external binding in-edge. Each root is tagged `source: heuristic|declared`. Today all are heuristic; that is acceptable. Declared inbound roots will later seed at higher priority without changing this protocol.
50
+
51
+ Edge semantics worth knowing when reading output: `nexusCall` = contract cut; `asyncBacking` target = a root; `signalSend` = a *soft* edge that keeps two workflows in one blob but as **separate** roots/chunks (never treat it as a binding call edge).
52
+
53
+ ## Selective dispatch against existing work
54
+
55
+ The decomposition is computed over the **design**. It does not know what is already implemented. Before dispatching any chunk:
56
+
57
+ 1. Resolve the chunk's definitions to code via the `# impl: <dirs>` link header (see `temporal-architect-design`'s `twf-conventions.md`).
58
+ 2. If there is **no linked code**, the chunk is new → dispatch an author.
59
+ 3. If there **is** linked code, run the author skill's fast verify on it as a cheap changed-vs-unchanged signal — e.g. `author-go`'s `go build` / `go test` on the linked package. Treat a clean build/test against the current `.twf` as "unchanged, skip"; a failure or a `.twf` edit touching that chunk as "changed, dispatch."
60
+ 4. **Skip unchanged chunks.** Never re-author a component that doesn't need altering — that is wasted context and risks churning working code.
61
+
62
+ This is a stopgap: there is no first-class chunk↔impl staleness check (chunk identity + impl link + a quick verify). The build/test signal is coarse but cheap. Tracked as a chunks-consumer backlog item.
63
+
64
+ ## Pin contracts only where it pays
65
+
66
+ Pin types/signatures **rigidly only at the hard-boundary and cross-language cuts** — the interfaces that are expensive to renegotiate and that multiple subagents depend on. Everywhere else, hand the author a **loose API suggestion** and let it refine the shape as it implements, feeding genuine constraints back. Freezing everything up front is waterfall; it caps the authors' autonomy and produces conflicting rework, not less of it.
67
+
68
+ ## Manual fallback
69
+
70
+ When `twf graph chunks` is unavailable:
71
+
72
+ 1. Run `twf symbols` (or read the `.twf`) to list workflows, activities, and Nexus operations.
73
+ 2. Seed roots heuristically: handler-bearing workflows, Nexus-op-backing workflows, and any workflow with no inbound call.
74
+ 3. Walk call edges from each root to gather its reachable children; each connected component is a chunk.
75
+ 4. Treat `nexus` operations as contract cuts (separate chunks either side).
76
+ 5. Apply the same selective-dispatch and contract-pinning logic above.
77
+
78
+ This is coarser (no complexity score, no ranked cuts) but follows the identical dispatch discipline, so adopting the tool later changes the *input*, not the protocol.
@@ -0,0 +1,16 @@
1
+ # Skill: Temporal Architect — Go Authoring
2
+
3
+ **Goal:** Translate a validated TWF design into correct, idiomatic Temporal Go SDK code.
4
+
5
+ **Primary focus:** Translation fidelity. Design decisions are already made. The hard part is mapping DSL constructs to Go SDK patterns precisely — respecting determinism constraints, context propagation, error handling, and SDK idioms.
6
+
7
+ **Scope:**
8
+ - Produces: compilable Temporal Go SDK code
9
+ - Consumes: a validated `.twf` file produced by the `design` skill
10
+ - Does not: make workflow design decisions, modify the DSL, or produce code for other languages
11
+
12
+ **Authoritative references:**
13
+ - Temporal docs MCP server — consult for current Go SDK API, especially for patterns that change across SDK versions
14
+ - `tools/spec/sections/` — source of truth for DSL construct semantics when mapping to Go (also `twf spec` / `twf spec <slug>`)
15
+
16
+ **Entry point:** `SKILL.md` → `reference/` for specific construct mappings → consult Temporal docs MCP for SDK specifics
@@ -0,0 +1,191 @@
1
+ ---
2
+ name: temporal-architect-author-go
3
+ description: Generate Go code from .twf workflow designs using the Temporal Go SDK. Use when implementing workflows defined in TWF, producing compilable Go packages from DSL specifications.
4
+ ---
5
+
6
+ # Temporal Architect: Go Authoring
7
+
8
+ Generate functioning Go code from `.twf` (Temporal Workflow Format) files using the Temporal Go SDK. The primary goal is producing code that compiles, runs, and correctly implements the workflow design. Always produce `.go` files as deliverables.
9
+
10
+ ---
11
+
12
+ ## Core Principles
13
+
14
+ **Root-down generation.** Start from root workflows (no parent), work down to children, then activities, then types. Each layer is constrained by what the layer above needs. Defer unknowns, revisit later.
15
+
16
+ **Write only what is needed.** No speculative fields, no extra types, no over-generation. The minimum bridge between DSL intent and working Go.
17
+
18
+ **Prefer imports over generation.** Check `go.mod` and existing project code first. Use well-known libraries when types match. Only generate stubs for application-specific types.
19
+
20
+ **Iterative type resolution.** Work from certainty outward. Explicit signatures first, then derive from constructors/field access, then defer the rest. Revisit deferred types as surrounding code solidifies. See [types.md](./reference/types.md).
21
+
22
+ **User as decision-maker.** The skill owns execution; the user owns consequential choices. Handle mechanical mappings, SDK boilerplate, and compilation fixes autonomously. Surface dependency choices, ambiguous domain logic, and architectural direction to the user — present specific options with tradeoffs, not open-ended questions. Revising a previously confirmed decision always requires user approval.
23
+ > Example: "For ChargePayment, should I use stripe-go (official SDK, matches your existing stripe dependency) or a generic HTTP client (more flexible, but more boilerplate)?"
24
+
25
+ ---
26
+
27
+ ## Process
28
+
29
+ ### Orient
30
+
31
+ Before generating, resolve **where the code lands** along two independent axes. Greenfield is the easy case; adoption into an existing repo is the common one, and an existing repo's conventions are **requirements to match**, not defaults to pick.
32
+
33
+ | Axis | Existing repo | Greenfield |
34
+ |------|---------------|------------|
35
+ | **1. Greenfield vs. existing** | *Detect* — cheap signals below; if any fire, you are in an existing repo | *Ask* the user |
36
+ | **2. Codegen variant** (proto-first vs. hand-written) | *Detect from the repo* and conform to it | *Ask*; default = hand-written |
37
+
38
+ **Cheap detection signals** (check these first — no subagent needed):
39
+
40
+ - `buf.gen.yaml` with a `protoc-gen-go_temporal` plugin → **proto-first**
41
+ - generated `*_temporal.pb.go` files → **proto-first**
42
+ - `(temporal.v1.activity)` / `(temporal.v1.workflow)` annotations in `.proto` files → **proto-first**
43
+ - none of the above, hand-written `workflow.ExecuteActivity` call sites → **hand-written**
44
+
45
+ **Variant → reference routing:**
46
+
47
+ | Variant | Load |
48
+ |---------|------|
49
+ | proto-first | [proto-driven.md](./reference/proto-driven.md) (alias: "PFI") — read in addition to the construct references below |
50
+ | hand-written | the construct references below (default) |
51
+
52
+ Route on concrete repo signals, never on a name or acronym. Adding a new variant later = one reference file + one routing row.
53
+
54
+ **For an existing repo, dispatch the shared `project-discovery` subagent** to scan a **bounded slice** (the domain or directory in scope — never the whole repo) and return a compact summary of tooling, layout, Temporal SDK usage, registration style, and existing `.twf`. Trigger it deliberately, not reflexively; if the slice is unclear, narrow it with the user first. Its contract lives in [project-discovery-subagent.md](../temporal-architect-design/reference/project-discovery-subagent.md) (owned by the design skill, shared across skills). Project-convention discovery is the subagent's job, not the orchestrator's — consume its summary, don't re-scan in the main context.
55
+
56
+ ### 1. Context Gathering
57
+
58
+ - Read `.twf` files in scope
59
+ - Examine `go.mod`, existing project code, and conventions (for an existing repo, this is the discovery subagent's summary from Orient)
60
+ - Ask the user about project context, domain, key dependencies — brief, targeted questions
61
+
62
+ ### 2. Dependency Resolution
63
+
64
+ Identify external integration points for each activity and resolve to concrete types. See [dependency-resolution.md](./reference/dependency-resolution.md) for the full process. Deliverable: a dependency map confirmed by the user before generation begins.
65
+
66
+ ### 3. Planning
67
+
68
+ - Identify root workflows (not called as children by other workflows in the `.twf` file)
69
+ - Outline the generation order: roots → children → activities → types
70
+ - Review the dependency map against planned type signatures — flag any conflicts
71
+ - If the dependency map is incomplete, note which decisions are deferred
72
+ - Surface ambiguities to the user
73
+
74
+ ### 4. Generate + Verify Incrementally
75
+
76
+ Root-down, with build checks between layers. Consult [reference files](#reference-index) for DSL→Go mapping at each layer.
77
+
78
+ | Layer | What | Check | Key references |
79
+ |-------|------|-------|----------------|
80
+ | 1a. Types + signatures | Structs, interfaces, function signatures (empty bodies, zero-value returns). Dependency map informs interface shapes | `go build` | [types.md](./reference/types.md) |
81
+ | 1b. Activity stubs | Forward-declare all activity functions/methods with correct signatures, empty bodies, zero-value returns. This makes activity functions available as references for Layer 2 and enables the nil-pointer method pattern (`var a *Activities; workflow.ExecuteActivity(ctx, a.Foo, ...)`) | `go build` | [activity-def.md](./reference/activity-def.md) |
82
+ | 2. Workflow bodies | Orchestration logic: activity calls, child workflows, signals, timers, selectors | `go build` | [workflow-def.md](./reference/workflow-def.md), [activity-call.md](./reference/activity-call.md) |
83
+ | 3. Activity impl | Thin activity methods + concrete implementations behind interfaces | `go build` | [activity-def.md](./reference/activity-def.md) |
84
+ | 4. Worker wiring | `cmd/` entry point: construct dependencies, wire activity struct, register types, start worker | `go build` | [worker.md](./reference/worker.md), [nexus-service-def.md](./reference/nexus-service-def.md) |
85
+ | 5. Tests | At minimum, one happy-path test per workflow using `testsuite.WorkflowTestSuite`. Recommended: the three-layer approach below. Catches: activity name resolution failures, serialization round-trip issues, update handler races, missing activity options | `go test` | [three-layer-testing.md](./reference/three-layer-testing.md) |
86
+ | 6. Final | Full correctness check | `go vet` | — |
87
+
88
+ **Recommended: three-layer testing.** A happy-path workflow test is the floor, not the ceiling. For any non-trivial design, test in three layers — workflows (mock the activities interface), activities (mock the client interface), and clients (real system, behind a build tag) — because each layer catches bugs the others structurally cannot: workflow tests can't see inside activities, activity tests can't see the real client, and they also guard replay safety by pinning the activity-call sequence. Mechanics and patterns are in [three-layer-testing.md](./reference/three-layer-testing.md).
89
+
90
+ After generation: present the code to the user for review.
91
+
92
+ ---
93
+
94
+ ## Activity Implementation Pattern
95
+
96
+ See [activity-def.md](./reference/activity-def.md#activity-implementation-pattern) for the full pattern (struct, methods, interfaces, concrete implementations).
97
+
98
+ ### Implementation Depth
99
+
100
+ Activity bodies in `.twf` are pseudocode that may describe richer logic than the generated code implements. When simplifying an activity relative to its TWF description, emit a `// TODO:` comment referencing the elided logic so the gap is visible:
101
+
102
+ ```go
103
+ func (a *Activities) ValidateExtraction(ctx context.Context, doc Document) (ValidationResult, error) {
104
+ // TODO: format conformance checks, cross-field consistency, external reference lookups (see TWF)
105
+ if doc.Text == "" {
106
+ return ValidationResult{Valid: false, Reason: "empty text"}, nil
107
+ }
108
+ return ValidationResult{Valid: true}, nil
109
+ }
110
+ ```
111
+
112
+ For **examples and prototypes**, shallow implementations with `// TODO:` markers are appropriate — the goal is demonstrating workflow orchestration, not domain logic. For **production code**, ask the user which activities need full implementations and which are stubs.
113
+
114
+ ---
115
+
116
+ ## Output Conventions
117
+
118
+ - Each `.twf` maps to a Go package; Go files live alongside `.twf` sources or where the user specifies
119
+ - One file per workflow, shared types file if needed, activity files grouped logically
120
+ - One `_test.go` file per workflow (at minimum) with happy-path workflow tests
121
+ - Package names derived from `.twf` filename (snake_case)
122
+ - Worker entry point in `cmd/`
123
+
124
+ ---
125
+
126
+ ## Reference Index
127
+
128
+ Read only what the current generation step requires.
129
+
130
+ ### Definitions
131
+
132
+ | DSL Construct | Go Mapping | File |
133
+ |---------------|------------|------|
134
+ | `workflow Name(...)` | Workflow function | [workflow-def.md](./reference/workflow-def.md) |
135
+ | `activity Name(...)` | Activity function | [activity-def.md](./reference/activity-def.md) |
136
+ | `worker Name:` | Worker entry point | [worker.md](./reference/worker.md) |
137
+ | `nexus service Name:` | Nexus service + handlers | [nexus-service-def.md](./reference/nexus-service-def.md) |
138
+
139
+ ### Calls
140
+
141
+ | DSL Construct | Go Mapping | File |
142
+ |---------------|------------|------|
143
+ | `activity Name(args) -> result` | `workflow.ExecuteActivity` | [activity-call.md](./reference/activity-call.md) |
144
+ | `workflow Name(args) -> result` | `workflow.ExecuteChildWorkflow` | [workflow-call.md](./reference/workflow-call.md) |
145
+ | `nexus Endpoint Service.Op(args) -> result` | `NexusClient.ExecuteOperation` | [nexus.md](./reference/nexus.md) |
146
+
147
+ ### Handlers
148
+
149
+ | DSL Construct | Go Mapping | File |
150
+ |---------------|------------|------|
151
+ | `signal Name(params):` | Signal channel + selector | [signal-handler.md](./reference/signal-handler.md) |
152
+ | `query Name(params) -> (Type):` | `workflow.SetQueryHandler` | [query-handler.md](./reference/query-handler.md) |
153
+ | `update Name(params) -> (Type):` | `workflow.SetUpdateHandler` | [update-handler.md](./reference/update-handler.md) |
154
+
155
+ ### Async Primitives
156
+
157
+ | DSL Construct | Go Mapping | File |
158
+ |---------------|------------|------|
159
+ | `await timer(duration)` | `workflow.Sleep` | [await-timer.md](./reference/await-timer.md) |
160
+ | `promise p <- ...` | Future (deferred `.Get`) | [promise.md](./reference/promise.md) |
161
+ | `state:` / `condition` / `set` / `unset` | `bool` + `workflow.Await` | [condition.md](./reference/condition.md) |
162
+
163
+ ### Compound Async
164
+
165
+ | DSL Construct | Go Mapping | File |
166
+ |---------------|------------|------|
167
+ | `await all:` | `workflow.Go` + futures | [await-all.md](./reference/await-all.md) |
168
+ | `await one:` | `workflow.NewSelector` | [await-one.md](./reference/await-one.md) |
169
+
170
+ ### Modifiers & Control Flow
171
+
172
+ | DSL Construct | Go Mapping | File |
173
+ |---------------|------------|------|
174
+ | `options: ...` | `ActivityOptions` / `ChildWorkflowOptions` | [options.md](./reference/options.md) |
175
+ | `detach workflow ...` | Fire-and-forget child (confirm start, skip result) | [detach.md](./reference/detach.md) |
176
+ | `if`/`for`/`switch`/`break`/`continue` | Go equivalents | [control-flow.md](./reference/control-flow.md) |
177
+ | `close complete`/`fail`/`continue_as_new` | `return` / `workflow.NewContinueAsNewError` | [close.md](./reference/close.md) |
178
+ | `x = expr` | Variable declaration/assignment | [assignment.md](./reference/assignment.md) |
179
+ | `heartbeat(details)` | `activity.RecordHeartbeat` | [heartbeat.md](./reference/heartbeat.md) |
180
+
181
+ ### Composite Patterns
182
+
183
+ | Topic | File |
184
+ |-------|------|
185
+ | Update + condition + selector, signal + sleep + await | [composite-patterns.md](./reference/composite-patterns.md) |
186
+
187
+ ### Types
188
+
189
+ | Topic | File |
190
+ |-------|------|
191
+ | Type resolution strategy | [types.md](./reference/types.md) |
@@ -0,0 +1,161 @@
1
+ # Subagent Adoption Plan
2
+
3
+ Notes on splitting the author-go skill into an orchestrator + worker subagents.
4
+
5
+ ---
6
+
7
+ ## Why subagents
8
+
9
+ The author-go skill has two kinds of work:
10
+
11
+ 1. **Interactive** -- context gathering, ambiguity resolution, activity body clarification, review. Requires user dialog.
12
+ 2. **Mechanical** -- SDK exploration, type generation, workflow body generation, build verification. Self-contained, parallelizable, context-heavy.
13
+
14
+ Mixing both in one context window means the 20 reference files, SDK source, and build output compete for tokens with the user conversation. Subagents isolate the mechanical work and return only summaries.
15
+
16
+ ### Supporting data
17
+
18
+ - Google Research (180 agent configs): multi-agent excels on **parallelizable/decomposable** tasks (80.9% improvement), but **degrades 39-70%** on sequential reasoning. Architecture should match task structure.
19
+ - Anthropic guidance: start with single agent + skills, add subagents when context isolation or parallelism justifies it. Orchestrator-worker is the sanctioned pattern (no peer-to-peer).
20
+ - Anthropic Agent SDK: subagents get isolated context windows, return summaries to orchestrator. Cannot spawn nested subagents.
21
+
22
+ ---
23
+
24
+ ## Architecture
25
+
26
+ ```
27
+ author-go/SKILL.md (orchestrator, inline)
28
+ Owns all user dialog
29
+ Runs in main conversation context
30
+ Spawns subagents for mechanical work
31
+
32
+ ├── sdk-explorer (Explore agent)
33
+ │ Reads SDK source / docs to identify available types and imports
34
+ │ Returns: dependency manifest (types, imports, patterns available)
35
+
36
+ ├── go-codegen (general-purpose agent)
37
+ │ Preloads reference skills for TWF → Go mapping
38
+ │ Generates types, signatures, workflow bodies
39
+ │ Returns: generated .go files
40
+
41
+ └── build-verifier (Bash agent)
42
+ Runs go build / go vet
43
+ Diagnoses errors
44
+ Returns: pass/fail summary with actionable fixes
45
+ ```
46
+
47
+ ### Phase mapping
48
+
49
+ | Phase | Owner | Why |
50
+ |-------|-------|-----|
51
+ | Phase 1: Context gathering | Orchestrator + sdk-explorer | Orchestrator asks user about project context. sdk-explorer runs in parallel scanning SDK/dependencies. |
52
+ | Phase 2: Planning | Orchestrator | Requires ambiguity resolution with user. Consumes sdk-explorer's manifest. |
53
+ | Phase 3 Layer 1: Types + signatures | go-codegen | Mechanical. Reference-heavy. Parallelizable per workflow tree. |
54
+ | Phase 3 Layer 2: Workflow bodies | go-codegen | Mechanical TWF → Go SDK mapping. |
55
+ | Phase 3 Layer 3: Activity bodies | Orchestrator | Pseudocode in .twf requires user clarification. |
56
+ | Phase 3 Layer 4: Build verification | build-verifier | Verbose output stays isolated. Returns summary. |
57
+ | Phase 4: Review | Orchestrator | User feedback loop. |
58
+
59
+ ---
60
+
61
+ ## Subagent definitions
62
+
63
+ ### sdk-explorer
64
+
65
+ **Purpose:** Scan SDK and project dependencies to build a manifest of available types, imports, and patterns. Answers "what already exists?" so the orchestrator can follow the "prefer imports over generation" principle.
66
+
67
+ **Critical:** Don't just `go doc` individual types in isolation. Trace the actual call chain from activity code to SDK method and verify every type in the signature. SDK types often have union/wrapper variants (e.g., `ToolParam` vs `ToolUnionParam`) that only surface when you check the struct field that accepts them. The manifest must reflect the types the code will actually compile against, not the types that look right by name.
68
+
69
+ **Sources (suggest both, don't constrain):**
70
+ - Local module cache: `$GOPATH/pkg/mod/go.temporal.io/sdk@version/`
71
+ - Web: SDK docs, godoc, GitHub source
72
+
73
+ **Returns:** Structured summary -- available types, import paths, relevant SDK patterns. For each SDK call site, include the exact method signature and the concrete types of every parameter and return value.
74
+
75
+ ```yaml
76
+ ---
77
+ name: sdk-explorer
78
+ description: Explore Temporal SDK and project dependencies to identify available types and imports.
79
+ tools: Read, Glob, Grep, Bash, WebFetch, WebSearch
80
+ model: sonnet
81
+ ---
82
+ ```
83
+
84
+ ### go-codegen
85
+
86
+ **Purpose:** Generate Go code from TWF designs using the reference material. Handles Layers 1-2 (types, signatures, workflow bodies). Can run one instance per independent workflow tree for parallelism.
87
+
88
+ **Preloads:** The author-go reference files via the `skills` field. This keeps the 20 reference docs out of the main conversation's context.
89
+
90
+ ```yaml
91
+ ---
92
+ name: go-codegen
93
+ description: Generate Go Temporal workflow code from TWF designs. Use for types, signatures, and workflow bodies.
94
+ tools: Read, Write, Edit, Glob, Grep
95
+ model: sonnet
96
+ skills:
97
+ - temporal-go-reference
98
+ ---
99
+ ```
100
+
101
+ ### build-verifier
102
+
103
+ **Purpose:** Run `go build` and `go vet`, diagnose errors, return actionable summary. Keeps verbose compiler output out of the main context.
104
+
105
+ ```yaml
106
+ ---
107
+ name: build-verifier
108
+ description: Run Go build and vet, diagnose errors, return summary.
109
+ tools: Bash, Read, Glob, Grep
110
+ model: haiku
111
+ ---
112
+ ```
113
+
114
+ ---
115
+
116
+ ## Skill composition
117
+
118
+ Claude Code supports two composition directions:
119
+
120
+ | Direction | Mechanism | Use case |
121
+ |-----------|-----------|----------|
122
+ | Skill spawns subagent | `context: fork` in skill frontmatter | Entire skill runs as isolated subagent |
123
+ | Subagent loads skills | `skills` field in agent frontmatter | Subagent gets domain knowledge injected at startup |
124
+
125
+ For author-go, we use **both**:
126
+ - The main skill runs **inline** (no `context: fork`) because it needs user dialog
127
+ - The go-codegen subagent **loads reference skills** so it has the TWF → Go mapping knowledge
128
+ - The orchestrator (main conversation with skill loaded) spawns subagents via the Task tool
129
+
130
+ ---
131
+
132
+ ## Per-workflow-tree parallelism
133
+
134
+ After Phase 2 identifies independent root workflows, each root + its children + its activities can be a separate go-codegen subagent invocation. They don't share state and can generate in parallel.
135
+
136
+ Example: a .twf file with 3 independent root workflows → 3 parallel go-codegen subagents, each producing its own .go files.
137
+
138
+ ---
139
+
140
+ ## Cross-language generalization
141
+
142
+ This pattern generalizes to other language targets:
143
+
144
+ ```
145
+ .claude/agents/
146
+ ├── sdk-explorer.md # shared, parameterized by language/SDK
147
+ ├── go-codegen.md # Go-specific, loads go reference skills
148
+ ├── python-codegen.md # Python-specific, loads python reference skills
149
+ └── build-verifier.md # parameterized (go build vs pytest vs tsc)
150
+ ```
151
+
152
+ Each codegen agent loads only its language's reference material. The orchestrator skill per language (author-go, author-python, etc.) handles the dialog. A user request like "implement in Go and Python" spawns both codegen agents in parallel with full context isolation.
153
+
154
+ ---
155
+
156
+ ## Open questions
157
+
158
+ - **Skill splitting granularity:** Should reference files become a separate skill (`temporal-go-reference`) that the codegen agent preloads, or should they stay as files the agent reads on demand?
159
+ - **sdk-explorer scope:** Should it also scan the user's existing project code for conventions, or is that the orchestrator's job during Phase 1?
160
+ - **Error recovery:** When build-verifier reports failures, should the orchestrator fix them directly or re-invoke go-codegen with the error context?
161
+ - **Activity body generation:** Some activity bodies are unambiguous (simple SDK calls). Could a heuristic route "clear" bodies to a subagent and only surface "ambiguous" ones to the user?
@@ -0,0 +1,73 @@
1
+ # activity call
2
+
3
+ ## DSL
4
+
5
+ ```twf
6
+ activity ValidateOrder(order) -> validated
7
+ ```
8
+
9
+ ## Common Mistakes
10
+
11
+ ```go
12
+ // WRONG: string activity name — loses compile-time safety, breaks test discovery
13
+ err := workflow.ExecuteActivity(ctx, "ValidateOrder", order).Get(ctx, &validated)
14
+
15
+ // RIGHT: function reference — compiler verifies the function exists
16
+ err := workflow.ExecuteActivity(ctx, ValidateOrder, order).Get(ctx, &validated)
17
+
18
+ // RIGHT: method reference via nil pointer (struct pattern)
19
+ var a *Activities
20
+ err := workflow.ExecuteActivity(ctx, a.ValidateOrder, order).Get(ctx, &validated)
21
+ ```
22
+
23
+ ## Go
24
+
25
+ ```go
26
+ var validated ValidateResult
27
+ err := workflow.ExecuteActivity(ctx, ValidateOrder, order).Get(ctx, &validated)
28
+ if err != nil {
29
+ return Result{}, err
30
+ }
31
+ ```
32
+
33
+ ## With inline options
34
+
35
+ ### DSL
36
+
37
+ ```twf
38
+ activity ValidateOrder(order) -> validated
39
+ options:
40
+ start_to_close_timeout: 30s
41
+ ```
42
+
43
+ ### Go
44
+
45
+ ```go
46
+ actCtx := workflow.WithActivityOptions(ctx, workflow.ActivityOptions{
47
+ StartToCloseTimeout: 30 * time.Second,
48
+ })
49
+ var validated ValidateResult
50
+ err := workflow.ExecuteActivity(actCtx, ValidateOrder, order).Get(ctx, &validated)
51
+ if err != nil {
52
+ return Result{}, err
53
+ }
54
+ ```
55
+
56
+ For the full options reference, see [options.md](./options.md).
57
+
58
+ ## Notes
59
+
60
+ - No return value: omit the `Get` target variable, still check `err`
61
+ - The activity function is passed by reference (not a string) — `workflow.ExecuteActivity(ctx, FuncName, args...)`
62
+ - When using the struct method pattern (see [Activity Implementation Pattern](./activity-def.md#activity-implementation-pattern)), pass a method reference via nil pointer: `var a *Activities; workflow.ExecuteActivity(ctx, a.ValidateOrder, order)`
63
+ - `ctx` must carry activity options; see [options.md](./options.md) for setting `ActivityOptions`
64
+
65
+ ## When to use inline options vs shared context
66
+
67
+ - **Shared default context** (set `ActivityOptions` on `ctx` once near the top of the workflow): use when most activities share the same timeout and retry settings. This is the common case
68
+ - **Per-activity inline options** (create a new context with `workflow.WithActivityOptions`): use when a specific activity needs different timeouts or retry behavior (e.g., a long-running activity alongside short ones)
69
+ - When the DSL has an `options:` block on an activity call, always use per-activity inline options
70
+
71
+ ## Pitfalls
72
+
73
+ - `ctx` must carry `ActivityOptions` with at least one of `StartToCloseTimeout` or `ScheduleToCloseTimeout`. Omitting both produces a runtime error when the activity is scheduled