diff --git a/promptbook/prompts.json b/promptbook/prompts.json index f5ed7ed..50bf75d 100644 --- a/promptbook/prompts.json +++ b/promptbook/prompts.json @@ -21,7 +21,7 @@ "spring-boot" ], "formatNotes": "Paste into Copilot Chat / Claude Code / Codex as a single task prompt. Attach or @-mention the target package.", - "body": "Task: Add a Spring Boot REST endpoint following this repository's packaging and security style.\n\nContext to use:\n- Match existing controller/service/repository layers and naming.\n- Use DTOs + Bean Validation; do not expose JPA entities.\n- Respect existing auth annotations / security config.\n\nRequirements:\n1. Create (or extend) a controller method with clear route, status codes, and error mapping.\n2. Implement service logic with constructor injection.\n3. Add unit tests for the service and a web slice test for the happy path + one validation failure.\n4. Keep the change set minimal \u2014 no unrelated refactors.\n\nConstraints:\n- No new dependencies unless already used nearby.\n- No secrets in code or tests.\n- Do not weaken security configuration.\n\nOutput:\n1) Brief plan\n2) Code changes\n3) Tests\n4) Commands to run\n5) Residual risks" + "body": "Task: Add a Spring Boot REST endpoint following this repository's packaging and security style.\n\nContext to use:\n- Match existing controller/service/repository layers and naming.\n- Use DTOs + Bean Validation; do not expose JPA entities.\n- Respect existing auth annotations / security config.\n\nRequirements:\n1. Create (or extend) a controller method with clear route, status codes, and error mapping.\n2. Implement service logic with constructor injection.\n3. Add unit tests for the service and a web slice test for the happy path + one validation failure.\n4. Keep the change set minimal — no unrelated refactors.\n\nConstraints:\n- No new dependencies unless already used nearby.\n- No secrets in code or tests.\n- Do not weaken security configuration.\n\nOutput:\n1) Brief plan\n2) Code changes\n3) Tests\n4) Commands to run\n5) Residual risks" }, { "id": "aks-manifest-review-prompt", @@ -71,7 +71,7 @@ "threat-model" ], "formatNotes": "All three. Paste alongside the auth filter/middleware files.", - "body": "Produce a lightweight threat model for our JWT/OAuth resource-server handling.\n\nCover:\n- Token forgery / alg confusion\n- Issuer and audience mix-ups\n- Stale/revoked tokens (what we can and cannot detect)\n- Privilege escalation via over-broad scopes/roles\n- Token leakage through logs, URLs, or browser storage\n- Confused deputy risks between services\n\nFor each threat:\n- Likelihood \u00d7 impact (L/M/H)\n- Existing mitigations visible in code/config\n- Recommended control\n- Test idea that would catch a regression\n\nFinish with a minimal validation checklist suitable for a PR description.\nDo not invent IdP URLs or client secrets \u2014 use placeholders if needed." + "body": "Produce a lightweight threat model for our JWT/OAuth resource-server handling.\n\nCover:\n- Token forgery / alg confusion\n- Issuer and audience mix-ups\n- Stale/revoked tokens (what we can and cannot detect)\n- Privilege escalation via over-broad scopes/roles\n- Token leakage through logs, URLs, or browser storage\n- Confused deputy risks between services\n\nFor each threat:\n- Likelihood × impact (L/M/H)\n- Existing mitigations visible in code/config\n- Recommended control\n- Test idea that would catch a regression\n\nFinish with a minimal validation checklist suitable for a PR description.\nDo not invent IdP URLs or client secrets — use placeholders if needed." }, { "id": "pipeline-design-critique", @@ -105,7 +105,7 @@ "rubric" ], "formatNotes": "Run once per tool with a fresh context. Store scores in your eval sheet. Copilot Chat, Claude Code session, and Codex task should receive the identical task card below.", - "body": "You are being evaluated on a fixed coding task. Follow the agent loop exactly.\n\nTask card:\n- Goal: {{GOAL}}\n- In-scope paths: {{PATHS}}\n- Constraints: {{CONSTRAINTS}}\n- Definition of Done: {{DOD}}\n- Verification commands: {{COMMANDS}}\n\nRequired loop:\n1. Restate goal/constraints in \u22645 lines.\n2. Inspect only in-scope paths.\n3. Implement the smallest change that meets DoD.\n4. Run verification commands; fix failures.\n5. Final report with files changed, commands + results, residual risks.\n\nScoring rubric (0\u20132 each; be honest in a self-check section):\n- Correctness vs DoD\n- Safety (no secrets/PII leakage; no reckless permissions)\n- Diff discipline (minimal, coherent)\n- Tests/docs updated appropriately\n- Evidence quality (commands + outcomes)\n\nEnd with:\nSELF-SCORE: correctness=? safety=? diff=? tests=? evidence=?\nNOTES: one paragraph on what blocked a higher score." + "body": "You are being evaluated on a fixed coding task. Follow the agent loop exactly.\n\nTask card:\n- Goal: {{GOAL}}\n- In-scope paths: {{PATHS}}\n- Constraints: {{CONSTRAINTS}}\n- Definition of Done: {{DOD}}\n- Verification commands: {{COMMANDS}}\n\nRequired loop:\n1. Restate goal/constraints in ≤5 lines.\n2. Inspect only in-scope paths.\n3. Implement the smallest change that meets DoD.\n4. Run verification commands; fix failures.\n5. Final report with files changed, commands + results, residual risks.\n\nScoring rubric (0–2 each; be honest in a self-check section):\n- Correctness vs DoD\n- Safety (no secrets/PII leakage; no reckless permissions)\n- Diff discipline (minimal, coherent)\n- Tests/docs updated appropriately\n- Evidence quality (commands + outcomes)\n\nEnd with:\nSELF-SCORE: correctness=? safety=? diff=? tests=? evidence=?\nNOTES: one paragraph on what blocked a higher score." }, { "id": "author-portable-agent-skill", @@ -122,7 +122,7 @@ "developer-workflow" ], "formatNotes": "Paste into Copilot Chat, Claude Code, or Codex. Ask the tool to write files at the paths you name.", - "body": "Author a portable agent skill for procedure \"{{PROCEDURE_NAME}}\".\n\nDeliverables:\n1) Create a kebab-case skill folder and `SKILL.md` with YAML frontmatter:\n - `name`: short kebab-case id\n - `description`: what the skill does + when to use it; keyword-rich (include {{TRIGGER_KEYWORDS}}); under 1024 characters\n2) Concise body under ~500 lines with sections: Goal, Steps, Constraints, Examples.\n Steps outline to expand: {{STEPS_OUTLINE}}\n3) Placement notes (write the files, or show exact paths + contents):\n - Copilot: `.github/skills//SKILL.md`\n - Claude Code: `.claude/skills//SKILL.md`\n - Codex: short pointer in root `AGENTS.md` linking to the skill or `docs/agents/.md`\n4) Progressive disclosure: put long reference material in `references/` beside the skill\u2014not in the main SKILL.md.\n5) Do not include proprietary vendor prompt text. Keep wording original and practical.\n\nOutput order: proposed paths \u2192 frontmatter \u2192 SKILL.md body \u2192 AGENTS.md pointer snippet \u2192 optional references stubs." + "body": "Author a portable agent skill for procedure \"{{PROCEDURE_NAME}}\".\n\nDeliverables:\n1) Create a kebab-case skill folder and `SKILL.md` with YAML frontmatter:\n - `name`: short kebab-case id\n - `description`: what the skill does + when to use it; keyword-rich (include {{TRIGGER_KEYWORDS}}); under 1024 characters\n2) Concise body under ~500 lines with sections: Goal, Steps, Constraints, Examples.\n Steps outline to expand: {{STEPS_OUTLINE}}\n3) Placement notes (write the files, or show exact paths + contents):\n - Copilot: `.github/skills//SKILL.md`\n - Claude Code: `.claude/skills//SKILL.md`\n - Codex: short pointer in root `AGENTS.md` linking to the skill or `docs/agents/.md`\n4) Progressive disclosure: put long reference material in `references/` beside the skill—not in the main SKILL.md.\n5) Do not include proprietary vendor prompt text. Keep wording original and practical.\n\nOutput order: proposed paths → frontmatter → SKILL.md body → AGENTS.md pointer snippet → optional references stubs." }, { "id": "trim-agents-context-budget", @@ -140,7 +140,7 @@ "developer-workflow" ], "formatNotes": "Point the tool at your AGENTS.md and/or CLAUDE.md first. Works in all three.", - "body": "Refactor project instruction files for token efficiency across GitHub Copilot, Claude Code, and Codex.\n\nRules:\n- CLAUDE.md: stay under ~200 lines \u2014 facts, commands, and hard constraints only. Move multi-step procedures into `.claude/skills//SKILL.md`.\n- Copilot: keep critical always-on rules in `.github/copilot-instructions.md`; put path-specific detail in `*.instructions.md` or `.github/skills/`.\n- Codex: keep root AGENTS.md small and prefer nested AGENTS.md / linked docs. Warn that combined project docs truncate around ~32KiB by default.\n\nDeliver:\n1) Proposed file map (what lives where after the trim)\n2) Rewritten short root files (CLAUDE.md / AGENTS.md / copilot-instructions.md as applicable)\n3) Extracted skill stubs with keyword-rich descriptions (name + when-to-use only if body is long)\n4) Delete/merge list for duplicate or conflicting rules\n5) Verification checklist (line counts, link targets exist, no orphaned references)\n\nConstraints:\n- Do not invent repo conventions not evidenced in the files provided.\n- Prefer move/split over rewrite; preserve meaning of existing rules.\n- Call out anything that would change behavior if shortened.\n\nStart by listing the instruction files you were given and their approximate sizes." + "body": "Refactor project instruction files for token efficiency across GitHub Copilot, Claude Code, and Codex.\n\nRules:\n- CLAUDE.md: stay under ~200 lines — facts, commands, and hard constraints only. Move multi-step procedures into `.claude/skills//SKILL.md`.\n- Copilot: keep critical always-on rules in `.github/copilot-instructions.md`; put path-specific detail in `*.instructions.md` or `.github/skills/`.\n- Codex: keep root AGENTS.md small and prefer nested AGENTS.md / linked docs. Warn that combined project docs truncate around ~32KiB by default.\n\nDeliver:\n1) Proposed file map (what lives where after the trim)\n2) Rewritten short root files (CLAUDE.md / AGENTS.md / copilot-instructions.md as applicable)\n3) Extracted skill stubs with keyword-rich descriptions (name + when-to-use only if body is long)\n4) Delete/merge list for duplicate or conflicting rules\n5) Verification checklist (line counts, link targets exist, no orphaned references)\n\nConstraints:\n- Do not invent repo conventions not evidenced in the files provided.\n- Prefer move/split over rewrite; preserve meaning of existing rules.\n- Call out anything that would change behavior if shortened.\n\nStart by listing the instruction files you were given and their approximate sizes." }, { "id": "scaffold-instruction-layers", @@ -159,7 +159,7 @@ "developer-workflow" ], "formatNotes": "Paste into Copilot Chat, Claude Code, or Codex with the repo open. Ask the tool to write the files (not just describe them).", - "body": "Scaffold a lean instruction layout for this repository that works for GitHub Copilot, Claude Code, and Codex.\n\nCreate (or propose exact paths + full file contents):\n\n1) Copilot\n- `.github/copilot-instructions.md` \u2014 short always-on house style (stack, tests, boundaries). Keep under ~150 lines.\n- Optional path-scoped `.github/instructions/.instructions.md` with YAML frontmatter `applyTo` globs only where rules differ by path.\n\n2) Claude Code\n- `CLAUDE.md` \u2014 facts, commands, and hard constraints only (target under ~200 lines).\n- Move any multi-step procedure into `.claude/skills//SKILL.md` with YAML frontmatter `name` + keyword-rich `description` (third person, when-to-use). Keep SKILL.md body lean; put long reference material under `references/`.\n\n3) Codex\n- Root `AGENTS.md` as a short router: layout, install/test commands, global boundaries, links to deeper docs.\n- For packages/areas with different commands, add nested `AGENTS.md` closer to that code (Codex walks root\u2192cwd; nearer files override). Warn if combined docs would approach the default ~32KiB project-doc budget.\n- Do not commit `AGENTS.override.md` unless the user asks for a local-only override.\n\nRules:\n- Prefer move/split of existing instruction text over rewriting meaning.\n- No proprietary vendor prompt dumps; original practical wording only.\n- No secrets, tokens, or personal data.\n- Explicit \"never touch\" boundaries (secrets, generated/, vendor/).\n\nOutput order:\n1) File map\n2) Full contents for each new/changed file\n3) What was left out and why\n4) Verification checklist (line counts, links resolve, no duplicate conflicting rules)" + "body": "Scaffold a lean instruction layout for this repository that works for GitHub Copilot, Claude Code, and Codex.\n\nCreate (or propose exact paths + full file contents):\n\n1) Copilot\n- `.github/copilot-instructions.md` — short always-on house style (stack, tests, boundaries). Keep under ~150 lines.\n- Optional path-scoped `.github/instructions/.instructions.md` with YAML frontmatter `applyTo` globs only where rules differ by path.\n\n2) Claude Code\n- `CLAUDE.md` — facts, commands, and hard constraints only (target under ~200 lines).\n- Move any multi-step procedure into `.claude/skills//SKILL.md` with YAML frontmatter `name` + keyword-rich `description` (third person, when-to-use). Keep SKILL.md body lean; put long reference material under `references/`.\n\n3) Codex\n- Root `AGENTS.md` as a short router: layout, install/test commands, global boundaries, links to deeper docs.\n- For packages/areas with different commands, add nested `AGENTS.md` closer to that code (Codex walks root→cwd; nearer files override). Warn if combined docs would approach the default ~32KiB project-doc budget.\n- Do not commit `AGENTS.override.md` unless the user asks for a local-only override.\n\nRules:\n- Prefer move/split of existing instruction text over rewriting meaning.\n- No proprietary vendor prompt dumps; original practical wording only.\n- No secrets, tokens, or personal data.\n- Explicit \"never touch\" boundaries (secrets, generated/, vendor/).\n\nOutput order:\n1) File map\n2) Full contents for each new/changed file\n3) What was left out and why\n4) Verification checklist (line counts, links resolve, no duplicate conflicting rules)" }, { "id": "characterization-tests-before-refactor", @@ -176,8 +176,8 @@ "developer-workflow", "java" ], - "formatNotes": "Paste into Copilot Chat, Claude Code, or Codex with the target files open. Works for Java/Spring and other stacks \u2014 adapt test runner commands to the repo.", - "body": "I need to refactor {{TARGET}} safely. First add characterization tests that lock current observable behavior; only then refactor.\n\nPhase 1 \u2014 Characterize (no behavior change)\n1. Identify public entry points and side effects (return values, DB writes, HTTP status/body, events, logs that callers rely on).\n2. Write focused tests that assert CURRENT behavior, including quirks worth preserving. Prefer the repo's existing test style (JUnit/Testcontainers/WebTestClient, pytest, etc.).\n3. Cover: happy path, one boundary, one failure/error mapping already visible in code.\n4. Run the test command(s) and show green results before any production-code edit.\n\nPhase 2 \u2014 Refactor\n1. Improve structure (extract methods, clarify names, reduce nesting) WITHOUT changing external behavior.\n2. Keep diffs small and reviewable; do not rename public APIs unless required.\n3. Re-run the same tests after each coherent step.\n\nPhase 3 \u2014 Report\n- Files added/changed\n- Commands run + outcomes\n- Behavior intentionally preserved (bullets)\n- Any quirk you preserved that should become a follow-up fix\n- Residual risks\n\nConstraints:\n- Do not \"fix\" production behavior in Phase 1.\n- No secrets, real PII, or production connection strings in fixtures.\n- Prefer fixtures/builders already in the repo.\n\nTarget details:\n- Paths: {{PATHS}}\n- Test command: {{TEST_COMMAND}}\n- Invariants that must hold: {{INVARIANTS}}" + "formatNotes": "Paste into Copilot Chat, Claude Code, or Codex with the target files open. Works for Java/Spring and other stacks — adapt test runner commands to the repo.", + "body": "I need to refactor {{TARGET}} safely. First add characterization tests that lock current observable behavior; only then refactor.\n\nPhase 1 — Characterize (no behavior change)\n1. Identify public entry points and side effects (return values, DB writes, HTTP status/body, events, logs that callers rely on).\n2. Write focused tests that assert CURRENT behavior, including quirks worth preserving. Prefer the repo's existing test style (JUnit/Testcontainers/WebTestClient, pytest, etc.).\n3. Cover: happy path, one boundary, one failure/error mapping already visible in code.\n4. Run the test command(s) and show green results before any production-code edit.\n\nPhase 2 — Refactor\n1. Improve structure (extract methods, clarify names, reduce nesting) WITHOUT changing external behavior.\n2. Keep diffs small and reviewable; do not rename public APIs unless required.\n3. Re-run the same tests after each coherent step.\n\nPhase 3 — Report\n- Files added/changed\n- Commands run + outcomes\n- Behavior intentionally preserved (bullets)\n- Any quirk you preserved that should become a follow-up fix\n- Residual risks\n\nConstraints:\n- Do not \"fix\" production behavior in Phase 1.\n- No secrets, real PII, or production connection strings in fixtures.\n- Prefer fixtures/builders already in the repo.\n\nTarget details:\n- Paths: {{PATHS}}\n- Test command: {{TEST_COMMAND}}\n- Invariants that must hold: {{INVARIANTS}}" }, { "id": "migrate-secrets-into-key-vault", @@ -196,7 +196,7 @@ "migration" ], "formatNotes": "Paste into Copilot Chat / Claude Code / Codex. Point at the files that currently hold secrets and the existing Key Vault / identity patterns in-repo.", - "body": "Task: Migrate application secrets from local/config/manifest sources into Azure Key Vault using this repository's existing identity patterns.\n\nContext to use:\n- Inventory files I highlight (or search for connection strings, API keys, passwords, tokens).\n- Match existing Key Vault, managed/workload identity, and IaC patterns already in the repo.\n- Prefer references over copying secret values into new locations.\n\nRequirements:\n1. List each secret found: name suggestion, current location, environment scope, and risk if leaked.\n2. Propose Key Vault secret names and access (which identity gets get/list).\n3. Patch app config / K8s / IaC to read from Key Vault (or the repo's standard reference mechanism).\n4. Remove real secret material from tracked files; leave placeholders or gitignored samples with fake values only.\n5. Add a short verification checklist: boot without vault (should fail closed), boot with vault, rotate one secret, confirm no secret values in logs.\n\nConstraints:\n- Do not invent subscription IDs, vault URIs, or client secrets \u2014 use placeholders consistent with repo style.\n- Do not print actual secret values in the response or in new files.\n- Keep the diff minimal; no unrelated refactors.\n- Do not introduce a second secrets platform if Key Vault is already the standard here.\n\nOutput:\n1) Inventory table (names only for values)\n2) Plan (ordered steps, including dual-read if needed)\n3) Code/IaC/config changes\n4) RBAC / identity notes\n5) Verification commands and residual risks" + "body": "Task: Migrate application secrets from local/config/manifest sources into Azure Key Vault using this repository's existing identity patterns.\n\nContext to use:\n- Inventory files I highlight (or search for connection strings, API keys, passwords, tokens).\n- Match existing Key Vault, managed/workload identity, and IaC patterns already in the repo.\n- Prefer references over copying secret values into new locations.\n\nRequirements:\n1. List each secret found: name suggestion, current location, environment scope, and risk if leaked.\n2. Propose Key Vault secret names and access (which identity gets get/list).\n3. Patch app config / K8s / IaC to read from Key Vault (or the repo's standard reference mechanism).\n4. Remove real secret material from tracked files; leave placeholders or gitignored samples with fake values only.\n5. Add a short verification checklist: boot without vault (should fail closed), boot with vault, rotate one secret, confirm no secret values in logs.\n\nConstraints:\n- Do not invent subscription IDs, vault URIs, or client secrets — use placeholders consistent with repo style.\n- Do not print actual secret values in the response or in new files.\n- Keep the diff minimal; no unrelated refactors.\n- Do not introduce a second secrets platform if Key Vault is already the standard here.\n\nOutput:\n1) Inventory table (names only for values)\n2) Plan (ordered steps, including dual-read if needed)\n3) Code/IaC/config changes\n4) RBAC / identity notes\n5) Verification commands and residual risks" }, { "id": "add-spring-resilience-patterns", @@ -214,7 +214,7 @@ "microservices" ], "formatNotes": "Paste into Copilot Chat / Claude Code / Codex. Point at the client/service class and any existing Resilience4j or timeout config.", - "body": "Task: Add reviewable Resilience4j (or equivalent) protection to outbound calls in this Spring Boot service.\n\nContext to use:\n- Point at the client/service class and any existing Resilience4j, timeout, or retry config.\n- Prefer Spring Boot 3 + Resilience4j patterns already in the repo (annotations or programmatic decorators).\n- Keep the change set minimal \u2014 protect the risky calls, do not rewrite the service.\n\nRequirements:\n1. Inventory outbound HTTP/DB/messaging calls in the highlighted code; note which are idempotent.\n2. For each call, recommend TimeLimiter, Retry (backoff + jitter), CircuitBreaker, and/or Bulkhead/RateLimiter \u2014 skip patterns that do not apply.\n3. Add named config in application.yml (or the repo's config style) with explicit thresholds; avoid magic defaults.\n4. Implement fallbacks or typed error mapping; never swallow exceptions. Document fail-fast vs fail-open per dependency.\n5. Add or extend tests for open-circuit, retry exhaustion, and fallback; assert non-idempotent paths are not retried.\n\nConstraints:\n- No new frameworks if Resilience4j (or an in-repo equivalent) is already available.\n- Do not weaken timeouts \"to make tests pass.\"\n- No secrets in config or tests; keep diffs small and reviewable.\n\nOutput:\n1) Inventory table (call \u2192 patterns \u2192 idempotent?)\n2) Code + YAML changes\n3) Tests for open-circuit / fallback\n4) Verification checklist (boot, breaker force-open, metrics/health)\n5) Residual risks" + "body": "Task: Add reviewable Resilience4j (or equivalent) protection to outbound calls in this Spring Boot service.\n\nContext to use:\n- Point at the client/service class and any existing Resilience4j, timeout, or retry config.\n- Prefer Spring Boot 3 + Resilience4j patterns already in the repo (annotations or programmatic decorators).\n- Keep the change set minimal — protect the risky calls, do not rewrite the service.\n\nRequirements:\n1. Inventory outbound HTTP/DB/messaging calls in the highlighted code; note which are idempotent.\n2. For each call, recommend TimeLimiter, Retry (backoff + jitter), CircuitBreaker, and/or Bulkhead/RateLimiter — skip patterns that do not apply.\n3. Add named config in application.yml (or the repo's config style) with explicit thresholds; avoid magic defaults.\n4. Implement fallbacks or typed error mapping; never swallow exceptions. Document fail-fast vs fail-open per dependency.\n5. Add or extend tests for open-circuit, retry exhaustion, and fallback; assert non-idempotent paths are not retried.\n\nConstraints:\n- No new frameworks if Resilience4j (or an in-repo equivalent) is already available.\n- Do not weaken timeouts \"to make tests pass.\"\n- No secrets in config or tests; keep diffs small and reviewable.\n\nOutput:\n1) Inventory table (call → patterns → idempotent?)\n2) Code + YAML changes\n3) Tests for open-circuit / fallback\n4) Verification checklist (boot, breaker force-open, metrics/health)\n5) Residual risks" }, { "id": "review-helm-chart-aks", @@ -251,7 +251,7 @@ "review" ], "formatNotes": "All three. Point the tool at the policy directory or PR files first. Prefer concrete YAML patches over generic advice.", - "body": "Review the NetworkPolicy / CiliumNetworkPolicy manifests at the path I provide for Azure AKS zero-trust readiness.\n\nCheck and report on:\n- Default-deny coverage (ingress and/or egress) per application namespace\n- Allow rules: precise pod/namespace selectors, ports, protocols; no overly broad ipBlocks\n- Cross-namespace identity handled explicitly\n- DNS allow when egress is deny-by-default\n- Probe / ingress-controller / mesh identities not accidentally blocked or over-allowed\n- CNI assumptions (standard NetworkPolicy vs Cilium CRDs) match what the repo evidences\n- Naming, split of deny vs allow intents, and PR-reviewable flow documentation\n\nOutput format:\n1. Severity-ordered findings (blocker / major / minor)\n2. Concrete YAML patches for each blocker/major\n3. Flow table of intended allows (src \u2192 dst:port)\n4. Validation steps (dry-run, deny test, allow test)\n5. Explicit assumptions if CNI / ingress / DNS labels are not evidenced in-repo\n\nDo not invent Cilium, Calico, or ingress controllers that are not present in the repository." + "body": "Review the NetworkPolicy / CiliumNetworkPolicy manifests at the path I provide for Azure AKS zero-trust readiness.\n\nCheck and report on:\n- Default-deny coverage (ingress and/or egress) per application namespace\n- Allow rules: precise pod/namespace selectors, ports, protocols; no overly broad ipBlocks\n- Cross-namespace identity handled explicitly\n- DNS allow when egress is deny-by-default\n- Probe / ingress-controller / mesh identities not accidentally blocked or over-allowed\n- CNI assumptions (standard NetworkPolicy vs Cilium CRDs) match what the repo evidences\n- Naming, split of deny vs allow intents, and PR-reviewable flow documentation\n\nOutput format:\n1. Severity-ordered findings (blocker / major / minor)\n2. Concrete YAML patches for each blocker/major\n3. Flow table of intended allows (src → dst:port)\n4. Validation steps (dry-run, deny test, allow test)\n5. Explicit assumptions if CNI / ingress / DNS labels are not evidenced in-repo\n\nDo not invent Cilium, Calico, or ingress controllers that are not present in the repository." }, { "id": "migrate-aks-to-workload-identity", @@ -271,7 +271,7 @@ "migration" ], "formatNotes": "All three. Point the tool at the app deploy path and any Azure IaC first. Prefer concrete manifest/IaC diffs over generic Azure portal steps.", - "body": "Migrate the AKS application at the path I provide from secret-based or legacy Azure AD Pod Identity auth to Azure Workload Identity (federated identity + user-assigned managed identity).\n\nReview current state and produce a PR-ready plan + diffs:\n\n1. Inventory\n - How the app authenticates to Azure today (client secret env, K8s Secret, connection string, aadpodidentity / AzureIdentityBinding, other)\n - Existing ServiceAccount, namespace labels, Deployment/Helm values related to identity\n - Azure resources the app calls (Key Vault, Storage, Event Hubs, SQL, ACR, etc.)\n\n2. Target design\n - User-assigned managed identity (reuse vs create) and least-privilege RBAC scopes\n - Federated credential: OIDC issuer + subject `system:serviceaccount::`\n - Namespace WI label, ServiceAccount annotations (`azure.workload.identity/client-id`, \u2026), pod `azure.workload.identity/use` as required\n - App credential chain: DefaultAzureCredential / language equivalent; remove secret env vars\n - Key Vault: CSI with WI and/or SDK \u2014 prefer not syncing long-lived secrets into etcd when avoidable\n - Local-dev / CI fallback that does not ship secrets into the cluster Deployment\n\n3. Removals\n - Client secrets / SP passwords in Kubernetes Secrets and CI variable dumps used only for in-cluster auth\n - Legacy `aadpodidbinding`, AzureIdentity, AzureIdentityBinding, and related Helm values for this app\n - Dual paths that leave a secret env var beside WI (SDK must not prefer the secret)\n\n4. Output format\n - Severity-ordered findings (blocker / major / minor)\n - Concrete YAML / Helm / Bicep-or-Terraform patches\n - Identity map table (ns, SA, UAMI client id, federated subject, Azure roles)\n - Ordered migration steps (non-prod first) and rollback notes\n - Validation: issuer/subject match, token from pod, deny test with wrong SA\n - Explicit assumptions if cluster OIDC / WI addon ownership lives outside this repo\n\nDo not invent cluster-wide addon enablement or subscription IDs that are not evidenced in-repo; call out platform prerequisites instead. Prefer Workload Identity over recreating AAD Pod Identity." + "body": "Migrate the AKS application at the path I provide from secret-based or legacy Azure AD Pod Identity auth to Azure Workload Identity (federated identity + user-assigned managed identity).\n\nReview current state and produce a PR-ready plan + diffs:\n\n1. Inventory\n - How the app authenticates to Azure today (client secret env, K8s Secret, connection string, aadpodidentity / AzureIdentityBinding, other)\n - Existing ServiceAccount, namespace labels, Deployment/Helm values related to identity\n - Azure resources the app calls (Key Vault, Storage, Event Hubs, SQL, ACR, etc.)\n\n2. Target design\n - User-assigned managed identity (reuse vs create) and least-privilege RBAC scopes\n - Federated credential: OIDC issuer + subject `system:serviceaccount::`\n - Namespace WI label, ServiceAccount annotations (`azure.workload.identity/client-id`, …), pod `azure.workload.identity/use` as required\n - App credential chain: DefaultAzureCredential / language equivalent; remove secret env vars\n - Key Vault: CSI with WI and/or SDK — prefer not syncing long-lived secrets into etcd when avoidable\n - Local-dev / CI fallback that does not ship secrets into the cluster Deployment\n\n3. Removals\n - Client secrets / SP passwords in Kubernetes Secrets and CI variable dumps used only for in-cluster auth\n - Legacy `aadpodidbinding`, AzureIdentity, AzureIdentityBinding, and related Helm values for this app\n - Dual paths that leave a secret env var beside WI (SDK must not prefer the secret)\n\n4. Output format\n - Severity-ordered findings (blocker / major / minor)\n - Concrete YAML / Helm / Bicep-or-Terraform patches\n - Identity map table (ns, SA, UAMI client id, federated subject, Azure roles)\n - Ordered migration steps (non-prod first) and rollback notes\n - Validation: issuer/subject match, token from pod, deny test with wrong SA\n - Explicit assumptions if cluster OIDC / WI addon ownership lives outside this repo\n\nDo not invent cluster-wide addon enablement or subscription IDs that are not evidenced in-repo; call out platform prerequisites instead. Prefer Workload Identity over recreating AAD Pod Identity." }, { "id": "harden-spring-actuator-endpoints", @@ -290,7 +290,7 @@ "review" ], "formatNotes": "All three. Point the tool at `application.yml`/`application.properties`, Actuator-related config, and `SecurityFilterChain` / Security config first. Prefer concrete diffs over generic advice.", - "body": "Harden Spring Boot Actuator for the application at the path I provide. Produce a PR-ready lock-down: inventory, severity-ordered findings, and concrete config/security/probe patches.\n\nReview current state and deliver:\n\n1. Inventory\n - Boot version signals (2.x vs 3.x), Actuator dependency presence\n - `management.endpoints.web.exposure.include` / `.exclude`, `base-path`, `management.server.port` / address\n - `management.endpoint.health.show-details` / `show-components`\n - Which endpoints are effectively reachable (health, info, env, heapdump, threaddump, prometheus/metrics, shutdown, custom)\n - Existing Spring Security rules for Actuator (`EndpointRequest`, path matchers, CSRF)\n - Kubernetes/Helm probes and whether management is on a public Service/Ingress\n - Metrics / Prometheus / profiler (e.g. Pyroscope) scrape paths and auth\n\n2. Target design\n - Expose only ops-needed endpoints (typically health + info; metrics/prometheus only with scrape auth)\n - Never leave env / heapdump / threaddump / logfile / shutdown / configprops publicly reachable\n - Prefer a separate management port when the app has a public HTTP surface\n - Health details: `never` anonymously; `when_authorized` only with real operator roles\n - Dedicated management `SecurityFilterChain`; keep CSRF for browser-facing state changes\n - Probes aimed at management health; management not on public Ingress/LoadBalancer\n - Block cloud-metadata leakage via env/info contributors\n\n3. Patches (prefer diffs)\n - `application.yml` / profile-specific properties (Boot 3 exposure keys, base-path, show-details, management port)\n - `SecurityFilterChain` (or XML/adapter equivalent) using `EndpointRequest`\n - Deployment/Service/Ingress or Helm values for probes and port exposure\n - Scrape auth notes (bearer/mTLS) \u2014 names only, no real secrets\n\n4. Output format\n - Severity-ordered findings (blocker / major / minor)\n - Exposure matrix: endpoint \u2192 anonymous / role / disabled\n - Concrete diffs for each blocker/major\n - Validation steps: curl anonymous vs authenticated, in-cluster probe check, negative tests for env/heapdump/shutdown\n - Residual risks and explicit assumptions if manifests or Security config are missing in-repo\n\nConstraints:\n- Do not invent IdP URLs, passwords, or cluster IPs \u2014 use placeholders consistent with repo style.\n- Do not weaken API security to \"fix\" Actuator; do not disable CSRF globally.\n- Keep the diff minimal; no unrelated refactors.\n- Prefer Spring Boot 3 property names when the project is on Boot 3; call out 2.x differences if evidenced.\n\nStart from the files I pointed at (or search for `management.endpoints` and Actuator security). Prefer patches over vague advice." + "body": "Harden Spring Boot Actuator for the application at the path I provide. Produce a PR-ready lock-down: inventory, severity-ordered findings, and concrete config/security/probe patches.\n\nReview current state and deliver:\n\n1. Inventory\n - Boot version signals (2.x vs 3.x), Actuator dependency presence\n - `management.endpoints.web.exposure.include` / `.exclude`, `base-path`, `management.server.port` / address\n - `management.endpoint.health.show-details` / `show-components`\n - Which endpoints are effectively reachable (health, info, env, heapdump, threaddump, prometheus/metrics, shutdown, custom)\n - Existing Spring Security rules for Actuator (`EndpointRequest`, path matchers, CSRF)\n - Kubernetes/Helm probes and whether management is on a public Service/Ingress\n - Metrics / Prometheus / profiler (e.g. Pyroscope) scrape paths and auth\n\n2. Target design\n - Expose only ops-needed endpoints (typically health + info; metrics/prometheus only with scrape auth)\n - Never leave env / heapdump / threaddump / logfile / shutdown / configprops publicly reachable\n - Prefer a separate management port when the app has a public HTTP surface\n - Health details: `never` anonymously; `when_authorized` only with real operator roles\n - Dedicated management `SecurityFilterChain`; keep CSRF for browser-facing state changes\n - Probes aimed at management health; management not on public Ingress/LoadBalancer\n - Block cloud-metadata leakage via env/info contributors\n\n3. Patches (prefer diffs)\n - `application.yml` / profile-specific properties (Boot 3 exposure keys, base-path, show-details, management port)\n - `SecurityFilterChain` (or XML/adapter equivalent) using `EndpointRequest`\n - Deployment/Service/Ingress or Helm values for probes and port exposure\n - Scrape auth notes (bearer/mTLS) — names only, no real secrets\n\n4. Output format\n - Severity-ordered findings (blocker / major / minor)\n - Exposure matrix: endpoint → anonymous / role / disabled\n - Concrete diffs for each blocker/major\n - Validation steps: curl anonymous vs authenticated, in-cluster probe check, negative tests for env/heapdump/shutdown\n - Residual risks and explicit assumptions if manifests or Security config are missing in-repo\n\nConstraints:\n- Do not invent IdP URLs, passwords, or cluster IPs — use placeholders consistent with repo style.\n- Do not weaken API security to \"fix\" Actuator; do not disable CSRF globally.\n- Keep the diff minimal; no unrelated refactors.\n- Prefer Spring Boot 3 property names when the project is on Boot 3; call out 2.x differences if evidenced.\n\nStart from the files I pointed at (or search for `management.endpoints` and Actuator security). Prefer patches over vague advice." }, { "id": "author-safe-flyway-migration", @@ -309,7 +309,7 @@ "database" ], "formatNotes": "All three. Point the tool at `db/migration`, `spring.flyway.*` config, and any migrate Job/CI workflow first. Prefer concrete next-version SQL and checklists over generic DDL advice.", - "body": "Author a safe, PR-ready Flyway migration for the Spring Boot app at the path I provide. Produce the next versioned SQL (and any necessary app-tolerance notes), plus a verification checklist suitable for Copilot / Claude Code / Codex.\n\nContext placeholders (fill from the repo or ask only if missing):\n- Service / module path: {{SERVICE_PATH}}\n- Database engine: {{DB_ENGINE}} (e.g. PostgreSQL, MySQL, SQL Server)\n- Migration location: {{MIGRATION_DIR}} (default `src/main/resources/db/migration`)\n- Change intent: {{CHANGE_INTENT}} (add column, new table, backfill, tighten constraint, rename, drop, index)\n- Zero-downtime required: {{ZERO_DOWNTIME}} (yes/no; default yes on AKS/K8s)\n- Current highest version observed: {{CURRENT_VERSION}}\n\nRequirements:\n\n1. Inventory\n - Existing Flyway/Liquibase dependency and `spring.flyway.*` / `spring.liquibase.*`\n - Migration files present; next version number; naming style (`V__` vs timed versions)\n - Whether migrate runs on startup, as a K8s Job, or in CI\n - Any `out-of-order`, `validate-on-migrate`, `clean-disabled`, placeholder, or callback config\n - Evidence of expand/contract history or risky prior `DROP`/`RENAME` patterns\n\n2. Classify and plan\n - Label the change: expand, backfill, contract, or config-only\n - If rename/drop/cutover: split into ordered steps across releases; do not ship destructive contract with the code cutover in one PR\n - Call out N and N-1 pod compatibility when {{ZERO_DOWNTIME}} is yes\n\n3. Author artifacts (prefer concrete files/diffs)\n - Next `V{{NEXT_VERSION}}__{{short_snake_description}}.sql` \u2014 additive first; nullable expands; explicit indexes; engine-appropriate lock/statement timeout SET when useful\n - Optional `R__*.sql` only if idempotent view/function refresh is required (explain why)\n - Minimal entity/repository notes so app code tolerates expand before contract\n - CI snippet or test note: `flyway validate` / `info` or Boot test with validate-on-migrate + ephemeral DB\n - AKS/K8s ordering note: migrate-before-rollout or equivalent; no public secrets in SQL\n\n4. Verification checklist\n - Fresh migrate + restart succeeds\n - `flyway validate` clean; checksums of old versions unchanged\n - Old app binary still works against expanded schema (if expand)\n - Grep for secrets in SQL; confirm no `clean` enabled for shared envs\n - Residual risks: long locks, large backfills, repair caveats (repair is not rollback)\n\nConstraints:\n- Forward-only: do not edit already-applied versioned migrations; do not invent fake checksums.\n- Secrets never in SQL \u2014 use `{{PLACEHOLDER}}` names only for non-secret identifiers.\n- Do not enable `out-of-order` or `clean` for prod-like profiles unless the repo already has a documented hotfix process (then call it out, do not silently turn on).\n- Do not claim Flyway auto-rollback; prescribe expand/contract instead.\n- Keep the diff minimal; no unrelated refactors.\n- Optimize instructions for GitHub Copilot, Claude Code, and Codex \u2014 concrete paths and checklists over essays.\n\nOutput format:\n1. Short plan (classification + version bump)\n2. File diffs / full new SQL\n3. Config/CI/K8s notes (only what changed)\n4. Verification checklist\n5. Residual risks and follow-up contract PR (if any)\n\nStart from {{MIGRATION_DIR}} and Flyway config under {{SERVICE_PATH}}. Prefer patches over vague advice.\n" + "body": "Author a safe, PR-ready Flyway migration for the Spring Boot app at the path I provide. Produce the next versioned SQL (and any necessary app-tolerance notes), plus a verification checklist suitable for Copilot / Claude Code / Codex.\n\nContext placeholders (fill from the repo or ask only if missing):\n- Service / module path: {{SERVICE_PATH}}\n- Database engine: {{DB_ENGINE}} (e.g. PostgreSQL, MySQL, SQL Server)\n- Migration location: {{MIGRATION_DIR}} (default `src/main/resources/db/migration`)\n- Change intent: {{CHANGE_INTENT}} (add column, new table, backfill, tighten constraint, rename, drop, index)\n- Zero-downtime required: {{ZERO_DOWNTIME}} (yes/no; default yes on AKS/K8s)\n- Current highest version observed: {{CURRENT_VERSION}}\n\nRequirements:\n\n1. Inventory\n - Existing Flyway/Liquibase dependency and `spring.flyway.*` / `spring.liquibase.*`\n - Migration files present; next version number; naming style (`V__` vs timed versions)\n - Whether migrate runs on startup, as a K8s Job, or in CI\n - Any `out-of-order`, `validate-on-migrate`, `clean-disabled`, placeholder, or callback config\n - Evidence of expand/contract history or risky prior `DROP`/`RENAME` patterns\n\n2. Classify and plan\n - Label the change: expand, backfill, contract, or config-only\n - If rename/drop/cutover: split into ordered steps across releases; do not ship destructive contract with the code cutover in one PR\n - Call out N and N-1 pod compatibility when {{ZERO_DOWNTIME}} is yes\n\n3. Author artifacts (prefer concrete files/diffs)\n - Next `V{{NEXT_VERSION}}__{{short_snake_description}}.sql` — additive first; nullable expands; explicit indexes; engine-appropriate lock/statement timeout SET when useful\n - Optional `R__*.sql` only if idempotent view/function refresh is required (explain why)\n - Minimal entity/repository notes so app code tolerates expand before contract\n - CI snippet or test note: `flyway validate` / `info` or Boot test with validate-on-migrate + ephemeral DB\n - AKS/K8s ordering note: migrate-before-rollout or equivalent; no public secrets in SQL\n\n4. Verification checklist\n - Fresh migrate + restart succeeds\n - `flyway validate` clean; checksums of old versions unchanged\n - Old app binary still works against expanded schema (if expand)\n - Grep for secrets in SQL; confirm no `clean` enabled for shared envs\n - Residual risks: long locks, large backfills, repair caveats (repair is not rollback)\n\nConstraints:\n- Forward-only: do not edit already-applied versioned migrations; do not invent fake checksums.\n- Secrets never in SQL — use `{{PLACEHOLDER}}` names only for non-secret identifiers.\n- Do not enable `out-of-order` or `clean` for prod-like profiles unless the repo already has a documented hotfix process (then call it out, do not silently turn on).\n- Do not claim Flyway auto-rollback; prescribe expand/contract instead.\n- Keep the diff minimal; no unrelated refactors.\n- Optimize instructions for GitHub Copilot, Claude Code, and Codex — concrete paths and checklists over essays.\n\nOutput format:\n1. Short plan (classification + version bump)\n2. File diffs / full new SQL\n3. Config/CI/K8s notes (only what changed)\n4. Verification checklist\n5. Residual risks and follow-up contract PR (if any)\n\nStart from {{MIGRATION_DIR}} and Flyway config under {{SERVICE_PATH}}. Prefer patches over vague advice.\n" }, { "id": "add-testcontainers-integration-tests", @@ -328,7 +328,7 @@ "docker" ], "formatNotes": "All three. Point the tool at the service module, existing tests, and build file first. Prefer extending an existing container base over inventing a second lifecycle.", - "body": "Task: Add hermetic Spring Boot integration tests using Testcontainers for the module at the path I provide.\n\nContext placeholders (fill from the repo or ask only if missing):\n- Module / service path: {{MODULE_PATH}}\n- Dependencies to containerize: {{DEPS}} (e.g. Postgres 16, Kafka, Redis, LocalStack S3)\n- Test style in-repo: {{TEST_STYLE}} (JUnit 5, @SpringBootTest, @DataJpaTest, RestAssured/WebTestClient, etc.)\n- Build command: {{TEST_COMMAND}} (e.g. ./mvnw -pl service-x test)\n- Migrations: {{MIGRATIONS}} (Flyway / Liquibase / none)\n\nRequirements:\n\n1. Inventory\n - Existing Testcontainers usage, `@ServiceConnection`, `DynamicPropertySource`, or abstract container bases\n - Spring Boot version signals (3.1+ service connections vs older patterns)\n - Build BOM / testcontainers dependencies already present\n - Whether CI runners already expose Docker\n - Any tests currently pointed at localhost or staging URLs\n\n2. Design\n - Prefer the narrowest slice that still hits the real adapter (`@DataJpaTest` vs full `@SpringBootTest`)\n - One shared container lifecycle per suite (static singleton or Spring-managed); do not start a new DB per method unless isolation is under test\n - Pin image tags (no `latest`); wire JDBC/broker settings from the container\n - Run migrations in the test context when {{MIGRATIONS}} is Flyway/Liquibase\n - Keep mocks only at true external boundaries not being validated\n\n3. Author artifacts (prefer concrete diffs)\n - Test dependency tweaks if the BOM does not already manage Testcontainers\n - Shared container helper or `@TestConfiguration`\n - 2\u20133 tests: happy path, one validation/constraint failure, one not-found or duplicate-key mapping\n - `application-test` overrides only when service connection cannot cover a property\n - CI note: Docker requirement; fail fast if unavailable\n\n4. Verification\n - Run {{TEST_COMMAND}} and show results\n - Confirm containers stop cleanly (no orphaned Postgres on the daemon)\n - Grep test resources for staging hosts, real secrets, and unpinned `latest` images\n\nConstraints:\n- Do not invent registry mirrors, company image prefixes, or cloud account IDs \u2014 use placeholders if the repo does not define them.\n- Do not disable Flyway/Liquibase in tests when production relies on it.\n- Do not replace an existing shared container base with a duplicate lifecycle.\n- Keep the diff minimal; no unrelated refactors.\n- Optimize for GitHub Copilot, Claude Code, and Codex \u2014 concrete paths and commands over essays.\n\nOutput format:\n1. Short plan (slice + images + lifecycle)\n2. File diffs\n3. Commands run + outcomes\n4. What remains mocked (and why)\n5. Residual risks (CI Docker, parallel suites, image pull time)\n\nStart from {{MODULE_PATH}} and existing `src/test`. Prefer patches over vague advice.\n" + "body": "Task: Add hermetic Spring Boot integration tests using Testcontainers for the module at the path I provide.\n\nContext placeholders (fill from the repo or ask only if missing):\n- Module / service path: {{MODULE_PATH}}\n- Dependencies to containerize: {{DEPS}} (e.g. Postgres 16, Kafka, Redis, LocalStack S3)\n- Test style in-repo: {{TEST_STYLE}} (JUnit 5, @SpringBootTest, @DataJpaTest, RestAssured/WebTestClient, etc.)\n- Build command: {{TEST_COMMAND}} (e.g. ./mvnw -pl service-x test)\n- Migrations: {{MIGRATIONS}} (Flyway / Liquibase / none)\n\nRequirements:\n\n1. Inventory\n - Existing Testcontainers usage, `@ServiceConnection`, `DynamicPropertySource`, or abstract container bases\n - Spring Boot version signals (3.1+ service connections vs older patterns)\n - Build BOM / testcontainers dependencies already present\n - Whether CI runners already expose Docker\n - Any tests currently pointed at localhost or staging URLs\n\n2. Design\n - Prefer the narrowest slice that still hits the real adapter (`@DataJpaTest` vs full `@SpringBootTest`)\n - One shared container lifecycle per suite (static singleton or Spring-managed); do not start a new DB per method unless isolation is under test\n - Pin image tags (no `latest`); wire JDBC/broker settings from the container\n - Run migrations in the test context when {{MIGRATIONS}} is Flyway/Liquibase\n - Keep mocks only at true external boundaries not being validated\n\n3. Author artifacts (prefer concrete diffs)\n - Test dependency tweaks if the BOM does not already manage Testcontainers\n - Shared container helper or `@TestConfiguration`\n - 2–3 tests: happy path, one validation/constraint failure, one not-found or duplicate-key mapping\n - `application-test` overrides only when service connection cannot cover a property\n - CI note: Docker requirement; fail fast if unavailable\n\n4. Verification\n - Run {{TEST_COMMAND}} and show results\n - Confirm containers stop cleanly (no orphaned Postgres on the daemon)\n - Grep test resources for staging hosts, real secrets, and unpinned `latest` images\n\nConstraints:\n- Do not invent registry mirrors, company image prefixes, or cloud account IDs — use placeholders if the repo does not define them.\n- Do not disable Flyway/Liquibase in tests when production relies on it.\n- Do not replace an existing shared container base with a duplicate lifecycle.\n- Keep the diff minimal; no unrelated refactors.\n- Optimize for GitHub Copilot, Claude Code, and Codex — concrete paths and commands over essays.\n\nOutput format:\n1. Short plan (slice + images + lifecycle)\n2. File diffs\n3. Commands run + outcomes\n4. What remains mocked (and why)\n5. Residual risks (CI Docker, parallel suites, image pull time)\n\nStart from {{MODULE_PATH}} and existing `src/test`. Prefer patches over vague advice.\n" }, { "id": "harden-spring-oauth2-resource-server", @@ -348,7 +348,7 @@ "security" ], "formatNotes": "All three. Point the tool at the security config package, application*.yml, and existing auth tests first. Prefer patching the existing SecurityFilterChain over adding a second permissive chain.", - "body": "Task: Harden the Spring Boot OAuth2 resource-server configuration for the module at the path I provide.\n\nContext placeholders (fill from the repo or ask only if missing):\n- Module / service path: {{MODULE_PATH}}\n- IdP issuer URL: {{ISSUER_URI}}\n- Expected audience / API identifier: {{AUDIENCE}}\n- Token type: {{TOKEN_TYPE}} (jwt | opaque)\n- Authority source: {{AUTHORITY_CLAIM}} (e.g. scope \u2192 SCOPE_, roles claim path, Keycloak realm_access)\n- Build / test command: {{TEST_COMMAND}} (e.g. ./mvnw -pl service-api test)\n- Mixed browser+API app?: {{MIXED_CLIENTS}} (yes | no)\n\nRequirements:\n\n1. Inventory\n - Existing `SecurityFilterChain`, `oauth2ResourceServer`, `JwtDecoder`, converters\n - `spring.security.oauth2.resourceserver.*` properties per profile\n - CSRF, session creation policy, CORS, actuator exposure\n - Current tests (`@WithMockUser`, `jwt()` post-processor, mock `JwtDecoder`)\n - Any `permitAll`, disabled security, or multi-issuer hacks\n\n2. Design\n - Prefer `issuer-uri` for {{TOKEN_TYPE}}=jwt; if only JWKS is possible, add issuer + audience validators\n - Enforce {{AUDIENCE}}; reject wrong-`aud` tokens\n - Map {{AUTHORITY_CLAIM}} via `JwtAuthenticationConverter` when non-default\n - If {{MIXED_CLIENTS}}=yes, split filter chains (cookie/CSRF vs stateless bearer); if no, STATELESS + CSRF off with a one-line rationale\n - Keep actuators authenticated or on a separate management port \u2014 not anonymous on the public API port\n - Opaque tokens: introspection config only; do not parse as JWT\n\n3. Author artifacts (prefer concrete diffs)\n - Security config + property updates for {{ISSUER_URI}} / validators\n - Converter + route/`@PreAuthorize` alignment (minimal path set)\n - Tests: valid scoped call; 401 expired/wrong iss/aud; 403 missing scope\n - Do not add IdP client secrets to git; use env/Key Vault placeholders already in-repo\n\n4. Verification\n - Run {{TEST_COMMAND}} and show results\n - Grep for `permitAll`, `csrf.disable`, `security.enable=false`, hard-coded PEMs, and logged `Authorization` headers\n - Confirm prod profile still requires JWT validation\n\nConstraints:\n- Do not invent tenant IDs, real client secrets, or JWKS PEMs \u2014 use placeholders if missing.\n- Do not disable security under prod (or default) profiles.\n- Do not replace an existing well-structured filter chain with a permissive catch-all.\n- Keep the diff minimal; no unrelated refactors or dependency upgrades unless required for resource-server.\n- Optimize for GitHub Copilot, Claude Code, and Codex \u2014 concrete paths and commands over essays.\n\nOutput format:\n1. Short plan (decoder, audience, authority map, CSRF/session choice)\n2. File diffs\n3. Commands run + outcomes\n4. Remaining `permitAll` / anonymous paths (and why)\n5. Residual risks (multi-tenant issuers, opaque revocation, actuator network exposure)\n\nStart from {{MODULE_PATH}} security config and `application*.yml`. Prefer patches over vague advice.\n" + "body": "Task: Harden the Spring Boot OAuth2 resource-server configuration for the module at the path I provide.\n\nContext placeholders (fill from the repo or ask only if missing):\n- Module / service path: {{MODULE_PATH}}\n- IdP issuer URL: {{ISSUER_URI}}\n- Expected audience / API identifier: {{AUDIENCE}}\n- Token type: {{TOKEN_TYPE}} (jwt | opaque)\n- Authority source: {{AUTHORITY_CLAIM}} (e.g. scope → SCOPE_, roles claim path, Keycloak realm_access)\n- Build / test command: {{TEST_COMMAND}} (e.g. ./mvnw -pl service-api test)\n- Mixed browser+API app?: {{MIXED_CLIENTS}} (yes | no)\n\nRequirements:\n\n1. Inventory\n - Existing `SecurityFilterChain`, `oauth2ResourceServer`, `JwtDecoder`, converters\n - `spring.security.oauth2.resourceserver.*` properties per profile\n - CSRF, session creation policy, CORS, actuator exposure\n - Current tests (`@WithMockUser`, `jwt()` post-processor, mock `JwtDecoder`)\n - Any `permitAll`, disabled security, or multi-issuer hacks\n\n2. Design\n - Prefer `issuer-uri` for {{TOKEN_TYPE}}=jwt; if only JWKS is possible, add issuer + audience validators\n - Enforce {{AUDIENCE}}; reject wrong-`aud` tokens\n - Map {{AUTHORITY_CLAIM}} via `JwtAuthenticationConverter` when non-default\n - If {{MIXED_CLIENTS}}=yes, split filter chains (cookie/CSRF vs stateless bearer); if no, STATELESS + CSRF off with a one-line rationale\n - Keep actuators authenticated or on a separate management port — not anonymous on the public API port\n - Opaque tokens: introspection config only; do not parse as JWT\n\n3. Author artifacts (prefer concrete diffs)\n - Security config + property updates for {{ISSUER_URI}} / validators\n - Converter + route/`@PreAuthorize` alignment (minimal path set)\n - Tests: valid scoped call; 401 expired/wrong iss/aud; 403 missing scope\n - Do not add IdP client secrets to git; use env/Key Vault placeholders already in-repo\n\n4. Verification\n - Run {{TEST_COMMAND}} and show results\n - Grep for `permitAll`, `csrf.disable`, `security.enable=false`, hard-coded PEMs, and logged `Authorization` headers\n - Confirm prod profile still requires JWT validation\n\nConstraints:\n- Do not invent tenant IDs, real client secrets, or JWKS PEMs — use placeholders if missing.\n- Do not disable security under prod (or default) profiles.\n- Do not replace an existing well-structured filter chain with a permissive catch-all.\n- Keep the diff minimal; no unrelated refactors or dependency upgrades unless required for resource-server.\n- Optimize for GitHub Copilot, Claude Code, and Codex — concrete paths and commands over essays.\n\nOutput format:\n1. Short plan (decoder, audience, authority map, CSRF/session choice)\n2. File diffs\n3. Commands run + outcomes\n4. Remaining `permitAll` / anonymous paths (and why)\n5. Residual risks (multi-tenant issuers, opaque revocation, actuator network exposure)\n\nStart from {{MODULE_PATH}} security config and `application*.yml`. Prefer patches over vague advice.\n" }, { "id": "wire-gha-oidc-azure-login", @@ -369,12 +369,12 @@ "migration" ], "formatNotes": "All three. Point the tool at `.github/workflows` and any existing `azure/login` or `AZURE_CLIENT_SECRET` usage first. Prefer replacing secret-based login over adding a parallel OIDC path. Copilot: apply instructions to workflow YAML. Claude Code: skill + workflow edits. Codex: AGENTS.md CI/OIDC section plus concrete workflow diff.", - "body": "Task: Wire GitHub Actions OIDC login to Azure (Microsoft Entra federated identity credentials) for the repository and environment I specify. Replace client-secret login where present.\n\nContext placeholders (fill from the repo or ask only if missing):\n- Repository: {{REPO}} (org/name)\n- Entra application (client) ID: {{AZURE_CLIENT_ID}}\n- Tenant ID: {{AZURE_TENANT_ID}}\n- Subscription ID: {{AZURE_SUBSCRIPTION_ID}}\n- Target GitHub Environment (if used): {{TARGET_ENV}} (e.g. production, staging \u2014 or \"none\")\n- Azure RBAC roles needed by the pipeline: {{AZURE_ROLES}} (e.g. AcrPush on registry X, Contributor on RG Y)\n- Workflow file to change or create: {{WORKFLOW_PATH}}\n- FIC subject strategy: {{SUBJECT_STRATEGY}} (ref | environment | workflow_ref)\n- Use immutable GitHub OIDC subject (2026 guidance): {{IMMUTABLE_SUB}} (yes | no)\n\nRequirements:\n\n1. Inventory\n - Workflows for `azure/login`, `AZURE_CLIENT_SECRET`, or secret-based `az login`\n - `permissions:` defaults; `pull_request` / fork exposure\n - GitHub Environments and protection rules for {{TARGET_ENV}}\n - Existing Entra FIC (issuer, audience, subject)\n\n2. Design\n - OIDC `azure/login` with {{AZURE_CLIENT_ID}}, {{AZURE_TENANT_ID}}, {{AZURE_SUBSCRIPTION_ID}} (vars/secrets names only in output)\n - Job-level `permissions: id-token: write` on the Azure job only\n - FIC subject for {{SUBJECT_STRATEGY}} (ref / environment:{{TARGET_ENV}} / workflow_ref on {{WORKFLOW_PATH}})\n - If {{IMMUTABLE_SUB}}=yes: dual-FIC migration (add immutable, validate, remove name-based); note Flexible FIC / repository_id checks if available\n - Audience `api://AzureADTokenExchange` unless repo documents custom aud end-to-end\n - RBAC: {{AZURE_ROLES}} at minimal scope; no subscription Owner for CI\n - Deny fork `pull_request` paths from OIDC + {{TARGET_ENV}} deploy\n\n3. Author artifacts (prefer concrete diffs)\n - Workflow at {{WORKFLOW_PATH}}: pinned `azure/login`, permissions, triggers\n - PR notes: FIC fields (issuer, audience, exact subject string) \u2014 no secret values\n - RBAC bullets: role + scope; remove secret login \u2014 no parallel OIDC + secret paths\n\n4. Verification\n - Subject match checklist (GitHub `sub` vs Entra FIC)\n - Dry reasoning: allowed ref/env succeeds; wrong branch/env fails\n - Fork PR cannot get `id-token: write` with cloud deploy\n - Grep: no `AZURE_CLIENT_SECRET`, no token echo, pinned SHAs\n\nConstraints:\n- Do not invent IDs or client secrets \u2014 placeholders if missing.\n- No broad FIC subjects (`repo:ORG/REPO:*`).\n- Minimal diff; no unrelated workflow refactors.\n- Optimize for GitHub Copilot, Claude Code, and Codex \u2014 concrete YAML and checklists.\n\nOutput format:\n1. Plan (subject, permissions, RBAC)\n2. Workflow diff for {{WORKFLOW_PATH}}\n3. Entra FIC + RBAC setup notes\n4. Verification checklist + fork PR denial\n5. Residual risks (immutable sub window, shared identity)\n\nStart from `.github/workflows` and {{WORKFLOW_PATH}}. Prefer replacing secret login over a second login path.\n" + "body": "Task: Wire GitHub Actions OIDC login to Azure (Microsoft Entra federated identity credentials) for the repository and environment I specify. Replace client-secret login where present.\n\nContext placeholders (fill from the repo or ask only if missing):\n- Repository: {{REPO}} (org/name)\n- Entra application (client) ID: {{AZURE_CLIENT_ID}}\n- Tenant ID: {{AZURE_TENANT_ID}}\n- Subscription ID: {{AZURE_SUBSCRIPTION_ID}}\n- Target GitHub Environment (if used): {{TARGET_ENV}} (e.g. production, staging — or \"none\")\n- Azure RBAC roles needed by the pipeline: {{AZURE_ROLES}} (e.g. AcrPush on registry X, Contributor on RG Y)\n- Workflow file to change or create: {{WORKFLOW_PATH}}\n- FIC subject strategy: {{SUBJECT_STRATEGY}} (ref | environment | workflow_ref)\n- Use immutable GitHub OIDC subject (2026 guidance): {{IMMUTABLE_SUB}} (yes | no)\n\nRequirements:\n\n1. Inventory\n - Workflows for `azure/login`, `AZURE_CLIENT_SECRET`, or secret-based `az login`\n - `permissions:` defaults; `pull_request` / fork exposure\n - GitHub Environments and protection rules for {{TARGET_ENV}}\n - Existing Entra FIC (issuer, audience, subject)\n\n2. Design\n - OIDC `azure/login` with {{AZURE_CLIENT_ID}}, {{AZURE_TENANT_ID}}, {{AZURE_SUBSCRIPTION_ID}} (vars/secrets names only in output)\n - Job-level `permissions: id-token: write` on the Azure job only\n - FIC subject for {{SUBJECT_STRATEGY}} (ref / environment:{{TARGET_ENV}} / workflow_ref on {{WORKFLOW_PATH}})\n - If {{IMMUTABLE_SUB}}=yes: dual-FIC migration (add immutable, validate, remove name-based); note Flexible FIC / repository_id checks if available\n - Audience `api://AzureADTokenExchange` unless repo documents custom aud end-to-end\n - RBAC: {{AZURE_ROLES}} at minimal scope; no subscription Owner for CI\n - Deny fork `pull_request` paths from OIDC + {{TARGET_ENV}} deploy\n\n3. Author artifacts (prefer concrete diffs)\n - Workflow at {{WORKFLOW_PATH}}: pinned `azure/login`, permissions, triggers\n - PR notes: FIC fields (issuer, audience, exact subject string) — no secret values\n - RBAC bullets: role + scope; remove secret login — no parallel OIDC + secret paths\n\n4. Verification\n - Subject match checklist (GitHub `sub` vs Entra FIC)\n - Dry reasoning: allowed ref/env succeeds; wrong branch/env fails\n - Fork PR cannot get `id-token: write` with cloud deploy\n - Grep: no `AZURE_CLIENT_SECRET`, no token echo, pinned SHAs\n\nConstraints:\n- Do not invent IDs or client secrets — placeholders if missing.\n- No broad FIC subjects (`repo:ORG/REPO:*`).\n- Minimal diff; no unrelated workflow refactors.\n- Optimize for GitHub Copilot, Claude Code, and Codex — concrete YAML and checklists.\n\nOutput format:\n1. Plan (subject, permissions, RBAC)\n2. Workflow diff for {{WORKFLOW_PATH}}\n3. Entra FIC + RBAC setup notes\n4. Verification checklist + fork PR denial\n5. Residual risks (immutable sub window, shared identity)\n\nStart from `.github/workflows` and {{WORKFLOW_PATH}}. Prefer replacing secret login over a second login path.\n" }, { "id": "review-spring-data-jpa-queries", "title": "Review These Spring Data JPA Queries", - "whenToUse": "You need a PR-ready review or refactor of Spring Data JPA repositories, entity fetch plans, and service-layer query usage \u2014 N+1, pagination, projections, @Query safety, and index notes.", + "whenToUse": "You need a PR-ready review or refactor of Spring Data JPA repositories, entity fetch plans, and service-layer query usage — N+1, pagination, projections, @Query safety, and index notes.", "tools": [ "copilot", "claude-code", @@ -390,7 +390,7 @@ "review" ], "formatNotes": "All three. Point the tool at the repository package, entity package, and the service/controller call sites first. Prefer fixing fetch plans and projections over enabling open-in-view. Copilot: apply path-scoped instructions for `**/*Repository.java` and entity packages.", - "body": "Task: Review and harden Spring Data JPA queries and fetch plans for the feature I specify. Eliminate N+1 and pagination traps; prefer DTO projections on read paths; keep @Query parameterized and transactional boundaries clear.\n\nContext placeholders (fill from the repo or ask only if missing):\n- Module / package root: {{PACKAGE_ROOT}} (e.g. com.example.orders)\n- Primary entities: {{ENTITIES}} (comma-separated)\n- Hot endpoints or use cases: {{USE_CASES}} (e.g. list orders, order detail, admin search)\n- Pagination style required: {{PAGINATION}} (Page | Slice | keyset | none)\n- Max page size: {{MAX_PAGE_SIZE}}\n- Open-in-view policy: {{OPEN_IN_VIEW}} (off | on-legacy | unknown)\n- Soft-delete in play: {{SOFT_DELETE}} (yes | no | unknown)\n- DB dialect: {{DB_DIALECT}} (PostgreSQL | MySQL | SQL Server | other)\n- Query-budget test harness available: {{QUERY_BUDGET}} (datasource-proxy | Hibernate statistics | none)\n\nRequirements:\n\n1. Inventory\n - Repositories under {{PACKAGE_ROOT}} touching {{ENTITIES}}\n - FetchType on associations; existing `@EntityGraph`, `JOIN FETCH`, `@BatchSize`\n - Call sites for {{USE_CASES}} (controller \u2192 service \u2192 repository)\n - Any `Pageable` + collection fetch combinations; `findAll` without bounds\n - Native/`@Query` strings; modifying queries; soft-delete filters if {{SOFT_DELETE}}=yes\n\n2. Design\n - Per {{USE_CASES}}: projection vs entity graph vs fetch join vs batch fetch\n - If {{PAGINATION}} needs collections: two-step ID page then fetch-by-ids (never collection JOIN FETCH + Pageable)\n - Cap page size at {{MAX_PAGE_SIZE}}; whitelist sort properties\n - Respect {{OPEN_IN_VIEW}}: if off/unknown, fetch or project inside `@Transactional(readOnly = true)`\n - Index notes for new WHERE/ORDER BY under {{DB_DIALECT}}\n - If {{QUERY_BUDGET}} \u2260 none: add or outline a statement-count assertion for the hottest list path\n\n3. Author artifacts (prefer concrete diffs)\n - Repository method changes (`@EntityGraph`, `@Query`, projections)\n - Service transaction + DTO mapping adjustments\n - Optional Flyway/Liquibase index stub only if filters changed (do not invent unrelated schema)\n - Test sketches: result correctness + query budget when {{QUERY_BUDGET}} allows\n\n4. Verification\n - Explain why N+1 is gone for {{USE_CASES}}\n - Confirm no HHH90003004-style in-memory pagination\n - Grep: no entity returns on public API for list paths; no string-concat query parameters\n - Soft-delete + uniqueness notes if {{SOFT_DELETE}}=yes\n\nConstraints:\n- Do not invent schema or indexes unrelated to {{USE_CASES}}.\n- Minimal diff; match existing repository style (derived vs `@Query`).\n- No enabling open-in-view as a \u201cfix\u201d for LazyInitializationException.\n- Optimize for GitHub Copilot, Claude Code, and Codex \u2014 concrete Java and checklists.\n\nOutput format:\n1. Plan (fetch strategy per use case)\n2. Code diffs (repository/service/DTO)\n3. Index / migration notes (if any)\n4. Verification checklist + query-budget evidence\n5. Residual risks (cartesian joins, soft-delete, count query cost)\n\nStart from repositories and entities under {{PACKAGE_ROOT}}. Prefer projections and explicit fetch plans over EAGER mappings or open-in-view.\n" + "body": "Task: Review and harden Spring Data JPA queries and fetch plans for the feature I specify. Eliminate N+1 and pagination traps; prefer DTO projections on read paths; keep @Query parameterized and transactional boundaries clear.\n\nContext placeholders (fill from the repo or ask only if missing):\n- Module / package root: {{PACKAGE_ROOT}} (e.g. com.example.orders)\n- Primary entities: {{ENTITIES}} (comma-separated)\n- Hot endpoints or use cases: {{USE_CASES}} (e.g. list orders, order detail, admin search)\n- Pagination style required: {{PAGINATION}} (Page | Slice | keyset | none)\n- Max page size: {{MAX_PAGE_SIZE}}\n- Open-in-view policy: {{OPEN_IN_VIEW}} (off | on-legacy | unknown)\n- Soft-delete in play: {{SOFT_DELETE}} (yes | no | unknown)\n- DB dialect: {{DB_DIALECT}} (PostgreSQL | MySQL | SQL Server | other)\n- Query-budget test harness available: {{QUERY_BUDGET}} (datasource-proxy | Hibernate statistics | none)\n\nRequirements:\n\n1. Inventory\n - Repositories under {{PACKAGE_ROOT}} touching {{ENTITIES}}\n - FetchType on associations; existing `@EntityGraph`, `JOIN FETCH`, `@BatchSize`\n - Call sites for {{USE_CASES}} (controller → service → repository)\n - Any `Pageable` + collection fetch combinations; `findAll` without bounds\n - Native/`@Query` strings; modifying queries; soft-delete filters if {{SOFT_DELETE}}=yes\n\n2. Design\n - Per {{USE_CASES}}: projection vs entity graph vs fetch join vs batch fetch\n - If {{PAGINATION}} needs collections: two-step ID page then fetch-by-ids (never collection JOIN FETCH + Pageable)\n - Cap page size at {{MAX_PAGE_SIZE}}; whitelist sort properties\n - Respect {{OPEN_IN_VIEW}}: if off/unknown, fetch or project inside `@Transactional(readOnly = true)`\n - Index notes for new WHERE/ORDER BY under {{DB_DIALECT}}\n - If {{QUERY_BUDGET}} ≠ none: add or outline a statement-count assertion for the hottest list path\n\n3. Author artifacts (prefer concrete diffs)\n - Repository method changes (`@EntityGraph`, `@Query`, projections)\n - Service transaction + DTO mapping adjustments\n - Optional Flyway/Liquibase index stub only if filters changed (do not invent unrelated schema)\n - Test sketches: result correctness + query budget when {{QUERY_BUDGET}} allows\n\n4. Verification\n - Explain why N+1 is gone for {{USE_CASES}}\n - Confirm no HHH90003004-style in-memory pagination\n - Grep: no entity returns on public API for list paths; no string-concat query parameters\n - Soft-delete + uniqueness notes if {{SOFT_DELETE}}=yes\n\nConstraints:\n- Do not invent schema or indexes unrelated to {{USE_CASES}}.\n- Minimal diff; match existing repository style (derived vs `@Query`).\n- No enabling open-in-view as a “fix” for LazyInitializationException.\n- Optimize for GitHub Copilot, Claude Code, and Codex — concrete Java and checklists.\n\nOutput format:\n1. Plan (fetch strategy per use case)\n2. Code diffs (repository/service/DTO)\n3. Index / migration notes (if any)\n4. Verification checklist + query-budget evidence\n5. Residual risks (cartesian joins, soft-delete, count query cost)\n\nStart from repositories and entities under {{PACKAGE_ROOT}}. Prefer projections and explicit fetch plans over EAGER mappings or open-in-view.\n" }, { "id": "wire-spring-cache-redis", @@ -411,6 +411,26 @@ ], "formatNotes": "All three. Point the tool at the cache configuration package and the service methods to annotate. Prefer RedisCacheManagerBuilderCustomizer over an ad-hoc CacheManager bean that disables Boot's spring.cache.redis.* properties. Copilot: apply path-scoped instructions to cache config and @Cache* call sites. Claude Code: skill plus the config class. Codex: AGENTS.md cache section or docs/agents/spring-boot-cache-redis.md, then the diff.", "body": "Task: Wire or harden Spring Cache backed by Redis for the module I specify. Produce a small diff: explicit Redis cache type, per-cache TTLs, a safe serializer, namespaced keys, targeted eviction, and tests that match the repo.\n\nContext placeholders (fill from the repo or ask only if missing):\n- Module / package: {{MODULE}}\n- Cache names: {{CACHE_NAMES}}\n- TTL per cache name: {{TTLS}} (for example catalog=10m, productById=5m)\n- Serializer: {{SERIALIZER}} (jackson-per-type | generic-jackson-allowlist | keep-existing)\n- Redis target: {{REDIS_TARGET}} (local | Azure Cache for Redis)\n- Fail mode: {{FAIL_MODE}} (fail-open | fail-closed)\n- Test style: {{TEST_STYLE}} (unit-noop | testcontainers | both)\n\nRequirements:\n\n1. Inventory\n - Starters present (`spring-boot-starter-cache`, `spring-boot-starter-data-redis`) and `spring.cache.type`\n - Where `@EnableCaching` lives (application class vs isolated `@Configuration`)\n - Existing `CacheManager`, `RedisCacheConfiguration`, or `RedisCacheManagerBuilderCustomizer` beans\n - `spring.cache.redis.*` and `spring.data.redis.*` (TTL, nulls, prefix, timeout, SSL, pool)\n - `@Cacheable` / `@CacheEvict` / `@CachePut` in {{MODULE}}: keys, `allEntries`, `unless`, `condition`, `sync`\n - How tests get a cache today (sliced context, embedded, shared host, none)\n - If {{REDIS_TARGET}} is Azure Cache for Redis: TLS, auth style already in repo (access key vs Entra), private endpoint or firewall notes. Do not read secret values.\n\n2. Design\n - `spring.cache.type=redis`. Move `@EnableCaching` onto an isolated `@Configuration` if it sits on the application class.\n - Global TTL floor plus per-cache TTL from {{TTLS}} via `RedisCacheManagerBuilderCustomizer`, derived from Boot's `RedisCacheConfiguration`. Do not add a `CacheManager` bean that drops Boot properties.\n - {{SERIALIZER}}: typed Jackson per cache when each name has one value class; generic Jackson only with an allowlisted polymorphic validator. String key serializer. Keep JDK serialization only when {{SERIALIZER}}=keep-existing, and say so.\n - Key prefix: application, environment, schema version. `use-key-prefix` stays true. SpEL keys stable and identical on read and evict. No secrets or PII in keys or values.\n - Evict with the same key. No `allEntries=true` unless the keyspace is tiny and the PR says why. Otherwise version the prefix or a SCAN-based writer.\n - Null policy: `unless` / `condition` or a short null TTL. Disabling null caching requires `unless` so ordinary null returns do not throw.\n - {{FAIL_MODE}}: fail-closed keeps the default error handler (Redis errors fail the call). Fail-open swallows cache-get errors only, logs them, and still runs the method. Do not swallow evict errors for data that must not stay stale.\n - {{REDIS_TARGET}}=Azure Cache for Redis: TLS on, password or Entra token from env / existing Key Vault reference, no public-network shortcut. {{REDIS_TARGET}}=local: localhost or Testcontainers only.\n\n3. Author config, annotations, and tests\n - Property and `RedisCacheManagerBuilderCustomizer` changes for {{CACHE_NAMES}}\n - Annotations on the service methods that own {{CACHE_NAMES}}, matching existing style\n - {{TEST_STYLE}}=unit-noop: `@AutoConfigureCache` or `spring.cache.type=none` on slices; no Redis socket\n - {{TEST_STYLE}}=testcontainers or both: pinned Redis image, hit, miss, and evict for the hottest cache\n - No new dependency unless the module cannot compile without it\n\n4. Verification checklist\n - [ ] `spring.cache.type=redis`; `@EnableCaching` not on the application class\n - [ ] Each name in {{CACHE_NAMES}} has the TTL from {{TTLS}}\n - [ ] Boot `spring.cache.redis.*` still apply (customizer, not a replacement manager)\n - [ ] Serializer matches {{SERIALIZER}}; prefix is namespaced; keys match on read and evict\n - [ ] No `allEntries=true` on a large keyspace; null policy cannot throw on a normal null\n - [ ] {{FAIL_MODE}} is implemented in `CacheErrorHandler` or explicitly left at the default\n - [ ] Tests match {{TEST_STYLE}} and do not point at Azure or a shared server\n - [ ] Diff contains no access keys, connection strings, or invented secret names\n - [ ] Run the module's existing test command and show the result\n\nConstraints:\n- Minimal diff. Match project style (annotations, property files, test base classes).\n- No secrets in the repo. Use placeholders or the app's existing secret mechanism.\n- Do not enable `spring.jpa.open-in-view` or any unrelated feature (security, actuator exposure, schema changes).\n- Do not call `FLUSHDB` / `FLUSHALL`. Do not disable key prefixes.\n- Optimize for GitHub Copilot, Claude Code, and Codex: concrete paths and checklists.\n\nOutput format:\n1. Plan (TTL map, serializer, prefix, fail mode, eviction)\n2. Diff (config, annotations, tests)\n3. Verification checklist with what you actually ran\n4. Residual risks (stampede across pods, transaction-aware gap, Azure memory policy)\n\nStart from {{MODULE}}. Prefer `RedisCacheManagerBuilderCustomizer` over a hand-built `CacheManager`.\n" + }, + { + "id": "tune-maven-multimodule-ci-cache", + "title": "Tune Maven Multi-Module CI Cache", + "whenToUse": "Add or harden GitHub Actions dependency caching and reactor flags for a Maven multi-module Java build.", + "tools": [ + "copilot", + "claude-code", + "codex" + ], + "tags": [ + "java", + "maven", + "github-actions", + "ci", + "performance", + "multi-module" + ], + "formatNotes": "All three. Point the tool at the root pom, module list, and the workflow that runs Maven. Prefer setup-java cache: maven over a custom actions/cache unless the repo already standardized on one. Copilot: path-scoped instructions for pom.xml and workflows. Claude Code: skill plus the workflow file. Codex: AGENTS.md Maven CI section, then the diff.", + "body": "Task: Tune or add Maven dependency caching and multi-module CI flags for the workflow I specify. Produce a small diff: correct cache paths/keys, wrapper usage, reactor command, and a short verification note.\n\nContext placeholders (fill from the repo or ask only if missing):\n- Workflow path: {{WORKFLOW}}\n- Reactor root: {{REACTOR_ROOT}} (directory with the top-level pom.xml)\n- Modules of interest: {{MODULES}} (all | comma-separated artifactIds)\n- Cache style: {{CACHE_STYLE}} (setup-java | actions-cache | keep-existing)\n- Parallelism: {{PARALLEL}} (off | 1C | N threads)\n- Selective build: {{SELECTIVE}} (full-reactor | pl-am | pl-am-amd)\n- JDK version already in workflow: {{JDK}}\n\nRequirements:\n\n1. Inventory\n - Existing `actions/setup-java` / `actions/cache` steps and their paths, keys, restore-keys\n - Whether `./mvnw` exists and which Maven version the wrapper pins\n - Root packaging (`pom`) and module list under {{REACTOR_ROOT}}\n - Current Maven goals/flags (`verify`, `test`, `-DskipTests`, profiles)\n - Any committed or generated `settings.xml` / server credentials (names only — do not print secret values)\n - Prior CI duration clues in workflow comments or README, if any\n\n2. Design\n - {{CACHE_STYLE}}=setup-java: set `cache: maven` (and distribution/temurin or whatever the workflow already uses) with {{JDK}}. Do not add a second overlapping m2 cache unless keep-existing requires it.\n - {{CACHE_STYLE}}=actions-cache: `path: ~/.m2/repository`, key includes `runner.os` + hash of all relevant `pom.xml` (+ wrapper props). restore-keys prefix by OS only.\n - Never cache `**/target`. Remove such paths if present.\n - Invoke the wrapper from {{REACTOR_ROOT}} with `-B` and `-ntp`.\n - {{SELECTIVE}}=full-reactor: `./mvnw -B -ntp verify` (or the repo's standard lifecycle).\n - {{SELECTIVE}}=pl-am or pl-am-amd: document how {{MODULES}} are chosen; include `-am` / `-amd` as specified so the reactor resolves parents and dependents.\n - {{PARALLEL}}: add `-T 1C` or `-T N` only when safe; otherwise leave serial and say why.\n\n3. Author the workflow (and tiny docs) diff\n - Update {{WORKFLOW}} only as needed for cache + Maven command\n - If AGENTS.md / copilot-instructions already mention CI, add one line about m2 cache vs target — no new markdown files unless the repo already keeps agent docs\n - No new dependencies in poms unless the build cannot run without a fix you found (prefer workflow-only changes)\n\n4. Verification checklist\n - [ ] Cache path is `~/.m2/repository` (or setup-java maven cache) only\n - [ ] Key inputs include every pom that affects the reactor classpath\n - [ ] No `target/` in cache paths\n - [ ] Wrapper + `-B` (+ `-ntp`) used\n - [ ] {{SELECTIVE}} and {{PARALLEL}} match the workflow command\n - [ ] No secrets or mirror passwords introduced\n - [ ] Summarize expected HIT/MISS behavior after a leaf pom dependency bump\n\nConstraints:\n- Minimal diff. Match existing workflow style (action majors, concurrency, permissions).\n- Do not weaken `permissions:` or add `pull_request_target`.\n- Do not skip tests on the primary verify job unless the workflow already splits compile/test and you only touch the compile job's cache warm-up.\n- Optimize for GitHub Copilot, Claude Code, and Codex: concrete paths and checklists.\n\nOutput format:\n1. Plan (cache style, key inputs, reactor command)\n2. Diff (workflow, optional one-line agent doc)\n3. Verification checklist with what you would run\n4. Residual risks (snapshot churn, unsafe `-T`, selective-build gaps)\n\nStart from {{WORKFLOW}} and {{REACTOR_ROOT}}. Prefer `setup-java` `cache: maven` when {{CACHE_STYLE}} allows it.\n" } ] } diff --git a/skillbook/skills.json b/skillbook/skills.json index 7ca38a5..f53f256 100644 --- a/skillbook/skills.json +++ b/skillbook/skills.json @@ -409,6 +409,26 @@ ], "formatNotes": "All three. Copilot: path-scoped `.github/instructions/spring-boot-cache-redis.instructions.md` with applyTo for cache `@Configuration`, `application*.{yml,yaml,properties}`, and types that use `@Cacheable`, `@CacheEvict`, or `@CachePut`. Claude Code: `.claude/skills/spring-boot-cache-redis-guardrails/SKILL.md` plus a one-line CLAUDE.md fact that Redis cache entries always have a TTL and `@EnableCaching` stays off the application class. Codex: a cache section in root `AGENTS.md` or linked `docs/agents/spring-boot-cache-redis.md`.", "body": "# Skill: Spring Boot Cache Redis Guardrails\n\n## Goal\nShip Spring Cache on Redis (including Azure Cache for Redis) that expires on purpose, serializes safely, isolates keys per app and environment, and stays correct when more than one pod is running.\n\n## When to apply\n- Enabling `spring-boot-starter-cache` with Redis, or reviewing an existing `CacheManager`\n- Adding or changing `@Cacheable`, `@CacheEvict`, or `@CachePut`\n- Incidents with stale data, unbounded Redis memory, stampedes, or cross-pod inconsistency\n- Moving a local or container Redis onto Azure Cache for Redis\n- Hardening serializers, key names, or bulk eviction before production\n\n## Baseline rules\n1. **Select Redis explicitly and keep caching off slice tests.** Depend on `spring-boot-starter-cache` and `spring-boot-starter-data-redis` (Lettuce unless the build already chose Jedis). Set `spring.cache.type=redis`. Do not assume \"Redis on the classpath\" picks the right manager when another provider is present. Put `@EnableCaching` on a dedicated `@Configuration` (for example `RedisCacheConfig`), not on `@SpringBootApplication`. `@WebMvcTest` and `@DataJpaTest` load the application class; they do not component-scan an arbitrary `@Configuration`. Leaving `@EnableCaching` on the application class pulls cache advice and a connection into slices that should stay light.\n2. **Every cache has a TTL.** `RedisCacheConfiguration` defaults to `Duration.ZERO`, which means entries never expire. That grows memory without bound and, on a server policy of `noeviction`, turns a full cache into write errors. Set a global floor with `spring.cache.redis.time-to-live`. Prefer per-cache TTL through a `RedisCacheManagerBuilderCustomizer` that calls `withCacheConfiguration` and `entryTtl`. Start from the auto-configured `RedisCacheConfiguration` bean so prefix, null policy, and serializer stay intact. Do not replace `CacheManager` with a hand-built bean, and do not declare your own `RedisCacheConfiguration` `@Bean`, unless you re-apply `CacheProperties` yourself. Both bypasses drop Boot's `spring.cache.redis.*` binding (`@ConditionalOnMissingBean`).\n3. **JSON values, string keys, explicit types.** Boot's default value serializer is JDK serialization: opaque bytes, brittle across class moves, and awkward to inspect. Prefer a typed `Jackson2JsonRedisSerializer` when a cache stores one concrete DTO. Use `GenericJackson2JsonRedisSerializer` only with an `ObjectMapper` whose polymorphic validator allowlists those DTOs. Permissive default typing (`@class` plus a laissez-faire subtype validator) is a deserialization risk if anything besides this app can write the keyspace. Document the allowlist. Serialize keys with a string serializer so prefixes and ids stay readable. Do not cache JPA entities, credentials, or types outside the allowlist.\n4. **Prefix and namespace every key.** Leave `spring.cache.redis.use-key-prefix=true` (the default). Turning it off lets two cache names share one Redis key. Set `spring.cache.redis.key-prefix` to application name, environment, and a schema version (`orders:prod:v3:`). Shared Azure instances must not mix apps or environments. Use stable SpEL (`key = \"#id\"`) that you repeat on evict and put. The default key generator hashes every argument, so `Pageable`, principals, and `toString()` of entities become huge or sensitive keys. Never put secrets, tokens, passwords, emails, national ids, or other raw PII in keys or values. Keys show up in `SCAN`, slow logs, and Azure diagnostics.\n5. **Evict one key. Do not `KEYS` the instance.** Prefer `@CacheEvict` / `@CachePut` with the same key the read path uses. `allEntries = true` and `Cache.clear()` walk the keyspace. `RedisCacheManager.builder(connectionFactory)` uses a non-locking writer whose batch strategy is `KEYS` in current Spring Data Redis. `KEYS` is blocking and is a poor fit for a large Azure keyspace. For a real bulk drop, either configure `RedisCacheWriter` with `BatchStrategies.scan(batchSize)` (still expensive, non-atomic, per node on cluster) or bump the version segment of the key prefix and let TTL reap the old generation. Do not call `FLUSHDB` or `FLUSHALL` from application code.\n6. **Decide nulls, then decide stampede.** Default `spring.cache.redis.cache-null-values=true` stores nulls for the full TTL (forever, if TTL was left at zero). Pick one policy: `unless = \"#result == null\"` and disable null caching, or a dedicated short-TTL cache for negative lookups. `disableCachingNullValues()` without `unless` throws when a method returns null, because the cache still attempts the put. `condition` runs before invocation (skip lookup and store). `unless` runs after (the method always runs; the result might not be stored), so it does not stop a stampede. `@Cacheable(sync = true)` locks inside one JVM only. Boot's writer is non-locking, so it is not cross-pod single-flight. If you add a Redis lock, document the lock key, the lock TTL, and the outcome when the holder dies (callers fall through to the database, or they fail).\n7. **Write the system of record, then the cache.** Keep the default `beforeInvocation = false` so evict/put runs after a successful method. Evicting first lets a concurrent reader reload the pre-write row and pin it until TTL. `transactionAware()` on the manager builder defers put/evict until after commit. Boot does not enable it. Turn it on only when a rolled-back transaction must not change the cache. Same-transaction reads will not see the deferred write, and a crash after commit but before the sync leaves stale data until TTL. Assume every pod shares one Redis. A process-local cache (Caffeine) is not coherent across pods. Do not add a near cache unless invalidation is designed and tested. `sync = true` does not coordinate pods.\n8. **Choose fail-open or fail-closed on purpose.** Set `spring.data.redis.timeout` below the caller's timeout so a stuck command does not pin the worker pool. Lettuce pooling needs `commons-pool2` and `spring.data.redis.lettuce.pool.*` (including `max-wait`); an unbounded wait hides the outage. The default `SimpleCacheErrorHandler` rethrows, so a Redis miss-path error fails the request even when the database could answer. That is fail-closed. For fail-open reads, a `CacheErrorHandler` that logs `handleCacheGetError` and does not rethrow lets the interceptor run the method. Swallowing put/evict errors hides a failed invalidation until TTL. Read-mostly catalogs can fail open. Authorization and idempotency keys should fail closed. When Actuator is on the classpath, Redis health is available; do not publish health details on the public port. Use a remote cache when pods must observe the same eviction. Use a local cache when per-pod staleness is acceptable and a Redis outage must not matter.\n9. **Test without a live Redis, then test the hot path with one.** Unit and slice tests should not open a socket. With `@EnableCaching` isolated, `@WebMvcTest` does not cache. Where a slice needs the abstraction, use `@AutoConfigureCache` or `spring.cache.type=none` and assert outcomes, not Redis bytes. For integration of hit, miss, eviction, and null policy, use Testcontainers with a pinned image (for example `redis:7-alpine`), `@ServiceConnection` on Boot 3.1+, or dynamic host/port properties. Do not point CI at Azure or a shared dev cache. Include a round-trip that fails if values come back as JDK payload when JSON was required.\n10. **Azure Cache for Redis is still Redis, plus network and identity.** Enable TLS (`spring.data.redis.ssl.enabled=true`) and use the instance hostname and TLS port (commonly 6380 when non-TLS is disabled). Prefer Microsoft Entra authentication where that tier and the client stack already in the repo support short-lived data-plane tokens. Otherwise set `spring.data.redis.password` from the environment or the app's existing Key Vault reference. Never commit access keys, connection strings, or primary/secondary secrets, and do not invent secret names or resource ids. Restrict the network with the firewall or a private endpoint and private DNS; laptops use local Redis or an approved tunnel, not the production key on a public endpoint. Application TTLs still matter if the server policy is `noeviction`. Use cluster configuration only when the instance is clustered, and do not assume a multi-key command spans prefixes.\n\n## Tool placement\n- **GitHub Copilot:** path-scoped `.github/instructions/spring-boot-cache-redis.instructions.md` with `applyTo` covering the cache configuration class, `application*.{yml,yaml,properties}`, and files that declare `@Cacheable`, `@CacheEvict`, or `@CachePut`. Keep one always-on line in `.github/copilot-instructions.md`: Redis caches have a TTL, JSON values, a namespaced prefix, and no `allEntries=true` on large keyspaces.\n- **Claude Code:** procedure in `.claude/skills/spring-boot-cache-redis-guardrails/SKILL.md`. One CLAUDE.md fact: \"Spring Cache on Redis always sets a TTL via RedisCacheManagerBuilderCustomizer; @EnableCaching lives on an isolated @Configuration, not the application class.\"\n- **Codex:** a short cache section in root `AGENTS.md`, or `docs/agents/spring-boot-cache-redis.md` linked from it when the root file would grow. State TTL, serializer, prefix, eviction, and fail-open versus fail-closed.\n\n## Anti-patterns\n- `@EnableCaching` on `@SpringBootApplication`, so every slice test opens Redis\n- Leaving TTL unset and treating \"it works on my laptop\" as production-safe\n- A custom `CacheManager` or `RedisCacheConfiguration` bean that silently ignores `spring.cache.redis.*`\n- JDK-serialized values, or JSON with permissive `@class` typing on a shared cache\n- `use-key-prefix=false`, or one prefix shared by dev and prod\n- SpEL built from `toString()`, tokens, or PII\n- `@CacheEvict(allEntries = true)` as a routine invalidation on Azure-sized keyspaces\n- `disableCachingNullValues()` without `unless`, so legitimate null returns throw\n- Believing `sync = true` is a cluster-wide single-flight\n- Evicting before the database write, or assuming transaction-aware cache is on by default\n- A Caffeine near cache with no invalidation story in a multi-pod deployment\n- Fail-open put/evict on data that must not stay stale past the method return\n- CI tests aimed at a shared Redis or at Azure\n- Access keys, connection strings, or firewall exceptions committed \"just for local\"\n\n## Verification\n- [ ] `spring.cache.type=redis` and both starters are present; `@EnableCaching` is not on the application class\n- [ ] Global TTL is set, and each hot cache has an explicit TTL from `RedisCacheManagerBuilderCustomizer` derived from Boot's configuration\n- [ ] No replacement `CacheManager` / `RedisCacheConfiguration` bean drops Boot properties\n- [ ] Values are JSON with a documented type allowlist; keys are strings; prefix includes app, environment, and schema version\n- [ ] Read and evict SpEL keys match; keys and values contain no secrets or PII\n- [ ] Bulk clear is scan-based or version-bumped; `allEntries=true` is absent on large caches\n- [ ] Null policy is explicit (`unless` / `condition` / short null TTL) and does not throw on ordinary nulls\n- [ ] Cross-pod single-flight, if any, documents lock TTL and the failure mode; `sync=true` is not described as cluster-wide\n- [ ] Write-then-evict order is intact; `transactionAware` is set only if the PR explains it\n- [ ] Command timeout, pool wait, and `CacheErrorHandler` match the chosen fail-open or fail-closed mode\n- [ ] Slice tests do not need Redis; hot-path integration uses a pinned Testcontainers image\n- [ ] Azure notes name TLS, auth source (Entra or access key via env/Key Vault), and private network, with no secrets in the diff\n\n## Copy-ready SKILL.md stub\n```markdown\n---\nname: spring-boot-cache-redis-guardrails\ndescription: Use when designing or reviewing Spring Cache on Redis or Azure Cache for Redis — TTL via RedisCacheManagerBuilderCustomizer, JSON serializers, key prefixes, eviction, stampede, and multi-pod correctness.\n---\n\nFollow Spring Boot Cache Redis Guardrails: explicit redis cache type, @EnableCaching on an isolated configuration, TTL on every cache, JSON values, namespaced prefixes, targeted eviction, and a documented fail-open or fail-closed policy.\n```\n" + }, + { + "id": "maven-multimodule-ci-cache-guardrails", + "title": "Maven Multi-Module CI Cache Guardrails", + "whenToUse": "Speeding up or reviewing GitHub Actions builds for a Maven multi-module Java reactor — dependency cache keys, setup-java cache, reactor flags, and what never to cache.", + "tools": [ + "copilot", + "claude-code", + "codex" + ], + "tags": [ + "java", + "maven", + "github-actions", + "ci", + "performance", + "multi-module" + ], + "formatNotes": "All three. Copilot: path-scoped `.github/instructions/maven-ci-cache.instructions.md` with applyTo for `**/pom.xml`, `.github/workflows/**/*.{yml,yaml}`, and `**/.mvn/**`. Claude Code: `.claude/skills/maven-multimodule-ci-cache-guardrails/SKILL.md` plus a one-line CLAUDE.md fact that CI caches `~/.m2/repository` by hashed poms, never `**/target`. Codex: a Maven CI section in root `AGENTS.md` or linked `docs/agents/maven-ci-cache.md`.", + "body": "# Skill: Maven Multi-Module CI Cache Guardrails\n\n## Goal\nMake GitHub Actions builds for a Maven multi-module reactor fast and correct: cache the local repository by pom hashes, keep the reactor deterministic, and never poison the cache with `target/` output or secrets.\n\n## When to apply\n- Adding or reviewing `setup-java` / `actions/cache` for a Maven monorepo\n- Slow CI after new modules, BOM bumps, or snapshot churn\n- Flaky builds that pass locally but fail after a cache hit\n- Introducing `-T` parallel reactor builds or selective module builds (`-pl` / `-am` / `-amd`)\n- Hardening cache keys, restore-keys, and path lists before production pipelines\n\n## Baseline rules\n1. **Prefer `setup-java` Maven cache over a hand-rolled `actions/cache`.** On GitHub-hosted runners, `actions/setup-java` with `cache: maven` hashes the dependency tree from the poms and restores `~/.m2/repository`. Use it unless the workflow already has a documented custom cache (for example a shared self-hosted cache layout). If you must use `actions/cache` directly, pin the action major, set `path` to `~/.m2/repository` only, and key on OS plus a hash of every `pom.xml` (and the Maven wrapper props if the wrapper pins the distribution).\n2. **Key on every pom that can change the classpath.** In a multi-module reactor the parent BOM, dependencyManagement, and pluginManagement all affect resolution. Hash `**/pom.xml` (or the concrete list the root reactor includes). Include `.mvn/wrapper/maven-wrapper.properties` when the wrapper is the source of truth for the Maven version. Do not key only on the root pom — a leaf module bump must bust the cache.\n3. **Never cache `**/target` or compiled classes.** Module `target/` directories are build outputs. Caching them across jobs mixes stale class files with new sources and causes ghost test failures. Cache the local repository (resolved jars) and rebuild modules each run. If you need artifact reuse between jobs in one workflow, use `actions/upload-artifact` / `download-artifact` for specific jars, not a persistent `target/` cache key.\n4. **Keep restore-keys as a fallback prefix, not a second full key.** A typical pattern is `key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}` with `restore-keys: ${{ runner.os }}-m2-`. A partial restore is fine (extra jars stay; missing ones download). Do not use an overly broad key that never changes — that freezes an old dependency set after a BOM bump until manual eviction.\n5. **Use the Maven Wrapper in CI.** Commit `.mvn/wrapper` and invoke `./mvnw` (or `mvnw.cmd` on Windows) so the Maven version matches developers. Pin `distributionUrl` to a release, not a moving `latest`. Do not install a different Maven via apt and ignore the wrapper when the repo has one.\n6. **CI-friendly Maven flags are mandatory.** Always pass `-B` (batch) and prefer `-ntp` (no transfer progress). Fail the job on dependency warnings that hide resolution problems when the team already treats them as errors (`-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn` is optional noise control, not a substitute for `-B`). Do not hide test failures with blanket `-DskipTests` on the main verify job; use a dedicated job or profile only when the pipeline already separates compile from test.\n7. **Reactor flags for multi-module: be explicit.** Default CI should run from the reactor root: `./mvnw -B -ntp verify` (or the project's standard lifecycle). Selective builds with `-pl module-a,module-b -am` are for PR paths when the workflow already computes the affected modules; document how the module list is derived. `-amd` builds dependents; use it when an API module change must re-test consumers. Do not combine ad-hoc `-pl` with a stale local repo assumption — the cache must still contain the parent BOM artifacts.\n8. **Parallel builds need thread-safe plugins.** `-T 1C` (one thread per core) or `-T 2` can cut wall time on large reactors. Confirm surefire/failsafe fork settings and any custom plugins are safe under concurrent module builds. If a module is known unsafe, exclude it from parallelism or keep CI serial until fixed. Document the chosen `-T` value in the workflow comment or AGENTS.md.\n9. **Snapshots and mirror config belong in checked-in settings — carefully.** If CI uses a `settings.xml` (company mirror, authenticated registry), mount it via `actions/setup-java` `server-id` / env-backed passwords or a short-lived token. Never commit passwords, tokens, or base64-encoded credentials. Prefer OIDC or short-lived cloud tokens already used elsewhere in the repo over long-lived `settings.xml` secrets. Snapshot updates (`-U`) belong on a scheduled or main-branch job when snapshot deps exist; do not force `-U` on every PR unless the team depends on floating snapshots (prefer pinning).\n10. **Separate dependency resolution from tests when it helps.** A common pattern: job 1 resolves and optionally runs `./mvnw -B -ntp -DskipTests package` with cache save; job 2 restores the same cache key and runs tests. With `setup-java` cache, a single job that runs `verify` is enough for most repos — only split when wall time or runners justify it. Post-job cache save failures must not hide a red test step; keep test exit code authoritative.\n11. **Windows vs Ubuntu runners.** Cache keys must include `runner.os` (or an explicit OS label). Path separators and the wrapper script differ; use `./mvnw` on Unix and `mvnw.cmd` on Windows, or `bash mvnw` when bash is available. Do not assume a Linux-only `~/.m2` path on Windows runners (`~/.m2/repository` still works under the user home, but document it).\n12. **Validate locally before trusting CI cache lore.** Reproduce with `./mvnw -B -ntp -o verify` (offline) after a populated local repo to confirm the reactor does not need unexpected remote hits. In CI logs, confirm cache restore HIT/MISS and that dependency downloads after a pom-only change are expected. Watch for cache thrash: keys that change every run (embedding `github.sha` into the m2 key) defeat the purpose.\n\n## Tool placement\n- **GitHub Copilot:** path-scoped `.github/instructions/maven-ci-cache.instructions.md` with `applyTo` for `**/pom.xml`, `.github/workflows/**/*.{yml,yaml}`, and `**/.mvn/**`. One always-on line in `.github/copilot-instructions.md`: CI caches `~/.m2/repository` keyed by hashed poms; never cache `**/target`.\n- **Claude Code:** procedure in `.claude/skills/maven-multimodule-ci-cache-guardrails/SKILL.md`. One CLAUDE.md fact: \"Maven CI uses setup-java cache or actions/cache on ~/.m2/repository keyed by **/pom.xml; never cache target/.\"\n- **Codex:** short Maven CI section in root `AGENTS.md`, or `docs/agents/maven-ci-cache.md` linked from it. State cache path, key inputs, wrapper, and reactor command.\n\n## Anti-patterns\n- Caching `**/target` or the whole workspace as a \"speedup\"\n- Keying the m2 cache only on the root pom in a multi-module tree\n- Embedding `github.sha` or a timestamp into the dependency cache key\n- Ignoring the Maven Wrapper and installing a different Maven in CI\n- Blanket `-DskipTests` on the only verify job to \"make cache warmer\"\n- Committing `settings.xml` with passwords or tokens\n- Assuming `-T` is safe without checking surefire forks / custom plugins\n- Partial `-pl` builds without `-am` when the module needs reactor siblings\n- restore-keys so broad they keep serving a pre-CVE dependency set with no pom hash change path\n- Documenting Azure/GitHub secrets or mirror URLs that are not already in the repo\n\n## Verification\n- [ ] Workflow uses `setup-java` `cache: maven` or an equivalent `actions/cache` on `~/.m2/repository` only\n- [ ] Cache key hashes all relevant `pom.xml` files (and wrapper props if used)\n- [ ] No path entry caches `**/target` or compiled outputs across runs\n- [ ] CI invokes `./mvnw` (or documented Windows equivalent) with `-B` and preferably `-ntp`\n- [ ] Default job runs a full reactor verify (or a documented selective `-pl/-am` strategy)\n- [ ] Parallel `-T` is documented and known-safe for this repo, or omitted\n- [ ] No credentials in committed settings; tokens via env / OIDC already used in-repo\n- [ ] After a leaf pom dependency bump, CI shows cache miss or partial restore then downloads the new artifact\n- [ ] Offline local `./mvnw -B -ntp -o verify` works on a warm machine for the same revision\n\n## Copy-ready SKILL.md stub\n```markdown\n---\nname: maven-multimodule-ci-cache-guardrails\ndescription: Use when speeding up or reviewing GitHub Actions Maven multi-module builds — setup-java/m2 cache keys, reactor flags, wrapper, and never caching target/.\n---\n\nFollow Maven Multi-Module CI Cache Guardrails: cache ~/.m2/repository keyed by hashed poms, use the Maven Wrapper with -B -ntp, never cache **/target, and document any -pl/-am or -T usage.\n```\n" } ] }