Skip to content
Back to skills

Team Lead

ASecurity

Domain coordinator for ticket-swarm. Receives a cluster of enriched tickets sharing a domain, detects intra-cluster dependencies, injects domain-specific context, sequences tickets to prevent merge conflicts, and launches pipelines in the correct order. Not user-invocable — only called by ticket-swarm.

  • 3 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 6, 2026
ai-agentsgophpsqlgitapidatabasefrontendbackendsecurity

Works with

  • api

Security analysis

A100/100

Scanned December 6, 2026

npx -y skills add flopperj/dotfiles-core --skill team-lead --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Team Lead?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Team Lead
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/flopperj-team-lead/badge)](https://www.skillsdirectory.com/skills/flopperj-team-lead)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: team-lead
description: "Domain coordinator for ticket-swarm. Receives a cluster of enriched tickets sharing a domain, detects intra-cluster dependencies, injects domain-specific context, sequences tickets to prevent merge conflicts, and launches pipelines in the correct order. Not user-invocable — only called by ticket-swarm."
user-invocable: false
---

# Team Lead

Coordinate a cluster of tickets within a single domain. Detect dependencies,
inject domain context, sequence properly, and launch pipelines.

This skill is an **internal orchestration component** — it is only called by
`ticket-swarm`, never directly by the user.

---

## Responsibility boundaries

A team lead is a **coordinator**, not a new agent role. It groups, sequences,
and injects context, then delegates to the same pipeline agents.

<!-- BEGIN RESPONSIBILITY BOUNDARIES -->
<!-- EXTRA_ROWS: team-lead,ticket-pickup -->
| Agent | Sole responsibility | NEVER does |
|---|---|---|
| **Team Lead** | Dependency detection, domain context injection, within-cluster sequencing, pipeline dispatch | Write code, produce plans, perform strategic analysis, review PRs, enrich tickets, classify complexity |
| **Ticket Pickup** | Fetch ticket, enrich with codebase context, classify complexity, route to pipeline | Write code, produce plans, perform strategic analysis, review PRs |
| **Aristotle** | Strategic analysis — assumptions, first principles, highest-leverage direction | Name file paths, produce code, plan execution, review PRs |
| **Optimus** | Execution planning — file paths, step sequencing, risk assessment, architecture | Write code, make file edits, run commands, re-litigate upstream strategic decisions, review PRs |
| **Cyrus** | TDD implementation — write tests first, then code, hit 80%+ coverage | Redesign architecture, question strategic direction, skip tests, review PRs |
| **Ranger** | Staff-level PR review — analyze diffs, score issues, report findings | Write code, make edits, implement fixes, plan architecture, perform strategic analysis |
| **Scout** | PR review — analyze diffs, score issues, report findings | Write code, make edits, implement fixes, plan architecture, perform strategic analysis |
| **Auditor** | Code complexity analysis, reviewer routing | Write code, review code, post to GitHub, implement fixes |
<!-- END RESPONSIBILITY BOUNDARIES -->

---

## Input contract

The team lead receives from ticket-swarm:

- **Cluster**: A list of enriched tickets (from ticket-pickup Steps 2-4),
  each with:
  - Ticket key, summary, priority, complexity classification
  - `ticket_complexity: simple | medium | complex` per ticket
  - Codebase references (file paths found during enrichment)
  - Jira linked issues (blockers, duplicates, related)
- **Domain tag**: `backend`, `frontend`, `infra`, or `unknown`
- **Execution flags**: `swarm_mode: true`, `execution_mode: autonomous`,
  and `unbounded: true` when the swarm was invoked with it
- **Parent story key** (optional): If these tickets are sub-tasks of a
  Story, the parent key for Jira comment context

---

## Step 1: Analyze dependencies within the cluster

Examine the enriched ticket data to detect relationships:

### File-level dependencies

Compare codebase references across tickets in the cluster. If two tickets
reference the same file:
- They **must not** run in parallel (merge conflict risk)
- Sequence them: the simpler ticket runs first (fewer changes = easier base
  for the next ticket)
- Mark with: `[sequenced: shared file {path}]`

### Jira link dependencies

Check linked issues between tickets in the cluster:
- **"Blocks" links**: If ticket A blocks ticket B, A must complete first
- **"Relates to" links**: Advisory only — note the relationship but don't
  force sequencing unless files also overlap
- **"Duplicate" links**: Flag to the swarm orchestrator — duplicates should
  not both be implemented

### Logical ordering

For sub-tasks from a Story decomposition, infer logical dependencies even
if files don't overlap:
- Database schema changes before API changes
- API changes before frontend changes
- Shared libraries/interfaces before consumers
- Tests that validate integration after the components they test

### Build the dependency graph

Produce a sequencing plan:

```
Cluster: Backend (4 tickets)

  Wave 1 (parallel):
    PROJ-1003 (Simple) — DB migration, no dependencies
    PROJ-1007 (Simple) — Config change, independent

  Wave 2 (parallel, depends on Wave 1):
    PROJ-1001 (Medium) — API update, depends on PROJ-1003 [shared: src/billing/Account.php]
    PROJ-1009 (Simple) — Error handler fix, independent

  Wave 3 (sequential, depends on Wave 2):
    PROJ-1002 (Medium) — Service integration, depends on PROJ-1001 [Blocks link]
```

If no dependencies exist, all tickets can run in parallel (single wave).

---

## Step 2: Inject domain context

Based on the domain tag, prepare domain-specific context to pass to each
pipeline. This context supplements the enriched ticket brief.

For the team's per-domain facts (source layout, test locations and mocking
library, validation commands, security rules, migration windows, flag config),
consult `## Domain conventions` in `~/.claude/overlay-context.md`. If that file or section is absent, fill the placeholders below from the project CLAUDE.md and the repo itself, and drop any line you cannot confirm.

