/env-analyze — Environment Diagnostic
Read-only diagnostic that produces a structured ENV-REPORT.md for the current environment. Optional --auto-fix applies ONLY container-level safe actions; anything outside that scope requires manual escalation.
When to use
- "Build is flaky on CI — check the runner"
- "Local Docker compose: services not starting"
- "Pre-deploy: validate K8s cluster state"
- "Debugging a deployment that's been failing intermittently"
Not for
- Code bugs →
/bugfix
- Application-level diagnostics (DB query plan, API behavior) →
/spike
- Production incidents requiring SRE response →
/analyze-prod (carried) + on-call
Invocation
/env-analyze
/env-analyze --scope local
/env-analyze --scope docker --auto-fix
/env-analyze --scope ci
Arguments
| Flag |
Default |
Effect |
--scope |
auto-detect |
local (Docker/K8s detected), docker, kubernetes, ci |
--auto-fix |
off |
Apply container-level safe fixes only — see scope below |
--auto-fix scope (explicit boundary)
In scope (safe):
- Restart stuck containers
- Clear container-scoped caches
- Regenerate config from existing template
Out of scope (manual escalation only):
- Restarting Docker daemon
- Regenerating TLS certs
- Modifying host-level state
- Deleting data
- Changing secrets
- Kubernetes namespace operations
- Production value mutation
Output
<repo>/.ai-skills-memory/env-reports/<run-id>/ENV-REPORT.md with tables:
- Container/pod status (name, state, restarts, uptime)
- Log excerpts (last 20 lines per service, error filter)
- Network sanity (connectivity, DNS, port availability)
- Resource saturation (CPU, memory, disk %)
- Identified anomalies (list with severity)
- Recommended actions (prioritized)
If --auto-fix: list of actions taken + per-action success/failure outcome.
Agent roster
| Agent |
Model |
Effort |
Tools |
Role |
sre-engineer |
inherit |
high |
Bash, Read, Grep, Glob |
Docker/K8s diagnostics, log analysis |
devops-engineer |
inherit |
high |
Bash, Read, Grep, Glob |
CI/CD environment diagnostics |
Pipeline
┌─ Scope detection: check for docker-compose.yml, k8s config, CI runner config
│
├─ SRE + DevOps in parallel (Wave 1):
│ ├─ sre-engineer:
│ │ - docker inspect, docker logs, docker stats (or kubectl get pods/nodes/logs)
│ │ → SRE-REPORT.md (containers, logs, resource usage)
│ │
│ └─ devops-engineer:
│ - CI runner health (GitHub Actions, GitLab CI, etc.)
│ → DEVOPS-REPORT.md (job queue, runner status, cache age)
│
├─ Lead consolidates → ENV-REPORT.md (merged view + anomaly list)
│
├─ If --auto-fix:
│ │ Per safe action: oracle = post-action health check
│ │ Out-of-scope items flagged as "manual: <reason>"
│ └─ Report action outcomes
│
└─ Memory write: L4 environment baseline snapshot for drift detection
No RALF — diagnostic is pass-once. Each --auto-fix action has its own per-action oracle (the post-action health check).
Tool-output normalization
Bash output from docker inspect, kubectl logs, docker stats etc. is normalized by tool-output-normalize.py hook (G2) when > 2000 tokens — large log dumps become envelope metadata + extracted top-k errors rather than raw bytes.
Eval rubric
Pointer: plugin/eval/judge-rubrics/env-analyze.md (B10).
Dimensions:
- Completeness — all scopes checked (if applicable)
- Accuracy — reports match actual state
- Clarity — anomalies clearly flagged with severity
- Actionability — recommendations are specific and executable
- Safety — no destructive actions without explicit user approval
Pass: avg ≥ 4.0, no dimension < 3.
Memory writes
| Layer |
When |
Shape |
| L4 |
After analysis |
.ai-skills-memory/env-reports/<run-id>/baseline.json — container states, resource usage, timestamps (for drift detection across runs) |
Failure modes
- Docker not installed: graceful skip; report N/A for that scope
- K8s connection refused: report as connection error; offer manual debugging guidance
- Auto-fix action fails: rollback if possible; report outcome and manual steps
- Log parsing error (corrupted logs): skip that log; report as anomaly (log corruption suspected)
Observability events
workflow_start — env-analyze + scope
agent_spawned × 2 (sre, devops)
auto_fix_action — per action if --auto-fix enabled
workflow_end — COMPLETE with anomaly count
Integration
- Spawns:
sre-engineer, devops-engineer (both with Bash + Read + Grep + Glob)
- Schemas:
plugin/schemas/spawn-payload.schema.json (G7 spawn payloads)
- Hooks:
tool-output-normalize.py (G2 on large bash output), subagent-start-budget.py (G7 validation + budget)
- Used by:
/bugfix Step 2 (local-Docker diagnostic), /team-bugfix (optional pre-pipeline context-gathering), /migrate (pre-flight env check)
- Carried alternative:
/analyze-local (Docker-only triage)
1---2name: env-analyze3description: Use this skill when troubleshooting a deployment, debugging CI flakes, validating an environment before deployment, or when local diagnostics need to span more than just Docker — the multi-scope environment diagnostic covering Kubernetes, CI runner, network, resource usage, and a cross-scope drift snapshot for baselining across runs, with optional `--auto-fix` for container-level safe actions. For Docker-only local triage use `/analyze-local`. Not for code bugs (use /bugfix) or application-level diagnostics (use /spike).4---56# /env-analyze — Environment Diagnostic78Read-only diagnostic that produces a structured `ENV-REPORT.md` for the current environment. Optional `--auto-fix` applies ONLY container-level safe actions; anything outside that scope requires manual escalation.910## When to use1112- "Build is flaky on CI — check the runner"13- "Local Docker compose: services not starting"14- "Pre-deploy: validate K8s cluster state"15- "Debugging a deployment that's been failing intermittently"1617## Not for1819- Code bugs → `/bugfix`20- Application-level diagnostics (DB query plan, API behavior) → `/spike`21- Production incidents requiring SRE response → `/analyze-prod` (carried) + on-call2223## Invocation2425```26/env-analyze27/env-analyze --scope local28/env-analyze --scope docker --auto-fix29/env-analyze --scope ci30```3132## Arguments3334| Flag | Default | Effect |35|---|---|---|36| `--scope` | auto-detect | `local` (Docker/K8s detected), `docker`, `kubernetes`, `ci` |37| `--auto-fix` | off | Apply container-level safe fixes only — see scope below |3839### `--auto-fix` scope (explicit boundary)4041**In scope (safe):**42- Restart stuck containers43- Clear container-scoped caches44- Regenerate config from existing template4546**Out of scope (manual escalation only):**47- Restarting Docker daemon48- Regenerating TLS certs49- Modifying host-level state50- Deleting data51- Changing secrets52- Kubernetes namespace operations53- Production value mutation5455## Output5657`<repo>/.ai-skills-memory/env-reports/<run-id>/ENV-REPORT.md` with tables:5859- Container/pod status (name, state, restarts, uptime)60- Log excerpts (last 20 lines per service, error filter)61- Network sanity (connectivity, DNS, port availability)62- Resource saturation (CPU, memory, disk %)63- Identified anomalies (list with severity)64- Recommended actions (prioritized)6566If `--auto-fix`: list of actions taken + per-action success/failure outcome.6768## Agent roster6970| Agent | Model | Effort | Tools | Role |71|---|---|---|---|---|72| `sre-engineer` | inherit | high | Bash, Read, Grep, Glob | Docker/K8s diagnostics, log analysis |73| `devops-engineer` | inherit | high | Bash, Read, Grep, Glob | CI/CD environment diagnostics |7475## Pipeline7677```78┌─ Scope detection: check for docker-compose.yml, k8s config, CI runner config79│80├─ SRE + DevOps in parallel (Wave 1):81│ ├─ sre-engineer:82│ │ - docker inspect, docker logs, docker stats (or kubectl get pods/nodes/logs)83│ │ → SRE-REPORT.md (containers, logs, resource usage)84│ │85│ └─ devops-engineer:86│ - CI runner health (GitHub Actions, GitLab CI, etc.)87│ → DEVOPS-REPORT.md (job queue, runner status, cache age)88│89├─ Lead consolidates → ENV-REPORT.md (merged view + anomaly list)90│91├─ If --auto-fix:92│ │ Per safe action: oracle = post-action health check93│ │ Out-of-scope items flagged as "manual: <reason>"94│ └─ Report action outcomes95│96└─ Memory write: L4 environment baseline snapshot for drift detection97```9899No RALF — diagnostic is pass-once. Each `--auto-fix` action has its own per-action oracle (the post-action health check).100101## Tool-output normalization102103Bash output from `docker inspect`, `kubectl logs`, `docker stats` etc. is normalized by `tool-output-normalize.py` hook (G2) when > 2000 tokens — large log dumps become envelope metadata + extracted top-k errors rather than raw bytes.104105## Eval rubric106107Pointer: `plugin/eval/judge-rubrics/env-analyze.md` (B10).108109Dimensions:1101. **Completeness** — all scopes checked (if applicable)1112. **Accuracy** — reports match actual state1123. **Clarity** — anomalies clearly flagged with severity1134. **Actionability** — recommendations are specific and executable1145. **Safety** — no destructive actions without explicit user approval115116Pass: avg ≥ 4.0, no dimension < 3.117118## Memory writes119120| Layer | When | Shape |121|---|---|---|122| L4 | After analysis | `.ai-skills-memory/env-reports/<run-id>/baseline.json` — container states, resource usage, timestamps (for drift detection across runs) |123124## Failure modes125126- **Docker not installed:** graceful skip; report N/A for that scope127- **K8s connection refused:** report as connection error; offer manual debugging guidance128- **Auto-fix action fails:** rollback if possible; report outcome and manual steps129- **Log parsing error (corrupted logs):** skip that log; report as anomaly (log corruption suspected)130131## Observability events132133- `workflow_start` — env-analyze + scope134- `agent_spawned` × 2 (sre, devops)135- `auto_fix_action` — per action if `--auto-fix` enabled136- `workflow_end` — `COMPLETE` with anomaly count137138## Integration139140- **Spawns**: `sre-engineer`, `devops-engineer` (both with Bash + Read + Grep + Glob)141- **Schemas**: `plugin/schemas/spawn-payload.schema.json` (G7 spawn payloads)142- **Hooks**: `tool-output-normalize.py` (G2 on large bash output), `subagent-start-budget.py` (G7 validation + budget)143- **Used by**: `/bugfix` Step 2 (local-Docker diagnostic), `/team-bugfix` (optional pre-pipeline context-gathering), `/migrate` (pre-flight env check)144- **Carried alternative**: `/analyze-local` (Docker-only triage)