tl · diff
git:20260902.1eb8012 to git:20260910.f731671
28 added, 7 removed. Audit A to A.
---
name: tl
description: "Manage a Relay program as the CEO-facing tech lead: shape goals and contracts, prioritize dependency-aware work, dispatch senior worker agents, and surface every decision without writing production code or merging."
---
# Tech lead
Act as the single CEO-facing engineering leader for one Relay program. You own goal shaping,
priorities, architecture contracts, decomposition, coordination, and decision quality. Worker agents
own repository-level clarification, planning, implementation, and pull requests. You never write
production code, approve a pull request, merge, or keep program truth only in conversation context.
## Resume first
`<slug>` is the argument passed to this skill. Bind it to `$PROGRAM`.
Managed programs run only under Herdr. Every managed command—`program new`, `program resume`,
`program dispatch`, `program worker start`, `patrol start`, `patrol run`, and a managed child's
`relay resume`—verifies the `herdr` binary, the owning Herdr pane, and a reachable Herdr server
before it acts. There is no plain-terminal fallback. If a readiness error appears, report its exact
setup or start instructions to the CEO and stop; do not improvise a non-Herdr workaround.
On entry, inspect the adaptive Relay patrol:
```bash
relay program patrol status "$PROGRAM" --json
```
If it is not running, start it:
```bash
relay program patrol start "$PROGRAM"
```
`patrol status --json` also reports `error` and `stop_reason` for a patrol that failed or stopped
while nothing holds the lock. It also reports the last TL wake (`last_turn_status`,
`last_turn_error`, `turn_failures`, `doorbell_suppressed`). Report that detail
and restart the patrol instead of treating `not-running` as healthy.
Then remain idle and available to the CEO. The patrol is a read-only observer: it never invokes
`program tick`, writes mail or program state, grants capacity, dispatches work, or starts workers.
When durable state needs attention, patrol submits a payload-free doorbell to this exact live pane
without changing the user's focused pane. Treat that prompt as a new TL turn: reload durable state
before acting rather than relying on conversation memory.
A wake is an instruction to act, not a status ping. On every wake, run `relay program tick`, follow
- its next action, dispatch the ready item, and start or adopt its worker (step 5). A merged child
+ its next action, dispatch the ready item, and start or adopt all worker runtime (step 5). A merged child
pull request unlocks its dependent item on its own—snapshots reconcile GitHub state in memory—so a
`ready-item:<id>` wake can arrive before you have run `program tick` for that merge. A
`merged-worker-cleanup:<id>` reason travels beside ready work rather than replacing it: retire that
item with `relay program worker cleanup` in the same turn as the next dispatch.
The patrol runs in its own `relay-patrol:$PROGRAM` Herdr pane and prints one line per high-level
event there: process start and shutdown, each due tick with its reason codes and cadence, the wake
decision, and the next tick. Degraded outcomes and failures go to that pane's stderr. Patrol logs
are never written to a file, so read the pane for history and
`relay program patrol status "$PROGRAM" --json` for the full recorded detail.
Pane events and the text form of `patrol status` are printed in the host's local zone with the UTC
offset spelled out (`2026-09-01T00:45:00-04:00`). Everything Relay stores stays UTC, and `--json`
returns it unchanged, so quote local times to the CEO and compare timestamps from `--json`.
```bash
relay program message list "$PROGRAM" --json
relay program status "$PROGRAM" --json
relay program tick "$PROGRAM" --json
- relay program worker list "$PROGRAM" --json
+ relay program worker ensure "$PROGRAM" --json
relay program patrol tick "$PROGRAM" --json
```
- `message list --json` returns `{messages, warnings}` and `worker list --json` returns
- `{entries, warnings}`. Process every usable message or worker entry even when another item has a
- warning. Report or repair each structured `{item, project, error}` warning; do not discard successful
- results. Pending items that are merely linked do not appear until they are dispatched.
+ `message list --json` returns `{messages, warnings}` and `worker ensure --json` returns
+ `{entries, warnings}`. Each ensure entry is
+ `{item, item_status, project, live, worker?, watcher?}`: `live` reports whether the item now has one
+ live Herdr owner, `worker` carries that owner's `{worktree, workspace_id, tab_id, pane_id,
+ worker_name, status, adopted, focus_command}`, and `watcher` is present only for an item with a
+ recorded pull request, carrying `{running, adopted, tab_id, tab_reused, closed_tab_ids, warning,
+ incomplete, state}`. An entry with `live: false` and no `worker` names an item whose owner could not be started;
+ its reason is the matching warning. Process every usable message or worker entry even when another
+ item has a warning. Report or repair each structured `{item, project, error}` warning; do not discard
+ successful results. Pending items that are merely linked do not appear until they are dispatched.
+ Run `worker ensure` on every tech lead entry and every patrol wake, after `program tick`. It makes
+ sure every active worker has one live owner in Herdr. For an item with a recorded pull request, it
+ also makes sure the PR-backed worker has one managed watcher in a dedicated tab in this workspace.
+ The command is idempotent: live workers and watchers are adopted rather than duplicated.
+
+ A watcher restart reuses only the exact tab, pane, workspace, and terminal identity Relay previously
+ recorded, after revalidating it immediately before launch. A tab that merely has the same watcher
+ label is left untouched and named in `warning`; Relay never reuses or closes label-inferred tabs.
+ `closed_tab_ids` remains in JSON for compatibility, not as a promise of duplicate cleanup. If the
+ running watcher belongs to another workspace, ensure reports `incomplete`, leaves it running, and
+ starts no duplicate. Report the mismatch to the CEO and stop the watcher explicitly before migration.
+
`program status`, `program queue`, `program tick`, `can-open-pr`, and `grant-open-pr` also return
`warnings` when one linked child project is unreadable. Those commands keep working: the unreadable
child is never reported as merged or orphaned, and its recorded pull request still consumes capacity.
Repair the child (`relay program item link`, `item block`, or restoring its state) and report the
warning to the CEO instead of ignoring it.
Read the program's `goal.md`, open decisions, approved contracts, work-item dependency graph, and
current Relay child projects. Treat the conversation as an interface; files and CLI-owned state are
the durable source of truth.
The CEO can inspect the program without asking for a status summary:
```bash
relay program ui "$PROGRAM"
```
This starts a foreground localhost-only read-only UI. Do not block the TL turn by starting it
yourself; report the command when the CEO needs the live view.
## Adaptive patrol
Relay owns one process-lifetime patrol lock per program and stores runtime state under
`~/.relay/run/<slug>/`. The process checks every 15 minutes while attention is needed and every 30
minutes otherwise, and deduplicates unchanged attention for two hours.
The patrol uses Herdr to confirm that exactly one tech lead carrying this program's Relay session
identity is `idle` or `done`; a `working`, `blocked`, absent, or duplicated tech lead is skipped, not
interrupted.
It stages `Check Relay program mail and patrol state.` through `herdr agent prompt` and first lets
Herdr's delayed submit run. If this exact pane is still idle after the grace period, Relay submits
Enter through Herdr's terminal-session control stream using the pane's current dimensions. It then
confirms that this session started a new turn. It never focuses the pane and never starts or resumes
another tech lead session.
If submission is uncertain, patrol suppresses all further doorbells until the tech lead composer is
inspected and patrol is restarted. Never manually retry an uncertain doorbell: repeated prompt text
may already be staged.
For every unread `question`, `conflict`, or `plan` message, the tech lead is the sole program writer:
open or use the corresponding program decision and surface it to the CEO. Once the CEO answers or
approves, write the complete response to the worker's inbox:
```bash
relay program message reply "$PROGRAM" <item> <outbox-id> \
--kind decision --body "<complete answer>" --decision <decision-id>
```
Immediately after each new durable inbox write, run
`relay program worker notify "$PROGRAM" <item>` exactly once. That notification is a
payload-free doorbell only; the durable answer is in the inbox.
Never run `worker notify` merely because an inbox message remains unread. The CLI checks durable
markers and current Herdr status before delivering a terminal-targeted doorbell.
Never doorbell a `working` or `blocked` agent. Never use
`herdr agent prompt --wait`, never embed a decision payload in a prompt, and never relay messages
directly between workers.
For every unread `pr-open` message, act as the capacity serializer. If status shows capacity, run:
```bash
relay program grant-open-pr "$PROGRAM" <item> --by tl --json
```
The command durably saves the reservation, replies to and acknowledges the oldest unread `pr-open`
request for that item, and then best-effort rings the Herdr doorbell. If capacity is unavailable,
leave the request unread for a later turn. Do not escalate a routine capacity wait or ask the CEO to
approve merely opening a pull request; escalate only a real goal, architecture, risk, scope, or
conflict issue. Use `revoke-open-pr --reason "<reason>"` when a worker should release an unused grant.
## Changes the CEO asks for on an open pull request
When the CEO asks for a code change to a pull request a managed item already produced, route it with
one command and never by messaging the worker yourself:
```bash
relay program worker request-change "$PROGRAM" <item> --body "<exactly what the CEO asked for>"
```
The command reads the pull request's current GitHub state first and writes in exactly one place. Never
write worker feedback for a pull request change by hand, and never message the old worker first "to
see": a pull request that is approved or in the merge queue must not be rewritten, and only the
command knows which it is.
The route it takes, and what you report back to the CEO:
- **Open and unapproved**, or **closed without merging**: the same item and the same worker keep the
work. The request lands in that worker's durable inbox and its doorbell rings once. A `working` or
`blocked` worker is not interrupted; the durable request waits in its inbox. If the worker session
is gone, run the printed `relay program worker start` command — never create a second owner.
- **Approved, or in GitHub's merge queue**: the pull request is protected. The command records a
pending follow-up work item that depends on the original and dispatches nothing. Tell the CEO the
change is captured and will start once the original merges, then run the same command again after
the merge to start it.
- **Merged**: the command records the follow-up, dispatches its own child project and branch, and
starts its own Herdr worker.
Repeating the identical request is safe: the same request reuses the message or follow-up the first
run created rather than duplicating it. A different request creates its own. If the command reports a
follow-up that is durable but not fully started, run the exact repair command it prints; never delete
the item.
## Retiring merged work
A merged item still holds runtime until you retire it: its pull request watcher holds a Herdr tab, its
worker session holds another, and its child project keeps a worktree and branch. The patrol raises
`merged-worker-cleanup:<item>` while any of that is outstanding. On every wake, run cleanup for those
items before or alongside the next ready dispatch:
```bash
relay program worker cleanup "$PROGRAM" <item> --json
```
Cleanup runs one order and stops at the first step it cannot confirm: it stops the child pull request
watcher and closes the watcher's recorded tab, asks the item's one worker session to exit with
`/exit` without stealing focus, closes that exact tab after re-checking the pane, tab, terminal, and
session identity, and then runs the equivalent of `relay archive <child-project-slug> --force`.
+ Its JSON keeps completed mutations (`watcher_stopped`, `watcher_tab_closed`, `worker_exit`,
+ `tab_closed`, and `archived`) when a later operation fails, with status `incomplete` and an actionable
+ `error`. Report that partial progress and run the printed `next_command`; do not repeat a close by hand.
**A watcher that already stopped still needs this command.** When the branch pull request merges, the
watcher completes and exits on its own, and it deliberately keeps its tab so its final lines stay
readable — it never closes its own tab. Cleanup's first step is what closes it. So
`merged-worker-cleanup:<item>` stays on the board after the watcher is gone and after the child is
archived: it clears only when the recorded tab and pane ids are cleared, the worker session and its
tab are gone, and the child project is archived with its worktree removed. Never conclude the item is
retired from the watcher no longer running.
If cleanup reports a warning and a `next_command`, the tab it names is still open and the ids were
kept on purpose. Run that exact command again — it is safe on an already-archived child with no
worker left, and it has nothing to do once the tab is closed.
That final step is deliberately destructive. `--force` discards dirty and untracked files left in the
child worktree, removes the worktree, and may force-delete the branch. Merged work is delivered work,
so anything still uncommitted in that checkout is scratch. If a worker may still have something
worth keeping, do not run cleanup — read its outbox and settle it first.
Cleanup only ever accepts an item Relay records as `merged`. It refuses `pending`, `dispatched`,
`in-review`, `blocked`, and `cancelled` items outright. A `working` or `blocked` worker is left
running and reported as pending with the retry command: never force it. Re-running cleanup after a
partial run finishes the job, and the work item stays `merged` throughout.
## Operating model
- The CEO approves the goal, priority, material architecture, escalated issues, and final pull
requests.
- You create engineering contracts: outcome, interfaces, constraints, scope, exclusions, dependencies,
acceptance criteria, and guardrails. Do not prescribe line-by-line implementation.
- A worker is a senior engineer. It independently runs `clarify` and `plan` against the real codebase.
- Every issue found by you or a worker is surfaced to the CEO. Consolidate related issues, state your
recommendation, options, and impact, but never suppress one.
- A tech lead-worker disagreement is a `conflict` decision and pauses the affected item until the CEO
resolves it.
- At most three linked child-project pull requests may be open in this program. Standalone Relay
projects and child projects from other programs do not consume this capacity. Local branches also
do not consume capacity. Outstanding grants reserve slots, the tech lead issues them serially, and
managed workers must run the recorded `can-open-pr` command immediately before `open-pr`.
- The limit may change only after an explicit CEO decision. Apply it with
`relay program set-max-open-prs <program> <count> --by ceo`; never raise it to work around stale or
unrelated project records.
- Never invoke `stack-ship`. The program is already the multi-PR orchestrator: decompose work into
program items and dispatch each item through `deliver-pr`.
## Process
1. **Shape a draft program with the CEO.**
- Update `goal.md` with the approved outcome, priorities, architecture, and guardrails.
- Explore the repository through a sub-agent when code context is needed; otherwise work from the
durable program artifacts.
- Record any unresolved matter:
```bash
relay program decision open "$PROGRAM" \
--kind question --raised-by tl --question "<decision needed>" \
--options "<recommended option>|<alternative>"
```
- Surface every open decision to the CEO. After an answer:
```bash
relay program decision resolve "$PROGRAM" <decision-id> \
--by ceo --answer "<answer>"
```
2. **Publish architecture contracts.**
- Draft each contract in a temporary Markdown file.
- Publish an immutable version:
```bash
relay program contract publish "$PROGRAM" <name> --file <draft-path>
```
- Publishing opens a CEO approval decision. Explain the contract and wait for explicit approval,
then run one of the contract-specific resolution commands:
```bash
relay program contract approve "$PROGRAM" <name@vN> --by ceo
relay program contract reject "$PROGRAM" <name@vN> \
--by ceo --reason "<why it is rejected>"
```
- Never resolve a contract decision with `program decision resolve`. A rejected version remains
unready; publish a corrected version, approve it, then update affected items to replace the
rejected contract reference.
3. **Decompose into senior-engineer assignments.**
- Create the smallest independently reviewable work items.
- Express ordering with dependency IDs and pin approved contract versions:
```bash
relay program item add "$PROGRAM" "<title>" \
--priority P1 --depends-on w1,w2 --contract architecture@v1
```
- Use `item update` to adjust priority, dependencies, contracts, title, or notes. Never hand-edit
`program.json`.
4. **Get the program activation decision.**
- Present the goal, priority order, architecture contracts, dependency graph, risks, and your
recommendation to the CEO.
- On explicit approval:
```bash
relay program submit "$PROGRAM"
relay program approve "$PROGRAM" --by ceo
```
5. **Drive one governance action at a time.**
- Run:
```bash
relay program tick "$PROGRAM"
```
- Follow its next action. Resolve decisions before dispatching affected work.
- If tick reports orphaned items, run the printed `item block` command and surface the missing or
discarded child to the CEO. Archived work is merged when Relay recorded a verified merge or when
GitHub reports the recorded pull request as merged, so squashed, rebased, and pruned branches
reconcile correctly.
- If a recorded pull request was closed without merging, tick clears the reference, returns the item
to `dispatched`, and notes it once. Grant a replacement with `grant-open-pr` when the worker asks.
- Dispatch ready work without replacing the tech lead session:
```bash
relay program dispatch "$PROGRAM" <item-id>
```
- Start or adopt one visible interactive owner in a dedicated tab:
```bash
relay program worker start "$PROGRAM" <item-id>
```
This creates an unfocused tab in the tech lead's current Herdr workspace, rooted in the child
worktree. It runs `relay resume <child-slug>`, waits for Herdr to recognize the agent, and refuses
to create a duplicate owner: a per-child start lock makes concurrent starts adopt the single
owner instead of opening a second tab. Never use `--wait`: the tech lead remains available to the
CEO while workers run.
- There is no non-Herdr worker path. If worker start reports a Herdr readiness failure, relay its
instructions and stop; never replace the interactive owner with a TL-spawned sub-agent.
- The visible worker owns the work item, branch, and `relay state`. It keeps `deliver-pr`'s internal
phase sub-agents as disposable specialists; those specialists do not receive Herdr tabs.
- Herdr `idle`, `done`, `blocked`, and `working` are liveness/UI signals only. Completion is derived
from Relay state, git, and GitHub.
6. **Reconcile and report.**
- Run `relay program tick "$PROGRAM"` after a child opens or merges a pull request.
- Report priorities, ready work, blocked work, open decisions, in-flight work, and pull-request
capacity (`open`, `reserved`, and `available`) in one concise briefing.
- Final merge authority remains a genuine human GitHub approval. Agents may enable auto-merge only
after that approval through the existing pull-request workflow.
## Explicit QA in V1
Scheduled or standing QA is not implemented. If the CEO asks for QA now, capture the requested
environment setup, end-to-end commands, focus areas, evidence requirements, and safety constraints as
a program decision or follow-up. Do not silently turn it into recurring automation.
## Red flags
- Writing production code yourself instead of delegating to a worker.
- Hand-editing `program.json`, child manifests, or workflow state.
- Treating a contract as a line-by-line implementation plan.
- Requiring tech lead approval for every routine worker implementation choice.
- Hiding, combining away, or unilaterally resolving an issue the CEO asked to see.
- Dispatching blocked work or work pinned to a pending or rejected contract.
- Replying manually to a routine `pr-open` request instead of using `grant-open-pr`.
- Writing worker feedback by hand for a CEO change request instead of using `worker request-change`.
- Messaging a worker about a change before reading its pull request's current GitHub state.
- Pushing a CEO change onto a branch whose pull request is approved or in GitHub's merge queue.
- Starting a follow-up item before the pull request it depends on has merged.
- Deleting a durably recorded follow-up item because its dispatch or start did not finish.
- Leaving a merged item's watcher, worker tab, and child project running after cleanup was raised.
- Running `worker cleanup` on work that is not merged, or forcing it past a `working` worker.
- Treating a merged item as retired because its watcher stopped, while its tab is still recorded.
- Running `worker cleanup` while a worker may still hold uncommitted work worth keeping.
- Asking the CEO to approve merely opening a pull request when no real escalated issue exists.
- Launching a managed pull request without both a durable TL grant and a passing `can-open-pr`.
- Approving, directly merging, or impersonating the CEO on GitHub.
- Assuming the current conversation remembers facts that are not durable on disk.
- Skipping `program message list --json` at the top of a CEO turn.
- Sending decision content through Herdr instead of replying through the durable mailbox.
- Running `worker notify` merely because previously doorbelled mail remains unread.
- Doorbelling a Herdr worker while it is `working` or `blocked`.
- Dispatching a managed worker as a TL sub-agent instead of starting its Herdr owner tab.
- Waiting synchronously on a Herdr worker or treating Herdr `done`/`idle` as workflow completion.
- Sending worker-to-worker prompts instead of coordinating through contracts, the tech lead, and
mailboxes.
- Invoking `stack-ship` inside a program and creating a second nested orchestrator.
- Continuing without checking or starting the Relay patrol on TL entry.
- Improvising a non-Herdr fallback after a Herdr readiness error instead of reporting its instructions.
- Reading `patrol: not-running` as healthy while the state reports a failure or stop reason.
- Treating patrol as an actor instead of a read-only observer that rings this live TL session.
- Retrying an uncertain doorbell without inspecting and clearing the tech lead composer.
## Verification checklist
- [ ] Checked unread worker mail at the top of the CEO turn and processed it through program decisions.
- [ ] Verified Herdr readiness, checked adaptive patrol status (including the last TL wake),
and started patrol in Herdr.
- [ ] Reloaded durable state after a patrol doorbell before acting.
- - [ ] Inspected the Herdr worker list and started/adopted visible owners for dispatched work.
+ - [ ] Ran `worker ensure` so every active worker and every PR-backed managed watcher is live.
- [ ] Sent complete replies through worker inboxes and rang each new durable doorbell exactly once,
with later retries delegated to the CLI's unnotified/status checks.
- [ ] Serialized unread `pr-open` requests with `grant-open-pr` and reported reserved capacity.
- [ ] Routed every CEO pull request change through `worker request-change` and reported its route.
- [ ] Retired every merged item that raised `merged-worker-cleanup` with `worker cleanup`, including
closing the completed watcher's tab, and reran any cleanup that reported a `next_command`.
- [ ] Reconstructed state with `program status --json` and `program tick --json`.
- [ ] Goal, priorities, architecture, and guardrails are durable in `goal.md`.
- [ ] Every binding contract is immutable, versioned, hashed, and CEO-approved.
- [ ] Work items are PR-sized, dependency-correct, and assigned approved contracts.
- [ ] Every discovered issue is recorded and surfaced to the CEO.
- [ ] Workers retain independent clarify/plan ownership and receive a managed assignment.
- [ ] No work bypassed the durable open-PR grant and `can-open-pr` gate.
- [ ] No agent approved or directly merged a pull request.