### Backend domain context

```
Domain: Backend (<language / framework>)

Conventions:
- <where controllers, business logic and models live>
- Tests in <test directory> using <mocking library>
- <naming, style and structure rules from the project CLAUDE.md>

Validation:
- <static analysis that must pass after changes>
- <test command>

Security:
- XSS protection for any view/template changes
- CSRF protection for state-changing endpoints
- SQL injection protection for any database queries
```

### Frontend domain context

```
Domain: Frontend (<framework / language>)

Conventions:
- Components in <frontend source directory>
- Routes in <routes directory>
- Always use the design system's tokens — no hardcoded colors, spacing, or typography
- Check Figma alignment when available
- Invoke the frontend-design skill for any visual changes

Validation:
- <lint and type checks that must pass>
- <component test runner>
```

### Infra / Cross-Boundary domain context

```
Domain: Infrastructure / Cross-Boundary

Conventions:
- Schema and proto sources go in <schema directory>; never edit generated code directly
- <migration windows or release restrictions> — if a migration is needed, flag prominently
- Feature flags in <flag config file>, starting at <default rollout value>
- Observability: traces around entry points, logging context through call chains

Special rules:
- Changes that span backend + frontend must coordinate commit ordering
- Proto changes require regeneration step before dependent code compiles
```

### Unknown domain

No additional context injected. The ticket's own enrichment data is
sufficient.

---

## Swarm context accumulator

The team lead maintains a **shared context object** that accumulates results
across waves. This gives downstream agents awareness of what upstream agents
built, beyond just the files on disk.

> **Path note:** when Step 3's workflow path succeeds, `team-lead-waves`
> maintains this accumulator internally (same injection, same size
> limits) — the prose procedure below governs the **legacy fallback
> path** only.

**Initialize** the context as empty before Wave 1.

**After each wave completes**, append a brief summary:

```
Wave 1 results:
  PROJ-1003: Created src/billing/AccountId.php (new value object)
             Modified src/billing/Invoice.php (added billing_account_id column)
  PROJ-1007: Modified feature_flags.ini (added billing_multi_account flag)
```

**Inject** the accumulated context into each subsequent wave's pipeline
agents alongside the domain context: `"Prior wave context: {accumulated}"`

This context is **ephemeral** — it lives only for the duration of the
swarm run and is not persisted to agent memory. It is included in the
run log for swarm-retro analysis.

**Accumulator size limits:**
- Keep only the last 3 wave summaries in full detail
- For earlier waves: condense to a single line per ticket (key, files changed, pass/fail)
- Max total accumulator size: ~200 lines
- If exceeded: drop the oldest wave details, keeping only the condensed single-line entries

---

## Step 3: Execute waves — invoke the `team-lead-waves` workflow

