From e7d48a2d3daa478db0c171b85a9f596317e78bed Mon Sep 17 00:00:00 2001 From: Ramkumar Ethiraj <64294490+rmkr-dev@users.noreply.github.com> Date: Thu, 15 Oct 2026 05:06:23 +0000 Subject: [PATCH 1/2] Add AKS HPA requests and limits skill --- skillbook/skills.json | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/skillbook/skills.json b/skillbook/skills.json index f63f843..14a38ac 100644 --- a/skillbook/skills.json +++ b/skillbook/skills.json @@ -551,6 +551,27 @@ ], "formatNotes": "All three. Copilot: path-scoped `.github/instructions/maven-dependency-cve.instructions.md` with applyTo for `**/pom.xml`, suppressions XML, `.github/dependabot.yml`, and SCA workflows (optional `.github/skills/maven-dependency-cve-hygiene-guardrails/SKILL.md`). Claude Code: `.claude/skills/maven-dependency-cve-hygiene-guardrails/SKILL.md` plus a one-line CLAUDE.md fact that versions are BOM-managed and CVE overrides land after BOM import. Codex: a Maven supply-chain section in root `AGENTS.md` or linked `docs/agents/maven-dependency-cve.md`. Pair with maven-multimodule-ci-cache-guardrails for CI cache (not CVE) and container-image-hardening for base-image findings.", "body": "# Skill: Maven Dependency CVE Hygiene Guardrails\n\n## Goal\nKeep Java/Maven dependency graphs pinned, convergent, and continuously scanned so CVEs are caught in CI, fixed with deliberate BOM or override bumps, and never papered over with silent version drift or undocumented suppressions.\n\n## When to apply\n- New services or modules adding Spring Boot / platform BOM imports and third-party libraries\n- Dependabot, Renovate, or OWASP Dependency-Check / SCA findings on `pom.xml`\n- Reviews that mention version ranges, conflicting transitive jars, or \"just exclude it\"\n- Parent POM / company BOM changes that retarget dozens of managed versions\n- Release trains where snapshot or dynamic versions must not ship\n\n## Baseline rules\n1. **One source of truth for versions.** Prefer a parent POM or imported BOM (`type=pom` / `scope=import` in `dependencyManagement`) for Spring Boot, Jackson, Azure SDK, Testcontainers, and similar aligned sets. Module POMs declare dependencies **without** versions when the BOM already manages them. Do not sprinkle duplicate `` tags across modules.\n2. **Pin releases; ban ranges.** Use exact versions (or a single managed property) — never `LATEST`, `RELEASE`, or open Maven version ranges (`[1.0,)`) in production builds. Enforcer `requireReleaseDeps` (and ban snapshots on release profiles) keeps CI honest.\n3. **Enforce convergence.** Turn on `maven-enforcer-plugin` with `dependencyConvergence` (and usually `requireUpperBoundDeps`). When two paths pull different versions of the same GAV, fix it with `dependencyManagement` (preferred) or a justified exclusion — do not rely on nearest-wins mediation.\n4. **Declare what you compile against.** Anything referenced from source should be a **direct** dependency. Relying on a transitive for compile-scope APIs breaks when that transitive disappears in a BOM bump.\n5. **Override after the BOM import.** In `dependencyManagement`, order matters: the **last** matching entry wins. Put CVE hotfix overrides **after** the Spring Boot / platform BOM import so they actually take effect. Document the CVE id and removal criteria next to the override.\n6. **Upgrade before exclude.** Prefer bumping the BOM or the managing parent that brings the fixed version. Use `` only when the transitive is unused and an upgrade is blocked — and leave a comment with the ticket/CVE. Blanket exclusions that drop logging or security providers are not a fix.\n7. **Scan the resolved tree in CI.** Run OWASP `dependency-check-maven` (or the org's approved SCA: Snyk, Trivy filesystem, GitHub Dependabot alerts) against the **resolved** classpath, not only direct deps. Pin the plugin/action version. Set a fail threshold (for example `failBuildOnCVSS` ≥ 7 or org policy) on PR builds.\n8. **NVD / feed reliability.** For OWASP Dependency-Check in shared runners, prefer a mirrored NVD/data feed your platform already operates; document cache directories so every job does not hammer public NVD. A flaky CVE DB is not an excuse to skip the gate — fail closed or use a cached mirror.\n9. **Suppressions are temporary and reviewed.** Keep `dependency-check-suppressions.xml` (or tool equivalent) in-repo. Every suppression needs CVE/id, justification, owning team, and a review-by date. Scope suppressions tightly (specific GAV + CVE). Never commit a global \"suppress all until date\" without an issue link.\n10. **Dependabot / Renovate are input, not merge rights.** Enable Maven ecosystem updates; require green CI and a human review for BOM major bumps. Group patch updates when the org allows it; do not auto-merge major Spring Boot jumps without a regression plan.\n11. **SBOM when the release process asks for it.** Emit CycloneDX/SPDX from the same reactor CI job that signs the release. The SBOM must match what was scanned — no hand-edited component lists.\n12. **Separate app-jar CVEs from base-image CVEs.** Library findings belong in Maven hygiene; OS/base-layer findings belong with container image hardening. Do not close a Dockerfile CVE by tweaking an unrelated `pom.xml` exclude.\n\n## Workflow\n1. Inventory: root/parent POM, BOM imports, enforcer rules, existing SCA workflow, suppressions file, Dependabot config.\n2. `mvn -q dependency:tree -Dverbose` (or `dependency:tree -Dincludes=…`) for the affected module; locate the vulnerable GAV path.\n3. Choose fix: BOM bump → targeted `dependencyManagement` override → (last resort) exclusion + compensating direct dep.\n4. Wire or tighten CI scan + enforcer; add/update suppression only with justification.\n5. Run unit/integration tests for modules that touch the bumped libraries.\n6. PR notes: CVE ids, before/after versions, tree snippet, residual risk (unreachable code, waiting on upstream BOM).\n\n## Tool-specific notes\n### GitHub Copilot\n- Path-scoped `.github/instructions/maven-dependency-cve.instructions.md` with `applyTo` for `**/pom.xml`, `**/dependency-check-suppressions.xml`, `.github/dependabot.yml`, and SCA workflow YAML under `.github/workflows/`.\n- Always-on line in `.github/copilot-instructions.md`: versions come from BOM/`dependencyManagement`; no ranges; CVE fixes override after BOM import; suppressions need reason + review date.\n- Optional `.github/skills/maven-dependency-cve-hygiene-guardrails/SKILL.md` for agent mode.\n\n### Claude Code\n- Procedure in `.claude/skills/maven-dependency-cve-hygiene-guardrails/SKILL.md`.\n- CLAUDE.md fact: \"Maven versions are BOM-managed; enforcer convergence is required; CVE overrides land after BOM import; Dependency-Check (or org SCA) fails the PR above policy CVSS.\"\n- Before claiming done, show `dependency:tree` path for the CVE and the CI gate config.\n\n### Codex\n- Maven supply-chain section in root `AGENTS.md`, or nested `docs/agents/maven-dependency-cve.md` linked from it.\n- State: no version ranges, enforcer rules, override ordering, suppression policy, scanner command.\n\n## Anti-patterns\n- Version ranges or `LATEST`/`RELEASE` in deployable modules\n- Duplicate `` on a dep already managed by the Boot BOM (drift magnet)\n- CVE override placed **before** the BOM import (silently ignored)\n- Excluding a transitive \"to make the scanner green\" while still loading it via another path\n- Checking in an empty or eternal suppression file with no owners\n- Disabling `dependencyConvergence` instead of fixing the clash\n- Treating Dependabot PRs as rubber-stamps without reading the tree diff\n- Confusing container base-image CVEs with Maven artifact CVEs\n- Pinning a vulnerable version forever in a company BOM without a tracked bump\n\n## Verification checklist\n- [ ] BOM / `dependencyManagement` is the only version authority for shared stacks\n- [ ] No version ranges / LATEST / RELEASE on production deps\n- [ ] `dependencyConvergence` (and release `requireReleaseDeps`) enforced\n- [ ] Vulnerable GAV path identified via `dependency:tree`\n- [ ] Fix is BOM bump or post-BOM override (exclusion justified if used)\n- [ ] SCA / OWASP gate runs on PRs with pinned plugin/action and CVSS policy\n- [ ] Suppressions are scoped, justified, and dated for review\n- [ ] Tests pass for modules affected by the bump\n- [ ] PR lists CVE ids and residual risk\n\n## Copy-ready SKILL.md stub\n```markdown\n---\nname: maven-dependency-cve-hygiene-guardrails\ndescription: Use when reviewing or fixing Maven pom CVE findings — BOM pinning, enforcer convergence, post-BOM overrides, OWASP/Dependabot gates, and scoped suppressions. Prefer upgrades over exclusions.\n---\n\nFollow Maven Dependency CVE Hygiene Guardrails: BOM-managed versions, no ranges, enforcer convergence, CVE overrides after BOM import, CI SCA with a CVSS fail threshold, suppressions with reason and review date.\n```\n" + }, + { + "id": "aks-hpa-requests-limits-guardrails", + "title": "AKS HPA Requests & Limits Guardrails", + "whenToUse": "Reviewing or tuning AKS Deployments and HPAs when scaling misbehaves, pods sit Pending or get OOMKilled, or containers are missing CPU/memory requests and limits.", + "tools": [ + "copilot", + "claude-code", + "codex" + ], + "tags": [ + "aks", + "kubernetes", + "hpa", + "autoscaling", + "resources", + "devops", + "azure" + ], + "formatNotes": "All three. Copilot: path-scoped `.github/instructions/aks-hpa-requests-limits.instructions.md` with applyTo for Deployment/HPA/Helm globs (`**/k8s/**/*.yaml`, `**/manifests/**/*.yaml`, `**/charts/**/templates/**/*.yaml`, `**/*hpa*.yaml`) (optional `.github/skills/aks-hpa-requests-limits-guardrails/SKILL.md`). Claude Code: `.claude/skills/aks-hpa-requests-limits-guardrails/SKILL.md` plus a one-line CLAUDE.md fact that HPA targets assume every container sets requests. Codex: an autoscaling section in root `AGENTS.md` or linked `docs/agents/aks-hpa-requests-limits.md`. Pair with k8s-probes-graceful-shutdown-guardrails for readiness/termination and aks-workload-hardening for security context — this skill covers sizing and autoscaling only.", + "body": "# Skill: AKS HPA Requests & Limits Guardrails\n\n## Goal\nMake AKS Deployments scale predictably: every container has honest CPU/memory requests, limits are chosen on purpose, and the HorizontalPodAutoscaler reacts to the signal that actually tracks load — without flapping, starving the node pool, or fighting other autoscalers.\n\n## When to apply\n- Adding or editing a Deployment, StatefulSet, Helm values block, or `HorizontalPodAutoscaler` (`autoscaling/v2`)\n- HPA shows `` targets, never scales, or scales up and down every few minutes\n- Pods stuck `Pending` (insufficient cpu/memory) or `OOMKilled` / CPU-throttled under normal traffic\n- Namespace ResourceQuota rejections or LimitRange defaults silently changing pod specs\n- Right-sizing after a load test, incident, or cost review on AKS node pools\n\n## Baseline rules\n1. **Requests on every container.** Set `resources.requests.cpu` and `resources.requests.memory` on app containers, sidecars, and init containers. HPA resource metrics are computed as a percentage of the **request**, so a missing request means the HPA cannot compute utilization (or uses a LimitRange default that nobody chose). Treat a missing request as a bug, not a style nit.\n2. **Pick the QoS class deliberately.**\n - **Burstable** (requests < limits) is the default for most HTTP APIs and workers: it packs nodes efficiently and absorbs short spikes. Keep the memory limit close to the request (memory is not compressible — overshoot means OOMKill), and give CPU modest headroom or omit the CPU limit if the platform policy allows it.\n - **Guaranteed** (requests == limits for both CPU and memory) only for latency-critical or noisy-neighbor-sensitive workloads. It buys stable scheduling and eviction priority at the cost of idle reserved capacity and CFS throttling at the limit.\n - Write the chosen class and the reason in a manifest comment or values file.\n3. **No BestEffort in prod.** Pods with no requests/limits are evicted first and break ResourceQuota accounting. Namespaces with quotas should reject them; do not work around it by deleting the quota.\n4. **HPA only where horizontal scaling is real.** The workload must be mostly stateless (or shard-aware), tolerate extra replicas, and start fast enough to matter. For prod set `minReplicas >= 2` (pair with a PodDisruptionBudget) and set `maxReplicas` with headroom you have actually checked against node pool size, Cluster Autoscaler max node count, subnet/IP limits (Azure CNI), and downstream connection limits such as database pools.\n5. **Start CPU targets around 60–80%.** `averageUtilization` in that band leaves room for the scale-up lag (metrics scrape + pod start + readiness). Go lower for spiky traffic or slow-starting JVMs, higher for smooth batch-like load. Memory-based scaling is rarely a good primary signal for runtimes that do not release heap — prefer it only as a secondary metric.\n6. **Use the real signal when CPU is not it.** If queue depth, consumer lag, or requests-per-second drives load, scale on custom/external metrics (Prometheus adapter, Azure Monitor) or KEDA scalers (Service Bus, Event Hubs, Kafka, HTTP). KEDA owns the HPA it creates — do not also hand-write an HPA for the same Deployment.\n7. **Do not let VPA and HPA fight.** Never run VPA in `Auto`/`Recreate`/`InPlace` update mode on the same CPU/memory metrics an HPA scales on. VPA in `updateMode: \"Off\"` (recommendation-only) is fine and a good input for request sizing.\n8. **Probes gate useful capacity.** New replicas only help once they are Ready. Wire readiness and startup probes correctly — follow `k8s-probes-graceful-shutdown-guardrails` rather than re-deriving probe rules here.\n9. **Tune scale behavior to avoid flapping.** Use `behavior.scaleDown.stabilizationWindowSeconds` (default 300s; raise for bursty traffic) and `scaleDown.policies` that cap how many pods or what percent can go per period. Allow faster `scaleUp` with a short or zero window. Scale-up lag on AKS includes node provisioning when Cluster Autoscaler must add nodes — budget minutes, not seconds.\n10. **Respect ResourceQuota and LimitRange.** Check the namespace's quota (`requests.cpu`, `requests.memory`, `limits.*`, pod count) against `maxReplicas × per-pod requests`. Know what LimitRange defaults and min/max apply so manifest values are not silently overridden or rejected at admission.\n11. **Document where the numbers came from.** Record the evidence next to the values: load-test result, VPA recommendation, or observed p95 CPU/memory from Container Insights / Prometheus over a representative window. \"Copied from another service\" is not evidence.\n12. **Keep Helm and raw manifests in sync.** Resources and HPA settings live in values (per environment) with sane chart defaults; templates must not drop requests when a value is unset.\n\n## Workflow\n1. Inventory: containers (incl. sidecars/init), current requests/limits, QoS class, HPA spec/behavior, PDB, LimitRange, ResourceQuota, node pool SKU and autoscaler bounds.\n2. Measure: `kubectl top pods`, Container Insights or Prometheus p95/p99 over at least a week of normal traffic, plus a load test where possible.\n3. Size requests from steady-state p95 plus small headroom; set memory limit from peak plus safety margin; decide CPU limit by policy.\n4. Choose metric and target; set min/max with quota and node capacity math shown.\n5. Add `behavior` for scale-down stabilization; verify with a load ramp and `kubectl describe hpa`.\n\n## Anti-patterns\n- HPA on a Deployment whose containers have no CPU request\n- Sidecar with no requests making utilization math wrong for the whole pod\n- `maxReplicas: 100` with a 3-node pool and no Cluster Autoscaler\n- `minReplicas: 1` for a prod API with a PDB of `minAvailable: 1`\n- CPU limit equal to a tiny request on a JVM service (throttling at startup, slow readiness)\n- Memory limit far above request (\"burst\" that ends in node-pressure eviction)\n- VPA `Auto` mode plus CPU HPA on the same workload\n- Hand-written HPA alongside a KEDA ScaledObject for the same target\n- Scaling on memory for a heap-retaining runtime and never scaling down\n- Deleting or inflating ResourceQuota to make a rollout pass\n\n## Tool placement notes\n### GitHub Copilot\n- Path-scoped `.github/instructions/aks-hpa-requests-limits.instructions.md` with `applyTo` covering `**/k8s/**/*.yaml`, `**/manifests/**/*.yaml`, `**/charts/**/templates/**/*.yaml`, `**/charts/**/values*.yaml`, and `**/*hpa*.yaml`.\n- Optional `.github/skills/aks-hpa-requests-limits-guardrails/SKILL.md` for agent mode.\n\n### Claude Code\n- Procedure in `.claude/skills/aks-hpa-requests-limits-guardrails/SKILL.md`.\n- One CLAUDE.md fact: \"HPA utilization targets assume every container sets CPU/memory requests; never add an HPA without them.\"\n\n### Codex\n- An autoscaling section in root `AGENTS.md`, or `docs/agents/aks-hpa-requests-limits.md` linked from it, listing the request/limit policy, target band, and verification commands.\n\nPair with `k8s-probes-graceful-shutdown-guardrails` (readiness/termination) and `aks-workload-hardening` (security context, pod security) — this skill covers sizing and autoscaling only.\n\n## Review checklist\n- [ ] Every container (incl. sidecars/init) has CPU and memory requests\n- [ ] QoS class is intentional and documented; no BestEffort in prod\n- [ ] Memory limit set from observed peak; CPU limit follows platform policy\n- [ ] HPA metric matches the real load signal (CPU, custom, or KEDA)\n- [ ] `minReplicas >= 2` in prod; `maxReplicas` fits quota, node pool, and CA bounds\n- [ ] No VPA update mode on the same metrics; KEDA and HPA not doubled up\n- [ ] Scale-down stabilization/policies set; ramp test shows no flapping\n- [ ] Evidence for the numbers recorded in the PR or values comments\n\n## Copy-ready SKILL.md stub\n```markdown\n---\nname: aks-hpa-requests-limits-guardrails\ndescription: Use when adding or tuning AKS Deployments and HPAs — requests on every container, deliberate QoS, CPU target 60–80% or custom/KEDA metrics, scale-down stabilization, quota and node pool math, no VPA update mode on the same metrics.\n---\n\nFollow AKS HPA Requests & Limits Guardrails: requests everywhere, evidence-based sizing, intentional QoS, minReplicas >= 2 in prod, maxReplicas within quota and autoscaler bounds, and stabilized scale-down.\n```\n" } ] } From 26dc50d5c99d077e148cfc8da23caf7618c89eb6 Mon Sep 17 00:00:00 2001 From: Ramkumar Ethiraj <64294490+rmkr-dev@users.noreply.github.com> Date: Thu, 15 Oct 2026 05:06:23 +0000 Subject: [PATCH 2/2] Add tune AKS HPA requests and limits prompt --- promptbook/prompts.json | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/promptbook/prompts.json b/promptbook/prompts.json index f614b69..0589777 100644 --- a/promptbook/prompts.json +++ b/promptbook/prompts.json @@ -553,6 +553,27 @@ ], "formatNotes": "All three. Point the tool at the root/module `pom.xml`, enforcer config, suppressions file, and the CI workflow (or Jenkinsfile) that should fail on CVSS policy. Copilot: maven-dependency-cve path instructions plus those files in agent mode. Claude Code: the maven-dependency-cve-hygiene-guardrails skill plus the POM. Codex: AGENTS.md Maven supply-chain section, then the diff.", "body": "Task: Review and harden Maven dependency CVE hygiene for the reactor or module I specify. Produce a small, reviewable diff: BOM/override fixes, enforcer rules, CI scan gate, and only justified suppressions.\n\nContext placeholders (fill from the repo or ask only if missing):\n- Reactor / module path: {{MODULE_PATH}} (root pom or -pl module)\n- CVE or finding ids: {{CVE_IDS}} (comma-separated, or \"scan-first\")\n- Scanner: {{SCANNER}} (owasp-dependency-check | dependabot-only | org-sca | trivy-fs)\n- Fail threshold: {{FAIL_CVSS}} (e.g. 7.0)\n- BOM in use: {{BOM}} (spring-boot | custom-parent | none | unknown)\n- CI entrypoint: {{CI}} (path to workflow or Jenkinsfile)\n- Suppressions file: {{SUPPRESSIONS}} (path or \"create\")\n- Allowed fix style: {{FIX_STYLE}} (bom-bump | dependencyManagement-override | exclusion-last-resort | mixed)\n\nRequirements:\n\n1. Inventory\n - Parent/BOM imports and `dependencyManagement` order under {{MODULE_PATH}}\n - Existing `maven-enforcer-plugin` rules (convergence, upper-bound, release deps)\n - Current {{SCANNER}} config, plugin/action pins, and fail thresholds\n - {{SUPPRESSIONS}} contents: owners, dates, broad wildcards\n - Dependabot/Renovate Maven entries if present\n - For each id in {{CVE_IDS}} (or after a local scan): `mvn -q -pl … dependency:tree` path to the vulnerable GAV\n\n2. Design\n - Prefer {{FIX_STYLE}} with this order unless blocked: bump {{BOM}} / parent → post-BOM `dependencyManagement` override → exclusion only if unused and documented\n - Ensure overrides appear **after** BOM import so they win\n - Enable or tighten enforcer: `dependencyConvergence`, `requireUpperBoundDeps`, and release-profile `requireReleaseDeps` when missing\n - {{SCANNER}}=owasp-dependency-check: pin plugin version; set `failBuildOnCVSS` to {{FAIL_CVSS}}; wire into {{CI}}; note NVD/data-feed cache or mirror if the repo already has one — do not invent corporate URLs\n - {{SCANNER}}=dependabot-only: ensure Maven ecosystem + PR CI must pass; do not claim transitive CVEs are covered if only manifests are updated\n - Suppressions: add or keep only entries that cite {{CVE_IDS}}, specific GAV, justification, and a review-by date; remove eternal wildcards\n\n3. Author artifacts (prefer concrete diffs)\n - `pom.xml` / parent changes for versions and enforcer\n - {{CI}} job/steps for the scan (fail the PR on policy breach)\n - {{SUPPRESSIONS}} updates when unavoidable\n - Short note in existing AGENTS.md / copilot-instructions / CLAUDE.md only if those files already exist — one line on BOM + scan gate\n\n4. Verification\n - Re-run tree for {{CVE_IDS}} and show fixed version on the path\n - Run the module test command already used in-repo\n - Confirm scanner would fail on a known High finding (or document how to dry-run)\n - Grep for version ranges, `LATEST`, and duplicate managed versions\n\nConstraints:\n- Minimal diff; match existing POM style (properties vs direct versions).\n- Do not invent Nexus/Artifactory URLs, company BOM coordinates, or NVD mirror hosts — use placeholders if absent.\n- Do not disable enforcer or the scan gate to \"get green\".\n- Do not confuse container base-image CVEs with Maven artifact CVEs.\n- Optimize for GitHub Copilot, Claude Code, and Codex — concrete POM/XML and checklist output.\n\nOutput format:\n1. Plan (fix per CVE + gate changes)\n2. Diffs (pom, enforcer, CI, suppressions)\n3. Tree snippets before/after for {{CVE_IDS}}\n4. Verification checklist + residual risk\n\nStart from {{MODULE_PATH}}. Prefer BOM bumps and post-BOM overrides over exclusions.\n" + }, + { + "id": "tune-aks-hpa-requests-limits", + "title": "Tune AKS HPA With Requests and Limits", + "whenToUse": "Take an AKS workload and produce evidence-based requests/limits, an HPA (or KEDA) metric and target, sane min/max replicas, and scale-down behavior as a small YAML or Helm diff.", + "tools": [ + "copilot", + "claude-code", + "codex" + ], + "tags": [ + "aks", + "kubernetes", + "hpa", + "autoscaling", + "resources", + "devops", + "azure" + ], + "formatNotes": "All three. Point the tool at the Deployment/StatefulSet manifest or Helm chart + values file, the HPA or KEDA ScaledObject, and the namespace's ResourceQuota/LimitRange. Copilot: aks-hpa-requests-limits path instructions plus those files in agent mode. Claude Code: the aks-hpa-requests-limits-guardrails skill plus the manifests. Codex: AGENTS.md autoscaling section, then the diff.", + "body": "Task: Review and tune resource requests/limits and HorizontalPodAutoscaler settings for the AKS workload I specify. Produce a small, reviewable YAML or Helm values diff with the reasoning behind every number.\n\nContext placeholders (fill from the repo or ask only if missing):\n- Workload: {{WORKLOAD}} (Deployment/StatefulSet name)\n- Namespace: {{NAMESPACE}}\n- Manifest path: {{MANIFEST_PATH}} (raw YAML, kustomize overlay, or Helm chart + values file)\n- Scaling metric: {{METRIC}} (cpu | memory | custom | keda)\n- Target: {{TARGET}} (e.g. 70% CPU, 200 RPS per pod, 50 messages per replica)\n- Min replicas: {{MIN_REPLICAS}}\n- Max replicas: {{MAX_REPLICAS}}\n- Cluster Autoscaler on node pool: {{HAS_CLUSTER_AUTOSCALER}} (yes + min/max nodes | no | unknown)\n- Evidence available: {{EVIDENCE}} (load test | VPA recommendation | p95 from Container Insights/Prometheus | none)\n\nRequirements:\n\n1. Inventory\n - Every container in {{WORKLOAD}} (app, sidecars, init): current requests, limits, and resulting QoS class\n - Existing HPA / KEDA ScaledObject for {{WORKLOAD}}: metric, target, min/max, `behavior`\n - PodDisruptionBudget, LimitRange, and ResourceQuota in {{NAMESPACE}}\n - Any VPA object targeting {{WORKLOAD}} and its `updateMode`\n - Whether metrics-server (resource metrics) or the custom/external metrics adapter needed for {{METRIC}} is present\n\n2. Design\n - Add missing requests first; HPA utilization is a percentage of requests\n - Propose requests/limits from {{EVIDENCE}}; if none, give conservative starting values and say they must be validated\n - State the chosen QoS class (Burstable by default; Guaranteed only with a latency/noisy-neighbor reason)\n - {{METRIC}}=cpu: start {{TARGET}} in the 60–80% band unless evidence says otherwise\n - {{METRIC}}=custom or keda: name the metric/scaler and confirm only one autoscaler owns the Deployment\n - Check `{{MAX_REPLICAS}} × per-pod requests` against ResourceQuota and node pool capacity; with {{HAS_CLUSTER_AUTOSCALER}}=yes, check against max nodes and note scale-up lag\n - Prod: `{{MIN_REPLICAS}} >= 2` and consistent with the PDB\n - Add `behavior.scaleDown` stabilization and policies to stop flapping\n - Flag VPA in update mode on the same metrics as a conflict; recommend `updateMode: \"Off\"`\n\n3. Author artifacts\n - Minimal diff to {{MANIFEST_PATH}} (values file for Helm; keep template defaults safe)\n - Inline comments recording where each number came from\n - Do not change Cluster Autoscaler, node pool, or quota settings unless I ask — list recommended changes separately\n\n4. Verification\n - `kubectl apply --dry-run=server -f …` (or `helm template … | kubectl apply --dry-run=server -f -`)\n - `kubectl -n {{NAMESPACE}} describe hpa {{WORKLOAD}}` shows real targets, not ``\n - `kubectl -n {{NAMESPACE}} top pods -l app={{WORKLOAD}}` during a ramp\n - `kubectl -n {{NAMESPACE}} describe quota` and pending-pod events after scale-up\n\nConstraints:\n- Match existing manifest/Helm style; no unrelated refactors.\n- Do not invent metric names, cluster sizes, or quota values — use placeholders if unknown.\n- Do not rewrite probes; reference the probes skill if they block readiness.\n- Optimize for GitHub Copilot, Claude Code, and Codex — concrete YAML and a checklist.\n\nOutput format:\n1. Summary table: container | old req/lim | new req/lim | QoS | rationale; plus HPA old vs new (metric, target, min, max, behavior)\n2. Patch (YAML or values diff)\n3. Risks: VPA/KEDA conflicts, missing metrics pipeline, quota or Cluster Autoscaler limits\n4. Verification commands and expected output\n\nStart from {{MANIFEST_PATH}}. Add missing requests before touching HPA targets.\n" } ] }