Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions promptbook/prompts.json
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,26 @@
],
"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 `<unknown>`\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"
},
{
"id": "tune-spark-job-performance",
"title": "Tune a Spark Job From Its Plan and Metrics",
"whenToUse": "Take a slow or costly Spark/PySpark job, diagnose its hotspots from the physical plan and Spark UI metrics, and produce a minimal code/config diff with a before/after comparison.",
"tools": [
"copilot",
"claude-code",
"codex"
],
"tags": [
"spark",
"pyspark",
"databricks",
"performance",
"data-platform",
"sql"
],
"formatNotes": "All three. Point the tool at the job entrypoint, the job/cluster config, and any saved `explain` output or Spark UI stage metrics (paste the top slow stages if logs are not in the repo). Copilot: spark-job-tuning path instructions plus those files in agent mode. Claude Code: the spark-job-tuning-guardrails skill plus the job file. Codex: AGENTS.md Spark performance section, then the diff.",
"body": "Task: Diagnose and tune the Spark job I specify. Work from the physical plan and run metrics, apply the smallest set of changes that measurably helps, and give me a before/after comparison I can paste into the PR.\n\nContext placeholders (fill from the repo or ask only if missing):\n- Job entrypoint: {{JOB_PATH}} (PySpark/Scala file, notebook, or SQL file)\n- Platform: {{PLATFORM}} (databricks | synapse | hdinsight | spark-on-k8s | other)\n- Spark version: {{SPARK_VERSION}}\n- Inputs: {{INPUTS}} (tables/paths with approximate size and format)\n- Output: {{OUTPUT}} (table/path, format, partition columns)\n- Symptom: {{SYMPTOM}} (sla-miss | straggler-tasks | spill | small-files | oom | cost)\n- Evidence available: {{EVIDENCE}} (spark-ui | event-logs | explain-output | run-history | none)\n- Cluster definition: {{CLUSTER}} (path to job/cluster config, or \"unknown\")\n- Target: {{TARGET}} (e.g. under 30 min, 40% less cost, no spill)\n\nRequirements:\n\n1. Inventory\n - Read {{JOB_PATH}} end to end: sources, filters, joins, aggregations, window functions, UDFs, `cache`/`persist`, `collect`/`toPandas`, and the final write\n - Current Spark configs set in code, job JSON, or {{CLUSTER}} (AQE flags, shuffle partitions, broadcast thresholds, memory)\n - {{OUTPUT}} layout: partition columns, typical file count and size, compaction schedule if any\n - Whether table statistics exist for {{INPUTS}}\n\n2. Diagnose\n - Produce or request `explain(mode=\"formatted\")` for the heaviest query; list each Exchange, join strategy, and whether pushdown/pruning reached the scan\n - From {{EVIDENCE}}: top three slowest stages with shuffle read/write, spill, task count, and max vs p75 task duration\n - Classify each hotspot: excess data read, wrong join strategy, skew, bad partition sizing, spill, small files, driver bottleneck, or Python UDF overhead\n - If {{EVIDENCE}}=none, say which metrics to capture first and give a ranked hypothesis list instead of tuning blindly\n\n3. Fix (one change per hotspot, in this order)\n - Prune columns and filter before joins/aggregations\n - Choose join strategy: broadcast only a reliably small side; align key types to avoid casts\n - Skew: rely on AQE skew-join first; for aggregations or hot keys AQE cannot split, use pre-aggregation, hot-key isolation, or salting — name the hot keys\n - Partition sizing: keep AQE on; set an initial partition count high enough for coalescing; target roughly 100–200 MB per shuffle partition\n - Writes: `REBALANCE`/`repartition` by output partition columns; no high-cardinality partition columns; add or note compaction\n - Remove unneeded `cache()`, unbounded `collect()`/`toPandas()`, and replace row-at-a-time Python UDFs with built-ins or pandas UDFs\n - Change cluster size only after the above, and only with metrics showing the job is resource-bound\n\n4. Verification\n - Re-run on representative data (same skew and file layout as prod); fill the before/after table\n - Show the new plan excerpt proving the intended join/shuffle change\n - Confirm output row counts and checksums match the baseline run\n - Note behavior under 2× input growth (broadcast size, partition count)\n\nConstraints:\n- Minimal diff; match the repo's existing job structure and config style.\n- Keep AQE enabled; every config added gets a comment with its evidence.\n- Do not invent table names, cluster IDs, workspace URLs, or data sizes — use placeholders if unknown.\n- Do not change business logic or output schema; correctness beats speed.\n- Optimize for GitHub Copilot, Claude Code, and Codex — concrete code/config diffs and a checklist.\n\nOutput format:\n1. Hotspot table: stage | symptom | root cause | fix | expected impact\n2. Patch (job code + config diff)\n3. Before/after metrics: wall time, shuffle bytes, spill, max task time, output file count/size, cost if known\n4. Risks and follow-ups (data growth, stats refresh, compaction schedule)\n\nStart from {{JOB_PATH}}. Read the plan before changing any config.\n"
}
]
}
Loading
Loading