Wave execution runs through the saved `team-lead-waves` workflow
(`.claude/workflows/team-lead-waves.js`). The workflow owns the execution
topology — a sequential outer loop over waves, `parallel()` over each
wave's tickets — while this skill keeps ownership of **building** the
dependency graph (the Step 1 sequencing rules) and injecting domain
context (Step 2). The seam follows the same three-part contract as
`code-auditor/SKILL.md` Step 2 (the proven canary pattern): invoke,
validate, fall back.

1. **Invoke.** Invoke the `team-lead-waves` workflow, passing a single
   JSON object through the Workflow tool's `args`:
   - `waves` — the Step 1 sequencing plan in the swarm-context shape:
     an array of `{ index, tickets: [Jira keys], parallel }`. The
     workflow executes this plan as given; it never re-sequences.
   - `domain` — the cluster's domain tag (`backend` / `frontend` /
     `infra` / `unknown`)
   - `sequencing_reasons` — one entry per Step 1 ordering decision
   - `briefs` — a map from ticket key to that ticket's full pipeline
     brief text: the enriched ticket brief, the Step 2 domain context,
     the branch name (and base branch for sequenced tickets), and
     `ticket_complexity`. The workflow passes each brief verbatim to
     that ticket's pipeline agent.
   - `unbounded` — `true` when the swarm was invoked with it; omit
     otherwise. The workflow adds it to each pipeline's flags.
2. **Validate.** Check the workflow's return against
   [`.claude/workflows/schemas/swarm-context.json`](../../workflows/schemas/swarm-context.json).
   The five required fields must be present and well-typed:
   - `waves` (the executed wave plan, echoed back)
   - `sequencing_reasons` (array of strings)
   - `domain` (enum `backend` / `frontend` / `infra` / `unknown`)
   - `blocked` (Jira keys of tickets that did not complete; empty array
     when every ticket succeeded)
   - `results` (one entry per ticket that finished with status done, `{ ticket,
     status, summary, files }`, its `summary` carrying that ticket's
     `review_result` word for word)

   The optional `advisory` array may also be present. Unlike `blocked`, its
   items are objects, not bare keys: `{ "ticket": "PROJ-1234", "verdict":
   "one-line ruling" }`, one per ticket whose pipeline ended with a correct
   no-code answer. Do not require it; treat absence as empty. Do not reject
   a payload for carrying it.

   Validate **only those fields**. The workflow returns no prose — its
   per-wave narration goes to the run journal — so do not require or
   parse any text alongside the object. A malformed `args` payload makes
   the workflow return null fields that **fail this validation by
   design**, engaging the fallback below.
3. **Fall back.** If the invocation errors, returns nothing, or the
   return fails validation, run the **legacy prose wave execution**
   (labelled fallback block below) and drive the waves the old way.
   **State plainly in the output that the fallback path ran**, e.g.
   *"Workflow invocation unavailable — waves executed via the prose
   path."* The cluster gets processed either way; the only cost of a
   failed seam is a line of text.

**Journal diagnostic — check before declaring failure.** If the return
*seems* empty, consult the workflow run's `journal.jsonl` before
concluding the invocation failed. A workflow that ran correctly but
whose return did not surface looks identical to one that never ran; the
journal distinguishes them. Record what the journal showed alongside
the fallback notice.

**Fallback occurrences must be visible, not silent.** If the fallback
notice appears on every run, the workflow seam is broken and should be
treated as unproven rather than as a working feature — surface that
pattern to ticket-swarm and the user instead of quietly absorbing it.

**Concurrency ceiling.** `parallel()` caps at **16 concurrent agents**
(1000 per run). A wave wider than 16 queues rather than erroring — the
workflow logs each wave's width so a 40-ticket wave reads as queued, not
mysteriously slow. The same practical ceiling applies to the legacy
path's Agent-tool fan-out: log the wave width before launching.

**Interpreting the validated return:**

- The workflow maintains the swarm context accumulator internally
  (injecting prior-wave results into each subsequent wave's pipeline
  prompts, with the same condensation limits as the accumulator section
  below), so on this path there is no accumulator to maintain in prose.
- Per-wave progress narration lands in the workflow run's
  `journal.jsonl`; mine it for the per-wave detail lines when reporting
  to ticket-swarm.
