SKILL · multi-agent-orchestration
SKILL.md: incident runbook for a Java service on AWS
Symptom-matched runbooks with read-only investigation and human-approved remediation, adapted from the Anthropic SRE agent pattern to ECS, CloudWatch, and SSM.
✓ verified 2026-06-10 · stack: claude-code, java, aws · source
An incident runbook encoded as a skill, after the Anthropic Cookbook SRE agent: symptom signatures select the runbook, investigation is strictly read-only, and remediation presents options for human approval before any write. Progressive disclosure keeps it free until an incident matches: only the frontmatter loads at startup. Adapted for a Spring Boot service on ECS with CloudWatch, RDS PostgreSQL, and SSM Parameter Store.
---name: incident-runbookdescription: > SRE incident runbooks for Java services on ECS/CloudWatch. Use when investigating error-rate spikes, latency degradation, database connection exhaustion, or JVM memory pressure. Investigation first, always read-only; remediation only after presenting options to the human operator.---
# Incident runbooks
## Phases — non-negotiable
1. INVESTIGATE: read-only. Metrics, logs, health endpoints, deploy history.2. REMEDIATE: only after presenting findings and options, and only the option the human operator approves. Explain reasoning before every action.
## Symptom matching
| Symptoms | Runbook ||----------|---------|| db_connections_active > 80% of pool, "too many connections" in logs | DB connection exhaustion || P99 > 1000ms and spreading to downstream services | High-latency cascade || OutOfMemoryError in logs, GC pause > 500ms | JVM memory pressure |
## Investigation baseline (all incidents)
1. CloudWatch metrics for the service: 5xx rate, P99 latency, DB connection count — last 30 minutes against the 24-hour average.2. Health: GET /actuator/health — record any DOWN components.3. Errors: CloudWatch Logs Insights — fields @timestamp, level, message | filter level = "ERROR" | sort @timestamp desc | limit 504. Recent change: ECS deployment events in the last 2 hours.5. Blast radius: downstream service health endpoints and error rates.
## DB connection exhaustion
Investigate:- SELECT count(*), wait_event_type, wait_event FROM pg_stat_activity GROUP BY 2, 3;- Long transactions: SELECT pid, now() - xact_start, query FROM pg_stat_activity WHERE xact_start IS NOT NULL ORDER BY 2 DESC;- Current pool size: read /app/order-service/db-pool-size from SSM Parameter Store; compare with hikari maximum-pool-size in effect.
Remediate (present options; act only on approval):- A: Raise the pool-size parameter in SSM (valid range 5–50 per instance), then force a rolling ECS deployment to pick it up.- B: Rolling restart only — aws ecs update-service --force-new-deployment — to clear stale connections.- C: Terminate long-running transactions (requires DBA approval).
Verify: db_connections_active below 70% of pool within 5 minutes.
## High-latency cascade
Investigate:- Slowest spans from tracing; identify the root-cause operation.- External dependency timeouts: RDS, SQS, Secrets Manager, downstream HTTP.- ECS task CPU and memory utilisation.
Remediate (present options; act only on approval):- A: Open the Resilience4j circuit breaker on the failing dependency.- B: Scale out — raise the ECS service desired count.
Verify: P99 back under SLO within 10 minutes; no downstream DOWN states.
## After any remediation
Produce a timeline (symptoms, findings, action, verification) for thepost-incident review. If the fix implies an architectural change, draft anADR with /adr-author rather than leaving it in the incident channel.Pair the remediation phase with a PreToolUse hook that validates content,
not just paths: the cookbook’s pattern, and the same principle as
hooks as hard gates.
For option A above:
#!/bin/bashINPUT=$(cat)CMD=$(echo "$INPUT" | jq -r '.tool_input.command // empty')if [[ "$CMD" == *"ssm put-parameter"* && "$CMD" == *"db-pool-size"* ]]; then VALUE=$(echo "$CMD" | grep -oE -- '--value "?[0-9]+' | grep -oE '[0-9]+') if [[ -z "$VALUE" || "$VALUE" -lt 5 || "$VALUE" -gt 50 ]]; then echo "Blocked: db-pool-size must be 5-50, got '${VALUE:-none}'." >&2 exit 2 fifiexit 0What it does
- Loads on demand. At startup only the name and description register; the runbook body enters context when symptoms match, the progressive disclosure mechanism the cookbook and the skills engineering post both lean on.
- Separates reading from writing. The two-phase structure mirrors the cookbook’s investigate/remediate split with human review between phases; the agent’s value in phase one is speed of evidence-gathering, not autonomy.
- Validates remediation outside the model’s judgment. The hook checks the actual value being written against a business rule and exits 2 to block, exactly as the cookbook’s pre-execution validation scripts do.
- Ends in institutional memory. Every remediation produces a timeline and, where warranted, an ADR via the ADR author command.
Failure modes
- Read-only is a convention until permissions enforce it. Nothing in a
SKILL.md prevents a write during investigation. Back the phases with
permission rules: allowlist read commands (
aws cloudwatch get-*,aws logs *), gateaws ecs update-serviceandaws ssm put-parameterbehind ask rules. See permission policy design. - Symptom thresholds are placeholders. 80% pool utilisation and 1000ms P99 are this artifact’s examples; tune them to your SLOs or the skill fires late, or constantly. The pool-size valid range (5–50) is also an example (the cookbook example uses 5–100; adjust to your service’s connection count and instance count).
- The hook only sees what it parses. A pool-size change made through a different command shape (console, Terraform, a wrapper script) bypasses it. It is a guardrail on the agent’s tool calls, not change control.
- Stale runbooks are dangerous runbooks. A parameter path or service name that drifts from reality sends the agent investigating the wrong thing quickly and confidently. Review the skill whenever the topology changes.
Verified against the Cookbook SRE agent’s SKILL.md runbook format, two-phase workflow, pre-execution validation hooks, and its stated AWS adaptations (CloudWatch queries, ECS restarts, SSM-held configuration), fetched 2026-06-10.