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 @@ -594,6 +594,26 @@
],
"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"
},
{
"id": "harden-jenkinsfile",
"title": "Harden a Jenkinsfile",
"whenToUse": "Review a Jenkins pipeline for leaked-secret risks, controller-heavy Groovy, unbounded runs, and unpinned agents or libraries, and produce a minimal Declarative diff with lint output.",
"tools": [
"copilot",
"claude-code",
"codex"
],
"tags": [
"jenkins",
"ci",
"devsecops",
"groovy",
"security",
"kubernetes"
],
"formatNotes": "All three. Point the tool at the Jenkinsfile, any shared-library `vars/*.groovy` it loads, and the scripts its `sh` steps call; list credential IDs only, never secret values. Copilot: jenkins-pipeline path instructions plus those files in agent mode. Claude Code: the jenkins-declarative-pipeline-guardrails skill plus the Jenkinsfile. Codex: AGENTS.md Jenkins section, then the diff.",
"body": "Task: Review and harden the Jenkins pipeline I specify. Keep it Declarative, move heavy logic out of Groovy, make every run bounded and reproducible, and make sure no credential can leak — then give me a minimal diff I can open as a PR.\n\nContext placeholders (fill from the repo or ask only if missing):\n- Pipeline file: {{JENKINSFILE_PATH}} (usually `Jenkinsfile`)\n- Job type: {{JOB_TYPE}} (multibranch | pipeline | organization-folder)\n- Build stack: {{BUILD_STACK}} (maven | gradle | docker | python | other)\n- Agents available: {{AGENTS}} (labels, Kubernetes pod templates, or \"unknown\")\n- Shared libraries: {{LIBRARIES}} (names and versions, or \"none\")\n- Credential IDs in use: {{CREDENTIAL_IDS}} (IDs only — never paste secret values)\n- Deploy targets: {{DEPLOY_TARGETS}} (e.g. aks-dev, aks-prod, artifact-repo, none)\n- Pain points: {{PAIN}} (hangs | slow | flaky | controller-load | secret-exposure | none)\n\nRequirements:\n\n1. Inventory\n - Read {{JENKINSFILE_PATH}} end to end: agent declarations, `options`, `environment`, every stage, `when` conditions, `script {}` blocks, `input` steps, `parallel`/`matrix`, `post`\n - List each credential binding, how the secret is referenced, and which stages can see it\n - List shared libraries and the version each is loaded at, plus any `Jenkins.instance` or other internal API use\n - Note how fork PRs are treated if {{JOB_TYPE}} is multibranch\n\n2. Findings (rank by risk: secret exposure > untrusted code with credentials > controller load > unbounded runs > reproducibility > hygiene)\n - Groovy-interpolated secrets (`\"${TOKEN}\"` inside `sh`), echoed secrets, `set -x` around secrets, secrets written to the workspace\n - Builds that can run on the controller, `agent any` without labels, unpinned images or tools\n - Large `script {}` blocks, Groovy JSON/XML parsing, loops of tiny `sh` calls\n - Missing `timeout`, `buildDiscarder`, `timestamps`, or concurrency policy\n - `input` holding an agent; deploys without `lock`/`milestone`; `if` logic that should be `when { ... beforeAgent true }`\n - Unpinned `@Library` refs, overridden built-in steps, sandbox bypasses\n - Missing `post` publishing (tests, artifacts with fingerprints) and workspace cleanup\n\n3. Fix\n - Declarative structure with `agent none` at the top only if every stage declares its own agent; otherwise one labelled agent or pod template\n - Move heavy logic into scripts (`scripts/ci/*.sh`) or build-tool goals ({{BUILD_STACK}}: e.g. `./mvnw -B -ntp verify`)\n - Top-level `options { timeout(...); buildDiscarder(logRotator(...)); timestamps(); disableConcurrentBuilds(abortPrevious: true) }` — adjust stage timeouts knowing they include agent provisioning when the agent is stage-level\n - Bind credentials per stage with `withCredentials` or `credentials()`; reference them only inside single-quoted `sh` strings\n - Approval stages: `agent none`, `input` with `timeout`, and `lock`/`milestone` on deploys to {{DEPLOY_TARGETS}}\n - Pin `@Library` to a tag or commit; replace `Jenkins.instance` use with a supported step or flag it for a plugin\n - `post { always { junit ...; archiveArtifacts ... fingerprint: true } cleanup { cleanWs() } }`\n - Keep deploy credentials out of PR and fork builds\n\n4. Verification\n - Run the Declarative linter (`jenkins-cli declarative-linter` or the validate endpoint) and include its output\n - Run on a branch build and, for multibranch, a PR build; compare duration and queue time with recent builds\n - Confirm in the console log that secrets show as masked and are never printed by a step\n - List anything that needs a Jenkins admin (plugins, credential scope, fork trust settings, agent templates)\n\nConstraints:\n- Minimal diff; keep stage names and artifacts unless a rename is needed for clarity.\n- Do not invent credential IDs, agent labels, image names, or URLs — use placeholders if unknown.\n- Never print or request secret values; refer to credentials by ID only.\n- Do not change what gets built or deployed; behaviour stays the same except for the safety fixes.\n- Optimize for GitHub Copilot, Claude Code, and Codex — concrete Jenkinsfile diff and a checklist.\n\nOutput format:\n1. Findings table: severity | location | issue | fix\n2. Patch (Jenkinsfile diff plus any new scripts)\n3. Before/after: run duration, queue time, controller-side `script` lines, credentials scope per stage\n4. Admin follow-ups and residual risks\n\nStart from {{JENKINSFILE_PATH}}. Fix secret handling before anything else."
}
]
}
Loading
Loading