diff --git a/promptbook/prompts.json b/promptbook/prompts.json index 01416a7..0f8824f 100644 --- a/promptbook/prompts.json +++ b/promptbook/prompts.json @@ -160,6 +160,24 @@ ], "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)" + }, + { + "id": "characterization-tests-before-refactor", + "title": "Characterization Tests Before Refactor", + "whenToUse": "About to refactor messy code and need lock-in tests so behavior does not silently change.", + "tools": [ + "copilot", + "claude-code", + "codex" + ], + "tags": [ + "testing", + "refactor", + "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}}" } ] -} +} \ No newline at end of file diff --git a/skillbook/skills.json b/skillbook/skills.json index c732eab..d4d1ba2 100644 --- a/skillbook/skills.json +++ b/skillbook/skills.json @@ -162,6 +162,24 @@ ], "formatNotes": "All three. Copilot: path-scoped `.github/instructions/bicep.instructions.md` with applyTo `**/*.{bicep,bicepparam}`. Claude Code: `.claude/skills/azure-bicep-guardrails/SKILL.md`. Codex: nested `infra/AGENTS.md` or root `AGENTS.md` Azure IaC section.", "body": "# Skill: Azure Bicep IaC Guardrails\n\n## Goal\nProduce Bicep that is least-privilege, parameterized, and safe to review before Azure deployment.\n\n## When to apply\n- New or changed `.bicep` / `.bicepparam` modules\n- Reviews of infra PRs that touch resource IDs, RBAC, networking, or secrets\n\n## Rules\n1. Prefer modules with clear inputs/outputs; avoid giant monolithic main files when the repo already uses modules.\n2. Parameterize environment-specific values (names, SKUs, CIDRs); never hardcode subscription IDs or secrets in committed params.\n3. Use `@secure()` for secrets and Key Vault references where the pattern already exists; never echo secure params in outputs.\n4. Scope RBAC to the narrowest principal and role; prefer role assignments at resource/RG scope over subscription-wide.\n5. Explicitly set required tags used by the platform (owner, env, cost-center) when the repo already expects them.\n6. Prefer existing verified modules / patterns in-repo over inventing new resource types.\n7. For public endpoints: justify exposure; prefer private endpoints / VNet integration when sibling modules do.\n8. Keep API versions pinned and consistent with neighboring modules; do not float to latest without a reason.\n\n## Review checklist\n- What resources are created/updated/deleted?\n- Any wildcard `*` permissions or Owner assignments?\n- Are diagnostics / logging hooks aligned with existing modules?\n- Are dependsOn / existing resource references correct?\n- What is the rollback story if deploy fails mid-way?\n\n## Constraints\n- Do not invent tenant, subscription, or object IDs — use parameters or existing symbols.\n- Do not weaken network or RBAC controls \"just to make deploy work\".\n- Prefer what-if / validation commands the repo already documents.\n\n## Output format\n- Summary of modules/files touched\n- Bicep diffs ready to apply\n- Parameter changes (names only for secrets)\n- Validation commands (`az bicep build`, what-if, or repo scripts)\n- Residual risks" + }, + { + "id": "container-image-hardening", + "title": "Container Image Hardening", + "whenToUse": "Writing or reviewing Dockerfiles / OCI image builds destined for AKS or other Kubernetes.", + "tools": [ + "copilot", + "claude-code", + "codex" + ], + "tags": [ + "docker", + "containers", + "supply-chain", + "security" + ], + "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)" } ] -} +} \ No newline at end of file