- For each ticket in `blocked`, run Step 3.5 smart failure analysis
  before escalating. Tickets in `advisory` are **not** blocked: skip
  failure analysis, do not retry, and report them under Advisory. Any re-run this produces is a **prose-orchestrated**
  Agent call (see Truncation handling below).
- Feed the returned object into the Step 4 cluster report, with each
  finished ticket's `review_result` taken from its entry in `results`, or
  from the re-run's own result for a ticket a Step 3.5 re-run finished.

<!-- LEGACY FALLBACK — prose wave execution. Runs ONLY when the
     team-lead-waves workflow invocation or validation fails
     (Step 3, part 3). Do not run this when the workflow returned a
     valid swarm-context object. -->

### Fallback: legacy prose wave execution

Execute the sequencing plan from Step 1, wave by wave:

**For each wave:**

1. Launch one pipeline per ticket in the wave. For each ticket, invoke
   `ticket-pickup` with:
   - The enriched ticket brief
   - Domain context from Step 2
   - **Swarm context** from the accumulator (prior wave results)
   - Jira ticket key
   - Branch name (determined by ticket-swarm)
   - `swarm_mode: true`, `execution_mode: autonomous` (plus `unbounded: true`
     if received)
   - `ticket_complexity` from the ticket's classification (determines
     whether Cyrus auto-triggers Scout, code auditor, or Ranger on completion)
   - For independent tickets: branch is created by ticket-swarm (via
     `newbranch` or fallback) from the latest default branch
   - For sequenced tickets: the prior ticket's branch as the base
     (instead of the default branch)

2. Wait for all pipelines in the wave to complete.

3. Collect results from each pipeline:
   - Files changed, tests written, coverage metrics
   - Pass/fail status, blockers encountered
   - Reviewer results (Scout or Ranger depending on complexity), with the
     `review_result` value copied word for word

4. **Update the swarm context accumulator** with this wave's results
   (files created/modified, classes/interfaces established).

5. **If any pipeline in the wave fails or reports a blocker:**
   Run smart failure analysis (Step 3.5) before escalating.

6. Report wave completion to ticket-swarm:
   ```
   [Backend Lead] Wave 1 complete: 2/2 succeeded

     PROJ-1001: API update (Medium) — 2 files, 8 tests, coverage 90%, Auditor->Scout: clean
     PROJ-1007: Config change — 1 file, 2 tests, coverage 88%, Scout: clean

   Proceeding to Wave 2...
   ```

7. Proceed to the next wave.

Every pipeline invocation on this path is a **prose-orchestrated** Agent
call: verify the `<<task-complete>>` sentinel in each returned response
and emit `agent_truncated` on suspected truncation (see Truncation
handling below).

<!-- END LEGACY FALLBACK -->

---

## Step 3.5: Smart failure analysis

When a pipeline in a wave reports a blocker, auto-analyze before
escalating to the user. This reduces unnecessary user interruptions.

This applies on both Step 3 paths: on the workflow path, run it for each
ticket in the returned `blocked` array (mining the run journal for the
failure detail); on the legacy path, when a pipeline reports a blocker
mid-wave. Any retry or re-run this step launches is a prose-orchestrated
Agent call.

### Flaky test detection

Check if the failing test meets flaky test criteria:
- The test file was **not modified** by this pipeline (failure in
  pre-existing test code)
- The test name matches known flaky patterns from agent memory
  (`~/.claude/agent-memory/ticket-swarm/classification-heuristics.md`,
  "Known flaky tests" section)
- The failure message suggests timing/network issues (timeout, connection
  refused, intermittent assertion)

If flaky test criteria are met:
- **Auto-retry once** without user intervention
- Log as `[auto-retry: suspected flaky test — {test-name}]`
- If retry succeeds: proceed normally, note in run log
- If retry fails again: escalate as a real failure

### Cross-ticket dependency failure

Check if the error references code from another ticket in the cluster:
- The error message mentions a class, method, or file that another
  ticket in this cluster *created or modified* (from the swarm context
  accumulator)
- The error is a "class not found", "method not found", "undefined
  function", or import failure

If cross-ticket dependency is detected:
- **Auto-resequence**: move the failed ticket to a later wave, after
  the ticket that provides the dependency completes
- Log as `[auto-resequence: dependency on {other-ticket} — {symbol}]`
- Do not count this as a retry — it's a sequencing correction

