/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).4context: fork5argument-hint: "[--scope local|docker|kubernetes|ci] [--auto-fix]"6allowed-tools: Read Grep Glob Bash7---89# /env-analyze — Environment Diagnostic1011Read-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.1213## When to use1415- "Build is flaky on CI — check the runner"16- "Local Docker compose: services not starting"17- "Pre-deploy: validate K8s cluster state"18- "Debugging a deployment that's been failing intermittently"1920## Not for2122- Code bugs → `/bugfix`23- Application-level diagnostics (DB query plan, API behavior) → `/spike`24- Production incidents requiring SRE response → `/analyze-prod` (carried) + on-call2526## Invocation2728```29/env-analyze30/env-analyze --scope local31/env-analyze --scope docker --auto-fix32/env-analyze --scope ci33```3435## Arguments3637| Flag | Default | Effect |38|---|---|---|39| `--scope` | auto-detect | `local` (Docker/K8s detected), `docker`, `kubernetes`, `ci` |40| `--auto-fix` | off | Apply container-level safe fixes only — see scope below |4142### `--auto-fix` scope (explicit boundary)4344**In scope (safe):**45- Restart stuck containers46- Clear container-scoped caches47- Regenerate config from existing template4849**Out of scope (manual escalation only):**50- Restarting Docker daemon51- Regenerating TLS certs52- Modifying host-level state53- Deleting data54- Changing secrets55- Kubernetes namespace operations56- Production value mutation5758## Output5960`<repo>/.ai-skills-memory/env-reports/<run-id>/ENV-REPORT.md` with tables:6162- Container/pod status (name, state, restarts, uptime)63- Log excerpts (last 20 lines per service, error filter)64- Network sanity (connectivity, DNS, port availability)65- Resource saturation (CPU, memory, disk %)66- Identified anomalies (list with severity)67- Recommended actions (prioritized)6869If `--auto-fix`: list of actions taken + per-action success/failure outcome.7071## Agent roster7273| Agent | Model | Effort | Tools | Role |74|---|---|---|---|---|75| `sre-engineer` | inherit | high | Bash, Read, Grep, Glob | Docker/K8s diagnostics, log analysis |76| `devops-engineer` | inherit | high | Bash, Read, Grep, Glob | CI/CD environment diagnostics |7778## Pipeline7980```81┌─ Scope detection: check for docker-compose.yml, k8s config, CI runner config82│83├─ SRE + DevOps in parallel (Wave 1):84│ ├─ sre-engineer:85│ │ - docker inspect, docker logs, docker stats (or kubectl get pods/nodes/logs)86│ │ → SRE-REPORT.md (containers, logs, resource usage)87│ │88│ └─ devops-engineer:89│ - CI runner health (GitHub Actions, GitLab CI, etc.)90│ → DEVOPS-REPORT.md (job queue, runner status, cache age)91│92├─ Lead consolidates → ENV-REPORT.md (merged view + anomaly list)93│94├─ If --auto-fix:95│ │ Per safe action: oracle = post-action health check96│ │ Out-of-scope items flagged as "manual: <reason>"97│ └─ Report action outcomes98│99└─ Memory write: L4 environment baseline snapshot for drift detection100```101102No RALF — diagnostic is pass-once. Each `--auto-fix` action has its own per-action oracle (the post-action health check).103104## Tool-output normalization105106Bash 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.107108## Eval rubric109110Pointer: `plugin/eval/judge-rubrics/env-analyze.md` (B10).111112Dimensions:1131. **Completeness** — all scopes checked (if applicable)1142. **Accuracy** — reports match actual state1153. **Clarity** — anomalies clearly flagged with severity1164. **Actionability** — recommendations are specific and executable1175. **Safety** — no destructive actions without explicit user approval118119Pass: avg ≥ 4.0, no dimension < 3.120121## Memory writes122123| Layer | When | Shape |124|---|---|---|125| L4 | After analysis | `.ai-skills-memory/env-reports/<run-id>/baseline.json` — container states, resource usage, timestamps (for drift detection across runs) |126127## Failure modes128129- **Docker not installed:** graceful skip; report N/A for that scope130- **K8s connection refused:** report as connection error; offer manual debugging guidance131- **Auto-fix action fails:** rollback if possible; report outcome and manual steps132- **Log parsing error (corrupted logs):** skip that log; report as anomaly (log corruption suspected)133134## Observability events135136- `workflow_start` — env-analyze + scope137- `agent_spawned` × 2 (sre, devops)138- `auto_fix_action` — per action if `--auto-fix` enabled139- `workflow_end` — `COMPLETE` with anomaly count140141## Integration142143- **Spawns**: `sre-engineer`, `devops-engineer` (both with Bash + Read + Grep + Glob)144- **Schemas**: `plugin/schemas/spawn-payload.schema.json` (G7 spawn payloads)145- **Hooks**: `tool-output-normalize.py` (G2 on large bash output), `subagent-start-budget.py` (G7 validation + budget)146- **Used by**: `/bugfix` Step 2 (local-Docker diagnostic), `/team-bugfix` (optional pre-pipeline context-gathering), `/migrate` (pre-flight env check)147- **Carried alternative**: `/analyze-local` (Docker-only triage)