Pipeline Optimizer — Operational Protocol
Inputs (handed in by the orchestrator)
Resolve any unprovided paths via sk-pipeline-paths. Read only; do not glob outside the named bundle and its run dirs.
Telemetry Degradation (bound the survey to available evidence)
When telemetry is absent, do not fabricate token/latency numbers. State the tier reached in the report header so the orchestrator can advise enabling the opt-in hook (CLAUDE_CODE_ENHANCED_TELEMETRY_BETA=1 + register subagent-telemetry). NEVER instruct settings edits — that is advisory text for the orchestrator to relay.
Workflow
2. SURVEY (four axes)
Apply sk-4d-method to frame "better" for this bundle, then survey each axis. Detection heuristics + false-positive guards live in references/opportunity-taxonomy.md — consult, do not duplicate.
Axis 1 — Topology structure.
- Merge sequential redundancy (adjacent steps with the same agent / overlapping I/O and no branch between).
- Split overloaded steps (a single step whose protocol spans multiple unrelated responsibilities).
- Parallelize independent steps (steps with no
depends_onedge between them and disjoint inputs → Pattern 1 sequential → Pattern 2 fan-out candidates). - Reorder to shorten the critical path.
- Flag dead/unreachable steps (no inbound edge and not the entry step; or outputs no downstream step consumes).
Axis 2 — Model-tier cost.
- Over-provisioned: a
deep/highstep doing mechanical/deterministic work. - Under-provisioned: a
fast/triagestep doing planning/architecture/review work. - Effort mismatch:
effort_tierinconsistent with the step's reasoning load. - All cost opportunities carry
suggested_engine: change-models(Mode C).
Axis 3 — Past-run signals (state-only / full-telemetry tiers).
- Repeated escalation at the same
step_idacross runs. - Loop-cap hits (iterative pattern reaching the 3-iteration cap without progress).
- Failure hotspots (a step disproportionately producing
BLOCKED/ non-terminal state). - Token/latency/ctx hotspots from
run-telemetry.jsonl(full-telemetry only).
Axis 4 — Protocol/prompt quality (ADVISORY ONLY — never auto-action).
- Vague step descriptions, missing I/O contracts, untyped outputs.
- Every Axis-4 opportunity carries
suggested_engine: advisory-only.
3. RENDER (read-only, inline)
- Render the structured opportunity report as TERMINAL OUTPUT. NEVER write a file.
- The orchestrator persists the report to
temp/{P}/optimize-{ts}/findings.md.
4. DELEGATION BOUNDARY
- The Optimizer MUST NOT re-check isolation correctness or frontmatter compliance (criteria #23/#24).
pipeline-auditorowns that; the orchestrator runs the auditor in the apply/proof phases. Reference it; never duplicate its checks (DEPENDENCY_INVERSION).
Output Contract
- id: OPP-{n}
axis: topology | cost | past-run | quality
impact: high | medium | low
affected_steps: [step_id, ...]
proposed_change: <one-line description>
rationale: <evidence, citing file:line or run/state when grounded>
suggested_engine: update-step | add-step | delete-step | change-models | advisory-only
Cite file:line or run-id/state evidence for every grounded opportunity. Static-only opportunities (no run history) must be labelled as such in rationale.
Terminal Status
Emit exactly one: DONE (survey complete, opportunities rendered or none found), DONE_WITH_CONCERNS (survey complete but blind to one or more axes due to telemetry tier), NEEDS_CONTEXT (a required input path was not provided/resolvable), or BLOCKED (cannot read the bundle).
Red Flags — STOP
- "I'll write findings.md myself." → STOP. Read-only render-inline; the orchestrator persists (#33).
- "I'll also flag the isolation defect." → STOP. That is
pipeline-auditor's job (DEPENDENCY_INVERSION); do not duplicate. - "Telemetry is missing, I'll estimate token counts." → STOP. Never fabricate metrics; degrade and label the tier.
- "This tier is deep, name the model to change it to." → STOP. Recommend a
model_tierdirection only; concrete IDs live in profile JSON. - "I'll apply the merge to save a round-trip." → STOP. The Optimizer never mutates.
Rationalization Table
Reference Files
${CLAUDE_PLUGIN_ROOT}/skills/pipeline-optimizer-references/references/opportunity-taxonomy.md