### Real failure

If neither flaky test nor cross-ticket dependency applies:
- Surface to the user with failure analysis context:
  ```
  {ticket} [BLOCKED] — Test failure (real)
    Failing: {test-class}::{test-method}
    Analysis: Test file was modified by this pipeline. Failure is in new code.
    Not a flaky test. Not a cross-ticket dependency.
    -> retry   = Re-run this ticket's pipeline
    -> context = Provide additional context for Cyrus
    -> skip    = Skip this ticket
    -> abort   = Cancel this ticket
  ```
- Hold downstream waves that depend on this ticket
- Independent waves may proceed

### Recovery logging

All smart recovery actions are included in the cluster report and the
swarm run log for post-mortem analysis by swarm-retro:
```
Smart Recovery Actions:
  PROJ-1003: [auto-retry: suspected flaky test — PreviewTest::testTimeout] (succeeded)
  PROJ-1009: [auto-resequence: dependency on PROJ-1001 — Billing::processRefund] (moved to Wave 3)
```

---

## Step 4: Report cluster completion

When all waves complete (or all remaining tickets are blocked/aborted),
report the cluster summary to ticket-swarm:

```
[Backend Lead] Cluster complete: 4/4 tickets processed

  Succeeded: 2 (PROJ-1003, PROJ-1007)
  Advisory:  1 (PROJ-1001 — analysis says this is a config change on the vendor side, not code)
  Blocked:   1 (PROJ-1002 — test failure in integration step)

  Waves executed: 3
  Agents spawned: 4
  Total files changed: 8
  Total tests written: 18
```

The report lists, for each finished ticket, its `review_result` copied
word for word from that ticket's entry in `results` (on the fallback
path, from that ticket's result collected in Step 3; for a ticket that a
Step 3.5 re-run finished, from that re-run's own result), because
ticket-swarm's PR gate reads it there and holds a finished ticket that
has none.

ticket-swarm aggregates reports from all team leads into the swarm
progress dashboard.

---

## Dependency edge cases

- **Circular dependencies**: If ticket A depends on B and B depends on A
  (from Jira Blocks links), flag this to ticket-swarm as unresolvable.
  Suggest the user merge the tickets or clarify the dependency direction.
- **Single-ticket clusters**: If the domain has only one ticket, skip
  dependency analysis and wave scheduling. Launch the pipeline directly.
- **All-independent clusters**: If no dependencies are detected, launch
  all tickets in a single wave (maximum parallelism).
- **Branch chaining for sequential tickets**: When ticket B depends on
  ticket A, B's branch should be created from A's completed branch (not
  from the default branch). This ensures B sees A's changes. The team
  lead instructs ticket-pickup to use the appropriate base branch.
- **Pre-existing branches**: Before creating any branch, check if one
  matching the ticket key already exists (`git branch --list "*{key}*"`).
  If found, use it — the user may have pre-created the branch manually.
  For chained tickets, verify the pre-existing branch is based on the
  correct parent (rebase onto A's branch if needed).

## Truncation handling — sentinel scoping

The `<<task-complete>>` sentinel requirement is scoped by who owns the
stage:

- **Workflow-owned stages are exempt.** When Step 3's `team-lead-waves`
  workflow path succeeds, each pipeline stage runs as `agent()` with the
  `TICKET_RESULT` schema — a schema-validated return **is** the
  completion signal, and a dead or truncated agent surfaces as `null`
  (attributed to its ticket and reported in `blocked`). Do not look for
  the sentinel there; its absence means nothing.
- **Prose-orchestrated calls still require it.** Every `Agent` tool call
  this skill makes directly — the LEGACY FALLBACK wave execution, Step
  3.5 retries and re-runs, and any other direct pipeline invocation —
  must be verified to contain the `<<task-complete>>` sentinel before
  its output is consumed. See `~/.claude/_shared/agent-turn-cap-warning.md`
  for the detection rule and the swarm-mode response (record, mark the
  ticket blocked with reason `agent_truncated`, move to the next
  ticket). **Still emit the `agent_truncated` metric** for these calls —
  see `~/.claude/skills/metrics-emit/SKILL.md` → `agent_truncated`.

## Maintenance

If you discover something during this task that would improve this skill,
propose the change and ask me to confirm before saving it.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.