diff --git a/promptbook/prompts.json b/promptbook/prompts.json index 21e07c2..8ca7f8d 100644 --- a/promptbook/prompts.json +++ b/promptbook/prompts.json @@ -197,6 +197,24 @@ ], "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" + }, + { + "id": "add-spring-resilience-patterns", + "title": "Add Spring Resilience Patterns", + "whenToUse": "You have an outbound HTTP/DB/messaging call in a Spring Boot service and want reviewable Resilience4j (or equivalent) protection.", + "tools": [ + "copilot", + "claude-code", + "codex" + ], + "tags": [ + "java", + "spring-boot", + "resilience", + "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" } ] } diff --git a/skillbook/skills.json b/skillbook/skills.json index 2393b6e..e0dad72 100644 --- a/skillbook/skills.json +++ b/skillbook/skills.json @@ -198,6 +198,24 @@ ], "formatNotes": "All three. Copilot: `.github/instructions/keyvault.instructions.md` with applyTo for `**/*.{java,cs,ts,js,yml,yaml,bicep,tf}` and `**/appsettings*.json`. Claude Code: `.claude/skills/azure-key-vault/SKILL.md`. Codex: section in root `AGENTS.md` or `docs/agents/key-vault.md` linked from AGENTS.md.", "body": "# Skill: Azure Key Vault App Integration\n\n## Goal\nIntegrate applications with Azure Key Vault so secrets are fetched via identity, rotated safely, and never committed or logged.\n\n## When to apply\n- New or existing services that need DB passwords, API keys, certificates, or signing keys\n- Reviews that find secrets in config files, env samples committed with real values, or long-lived connection strings\n- Migrations from App Settings / Kubernetes secrets / `.env` files into Key Vault\n\n## Preferred patterns\n1. **Identity over keys**: prefer managed identity / workload identity to Key Vault; avoid embedding vault access keys or client secrets when identity is available.\n2. **Least privilege**: grant get/list only on the secrets the app needs; separate read vs admin principals.\n3. **Names and versions**: use stable secret names; pin to a version only when required for rollback, otherwise take the current version deliberately.\n4. **Caching**: cache secret values in-process with a short TTL and refresh on failure; do not dump full secret maps into logs.\n5. **Local/dev**: use user secrets, `.env` (gitignored), or a non-prod vault — never commit real values; document required secret *names* only.\n6. **Rotation**: design callers to tolerate rotation (reconnect pools, reload config) without redeploying for every rotate when the platform supports it.\n\n## Implementation steps\n1. Inventory secrets the change introduces or touches (name, owner, environments).\n2. Confirm vault and RBAC/access policy patterns already used in-repo; match them.\n3. Replace inline secret material with references (Key Vault reference, CSI driver, SDK getSecret, etc. as used by the stack).\n4. Ensure startup fails closed if required secrets are missing (clear error, no half-boot with empty credentials).\n5. Add or update tests/mocks so unit tests never need real vault credentials.\n6. Update runbooks: where secrets live, who can rotate, and how to verify after rotate.\n\n## Constraints\n- Do not print secret values, full connection strings, or private keys in logs, traces, or PR descriptions.\n- Do not weaken TLS or disable certificate validation to “make Key Vault work.”\n- Prefer platform-native Key Vault integration already in the repo over new SDKs or sidecar patterns.\n- Keep IaC changes aligned with existing modules (Bicep/Terraform/Helm) — no one-off portal-only grants in production paths.\n\n## Output format\n- Summary of secrets moved or referenced (names only)\n- Code/IaC/config diffs\n- Identity and RBAC changes required\n- Verification steps (app start, rotate drill, negative test for missing secret)\n- Residual risks (caching, dual-read during migration, break-glass)" + }, + { + "id": "spring-boot-resilience4j", + "title": "Spring Boot Resilience4j Guardrails", + "whenToUse": "Adding timeouts, retries, circuit breakers, or bulkheads to a Spring Boot service — or reviewing a PR that calls unreliable dependencies without resilience.", + "tools": [ + "copilot", + "claude-code", + "codex" + ], + "tags": [ + "java", + "spring-boot", + "resilience", + "microservices" + ], + "formatNotes": "All three. Copilot: `.github/instructions/resilience.instructions.md` with applyTo for `**/*.{java,yml,yaml}` and Spring config. Claude Code: `.claude/skills/spring-resilience4j/SKILL.md`. Codex: section in root `AGENTS.md` or `docs/agents/resilience4j.md` linked from AGENTS.md.", + "body": "# Skill: Spring Boot Resilience4j Guardrails\n\n## Goal\nAdd timeouts, retries, circuit breakers, and bulkheads to Spring Boot 3 services so outbound calls fail predictably and recover safely.\n\n## When to apply\n- HTTP/DB/messaging clients without explicit resilience\n- PRs calling unreliable dependencies with only default timeouts\n- Hardening services that rely on ad-hoc try/catch\n\n## Preferred patterns\n1. **TimeLimiter** — bound every outbound call; prefer fail-fast over hanging threads.\n2. **Retry** — exponential backoff + jitter; only idempotent ops and transient faults (timeouts, 502/503/504), never business 4xx.\n3. **CircuitBreaker** — open on error-rate/slow-call thresholds; choose fail-fast vs fail-open explicitly.\n4. **Bulkhead / RateLimiter** — isolate concurrency so one dependency cannot starve the JVM.\n5. **YAML config** — named instances in `application.yml`; avoid magic defaults in code.\n6. **Metrics & health** — expose breaker state via Actuator/health already in-repo.\n\n## Implementation steps\n1. Inventory outbound calls; mark which are idempotent.\n2. Match existing Resilience4j / Spring Boot starter usage in-repo.\n3. Decorate with named `@TimeLimiter`, `@Retry`, `@CircuitBreaker`, `@Bulkhead` / `@RateLimiter`.\n4. Fallbacks return safe degraded responses or typed errors — never swallow exceptions.\n5. Wire YAML per instance; document fail-fast vs fail-open per dependency.\n6. Tests: open-circuit, retry exhaustion, fallback, no retries on non-idempotent calls.\n\n## Review checklist\n- End-to-end timeouts (client + resilience layer)\n- Retries gated on idempotency + transient errors only\n- CircuitBreaker thresholds and half-open behavior documented\n- Bulkhead/RateLimiter prevents thread-pool exhaustion\n- No silent catch-and-ignore; stable API/problem error mapping\n- Metrics/health visible; config in YAML not hardcoded literals\n\n## Done when\nNamed Resilience4j protection, YAML config, open-circuit/fallback tests, and a fail-fast vs fail-open note per dependency are in place." } ] }