diff --git a/promptbook/prompts.json b/promptbook/prompts.json index 444f516..3f2d16c 100644 --- a/promptbook/prompts.json +++ b/promptbook/prompts.json @@ -370,6 +370,27 @@ ], "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" + }, + { + "id": "review-spring-data-jpa-queries", + "title": "Review These Spring Data JPA Queries", + "whenToUse": "You need a PR-ready review or refactor of Spring Data JPA repositories, entity fetch plans, and service-layer query usage \u2014 N+1, pagination, projections, @Query safety, and index notes.", + "tools": [ + "copilot", + "claude-code", + "codex" + ], + "tags": [ + "java", + "spring-boot", + "spring-data-jpa", + "sql", + "performance", + "hibernate", + "review" + ], + "formatNotes": "All three. Point the tool at the repository package, entity package, and the service/controller call sites first. Prefer fixing fetch plans and projections over enabling open-in-view. Copilot: apply path-scoped instructions for `**/*Repository.java` and entity packages.", + "body": "Task: Review and harden Spring Data JPA queries and fetch plans for the feature I specify. Eliminate N+1 and pagination traps; prefer DTO projections on read paths; keep @Query parameterized and transactional boundaries clear.\n\nContext placeholders (fill from the repo or ask only if missing):\n- Module / package root: {{PACKAGE_ROOT}} (e.g. com.example.orders)\n- Primary entities: {{ENTITIES}} (comma-separated)\n- Hot endpoints or use cases: {{USE_CASES}} (e.g. list orders, order detail, admin search)\n- Pagination style required: {{PAGINATION}} (Page | Slice | keyset | none)\n- Max page size: {{MAX_PAGE_SIZE}}\n- Open-in-view policy: {{OPEN_IN_VIEW}} (off | on-legacy | unknown)\n- Soft-delete in play: {{SOFT_DELETE}} (yes | no | unknown)\n- DB dialect: {{DB_DIALECT}} (PostgreSQL | MySQL | SQL Server | other)\n- Query-budget test harness available: {{QUERY_BUDGET}} (datasource-proxy | Hibernate statistics | none)\n\nRequirements:\n\n1. Inventory\n - Repositories under {{PACKAGE_ROOT}} touching {{ENTITIES}}\n - FetchType on associations; existing `@EntityGraph`, `JOIN FETCH`, `@BatchSize`\n - Call sites for {{USE_CASES}} (controller \u2192 service \u2192 repository)\n - Any `Pageable` + collection fetch combinations; `findAll` without bounds\n - Native/`@Query` strings; modifying queries; soft-delete filters if {{SOFT_DELETE}}=yes\n\n2. Design\n - Per {{USE_CASES}}: projection vs entity graph vs fetch join vs batch fetch\n - If {{PAGINATION}} needs collections: two-step ID page then fetch-by-ids (never collection JOIN FETCH + Pageable)\n - Cap page size at {{MAX_PAGE_SIZE}}; whitelist sort properties\n - Respect {{OPEN_IN_VIEW}}: if off/unknown, fetch or project inside `@Transactional(readOnly = true)`\n - Index notes for new WHERE/ORDER BY under {{DB_DIALECT}}\n - If {{QUERY_BUDGET}} \u2260 none: add or outline a statement-count assertion for the hottest list path\n\n3. Author artifacts (prefer concrete diffs)\n - Repository method changes (`@EntityGraph`, `@Query`, projections)\n - Service transaction + DTO mapping adjustments\n - Optional Flyway/Liquibase index stub only if filters changed (do not invent unrelated schema)\n - Test sketches: result correctness + query budget when {{QUERY_BUDGET}} allows\n\n4. Verification\n - Explain why N+1 is gone for {{USE_CASES}}\n - Confirm no HHH90003004-style in-memory pagination\n - Grep: no entity returns on public API for list paths; no string-concat query parameters\n - Soft-delete + uniqueness notes if {{SOFT_DELETE}}=yes\n\nConstraints:\n- Do not invent schema or indexes unrelated to {{USE_CASES}}.\n- Minimal diff; match existing repository style (derived vs `@Query`).\n- No enabling open-in-view as a \u201cfix\u201d for LazyInitializationException.\n- Optimize for GitHub Copilot, Claude Code, and Codex \u2014 concrete Java and checklists.\n\nOutput format:\n1. Plan (fetch strategy per use case)\n2. Code diffs (repository/service/DTO)\n3. Index / migration notes (if any)\n4. Verification checklist + query-budget evidence\n5. Residual risks (cartesian joins, soft-delete, count query cost)\n\nStart from repositories and entities under {{PACKAGE_ROOT}}. Prefer projections and explicit fetch plans over EAGER mappings or open-in-view.\n" } ] } diff --git a/skillbook/skills.json b/skillbook/skills.json index 192041e..cd1a91b 100644 --- a/skillbook/skills.json +++ b/skillbook/skills.json @@ -369,6 +369,26 @@ ], "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" + }, + { + "id": "spring-data-jpa-query-guardrails", + "title": "Spring Data JPA Query Guardrails", + "whenToUse": "Designing, reviewing, or refactoring Spring Data JPA repositories, entity mappings, and service-layer query usage — especially list/detail endpoints, reports, or any path where N+1, over-fetch, or unsafe @Query patterns may appear.", + "tools": [ + "copilot", + "claude-code", + "codex" + ], + "tags": [ + "java", + "spring-boot", + "spring-data-jpa", + "sql", + "performance", + "hibernate" + ], + "formatNotes": "All three. Copilot: path-scoped `.github/instructions/spring-data-jpa-query.instructions.md` with applyTo for `**/repository/**/*.java`, `**/entity/**/*.java`, `**/*Repository.java`, and persistence YAML. Claude Code: `.claude/skills/spring-data-jpa-query-guardrails/SKILL.md` plus a one-line CLAUDE.md fact on lazy-by-default and no collection fetch+Pageable. Codex: `AGENTS.md` persistence section or linked `docs/agents/spring-data-jpa.md`.", + "body": "# Skill: Spring Data JPA Query Guardrails\n\n## Goal\nShip Spring Data JPA access that is correct, lean, and predictable under production data volumes — no accidental N+1, no in-memory pagination traps, no entity leakage at API boundaries, and query plans that match indexes and use cases.\n\n## When to apply\n- New or changed `JpaRepository` / `@Query` / Specifications / Criteria\n- Entity mapping changes (`@OneToMany`, `@ManyToOne`, embeddables, soft-delete filters)\n- List/detail REST or batch jobs that traverse associations\n- Reviews mentioning slow endpoints, high DB CPU, `HHH90003004`, LazyInitializationException, or cartesian explosions\n- Migrations that add columns/indexes used by hot queries (pair with Flyway guardrails when schema changes)\n\n## Baseline rules\n1. **Associations lazy by default.** Map `@ManyToOne` / `@OneToOne` / collections as `FetchType.LAZY`. Override EAGER defaults explicitly. Opt into loading per use case with fetch joins, `@EntityGraph`, or batch fetch — never by leaving EAGER on the mapping.\n2. **Kill N+1 deliberately.** Prefer `@EntityGraph(attributePaths = …)` or JPQL `JOIN FETCH` for associations you always need on that path. For list views with collections, prefer `@BatchSize` / `hibernate.default_batch_fetch_size` or a two-step ID query over silent per-row selects. Assert a query budget in tests (statement count or datasource proxy) for hot paths.\n3. **Never combine collection `JOIN FETCH` with `Pageable`.** Hibernate warns (`HHH90003004`) and paginates in memory. Use: (a) page entity IDs first, then `JOIN FETCH` / entity graph for those IDs; or (b) `@EntityGraph` / batch fetch without collection fetch join on the paged query; or (c) DTO projection that does not inflate rows.\n4. **Projections for reads.** Closed interface or class-based DTO projections (constructor expressions / `@SqlResultSetMapping` when needed) for list and report endpoints. Do not return managed entities (or open SpEL projections that force full entity load) from public APIs.\n5. **`@Query` safety.** Prefer parameterized JPQL/SQL (`:name` / `?1`) — never string-concatenated user input. For modifying queries use `@Modifying(clearAutomatically = true, flushAutomatically = true)` and call from a transactional service. Document native SQL dialect assumptions. Avoid `SELECT *` entity natives that skip the persistence context contract unless reviewed.\n6. **Transactional boundaries.** Read paths: `@Transactional(readOnly = true)` on the service method that owns the session through mapping. Do not touch lazy collections in controllers after the session closes — map to DTOs inside the transaction or use Open-in-view only if the project already standardizes it (prefer off + explicit fetch). Write paths: one clear transactional service method; no repository calls from controllers that start implicit transactions inconsistently.\n7. **Pagination contracts.** Always pass `Pageable` (or keyset/`Slice` when appropriate) for unbounded lists. Cap `size` at the API layer. Prefer `Slice` when total count is expensive and not required. Sort only on whitelisted properties.\n8. **Indexing and explain awareness.** For every new filter/sort/join used in production paths, confirm a supporting index exists or is added in the same change set. Mentally (or via `EXPLAIN`) check selectivity; avoid leading-wildcard `LIKE` and functions on indexed columns in hot queries.\n9. **Soft-delete and filters.** If using `@SQLRestriction` / `@Where` / `@SoftDelete`, ensure count queries, unique constraints, and admin “include deleted” paths are intentional. Soft-delete + unique natural keys need partial unique indexes or equivalent.\n10. **Batching writes.** For bulk inserts/updates, enable JDBC batching (`hibernate.jdbc.batch_size`, order inserts/updates) and avoid flush-per-entity loops. Prefer set-based `@Modifying` queries for mass updates when entity lifecycle listeners are not required.\n11. **One collection fetch at a time.** Fetching two bag collections in one query causes cartesian products. Split queries or use batch fetch for the second collection.\n12. **Equals/hashCode discipline.** Do not use mutable fields or lazy associations in `equals`/`hashCode` for entities; prefer business keys carefully or ID-after-persist patterns already used in-repo.\n\n## Workflow\n1. Inventory repositories, entity graphs, and call sites for the feature (list vs detail vs write).\n2. Decide fetch strategy per use case: projection vs entity graph vs fetch join vs batch size.\n3. Author or adjust repository methods; keep derived query names honest; add `@EntityGraph` / `@Query` only when needed.\n4. Ensure service transaction + DTO mapping; no entity JSON serialization of lazy graphs.\n5. Add/adjust indexes with schema migration if filters changed.\n6. Add characterization or slice tests: correct results + query-count ceiling on the hot path.\n7. PR notes: fetch strategy, pagination approach, index changes, residual N+1 risk.\n\n## Tool-specific notes\n### GitHub Copilot\n- Path-scoped `.github/instructions/spring-data-jpa-query.instructions.md` with `applyTo` for repositories, entities, and persistence config.\n- Always-on: lazy associations; no collection JOIN FETCH + Pageable; DTOs at API boundary.\n- Extend existing repository patterns; do not introduce a second persistence style without cause.\n\n### Claude Code\n- Procedure in `.claude/skills/spring-data-jpa-query-guardrails/SKILL.md`.\n- CLAUDE.md fact: \"JPA associations are LAZY; list endpoints use projections or two-step ID fetch — never collection fetch join with Pageable.\"\n- Before claiming done, show SQL (log or test) and confirm query count for the list path.\n\n### Codex\n- `AGENTS.md` persistence section: N+1 rules, pagination trap, projection preference, `@Query` parameterization.\n- Link to this skill when root AGENTS.md would bloat.\n\n## Anti-patterns\n- `FetchType.EAGER` on `@ManyToOne` “for convenience”\n- Collection `JOIN FETCH` + `Pageable` on the same repository method\n- Returning JPA entities from REST controllers (especially with open-in-view papering over LazyInitializationException)\n- Open SpEL interface projections that load full entities\n- String-concatenated native SQL or JPQL from request parameters\n- `findAll()` without pagination on user-facing APIs\n- Touching lazy collections in `@Async` / event listeners after the session ended\n- Dual bag `JOIN FETCH` in one query (cartesian blow-up)\n- Relying on `spring.jpa.open-in-view=true` as the fetch strategy\n- Missing indexes for new WHERE/ORDER BY on hot paths\n- Soft-delete filters that break unique constraints or admin undelete without a plan\n\n## Verification checklist\n- [ ] Associations are LAZY unless a documented exception exists\n- [ ] Hot list path has no N+1 (query budget test or logged SQL review)\n- [ ] No collection fetch join combined with Pageable\n- [ ] API responses use DTOs/projections, not raw entities\n- [ ] All `@Query` / native SQL uses bind parameters\n- [ ] Read service methods are `readOnly` transactional where appropriate\n- [ ] Page/Slice size capped; sorts whitelisted\n- [ ] Indexes cover new filter/sort columns (migration linked)\n- [ ] Soft-delete behavior verified for counts and uniqueness\n- [ ] Bulk paths use batching or set-based updates when applicable\n\n## Copy-ready SKILL.md stub\n```markdown\n---\nname: spring-data-jpa-query-guardrails\ndescription: Use when designing or reviewing Spring Data JPA repositories and entity fetch plans — N+1, entity graphs vs fetch joins, pagination traps, DTO projections, @Query safety, transactions, indexing.\n---\n\nFollow Spring Data JPA Query Guardrails: LAZY associations, deliberate fetch plans, no collection JOIN FETCH with Pageable, DTOs at the API boundary, parameterized queries, verify SQL and query counts on hot paths.\n```\n" } ] }