---
name: Validate Helm & K8s on Save
description: Validate Helm templates and K8s manifests when infrastructure files are saved
version: "2.0"
trigger:
  type: onSave
  filePattern: "infra/**/*.{yaml,yml,tpl}"
---

When a Helm or K8s manifest file is saved:

1. If it's under `infra/helm/`:
   - Run `helm template stonks-oracle infra/helm/stonks-oracle -n stonks-oracle` to validate template rendering
   - Check for template syntax errors
   - Verify the output contains expected resource types (Deployment, Service, Ingress, NetworkPolicy)
   - Report any rendering errors concisely

2. If it's under `infra/k8s/`:
   - Parse the YAML to check for syntax errors
   - Verify required fields exist (apiVersion, kind, metadata)
   - Check that namespace is set to `stonks-oracle`
   - Report any issues found
