plugins/dev/skills/_phase-agent-template/SKILL.md
Reference template every phase-agent skill copies (CTL-448). The leading underscore on the directory name prevents the skill loader from picking this up — it is NOT a runnable skill, only a structural template the nine real phase agents (phase-triage, phase-research, phase-plan, phase-implement, phase-verify, phase-review, phase-pr, phase-monitor-merge, phase-monitor-deploy) clone and specialize. The real phase skills MUST set `user-invocable: true` so `phase-agent-dispatch`'s `claude --bg "/catalyst-dev:phase-X ..."` slash command resolves (CTL-490).
npx skillsauth add coalesce-labs/catalyst _phase-agent-templateInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
This is the structural template for every phase agent in Initiative 1
(plan §"Phase-agent architecture"). It is NOT itself a skill — phase-N
SKILL.md files copy this skeleton and fill in the placeholders marked with
{{...}}. The leading underscore on this directory keeps the skill loader
from registering it. The real phase skills set user-invocable: true because
phase-agent-dispatch spawns them via claude --bg "/catalyst-dev:phase-X ..." —
the bg session parses that as a user slash command (CTL-490).
Every phase agent:
orch-${CATALYST_ORCHESTRATOR_ID} comms channel at entryplugins/dev/scripts/phase-agent-dispatch) — abort if missing.catalyst-session and writes per-phase status updates.plugins/dev/scripts/phase-agent-emit-complete which:
phase.<name>.{complete,failed}.<ticket> event
(broker phase_lifecycle route — CTL-447).${ORCH_DIR}/workers/<TICKET>/phase-<name>.json.catalyst-session.sh end.The dispatcher (plugins/dev/scripts/phase-agent-dispatch) sets these on
the spawned claude --bg process. The phase agent reads them at startup:
| Var | Meaning |
|---|---|
| CATALYST_ORCHESTRATOR_DIR | Where signal files live (workers/<TICKET>/phase-<name>.json) |
| CATALYST_ORCHESTRATOR_ID | Broker session correlation + comms channel suffix |
| CATALYST_PHASE | This phase's name (matches the skill suffix) |
| CATALYST_TICKET | The ticket this phase agent owns |
set -euo pipefail
: "${CATALYST_ORCHESTRATOR_DIR:?required (set by phase-agent-dispatch)}"
: "${CATALYST_ORCHESTRATOR_ID:?required}"
: "${CATALYST_PHASE:?required}"
: "${CATALYST_TICKET:?required}"
ORCH_DIR="$CATALYST_ORCHESTRATOR_DIR"
ORCH_ID="$CATALYST_ORCHESTRATOR_ID"
PHASE="$CATALYST_PHASE"
TICKET="$CATALYST_TICKET"
CHANNEL="orch-${ORCH_ID}"
SIGNAL_FILE="${ORCH_DIR}/workers/${TICKET}/phase-${PHASE}.json"
[[ -f "$SIGNAL_FILE" ]] || { echo "phase-${PHASE}: signal file missing" >&2; exit 1; }
PLUGIN_ROOT="${CLAUDE_PLUGIN_ROOT:-/Users/ryan/.claude/plugins/cache/catalyst/catalyst-dev/$(jq -r .version "${CLAUDE_PLUGIN_ROOT:-.}/.claude-plugin/plugin.json" 2>/dev/null || echo 0.0.0)}"
# 0. Codified bg_job_id yield (CTL-615). If the signal file's bg_job_id
# names a DIFFERENT live bg job, we are a redispatch duplicate of a
# still-running canonical worker. Bow out without touching the signal,
# without emitting any phase event. The helper writes a yield sidecar
# `${ORCH_DIR}/workers/${TICKET}/.phase-${PHASE}-yield` so the
# operator/daemon can attribute the no-op. Exit 0 by design — this is
# NOT a failure; the canonical worker keeps running.
YIELD_CHECK="${PLUGIN_ROOT}/scripts/phase-agent-yield-check.sh"
if [[ -x "$YIELD_CHECK" ]] && bash "$YIELD_CHECK" \
--signal "$SIGNAL_FILE" \
--phase "$PHASE" \
--worker-dir "$(dirname "$SIGNAL_FILE")"; then
echo "phase-${PHASE}: yielding to canonical worker (CTL-615)" >&2
exit 0
fi
# 1. Join the shared comms channel (best-effort — phase agents must not crash
# if catalyst-comms is unavailable).
COMMS="${PLUGIN_ROOT}/scripts/catalyst-comms"
[[ -x "$COMMS" ]] || COMMS="$(command -v catalyst-comms 2>/dev/null || true)"
if [[ -n "$COMMS" ]]; then
"$COMMS" join "$CHANNEL" --as "$TICKET" \
--capabilities "phase-${PHASE}: ${TICKET}" \
--orch "$ORCH_ID" --parent orchestrator --ttl 3600 >/dev/null 2>&1 || true
"$COMMS" send "$CHANNEL" "phase-${PHASE} started" --as "$TICKET" --type info \
--orch "$ORCH_ID" >/dev/null 2>&1 || true
fi
# 2. Start a catalyst-session (cost / token instrumentation).
SESSION_SCRIPT="${PLUGIN_ROOT}/scripts/catalyst-session.sh"
if [[ -x "$SESSION_SCRIPT" ]]; then
CATALYST_SESSION_ID=$("$SESSION_SCRIPT" start \
--skill "phase-${PHASE}" \
--ticket "$TICKET" \
--workflow "${CATALYST_SESSION_ID:-}")
export CATALYST_SESSION_ID
fi
# 3. Mark the signal file as "running" + record the start timestamp +
# persist catalystSessionId (CTL-496: orchestrate-roll-usage --phase
# reads this to attribute cost to the right session_metrics row without
# relying on the ticket+skill_name DB-lookup heuristic).
TS=$(date -u +%Y-%m-%dT%H:%M:%SZ)
TMP="${SIGNAL_FILE}.tmp.$$"
jq --arg ts "$TS" --arg sid "${CATALYST_SESSION_ID:-}" '
.status = "running"
| .updatedAt = $ts
| if $sid != "" then .catalystSessionId = $sid else . end
' "$SIGNAL_FILE" > "$TMP" \
&& mv "$TMP" "$SIGNAL_FILE"
Every phase agent declares a /goal line at the top of its phase-specific
work block. The condition MUST be transcript-evaluable and reference the
artifact this phase produces (per the lookup table in phase-agent-dispatch).
Example for phase-research:
/goal "I have written thoughts/shared/research/<date>-${TICKET,,}.md
with valid frontmatter and at least 10 file:line references AND I
have printed the path + a confirmation line; OR I have stopped
after 35 turns and printed what's done."
Turn caps come from .catalyst/config.json:catalyst.orchestration.phaseAgents.turnCaps.<phase>
with per-phase defaults baked into phase-agent-dispatch.
Outbound message types — phase agent → orchestrator:
| Type | When | Cadence per session |
|-------------|-----------------------------------------------|---------------------|
| info | Phase started / phase work milestones | 3–5 |
| attention | Scope conflict, missing access, repeated failures, stalled | 0–2 |
| question | Specific clarification needed (msg_id is correlation key) | 0–1 |
| done | Terminal success (emitted by phase-agent-emit-complete) | 1 |
Inbound message types — orchestrator → phase agent (reads on every loop tick):
| Type | Effect |
|-------------|-------------------------------------------------------------|
| directive | Answer to a previously-posted question (correlated via .re field). Phase agent uses the answer and proceeds. |
| pause | Halt and poll. Resumes on directive or info resume signal. |
| abort | Phase agent cleans up, calls phase-agent-emit-complete with --status failed --reason aborted_by_orchestrator, exits. |
Use the helper functions in plugins/dev/scripts/catalyst-comms directly —
do NOT reimplement send/poll logic per phase. The contract tests live in
plugins/dev/scripts/__tests__/phase-agent-comms.test.sh.
/goal "{{ transcript-evaluable goal condition for this phase }}"
{{ Phase-specific instructions. The actual work delegates to the canonical
skill (e.g., /catalyst-dev:research-codebase) via the Task tool wherever
possible. See plan §"Phase agents wrap canonical skills" for the mapping. }}
# Drain inbound comms one last time before emitting the complete event so
# we don't miss an abort sent in the final seconds.
if [[ -n "$COMMS" ]]; then
COMMS_CHANNEL_FILE="${CATALYST_DIR:-$HOME/catalyst}/comms/channels/${CHANNEL}.jsonl"
# (intentionally lightweight — full inbound handling is the prelude's job)
fi
# Emit phase-complete event + close signal file + end session.
EMIT="${PLUGIN_ROOT}/scripts/phase-agent-emit-complete"
if [[ -x "$EMIT" ]]; then
"$EMIT" --phase "$PHASE" --ticket "$TICKET" --status complete
fi
# Self-halt after complete to prevent zombie workers (CTL-778 step 2).
# Read our own bg_job_id from the signal file and ask Claude to stop us.
# Best-effort: a failed stop is covered by the daemon reaper backstop.
if [[ -n "${ORCH_DIR:-}" && -f "${ORCH_DIR}/workers/${TICKET}/phase-${PHASE}.json" ]]; then
_SELF_BG=$(jq -r '.bg_job_id // empty' \
"${ORCH_DIR}/workers/${TICKET}/phase-${PHASE}.json" 2>/dev/null || true)
[[ -n "$_SELF_BG" ]] && claude stop "${_SELF_BG:0:8}" >/dev/null 2>&1 || true
fi
# Best-effort: post done to the comms channel (final).
[[ -n "$COMMS" ]] && "$COMMS" done "$CHANNEL" --as "$TICKET" >/dev/null 2>&1 || true
Whenever a phase writes a failed/stalled signal that will be shown to the
operator (e.g. via the Inbox "Needs you" section), it MUST populate an
explanation block alongside failureReason. The contract shape:
{
"what_failed": "<specific symptom in plain language>",
"observed": { "<key>": "<value>", ... },
"attempts": ["<what was tried>", ...],
"why_gave_up": "<reason no further autonomous action was taken>",
"human_question": "<one specific, answerable question for the operator>"
}
Use the CLI shim so the shell can build the JSON without risk of syntax errors or missing fields:
EXPL_JSON="$(node "${PLUGIN_ROOT}/scripts/execution-core/escalation-explain.mjs" \
--ticket "$TICKET" --phase "$PHASE" \
--what-failed "{{ specific symptom }}" \
--observed "$(jq -nc '{key:"value"}' 2>/dev/null || echo '{}')" \
--why-gave-up "{{ reason }}" \
--human-question "{{ specific question }}" \
2>/dev/null || echo '{}')"
Then merge it into the signal alongside failureReason. Guard the value on a
prior line and pass the variable directly — never inline ${EXPL_JSON:-{}}: the
bash parser closes the parameter expansion at the FIRST }, so a non-empty value
like {"a":1} expands to {"a":1}} (trailing brace → invalid JSON → jq exits
non-zero → the && mv is skipped and the signal is never written). Verified in
bash 3.2 and 5.x.
[ -n "$EXPL_JSON" ] || EXPL_JSON='{}'
jq --arg ts "$(date -u +%Y-%m-%dT%H:%M:%SZ)" --argjson expl "$EXPL_JSON" \
'.status = "failed" | .failureReason = "{{ reason }}" | .explanation = $expl | .updatedAt = $ts' \
"$SIGNAL_FILE" > "$SIGNAL_FILE.tmp.$$" && mv "$SIGNAL_FILE.tmp.$$" "$SIGNAL_FILE"
The CLI shim rejects these with degraded: true and substitutes a
generic fallback. Never write:
Write the specific question instead:
Any non-recoverable failure (turn cap hit, prior artifact missing, scope conflict that the orchestrator cannot resolve):
"$EMIT" --phase "$PHASE" --ticket "$TICKET" --status failed \
--reason "{{ short human-readable reason }}"
[[ -n "$COMMS" ]] && "$COMMS" send "$CHANNEL" "phase-${PHASE} failed: {{reason}}" \
--as "$TICKET" --type attention --orch "$ORCH_ID" >/dev/null 2>&1 || true
exit 1
The orchestrator's Phase 4 monitor receives the phase.<name>.failed.<ticket>
event via the broker phase_lifecycle route and dispatches a fix-up phase
agent (same skill, --resume flag, prompt seeded with the prior failure
context). One retry; second failure escalates to user via attention.
Claude Code skills don't support inheritance — each SKILL.md is its own unit. The template lives here so phase agents stay synchronized at edit time (when adding a new phase, copy this file, fill in the placeholders), not at runtime. If the contract changes, every phase SKILL.md needs to be manually re-aligned — there is no automatic propagation.
testing
Phase-agent that fixes a failing verify verdict so the pipeline self-heals instead of stalling to needs-human (CTL-653). Reads `${ORCH_DIR}/workers/<ticket>/verify.json`, fixes the `findings[]` (every severity:"high" plus the regression_risk drivers) directly via Edit/Write, commits the remediation, and emits `phase.remediate.complete.<ticket>`. The scheduler's router then re-dispatches `verify` to re-check (the verify⇄remediate cycle, cap 3). Dispatched as a `claude --bg` job by `phase-agent-dispatch`, which invokes it via slash command — hence `user-invocable: true`.
tools
--- name: phase-triage description: Phase agent that triages a Linear ticket — expands acronyms, classifies (feature/bug/docs/refactor/chore), identifies genuine blockers (a semantic second-pass over the backlog — NOT a prose scrape; CTL-838), estimates scope, writes triage.json, and posts a triage analysis comment to Linear. Triage completion is signaled by that comment plus the local triage.json — there is no `triaged` label. Emits phase.triage.complete.<TICKET> on success and phase.triage.fai
tools
Phase agent for the research step of the 9-phase orchestrator pipeline (CTL-450). Wraps /catalyst-dev:research-codebase and produces thoughts/shared/research/<date>-<ticket>.md, then emits phase.research.complete.<ticket>. Reads triage.json from the worker dir as its prior-phase artifact. Spawned via plugins/dev/scripts/phase-agent-dispatch, which invokes it via slash command — hence `user-invocable: true`.
development
Phase-agent wrapper that opens the pull request after implementation completes (CTL-449 Initiative 1 Phase 3). Delegates to `/catalyst-dev:create-pr` (which already auto-runs `describe-pr` and transitions Linear to `inReview`), then writes the PR number + URL into the phase signal file so the downstream `phase-monitor-merge` agent can read it without re-querying GitHub. Dispatched as a `claude --bg` job by `phase-agent-dispatch`, which invokes it via slash command — hence `user-invocable: true`.