diff --git a/promptbook/prompts.json b/promptbook/prompts.json index 11b823d..444f516 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 — 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 \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" }, { "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 × 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." + "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." }, { "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 ≤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." + "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." }, { "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—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." + "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." }, { "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 — 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 \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." }, { "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` — 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)" + "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)" }, { "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 — 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}}" + "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}}" }, { "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 — 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 \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" }, { "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 — 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" + "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" }, { "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 → 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 \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." }, { "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`, …), 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." + "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." }, { "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) — 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." + "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." }, { "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` — 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" + "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" }, { "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–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" + "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" }, { "id": "harden-spring-oauth2-resource-server", @@ -348,7 +348,28 @@ "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 → 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" + "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" + }, + { + "id": "wire-gha-oidc-azure-login", + "title": "Wire GitHub Actions OIDC Login to Azure", + "whenToUse": "You need PR-ready GitHub Actions workflow changes plus Entra federated-credential and Azure RBAC notes to replace client-secret Azure login with OIDC for a specific repo and environment.", + "tools": [ + "copilot", + "claude-code", + "codex" + ], + "tags": [ + "github-actions", + "azure", + "oidc", + "entra", + "security", + "ci", + "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" } ] } diff --git a/skillbook/skills.json b/skillbook/skills.json index 51a6ed9..192041e 100644 --- a/skillbook/skills.json +++ b/skillbook/skills.json @@ -349,6 +349,26 @@ ], "formatNotes": "All three. Copilot: path-scoped `.github/instructions/spring-oauth2-resource-server.instructions.md` with applyTo for `**/Security*Config*.java`, `**/*SecurityFilterChain*.java`, `**/src/main/resources/application*.{yml,yaml,properties}`, and `**/src/test/**/*Security*Test*.java`. Claude Code: `.claude/skills/spring-security-oauth2-resource-server/SKILL.md` (plus a short CLAUDE.md fact that APIs validate JWT via oauth2ResourceServer and never disable security in prod profiles). Codex: a Resource Server / JWT section in root `AGENTS.md` or nested `src/main/java/**/security/AGENTS.md`.", "body": "# Skill: Spring Security OAuth2 Resource Server Guardrails\n\n## Goal\nShip a Spring Boot 3 / Spring Security 6 API that validates bearer tokens correctly (signature, issuer, audience, lifetime), maps scopes/claims into authorities deliberately, keeps CSRF and session settings honest for stateless APIs, and fails closed without leaking token or key material.\n\n## When to apply\n- Adding `spring-boot-starter-oauth2-resource-server` or reviewing an existing `oauth2ResourceServer` `SecurityFilterChain`\n- Wiring JWT decoders via `issuer-uri`, `jwk-set-uri`, or a custom `JwtDecoder` bean\n- Mapping scopes / roles into `GrantedAuthority` and protecting routes or methods\n- Reviews that mention CSRF disabled, `permitAll` on actuators, multi-tenant issuers, or tests with security off\n- Pairing with gateway/BFF work where this service is the resource server, not the authorization server\n\n## Baseline rules\n1. **Prefer `issuer-uri` in production.** It discovers JWKS via OIDC metadata and validates `iss`. Use `jwk-set-uri` alone only when discovery is unavailable or startup must not call the IdP — then add explicit issuer (and audience) validators yourself.\n2. **Validate audience.** Default decoder checks signature, `iss` (with issuer-uri), and time claims; it does **not** enforce `aud`. Add an `OAuth2TokenValidator` so tokens minted for another API are rejected.\n3. **Pin algorithms.** Prefer asymmetric RS256/ES256 from JWKS. If you customize `NimbusJwtDecoder`, set allowed JWS algorithms explicitly; never accept `none` or mixed HMAC+RSA without a deliberate threat model.\n4. **Map authorities on purpose.** Default scope → `SCOPE_` prefix. For roles in `roles`, `realm_access`, or custom claims, use a `JwtAuthenticationConverter` and document the claim path. A valid JWT is not authorization for every route.\n5. **Authorize at the edge and in methods.** `authorizeHttpRequests` for coarse route rules; `@EnableMethodSecurity` + `@PreAuthorize` for finer checks. Keep authority names consistent across both.\n6. **CSRF off only for pure bearer APIs.** `SessionCreationPolicy.STATELESS` + CSRF disabled fits `Authorization: Bearer` with no cookie session. If the same app also serves browser cookie sessions, split filter chains — do not blanket-disable CSRF.\n7. **Opaque vs JWT is a product choice.** JWT: local JWKS validation. Opaque: introspection via `opaquetoken` properties. Do not parse opaque tokens as JWT; do not skip introspection client credentials.\n8. **Error responses stay boring.** 401 for missing/invalid tokens, 403 for insufficient scope. No stack traces, JWKS URLs, expected audiences, or raw tokens in bodies or logs.\n9. **Actuator and filter-order traps.** Do not `permitAll` on `/actuator/**` in the API chain. Prefer a separate management port or role gates. Custom filters before `BearerTokenAuthenticationFilter` must not short-circuit auth.\n10. **Multi-tenant issuers need an allowlist.** Multiple IdPs require a deliberate issuer→decoder map (or trusted-issuer list), not \"accept any `iss`\".\n11. **Test with JWT support, not only mocks.** `@WithMockUser` is fine for method-security units; resource-server integration tests should use `spring-security-test` JWT helpers (`jwt()` / `mockJwt`) or a test decoder that still enforces claim validators. Cover expired, wrong-`aud`, wrong-`iss`, and missing-scope cases.\n12. **Never disable security in prod profiles.** No permissive `SecurityFilterChain` under `prod`, no test-only bypass that leaks into default/prod. Test profiles may use a test decoder — production always validates against the real IdP JWKS/issuer.\n\n## Workflow\n1. Confirm this app is a **resource server** (validates tokens), not an authorization server.\n2. Inventory IdP: issuer, JWKS, expected `aud`, scope vs role claim shape, JWT vs opaque.\n3. Add the resource-server starter; set `spring.security.oauth2.resourceserver.jwt.issuer-uri` and an audience validator.\n4. Author the primary `SecurityFilterChain`: session policy, CSRF decision documented, `oauth2ResourceServer(jwt -> …)`, least-privilege matchers.\n5. Add a converter if authorities are non-default; enable method security where needed.\n6. Lock down actuators/internal paths; align management port / network policy.\n7. Add tests: happy path with required scope; 401 wrong iss/aud/expired; 403 missing scope.\n8. PR notes: issuer, audience, claim→authority map, CSRF rationale, remaining `permitAll` paths.\n\n## Tool-specific notes\n### GitHub Copilot\n- Path-scoped `.github/instructions/spring-oauth2-resource-server.instructions.md` with `applyTo` for security config, `application*.yml`, and `*Security*Test*.java`.\n- Always-on `.github/copilot-instructions.md`: one line — APIs use oauth2ResourceServer JWT validation with audience checks; never disable security in prod.\n- Extend the existing `SecurityFilterChain`; do not invent a second permissive chain.\n\n### Claude Code\n- Procedure in `.claude/skills/spring-security-oauth2-resource-server/SKILL.md`.\n- CLAUDE.md fact: \"Resource APIs validate JWT via Spring oauth2ResourceServer (issuer + audience); do not permitAll actuators or disable CSRF without a bearer-only rationale.\"\n- Run module tests and show 401/403 cases before claiming done.\n\n### Codex\n- Short `AGENTS.md` (or `…/security/AGENTS.md`): issuer-uri preferred, audience required, SCOPE_ or documented converter, CSRF only off for stateless bearer, no prod bypass.\n- Link to this skill or `docs/agents/spring-oauth2-resource-server.md` if root AGENTS.md would bloat.\n\n## Anti-patterns\n- `jwk-set-uri` without issuer/audience validators in multi-API estates\n- Unrestricted JWS algorithms or accepting `alg=none` on a custom decoder\n- `csrf.disable()` on a chain that still uses cookie sessions\n- `anyRequest().permitAll()` left in main \"temporarily\"\n- Logging bearer tokens or full JWT payloads at INFO\n- `@WithMockUser` alone as proof that JWT validation works\n- Hard-coded JWKS PEMs in-repo (breaks key rotation)\n- One chain mixing form-login pages and bearer APIs without path separation\n- Multi-tenant decode-first without an issuer allowlist\n- `@Profile(\"test\")` security config accidentally active outside tests\n\n## Done when\n- [ ] `issuer-uri` (or documented `jwk-set-uri` + validators) configured per environment\n- [ ] Audience (or equivalent API identifier) validated\n- [ ] Scope/role → authority mapping documented and enforced\n- [ ] CSRF/session settings match bearer-only vs cookie reality (split chains if mixed)\n- [ ] Actuator/admin paths are not anonymous on the public port\n- [ ] Tests cover valid token, wrong iss/aud, expired, and insufficient scope\n- [ ] No prod profile disables `SecurityFilterChain` or JWT validation\n- [ ] PR states IdP, audience, claim map, and remaining `permitAll` paths\n\n## Copy-ready SKILL.md stub\n```markdown\n---\nname: spring-security-oauth2-resource-server\ndescription: Use when configuring or reviewing Spring Boot OAuth2 resource-server JWT/opaque security — issuer-uri/JWKS, audience validation, scope authorities, CSRF for stateless APIs, actuators, and tests. Never disable security in prod.\n---\n\nFollow the Spring Security OAuth2 Resource Server Guardrails skill: issuer + audience validation, deliberate authority mapping, bearer-only CSRF rationale, locked-down actuators, JWT-aware tests.\n```\n" + }, + { + "id": "gha-oidc-azure-guardrails", + "title": "GitHub Actions OIDC Azure Login Guardrails", + "whenToUse": "Wiring or reviewing GitHub Actions jobs that authenticate to Azure with OIDC (Microsoft Entra federated identity credentials) instead of long-lived client secrets — including subject-claim strategy, immutable sub migration, RBAC, and fork-PR safety.", + "tools": [ + "copilot", + "claude-code", + "codex" + ], + "tags": [ + "github-actions", + "azure", + "oidc", + "entra", + "security", + "ci" + ], + "formatNotes": "All three. Copilot: path-scoped `.github/instructions/gha-oidc-azure.instructions.md` with applyTo `**/.github/workflows/*.{yml,yaml}` and any reusable workflow that calls `azure/login`. Claude Code: `.claude/skills/gha-oidc-azure-guardrails/SKILL.md` (plus a one-line CLAUDE.md fact that Azure deploy jobs use OIDC + least-privilege FIC subjects, never client secrets in git). Codex: a GitHub Actions / Azure OIDC section in root `AGENTS.md` or `.github/AGENTS.md` covering permissions, FIC subjects, and immutable sub migration.", + "body": "# Skill: GitHub Actions OIDC Azure Login Guardrails\n\n## Goal\nAuthenticate GitHub Actions jobs to Azure with short-lived tokens via OIDC federated identity credentials (FIC), scoped subjects, least-privilege RBAC, and safe workflow permissions — without long-lived `AZURE_CLIENT_SECRET` values in GitHub secrets.\n\n## When to apply\n- Adding or changing deploy/infra jobs that call `azure/login`, `az`, Terraform, Bicep, or Azure CLI against subscriptions\n- Migrating from service-principal client secrets or stored PATs to OIDC\n- Configuring Entra app registrations or user-assigned managed identities with FIC for GitHub's OIDC issuer\n- Reviews mentioning broad `sub` patterns, missing `id-token: write`, or fork PR workflows with cloud access\n- 2026 immutable OIDC subject-claim work (name-based `sub` recycling on rename/transfer)\n\n## Baseline rules\n1. **Prefer OIDC over long-lived secrets.** Use federated credentials so GitHub mints a job-scoped ID token Entra trusts. Do not keep `AZURE_CLIENT_SECRET` \"just in case\" after OIDC works.\n2. **Use official login action with explicit IDs.** `azure/login@v2` (or current verified release) with `client-id`, `tenant-id`, and `subscription-id` from GitHub **variables** or environment configuration — not hardcoded in public forks. Pin the action to a full commit SHA or a verified tag your repo already uses.\n3. **Grant `id-token: write` only where needed.** Set workflow default `permissions` to `contents: read` (and other read scopes as required). Add `permissions:\n id-token: write` (plus deploy scopes) on the **job** that logs into Azure — avoid repo-wide wildcard escalation if a narrower reusable workflow can own the token.\n4. **Pick the tightest FIC subject strategy.** Entra FIC `subject` must match GitHub's OIDC `sub` for that job context. Common patterns (least privilege first when they fit):\n - **Environment:** `repo:ORG/REPO:environment:NAME` — pair with GitHub Environments, required reviewers, and deployment branches for production.\n - **Ref (branch/tag):** `repo:ORG/REPO:ref:refs/heads/main` or tag ref — good for branch-locked promotion.\n - **Job workflow ref:** `repo:ORG/REPO:ref:refs/heads/main:workflow:FILE:job:JOB` — narrows to one workflow job; use when multiple jobs share a branch but only one may touch Azure.\n Avoid `repo:ORG/REPO:*` or other catch-all subjects that let any workflow job in the repo authenticate.\n5. **Audience defaults.** Use Entra's default federated audience `api://AzureADTokenExchange` unless every layer (FIC, token exchange, custom middleware) is deliberately configured for a custom `aud`. Mismatched audience is a common \"login works in one pipeline only\" failure.\n6. **2026 immutable subject claims.** GitHub can emit **name-based** subjects that embed `ORG/REPO` strings. Those strings can be **reused** after rename, transfer, or org restructuring — a recycled name must not inherit old FIC trust. **Prefer or migrate to immutable subjects** that bind to stable numeric IDs (repository and owner identifiers in the claim shape GitHub documents for your account tier). Migration playbook without downtime:\n - Add a **second** FIC with the immutable subject (keep the existing name-based FIC).\n - Run representative workflows; confirm Entra accepts the new `sub` and Azure RBAC still resolves.\n - Remove the name-based FIC after soak.\n Where supported, use **Flexible FIC** or supplemental claim checks (`repository_id`, `repository_owner_id`, etc.) as defense in depth so trust does not depend on display names alone.\n7. **RBAC on the Azure identity.** Grant only roles required for the pipeline task — e.g. `AcrPush` on a registry, `Key Vault Secrets User` on one vault, `Contributor` scoped to a resource group. Avoid `Owner` / `User Access Administrator` at subscription scope for CI. Separate identities per environment when blast radius differs.\n8. **Pin actions; protect tokens.** Pin third-party actions by SHA; do not `echo` ID tokens, `AZURE_*` env dumps, or `::debug::` secrets. Disable verbose logging on login steps in shared workflows.\n9. **Fork PR safety.** `pull_request` from forks must not receive `id-token: write` with cloud deploy secrets or environments that grant Azure. Use `pull_request_target` only under org-approved patterns; default to \"OIDC jobs run on `push` / `workflow_dispatch` / internal PRs only\".\n10. **Issuer validation stays on.** Entra FIC issuer must be `https://token.actions.githubusercontent.com` (GitHub's OIDC issuer). Do not disable issuer or audience validation in custom scripts that exchange tokens manually.\n\n## Workflow\n1. Inventory existing workflows under `.github/workflows` for `azure/login`, `AZURE_CLIENT_SECRET`, or `credentials: ${{ secrets.*}}` patterns.\n2. Choose identity type: app registration service principal vs user-assigned managed identity (UAMI) — match what platform team supports for FIC.\n3. Design FIC subjects per environment/job; document {{ORG}}, {{REPO}}, environment names, and branch refs in runbooks (not secrets).\n4. Author workflow: job-level `permissions`, pinned `azure/login`, subsequent `az`/IaC steps using OIDC session only.\n5. Assign Azure RBAC on the identity; remove unused secret-based login paths.\n6. If migrating immutable `sub`: dual-FIC → validate → retire name-based FIC.\n7. PR notes: subject strategy, roles granted, fork policy, and verification evidence.\n\n## Tool-specific notes\n### GitHub Copilot\n- Path-scoped `.github/instructions/gha-oidc-azure.instructions.md` with `applyTo` for workflow YAML.\n- Always-on line: Azure jobs use OIDC + FIC; never add client secrets to git.\n- Extend existing deploy workflows; do not duplicate a secret-based login path.\n\n### Claude Code\n- Procedure in `.claude/skills/gha-oidc-azure-guardrails/SKILL.md`.\n- CLAUDE.md fact: \"Azure deploy from Actions uses OIDC (`id-token: write` on the deploy job only) and least-privilege FIC subjects.\"\n- Before claiming done, walk through subject match checklist and fork PR denial reasoning.\n\n### Codex\n- `AGENTS.md` CI/OIDC section: permissions model, FIC subject patterns, immutable sub migration, no secrets in YAML.\n- Link to this skill if root AGENTS.md would bloat.\n\n## Anti-patterns\n- Storing `AZURE_CLIENT_SECRET` alongside OIDC \"for rollback\"\n- FIC subject `repo:ORG/REPO:*` or environment `*` shared by prod and dev\n- Same Entra app + FIC for every environment and every repo in the org\n- Granting subscription `Owner` to a CI service principal\n- `permissions: write-all` or top-level `id-token: write` on every job including fork PR builds\n- Logging OIDC ID tokens or `ACTIONS_ID_TOKEN_REQUEST_TOKEN` output\n- Disabling issuer validation in custom token-exchange scripts\n- Relying solely on name-based `sub` after repo transfer without re-auditing FIC trust\n- Unpinned `azure/login@main` or other floating action refs\n\n## Verification checklist\n- [ ] Only deploy/login jobs have `id-token: write`; default permissions are read-mostly\n- [ ] FIC issuer is GitHub Actions OIDC; audience matches token exchange expectations\n- [ ] FIC `subject` equals the `sub` for the intended ref/environment/workflow job (document the expected string)\n- [ ] `azure/login` succeeds on allowed branch/environment; **fails** on wrong ref or unapproved environment\n- [ ] No `AZURE_CLIENT_SECRET` in GitHub secrets for this path (or tracked deprecation issue)\n- [ ] Fork `pull_request` workflows cannot reach OIDC + protected environment deploy\n- [ ] Action SHAs pinned; login steps do not echo tokens\n- [ ] Azure roles scoped to required resources only (list role + scope in PR)\n- [ ] If immutable sub migration: dual FIC tested before removing legacy FIC\n\n## Copy-ready SKILL.md stub\n```markdown\n---\nname: gha-oidc-azure-guardrails\ndescription: Use when wiring GitHub Actions OIDC login to Azure/Entra — FIC subjects, id-token permissions, immutable sub migration, RBAC, fork PR safety. Prefer OIDC over client secrets.\n---\n\nFollow GitHub Actions OIDC Azure Login Guardrails: job-scoped id-token, least-privilege FIC subjects, pinned azure/login, no secrets in git, verify wrong-ref failures.\n```\n" } ] }