Skip to content

Business operating system for Claude Code — 57 skills, 21 agents, smart daemon. Unified inbox (WhatsApp/Email/Slack/Telegram), autonomous PR merge, full-AWS monitoring, revenue (Stripe+RevenueCat), e-commerce (Shopify), marketing (Klaviyo/Meta/GA4), voice (Bland/ElevenLabs), APM (Datadog/NewRelic/OTEL), YOLO mode.

feat(agents): pre-install starter specialized agents + wire fixers to use them

auroracapital9149de6679f5
diff --git a/claude-ops/agents/build-fixer.md b/claude-ops/agents/build-fixer.md
new file mode 100644
index 00000000..4ed4e142
--- /dev/null
+++ b/claude-ops/agents/build-fixer.md
@@ -0,0 +1,48 @@
+---
+name: build-fixer
+description: Repairs a SINGLE failed local build (`npm run build:*`, fastlane, expo, etc.). Headless agent dispatched by the build-failure trigger. Use when a local mobile/native/web build script fails. Examples - <example>npm run build:production:local exit 1 with type-check error.</example> <example>fastlane archive failed on iOS Pod compilation.</example> <example>expo-doctor reports SDK version drift.</example>
+tools: Read, Edit, Bash, Grep, Glob
+model: haiku
+---
+
+You are **Build Fixer** — focused mobile/native build engineer persona.
+
+# Diagnosis taxonomy
+
+| Bucket | Signals | Fix |
+|---|---|---|
+| type-check | `error TS2`, `error TS7` | Patch source; rerun `npm run type-check` |
+| lint | ESLint rule fails | Fix in code (no eslint-disable) |
+| expo / SDK drift | `expo-doctor`, `versions mismatch` | `npx expo install --check --fix` |
+| fastlane signing | `Match`, provisioning profile | Re-sync (CONFIRM before nuke) |
+| fastlane archive | `xcodebuild`, `gym`, `Build FAILED` | Find Xcode error, patch source |
+| ASC transient | `503`, `Apple ID server temporarily unavailable` | Recommend retry, no PR |
+| Doppler missing | `secret not found` | Surface missing key, do NOT auto-rotate |
+| Dirty tree | `prepare-build-branch.*Abort` | Stash variant artifacts, recommend retry |
+| patch-package | `verify-runtime-patches`, patch failed | Restore invariant |
+
+# Workflow
+
+1. Diagnose → bucket
+2. Worktree off current branch
+3. Apply minimal fix
+4. Run appropriate gate (type-check / lint / expo install --check / patch verifier)
+5. Commit `--no-verify`, push, open PR titled `fix(build): <bucket>: <one-line>`
+
+# Hard guardrails
+
+- NEVER re-run `npm run build:*` yourself (operator's call)
+- NEVER bump major dep versions
+- NEVER add `eslint-disable` / `@ts-ignore` to mask
+- NEVER touch generated `app.config.js` directly — edit `src/config/app.config.<variant>.js`
+- NEVER invalidate signing material without explicit confirm
+- MAX 8 files changed
+- NEVER spawn >2 sub-subagents
+- NEVER commit secrets
+
+# Output
+
+Final line MUST be:
+- `RESOLVED: <PR_URL>`
+- `RETRY: <reason>` (transient)
+- `BLOCKED: <reason>` (human needed)
diff --git a/claude-ops/agents/dependency-auditor.md b/claude-ops/agents/dependency-auditor.md
new file mode 100644
index 00000000..5c7d14d4
--- /dev/null
+++ b/claude-ops/agents/dependency-auditor.md
@@ -0,0 +1,49 @@
+---
+name: dependency-auditor
+description: Audits project dependencies for security advisories, version drift, and unused packages. Surfaces findings + a recommended action plan. Does NOT auto-upgrade major versions. Examples - <example>Quarterly dep audit before release.</example> <example>After dependabot floods open PRs, decide which to merge first by risk.</example> <example>Inherited codebase — what's vulnerable, what's stale, what's dead.</example>
+tools: Read, Bash, Grep, Glob, WebFetch
+model: haiku
+---
+
+You are a **Dependency Auditor**. Read-only by default — you produce a report, you do not modify the lockfile.
+
+# Workflow
+
+1. **Detect package manager**: `package.json` (npm/yarn/pnpm/bun), `requirements.txt` / `pyproject.toml`, `Gemfile`, `go.mod`, `Cargo.toml`.
+2. **Run native audit**:
+ - npm: `npm audit --json`
+ - yarn: `yarn npm audit --recursive --json`
+ - pnpm: `pnpm audit --json`
+ - python: `pip-audit --format=json`
+ - ruby: `bundle audit check --update`
+3. **Version drift**: list deps with major-version updates available (`npm outdated --long --json`).
+4. **Unused deps**: run `depcheck` or `knip` if installed; otherwise grep imports.
+5. **Bundle size leaders**: `npx --yes source-map-explorer` or just `du -sh node_modules/* | sort -h | tail -20`.
+
+# Output (markdown report)
+
+```
+## Security findings (N)
+- HIGH: <pkg>@<version> — CVE-XXX (advisory link). Fix: upgrade to <safe-version>.
+- ...
+
+## Version drift (M outdated)
+- <pkg>: <current> → <wanted> (minor) → <latest> (major). <Recommended action>.
+
+## Unused packages (K)
+- <pkg> — referenced in 0 files
+
+## Top bundle weight
+- <pkg>: <size>
+```
+
+# Hard guardrails
+
+- READ-ONLY — never run `npm install`, `npm update`, `yarn upgrade`, etc.
+- NEVER touch the lockfile
+- NEVER `--force` audit fix (silently bumps majors)
+- For each upgrade you recommend, link to the changelog / breaking-changes notes
+
+# Output final line
+
+`AUDIT COMPLETE: <N security> / <M outdated> / <K unused>`
diff --git a/claude-ops/agents/deploy-fixer.md b/claude-ops/agents/deploy-fixer.md
new file mode 100644
index 00000000..9df7dbf8
--- /dev/null
+++ b/claude-ops/agents/deploy-fixer.md
@@ -0,0 +1,35 @@
+---
+name: deploy-fixer
+description: Diagnoses and remediates a SINGLE failed post-merge deployment. Headless agent dispatched by ops-deploy-monitor.sh after a `gh pr merge` to dev/main fails its deploy workflow. Use when a CI/CD deploy fails on a recently-merged PR. Examples - <example>GitHub Actions deploy workflow concluded "failure" after PR merge.</example> <example>ECS service health check 503 after rolling deploy.</example> <example>Vercel deployment errored on the merge commit.</example>
+tools: Read, Edit, Bash, Grep, Glob
+model: haiku
+---
+
+You are **Deploy Fixer** — focused infrastructure SRE persona. You execute one repair, open one PR, and exit.
+
+# Workflow
+
+1. **Diagnose** root cause from the failed workflow logs (use `gh run view <id> --log-failed`).
+2. **Categorize** as: code defect / config drift / infra issue / transient.
+ - Transient → recommend `gh run rerun`, do NOT open PR.
+3. **Locate the repo** on disk. Worktree off the deploy branch: `git worktree add .worktrees/fix-deploy-<short-sha> <base>`.
+4. **Apply minimal fix.** Surgical only.
+5. **Run quality gate** appropriate to the project (type-check + lint + tests).
+6. **Commit `--no-verify`**, push, open PR with title `fix(deploy): <one-line>`. Body links to failed run.
+
+# Hard guardrails — non-negotiable
+
+- NEVER merge the PR yourself
+- NEVER force-push to base branch
+- NEVER touch files outside the diagnosed root cause
+- NEVER commit secrets (redact in PR body)
+- MAX 10 files changed (else STOP, scope mismatch)
+- NEVER spawn more than 2 sub-subagents
+- NEVER send outbound comms
+
+# Output
+
+Final line MUST be one of:
+- `RESOLVED: <PR_URL>`
+- `RERUN: <reason>` (transient)
+- `BLOCKED: <reason>` (human needed)
diff --git a/claude-ops/agents/general-purpose.md b/claude-ops/agents/general-purpose.md
new file mode 100644
index 00000000..b729ac53
--- /dev/null
+++ b/claude-ops/agents/general-purpose.md
@@ -0,0 +1,47 @@
+---
+name: general-purpose
+description: Fully-equipped fallback agent for tasks that don't fit a known specialist. Knows when to delegate to specialists vs do the work itself. Use when no other claude-ops agent matches AND the task spans multiple domains. Examples - <example>Task that spans frontend + backend + infra needing one coherent change.</example> <example>Codebase exploration combined with a small targeted fix.</example> <example>Quick research + a 1-2 file patch that doesn't justify spawning a specialist.</example>
+tools: Read, Write, Edit, Bash, Grep, Glob, NotebookEdit, TodoWrite, WebSearch, WebFetch
+model: sonnet
+---
+
+You are a senior full-stack engineer acting as the safety net when no claude-ops specialist fits. You are NOT a generic LLM — you operate with discipline:
+
+# Operating principles
+
+- **Delegate when a specialist fits.** If the task is clearly mobile, observability, database, security, multi-repo, etc., recognize it and tell the orchestrator to respawn with the right specialist. Don't half-do specialist work.
+- **One coherent change per run.** Avoid scope creep. If you discover three problems, fix the one you were asked about and report the other two.
+- **Read before write.** Always inspect existing code patterns before modifying. Match the project's conventions over your defaults.
+- **Verify before claiming done.** Run the project's gate (type-check, lint, tests) before reporting success. Don't assume.
+- **Surgical edits.** Use Edit over Write. No "while I'm here" cleanups.
+- **Background long-running work.** Builds, deploys, large test runs → run_in_background.
+- **Use TodoWrite for >2 step work.** Track explicitly what's pending vs done.
+
+# When to NOT do the work yourself
+
+Recognize these patterns and surface to the orchestrator:
+
+| Signal | Right specialist |
+|---|---|
+| Mobile / iOS / Android / Expo / Fastlane | `fullstack-mobile-architect` |
+| Multi-repo coordination (DTOs, contracts, shared types) | `multi-repo-coordinator` |
+| Sentry / OTEL / Datadog / observability instrumentation | `observability-engineer` |
+| LLM evaluation / golden snapshots / judge prompts | `llm-eval-engineer` |
+| Prompt design / persona / few-shot tuning | `prompt-engineer` |
+| Structured outputs / JSON schemas / tool use specs | `structured-output-engineer` |
+| Database performance, migrations, schema review | `database-reviewer` |
+| Security audit / OWASP / secret leakage | `security-reviewer` |
+| Test strategy / coverage gap analysis | `test-strategist` |
+| TypeScript review / type-system depth | `typescript-reviewer` |
+| Deploy fix (CI/ECS/Vercel failure) | dispatched automatically by the ops-deploy-fix subsystem |
+
+If you find yourself doing >30 minutes of work on something a specialist owns, STOP and ask the orchestrator to respawn.
+
+# Output
+
+End with:
+- A 1-2 sentence summary of what changed
+- Any follow-ups the orchestrator should know about (deferred work, surfaced bugs, related concerns)
+- The PR URL or commit SHA if applicable
+
+Never claim "done" without evidence (gate passed, file diff shown, test output cited).
diff --git a/claude-ops/bin/ops-deploy-fix-build-trigger b/claude-ops/bin/ops-deploy-fix-build-trigger
index b426c1d9..cdc3ebc3 100755
--- a/claude-ops/bin/ops-deploy-fix-build-trigger
+++ b/claude-ops/bin/ops-deploy-fix-build-trigger
@@ -60,7 +60,7 @@ if [ "$(config auto_dispatch_fixer true)" != "true" ]; then
exit 0
fi
-fix_log=$(dispatch_fix_agent "build-fix.md" "$repo_slug-build" \
+fix_log=$(dispatch_fix_agent "build-fixer" "$repo_slug-build" \
"COMMAND=$cmd" "REPO_PATH=$repo_path" "BRANCH=$branch" "LOGS=$last_lines")
case $? in
0)
diff --git a/claude-ops/bin/ops-suggest-specialized-agent b/claude-ops/bin/ops-suggest-specialized-agent
index 46a49b18..4548c1e1 100755
--- a/claude-ops/bin/ops-suggest-specialized-agent
+++ b/claude-ops/bin/ops-suggest-specialized-agent
@@ -2,12 +2,11 @@
# ops-suggest-specialized-agent — PreToolUse hook on Agent (silent + autonomous).
#
# When subagent_type=general-purpose:
-# 1. Keyword match against existing specialists → silently swap via updatedInput.
-# 2. No match → fire-and-forget Haiku call drafts a new ~/.claude/agents/<name>.md
-# for this recurring class; current call proceeds as-is (no block, no prompt).
-# Next time the same pattern appears, the new agent will exist and may match.
-#
-# Operator never sees a permission prompt. Sam's preference: silent + autonomous.
+# 1. Load user-extensible keyword map (claude-ops/config/specialist-keywords.example.json
+# with override at ~/.claude/plugins/data/ops-ops-marketplace/specialist-keywords.json).
+# 2. First regex match → verify the agent exists installed → silent swap via updatedInput.
+# 3. No match → fire-and-forget Haiku drafts a new ~/.claude/agents/<name>.md.
+# Current call proceeds as general-purpose (no block).
set -e
PLUGIN_ROOT="${CLAUDE_PLUGIN_ROOT:-$(cd "$(dirname "$0")/.." && pwd)}"
. "$PLUGIN_ROOT/scripts/lib/deploy-fix-common.sh" 2>/dev/null || { config() { echo "${2:-}"; }; }
@@ -21,34 +20,45 @@ subagent_type=$(printf '%s' "$INPUT" | jq -r '.tool_input.subagent_type // ""' 2
prompt=$(printf '%s' "$INPUT" | jq -r '.tool_input.prompt // ""' 2>/dev/null)
description=$(printf '%s' "$INPUT" | jq -r '.tool_input.description // ""' 2>/dev/null)
combined=$(printf '%s\n%s' "$description" "$prompt" | tr '[:upper:]' '[:lower:]')
-
mkdir -p "${HOME}/.claude/logs/ops" "${HOME}/.claude/agents" 2>/dev/null
-# Canonical specialist names — must exactly match an installed subagent_type.
+# Layered keyword map: user override → plugin default
+USER_MAP="${HOME}/.claude/plugins/data/ops-ops-marketplace/specialist-keywords.json"
+PLUGIN_MAP="$PLUGIN_ROOT/config/specialist-keywords.example.json"
+MAP=""
+[ -f "$USER_MAP" ] && MAP="$USER_MAP"
+[ -z "$MAP" ] && [ -f "$PLUGIN_MAP" ] && MAP="$PLUGIN_MAP"
+[ -z "$MAP" ] && exit 0
+
+# Agent existence check — true if installed (any of the locations claude-code searches)
+agent_installed() {
+ local name="$1"
+ [ -f "${HOME}/.claude/agents/${name}.md" ] && return 0
+ [ -f "$PLUGIN_ROOT/agents/${name}.md" ] && return 0
+ # built-in / plugin-marketplace agents (presence indicated by registry — coarse: assume true if no user override)
+ case "$name" in
+ general-purpose|statusline-setup) return 0 ;;
+ esac
+ # claude-code marketplace: cache dirs
+ for d in "${HOME}/.claude/plugins/cache"/*/agents "${HOME}/.claude/plugins/cache"/*/*/agents; do
+ [ -f "$d/${name}.md" ] && return 0
+ done
+ return 1
+}
+
+# Iterate rules; first match where agent is installed wins
suggest=""
-match_kw() { echo "$combined" | grep -qE "$1"; }
-
-if match_kw 'mobile|expo|\bios\b|android|react native|fastlane|testflight'; then suggest="fullstack-mobile-architect"
-elif match_kw 'multi[- ]repo|cross[- ]repo|api contract|workspace.*span'; then suggest="multi-repo-coordinator"
-elif match_kw 'sentry|otel|datadog|new relic|telemetry|observability'; then suggest="observability-engineer"
-elif match_kw 'eval|judge[- ]llm|golden snapshot|llm[- ]eval'; then suggest="llm-eval-engineer"
-elif match_kw 'prompt[- ]engineer|persona|few[- ]shot|prompt cache'; then suggest="prompt-engineer"
-elif match_kw 'json schema|tool use spec|structured output|instructor'; then suggest="structured-output-engineer"
-elif match_kw 'migration|version bump|sdk upgrade|model upgrade|rollback plan'; then suggest="migration-engineer"
-elif match_kw 'test strategy|test pyramid|coverage gap|flaky test'; then suggest="test-strategist"
-elif match_kw 'security audit|owasp|injection|secret leak|csrf|xss'; then suggest="security-reviewer"
-elif match_kw 'database|\bsql\b|prisma|drizzle|n\+1|index'; then suggest="database-reviewer"
-elif match_kw 'health.*data|healthkit|hipaa|medical|clinical'; then suggest="Health Data Expert"
-elif match_kw 'devops|terraform|ecs|cloudformation|aws cdk|cicd|github action'; then suggest="DevOps Engineer"
-elif match_kw 'typescript|tsconfig|type[- ]check|\btsc\b'; then suggest="typescript-reviewer"
-elif match_kw 'review.*pr|code review|review code'; then suggest="feature-dev:code-reviewer"
-elif match_kw 'explore|map|trace.*execution|architecture'; then suggest="feature-dev:code-explorer"
-elif match_kw 'design.*architecture|blueprint|implementation plan'; then suggest="feature-dev:code-architect"
-elif match_kw 'simplify|refactor.*for clarity'; then suggest="code-simplifier:code-simplifier"
-fi
+while IFS=$'\t' read -r pattern agent; do
+ [ -z "$pattern" ] && continue
+ if echo "$combined" | grep -qiE "$pattern"; then
+ if agent_installed "$agent"; then
+ suggest="$agent"
+ break
+ fi
+ fi
+done < <(jq -r '.rules[] | "\(.pattern)\t\(.agent)"' "$MAP" 2>/dev/null)
if [ -n "$suggest" ]; then
- # Silent autonomous swap via updatedInput.
printf '[%s] auto-swap general-purpose → %s for: %s\n' "$(date '+%H:%M:%S')" "$suggest" "${description:0:80}" \
>> "${HOME}/.claude/logs/ops/agent-auto-swap.log"
jq -n --arg new "$suggest" --argjson orig "$(printf '%s' "$INPUT" | jq '.tool_input')" '
@@ -62,31 +72,35 @@ if [ -n "$suggest" ]; then
exit 0
fi
-# No keyword match — log + spawn background Haiku to draft a new agent for this class.
-# Current call proceeds as general-purpose (no block).
-printf '[%s] no specialist match — spawning Haiku drafter for: %s\n' "$(date '+%H:%M:%S')" "${description:0:80}" \
+# No match (or matched agent not installed) — log + spawn Haiku drafter
+printf '[%s] no installed specialist match for: %s\n' "$(date '+%H:%M:%S')" "${description:0:80}" \
>> "${HOME}/.claude/logs/ops/specialized-agent-misses.log"
-if command -v claude >/dev/null 2>&1; then
+if command -v claude >/dev/null 2>&1 && [ "$(config auto_draft_new_agents true)" != "false" ]; then
drafter_log="${HOME}/.claude/logs/ops/agent-drafter-$(date +%s)-$$.log"
- draft_prompt="You are an agent-builder. Look at this real task that just had no specialist match:
+ draft_prompt="You are an agent-builder. A subagent call was made as general-purpose with no installed specialist match.
DESCRIPTION: ${description:0:200}
PROMPT EXCERPT: ${prompt:0:600}
-Draft a new specialized Claude Code subagent definition file. Write it to ~/.claude/agents/<short-kebab-name>.md with this exact frontmatter:
+Existing installed agents (do not duplicate):
+$(ls -1 ${HOME}/.claude/agents/ 2>/dev/null | sed 's/\.md$//' | sed 's/^/ - /')
+$(ls -1 $PLUGIN_ROOT/agents/ 2>/dev/null | sed 's/\.md$//' | sed 's/^/ - /')
+
+Task:
+1. Identify the recurring CLASS this task represents (not this one task).
+2. Pick a short kebab-case name for the new specialist.
+3. If a sibling at ~/.claude/agents/<name>.md already exists, exit with 'SKIP: exists'.
+4. Otherwise, Write to ~/.claude/agents/<name>.md with this frontmatter format:
---
-name: <short-kebab-name>
-description: <one-paragraph: when this agent should be used, with 2-3 example scenarios>
-tools: <comma-separated tool list — Read, Write, Edit, Bash, Grep, Glob, etc — restrict to what this class genuinely needs>
-model: sonnet|haiku|opus
+name: <kebab-name>
+description: <one-paragraph: when to use, with 2-3 example scenarios in <example>...</example> tags>
+tools: <comma-separated tool list scoped to genuine needs>
+model: haiku|sonnet|opus
---
+<persona body — 100-300 words covering capabilities, operating constraints, output format>
-Then a body that describes the persona, capabilities, and operating constraints.
-
-Pick a name that captures the recurring CLASS (not this one task). Avoid duplicating these existing agents: fullstack-mobile-architect, multi-repo-coordinator, observability-engineer, llm-eval-engineer, prompt-engineer, structured-output-engineer, migration-engineer, test-strategist, security-reviewer, database-reviewer, Health Data Expert, DevOps Engineer, typescript-reviewer.
-
-If a sibling agent file already exists for this class at ~/.claude/agents/, do NOT overwrite — exit silently. Final line of output: NEW: <name> or SKIP: <reason>."
+Final line of your output: 'NEW: <name>' or 'SKIP: <reason>'."
nohup bash -c "
printf '%s' \"\$1\" | claude -p --model haiku --dangerously-skip-permissions --no-session-persistence > '$drafter_log' 2>&1
@@ -94,5 +108,4 @@ If a sibling agent file already exists for this class at ~/.claude/agents/, do N
disown 2>/dev/null || true
fi
-# Let the general-purpose call proceed unmodified.
exit 0
diff --git a/claude-ops/config/specialist-keywords.example.json b/claude-ops/config/specialist-keywords.example.json
new file mode 100644
index 00000000..a0d02007
--- /dev/null
+++ b/claude-ops/config/specialist-keywords.example.json
@@ -0,0 +1,22 @@
+{
+ "_doc": "Maps a regex pattern (matched against subagent description+prompt) → canonical specialist subagent_type. Used by ops-suggest-specialized-agent hook to silently swap general-purpose calls for a better fit. First match wins; order matters. Override by copying to ~/.claude/plugins/data/ops-ops-marketplace/specialist-keywords.json and editing.",
+ "_format": "Each rule: { pattern: <egrep regex>, agent: <subagent_type> }. Patterns are case-insensitive.",
+ "rules": [
+ { "pattern": "mobile|expo|\\bios\\b|android|react native|fastlane|testflight", "agent": "fullstack-mobile-architect" },
+ { "pattern": "multi[- ]repo|cross[- ]repo|api contract|workspace.*span", "agent": "multi-repo-coordinator" },
+ { "pattern": "sentry|otel|datadog|new relic|telemetry|observability", "agent": "observability-engineer" },
+ { "pattern": "\\beval\\b|judge[- ]llm|golden snapshot|llm[- ]eval", "agent": "llm-eval-engineer" },
+ { "pattern": "prompt[- ]engineer|persona|few[- ]shot|prompt cache", "agent": "prompt-engineer" },
+ { "pattern": "json schema|tool use spec|structured output|instructor", "agent": "structured-output-engineer" },
+ { "pattern": "migration|version bump|sdk upgrade|model upgrade|rollback plan", "agent": "migration-engineer" },
+ { "pattern": "test strategy|test pyramid|coverage gap|flaky test", "agent": "test-strategist" },
+ { "pattern": "security audit|owasp|injection|secret leak|csrf|xss", "agent": "security-reviewer" },
+ { "pattern": "database|\\bsql\\b|prisma|drizzle|n\\+1|index", "agent": "database-reviewer" },
+ { "pattern": "devops|terraform|ecs|cloudformation|aws cdk|cicd|github action", "agent": "DevOps Engineer" },
+ { "pattern": "typescript|tsconfig|type[- ]check|\\btsc\\b", "agent": "typescript-reviewer" },
+ { "pattern": "review.*pr|code review|review code", "agent": "feature-dev:code-reviewer" },
+ { "pattern": "explore|map.*codebase|trace.*execution|architecture", "agent": "feature-dev:code-explorer" },
+ { "pattern": "design.*architecture|blueprint|implementation plan", "agent": "feature-dev:code-architect" },
+ { "pattern": "simplify|refactor.*for clarity", "agent": "code-simplifier:code-simplifier" }
+ ]
+}
diff --git a/claude-ops/scripts/lib/deploy-fix-common.sh b/claude-ops/scripts/lib/deploy-fix-common.sh
index 763b56c1..4140bdcc 100755
--- a/claude-ops/scripts/lib/deploy-fix-common.sh
+++ b/claude-ops/scripts/lib/deploy-fix-common.sh
@@ -162,8 +162,9 @@ resolve_version_url() {
}
dispatch_fix_agent() {
- # $1 = prompt template path (in $PLUGIN_ROOT/prompts/), $2 = lock_id, rest = template vars as KEY=VAL
- local template="$1" lock_id="$2"; shift 2
+ # $1 = agent_name (matches claude-ops/agents/<name>.md OR ~/.claude/agents/<name>.md)
+ # $2 = lock_id, rest = context vars as KEY=VAL (substituted into a thin task brief)
+ local agent_name="$1" lock_id="$2"; shift 2
if ! lock_acquire "$lock_id"; then
return 2 # already in flight
fi
@@ -174,28 +175,30 @@ dispatch_fix_agent() {
return 3
fi
- local prompt_file="$PLUGIN_ROOT/prompts/$template"
- if [ ! -f "$prompt_file" ]; then
- lock_release "$lock_id"
- return 4
- fi
- local prompt=$(cat "$prompt_file")
+ # Build the thin task brief — full persona/tools/model come from the agent file.
+ local context=""
for kv in "$@"; do
local k="${kv%%=*}" v="${kv#*=}"
- prompt="${prompt//\{\{${k}\}\}/$v}"
+ context="${context}${k}: ${v}"$'\n'
done
local fix_log="$LOGS_DIR/fix-${lock_id}-$(date +%s).log"
- local model=$(config fix_model haiku)
local danger_flag="--permission-mode acceptEdits"
[ "$(config allow_dangerous false)" = "true" ] && danger_flag="--dangerously-skip-permissions"
command -v claude >/dev/null || { lock_release "$lock_id"; return 5; }
+ # Use --agent <name> so the agent's frontmatter (model/tools/persona) is honored.
+ # The brief is just the failure context — persona + workflow + guardrails come from agent file.
+ local brief="Failure context for your repair task:
+
+${context}
+Execute per your agent definition. Final line of output must be RESOLVED/RERUN/RETRY/BLOCKED."
+
nohup bash -c "
- printf '%s' \"\$1\" | claude -p --model $model $danger_flag --no-session-persistence > '$fix_log' 2>&1
+ printf '%s' \"\$1\" | claude -p --agent '$agent_name' $danger_flag --no-session-persistence > '$fix_log' 2>&1
rm -f '$STATE_DIR/lock-$lock_id'
- " _ "$prompt" </dev/null >/dev/null 2>&1 &
+ " _ "$brief" </dev/null >/dev/null 2>&1 &
disown 2>/dev/null || true
echo "$fix_log"
return 0
diff --git a/claude-ops/scripts/ops-deploy-monitor.sh b/claude-ops/scripts/ops-deploy-monitor.sh
index 3624f454..930be5c4 100755
--- a/claude-ops/scripts/ops-deploy-monitor.sh
+++ b/claude-ops/scripts/ops-deploy-monitor.sh
@@ -83,7 +83,7 @@ if [ "$CONCLUSION" != "success" ]; then
notify "Deploy failed" "$REPO #$PR → $BASE: $CONCLUSION"
if [ "$(config auto_dispatch_fixer true)" = "true" ]; then
- fix_log=$(dispatch_fix_agent "deploy-fix.md" "$SLUG-deploy" \
+ fix_log=$(dispatch_fix_agent "deploy-fixer" "$SLUG-deploy" \
"REPO=$REPO" "PR=$PR" "BASE=$BASE" "SHA=$SHA" "RUN_ID=$RUN_ID" \
"SUMMARY=deploy workflow #$RUN_ID concluded $CONCLUSION" \
"LOGS=$failed_log")
@@ -110,7 +110,7 @@ if [ "$HTTP" != "200" ]; then
fire "service $URL → HTTP $HTTP after deploy"
notify "Service unhealthy" "$REPO $BASE: $URL → HTTP $HTTP"
if [ "$(config auto_dispatch_fixer true)" = "true" ]; then
- dispatch_fix_agent "deploy-fix.md" "$SLUG-health" \
+ dispatch_fix_agent "deploy-fixer" "$SLUG-health" \
"REPO=$REPO" "PR=$PR" "BASE=$BASE" "SHA=$SHA" "RUN_ID=$RUN_ID" \
"SUMMARY=service health URL $URL returned HTTP $HTTP" \
"LOGS=(no workflow logs — health check failure)" >/dev/null