From d6f777149594cbbb527b5ce4fc3df77ef300fe84 Mon Sep 17 00:00:00 2001 From: rmkr-dev Date: Fri, 11 Sep 2026 05:06:56 +0000 Subject: [PATCH] Add Key Vault skill and secrets migration prompt Extend Skillbook with Azure Key Vault app integration guidance and Promptbook with a safe secrets-to-Key-Vault migration task for Copilot, Claude Code, and Codex. --- promptbook/prompts.json | 21 ++++++++++++++++++++- skillbook/skills.json | 20 +++++++++++++++++++- 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/promptbook/prompts.json b/promptbook/prompts.json index 0f8824f..21e07c2 100644 --- a/promptbook/prompts.json +++ b/promptbook/prompts.json @@ -178,6 +178,25 @@ ], "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", + "title": "Migrate Secrets Into Key Vault", + "whenToUse": "You found credentials in config, manifests, or code and want a safe, reviewable migration into Azure Key Vault.", + "tools": [ + "copilot", + "claude-code", + "codex" + ], + "tags": [ + "azure", + "key-vault", + "secrets", + "security", + "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" } ] -} \ No newline at end of file +} diff --git a/skillbook/skills.json b/skillbook/skills.json index d4d1ba2..2393b6e 100644 --- a/skillbook/skills.json +++ b/skillbook/skills.json @@ -180,6 +180,24 @@ ], "formatNotes": "All three. Copilot: path-scoped `.github/instructions/docker.instructions.md` with applyTo for `**/Dockerfile*`, `**/*Containerfile*`, `**/docker-compose*.{yml,yaml}`. Claude Code: `.claude/skills/container-image-hardening/SKILL.md` (YAML name + keyword-rich description). Codex: section in root or `deploy/AGENTS.md`, or `.agents/skills/container-image-hardening/SKILL.md`.", "body": "# Skill: Container Image Hardening\n\n## Goal\nProduce lean, reproducible, least-privilege container images that are safe to run on AKS (or similar).\n\n## When to apply\n- New or changed Dockerfile / Containerfile / buildah scripts\n- Multi-stage builds, base-image upgrades, or image used by a Deployment\n\n## Hardening checklist (apply in order)\n1. **Pin bases**: digest-pin (`@sha256:…`) or immutable tags used by the platform; never `:latest` in production paths.\n2. **Multi-stage**: build in a fat stage; copy only runtime artifacts into a minimal final stage.\n3. **Non-root**: final USER is a non-root uid/gid; avoid running as root even if the orchestrator could override.\n4. **No secrets in layers**: never COPY `.env`, key files, or `npmrc` with tokens; use BuildKit secrets / runtime mounts.\n5. **Minimal attack surface**: no unused shells/package managers in the final image when feasible; drop build tools from runtime.\n6. **Health signal**: document the process model (PID 1, signal handling); prefer a dumb-init/tini only if the stack already uses it.\n7. **Metadata**: useful OCI labels (`org.opencontainers.image.*`) without leaking internal hostnames or personal data.\n8. **Supply chain**: generate or consume SBOM when the pipeline expects it; note image scan gate before promote.\n\n## Dockerfile patterns\n- Prefer `COPY --from=build` of exact paths over copying the whole build context into runtime.\n- Order layers for cache: dependency manifests before source.\n- `RUN` apt/apk with cleanup in the same layer; pin package versions when the repo already does.\n- Expose only required ports; do not bake environment-specific URLs into the image when config can be runtime.\n\n## Constraints\n- Do not invent private base images or registries that are not evidenced in-repo.\n- Do not weaken existing IMAGE signing / admission policy for convenience.\n- Keep local `docker build` / `buildx` commands accurate for this repo.\n\n## Output format\n- Patched Dockerfile(s) or clear unified diff\n- Table: control → status (pass/fail/n/a) → note\n- Suggested scan/SBOM commands matching repo CI\n- Residual risks (base CVEs, privileged bits, secret leakage)" + }, + { + "id": "azure-key-vault-app-integration", + "title": "Azure Key Vault App Integration", + "whenToUse": "Wiring an app or service to Azure Key Vault for secrets, certificates, or keys — or reviewing a PR that still embeds credentials.", + "tools": [ + "copilot", + "claude-code", + "codex" + ], + "tags": [ + "azure", + "key-vault", + "secrets", + "security" + ], + "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)" } ] -} \ No newline at end of file +}