Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions promptbook/prompts.json
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,26 @@
],
"formatNotes": "All three. Point the tool at `openapi/`, the API package, `pom.xml`/`build.gradle`, and security config. Copilot: path-scoped spring-openapi instructions plus the files. Claude Code: the spring-boot-openapi-contract-guardrails skill plus the module. Codex: AGENTS.md OpenAPI section, then the diff.",
"body": "Task: Scaffold or retrofit the Spring Boot API I specify so the OpenAPI contract is the source of truth. Produce a small diff plus a short verification note.\n\nContext placeholders (fill from the repo or ask only if missing):\n- OpenAPI spec path: {{SPEC}} (e.g. openapi/openapi.yaml)\n- Base package: {{PACKAGE}} (e.g. com.example.orders.api)\n- Module / Maven artifact: {{MODULE}}\n- API version prefix: {{API_VERSION}} (e.g. /api/v1)\n- springdoc starter: {{SPRINGDOC}} (springdoc-openapi-starter-webmvc-ui | webflux-ui | none-yet)\n- Auth scheme: {{AUTH}} (none | bearer-jwt | oauth2)\n\nRequirements:\n1. Inventory: list existing controllers, DTOs, exception handlers, and whether {{SPEC}} already exists. Note any entity leak or undocumented endpoints.\n2. Contract: create or update {{SPEC}} (OpenAPI 3) with paths under {{API_VERSION}}, components/schemas for each request/response, `application/problem+json` error responses, and {{AUTH}} security schemes applied to protected operations.\n3. Dependencies: add {{SPRINGDOC}} (or confirm present) and enable Problem Details. Keep the diff minimal — no unrelated starters.\n4. Code: under {{PACKAGE}}, add thin controllers matching the spec paths/methods, request/response DTOs (records preferred) with Bean Validation mirroring schema constraints, and a `@RestControllerAdvice` that returns `ProblemDetail` for validation and domain errors.\n5. Alignment: ensure field names, required flags, status codes, and media types match {{SPEC}}. Do not expose JPA entities. Prefer constructor binding / records over mutable anemic DTOs.\n6. Versioning: all new public routes live under {{API_VERSION}}; document the versioning rule in a short README section.\n7. Agent instruction files: add Copilot `.github/instructions/spring-openapi.instructions.md` with applyTo for controllers and OpenAPI YAML; Claude `.claude/skills/spring-boot-openapi-contract-guardrails/SKILL.md` (or a one-line CLAUDE.md pointer); and an OpenAPI section in `AGENTS.md`.\n8. Verification: add a test that loads the app (or MockMvc), fetches `/v3/api-docs` (or the committed YAML), and asserts key paths/schemas exist; optionally add an openapi-diff / golden-file check sketch in CI notes.\n\nOutput format:\n- Summary of changes (bullets)\n- Unified diff\n- Verification: commands to run tests and how to open Swagger UI / compare {{SPEC}} to `/v3/api-docs`\n- Risks / follow-ups (breaking changes deferred to a future major version, security on docs endpoints)\n\nConstraints: stay inside Java/Spring Boot; do not rewrite the service in another stack; do not change unrelated business logic; keep the diff reviewable and free of secrets.\n"
},
{
"id": "wire-llm-eval-regression-gate",
"title": "Wire an LLM Eval Regression Gate into CI",
"whenToUse": "Add or tighten a CI check that runs a pinned golden-set eval on prompt or model changes, compares against a committed baseline with tolerances and floors, and blocks the PR only on real regressions.",
"tools": [
"copilot",
"claude-code",
"codex"
],
"tags": [
"llm-eval",
"ci",
"github-actions",
"python",
"testing",
"quality-gates"
],
"formatNotes": "All three. Point the tool at `evals/`, `prompts/`, the LLM client package, model config, and `.github/workflows/` (or the Jenkinsfile). Copilot: llm-eval path instructions plus those files in agent mode. Claude Code: the llm-eval-ci-regression-gate skill plus the eval folder. Codex: AGENTS.md LLM evals section, then the diff.",
"body": "Task: Add (or tighten) an LLM eval regression gate in this repo's CI so prompt, model, retrieval, and tool-schema changes are scored on every PR and fail only on real regressions. Produce a small diff plus a short verification note.\n\nContext placeholders (fill from the repo or ask only if missing):\n- Eval entrypoint: {{EVAL_CMD}} (e.g. python -m evals.run --tier pr)\n- Golden set path: {{GOLDEN}} (e.g. evals/golden/core.jsonl)\n- Paths that change behaviour: {{WATCH_PATHS}} (e.g. prompts/**, src/app/llm/**, evals/**)\n- Model / deployment under test: {{MODEL}} (pinned version, not an alias)\n- Judge model (if any): {{JUDGE}} (pinned version, or none)\n- CI system: {{CI}} (github-actions | jenkins)\n- Provider auth in CI: {{AUTH}} (azure-oidc | env-secret)\n- Metrics and policy: {{METRICS}} (e.g. json_valid floor 1.0; label_accuracy floor 0.85 tol 0.03; safety_refusal floor 1.0)\n\nRequirements:\n1. Inventory: find the current eval code, golden data, model config, and CI workflows. Report what exists, what is unpinned, and whether any golden case contains real customer data or PII.\n2. Golden set: make sure {{GOLDEN}} has stable case ids and tags (happy-path, edge, safety, past-incident). Do not rewrite or delete existing cases; flag questionable ones in the report instead.\n3. Config pins: put {{MODEL}}, {{JUDGE}}, temperature, seed (where supported), samples per case (3 on PRs), and per-metric floor/tolerance/blocking flags in one config file. The runner must write these pins into its results file.\n4. Gate script: add `evals/gate.py` (Python, standard library plus what the repo already uses) that reads the results file and `evals/baseline.json`, computes per-metric aggregates across samples, and exits 1 when a blocking metric falls below its floor or drops more than its tolerance below baseline. For pass-rate metrics on fewer than ~200 cases, report a Wilson 95% interval next to the delta. Non-blocking (judge) metrics print a warning only.\n5. Baseline: if `evals/baseline.json` is missing, generate it from a run on the default branch and commit it separately with the config pins it came from. Never adjust the baseline in the same commit as a prompt or model change.\n6. Unit tests: pytest cases for gate.py covering pass, tolerance breach, floor breach, missing metric, and warn-only metric.\n7. CI wiring for {{CI}}:\n - GitHub Actions: workflow `.github/workflows/llm-eval.yml` on `pull_request` with `paths:` = {{WATCH_PATHS}}, plus a nightly `schedule` for the full tier. Top-level `permissions: contents: read` (add `id-token: write` only for azure-oidc, `pull-requests: write` only if it comments). Pin third-party actions to full commit SHAs. Skip secret-bearing steps when the PR comes from a fork. Set `timeout-minutes`, run {{EVAL_CMD}} then `python evals/gate.py`, upload the results file as an artifact, and append a Markdown table (metric, baseline, candidate, delta, verdict, worst failing ids) to `$GITHUB_STEP_SUMMARY`.\n - Jenkins: an equivalent stage with credentials bound only for that stage, `timeout`, archived results, and a failing build on gate exit 1.\n8. Agent instruction files: add Copilot `.github/instructions/llm-eval.instructions.md` with applyTo {{WATCH_PATHS}}; Claude `.claude/skills/llm-eval-ci-regression-gate/SKILL.md` (or a one-line CLAUDE.md rule); and an LLM evals section in `AGENTS.md` (or `evals/AGENTS.md`). Each one says: run the PR tier before claiming done, never edit the golden set or baseline alongside a prompt/model change, report the delta table.\n9. Docs: a short README section on running the eval locally, reading the summary, and the reviewed-PR process for updating the baseline.\n\nOutput format:\n- Summary of changes (bullets)\n- Unified diff\n- Verification: commands to run gate tests and a local PR-tier eval, plus a sample summary table\n- Risks / follow-ups (judge calibration still pending, cost per run, cases that need relabelling)\n\nConstraints: Python and the existing CI system only; no new eval SaaS or paid service without asking; no real secrets, tenant ids, or customer data in code, fixtures, or logs; keep the diff reviewable and do not change application behaviour.\n"
}
]
}
20 changes: 20 additions & 0 deletions skillbook/skills.json
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,26 @@
],
"formatNotes": "All three. Copilot: path-scoped `.github/instructions/spring-openapi.instructions.md` with applyTo `**/*Controller.java`, `**/openapi/**/*.{yaml,yml,json}`, `**/api/**/*.java`, and `**/dto/**/*.java`. Claude Code: `.claude/skills/spring-boot-openapi-contract-guardrails/SKILL.md` plus a one-line CLAUDE.md fact: OpenAPI YAML is source of truth; controllers and DTOs must match; errors are problem+json. Codex: an OpenAPI / API Contracts section in root `AGENTS.md` or linked `docs/agents/openapi.md`. Pair with spring-boot-actuator-hardening for docs-endpoint exposure; this skill owns contract fidelity.",
"body": "# Skill: Spring Boot OpenAPI Contract Guardrails\n\n## Goal\nREST APIs whose published OpenAPI 3 document is the source of truth — request/response shapes, validation, error media type, and versioning stay aligned with the running Spring Boot code.\n\n## When to apply\n- New Spring Boot services exposing HTTP APIs, or reviews that touch controllers, DTOs, or OpenAPI YAML\n- Migrations from code-first annotation sprawl to a maintained contract under `openapi/`\n- Client or partner integration work where a breaking schema change would ship unnoticed\n\n## Baseline rules\n1. **Contract first.** Keep an OpenAPI 3.0/3.1 document in the repo (e.g. `openapi/openapi.yaml`). Treat it as the source of truth for paths, methods, status codes, media types, and schemas. Generate or hand-write controllers and DTOs to match — do not invent fields in Java that are absent from the spec (or vice versa).\n2. **springdoc (or equivalent) stays honest.** Prefer springdoc-openapi to serve `/v3/api-docs` and Swagger UI from the running app. If you use annotation overlays (`@Operation`, `@Schema`), they must not contradict the YAML. Fail CI when the served document drifts from the committed contract (diff against a golden file or an openapi-diff step).\n3. **DTOs match schemas.** Map every request/response schema to a dedicated record/class. Use Jakarta Bean Validation (`@NotNull`, `@Size`, `@Email`, `@Pattern`, `@Valid` on nested objects) that mirrors `required`, `minLength`/`maxLength`, `pattern`, and `format` in the OpenAPI schema. Prefer records or immutable types; avoid exposing JPA entities on the wire.\n4. **Controllers are thin.** `@RestController` methods accept/return DTOs only, declare explicit `@RequestMapping`/`@GetMapping` paths and produces/consumes, and map to the versioned base path from the contract (`/api/v1/...`). No business logic in the controller — delegate to a service.\n5. **Errors are `application/problem+json`.** Enable Spring Problem Details (`spring.mvc.problemdetails.enabled=true` or WebFlux equivalent). Use `@RestControllerAdvice` returning `ProblemDetail` (or a documented subtype) for 4xx/5xx. Document error responses in the OpenAPI with `content.application/problem+json` and a Problem schema — do not leave error bodies as unspecified `application/json`.\n6. **Version deliberately.** Put the major version in the URL (`/api/v1`). Additive changes (new optional fields, new endpoints) stay in the same major; breaking changes get a new major and a deprecation window. Never silently rename or remove a required field.\n7. **Security and docs endpoints are explicit.** Document auth schemes (`bearer`, OAuth2) in the OpenAPI `components.securitySchemes` and apply them per operation. If Swagger UI / `/v3/api-docs` are exposed, gate them behind profile or Spring Security rules appropriate for the environment (see actuator hardening for management-port patterns).\n8. **Instruction files for coding agents.** Keep path-scoped Copilot instructions on controllers and OpenAPI YAML; a Claude skill for this checklist; and an AGENTS.md OpenAPI section so agents regenerate or edit against the contract instead of freelancing shapes.\n\n## Review checklist\n- [ ] Committed OpenAPI YAML covers every public endpoint (path, method, status, media type)\n- [ ] Request/response DTOs and Bean Validation match schema `required` / constraints\n- [ ] Controllers use versioned base path; no entity leak onto the API\n- [ ] Error responses documented and returned as `application/problem+json`\n- [ ] CI fails on contract drift (golden `/v3/api-docs` or openapi-diff)\n- [ ] Security schemes declared; docs UI not wide-open in production\n- [ ] Agent instruction files point at controllers + OpenAPI paths\n\n## Anti-patterns\n- Returning JPA entities or `Map<String,Object>` from controllers\n- `@ApiResponse` / springdoc annotations that disagree with the committed YAML\n- Undocumented 500 HTML error pages or ad-hoc `{ \"message\": \"...\" }` JSON\n- Breaking field renames without a `/api/v2` and a deprecation note\n"
},
{
"id": "llm-eval-ci-regression-gate",
"title": "LLM Eval CI Regression Gate",
"whenToUse": "Wiring or reviewing a CI job that scores prompt, model, retrieval, or tool-schema changes against a versioned golden set and fails the PR only on real regressions — baseline + tolerance, absolute floors, multi-sample runs, pinned model versions, and least-privilege workflow wiring.",
"tools": [
"copilot",
"claude-code",
"codex"
],
"tags": [
"llm-eval",
"ci",
"github-actions",
"python",
"testing",
"quality-gates"
],
"formatNotes": "All three. Copilot: path-scoped `.github/instructions/llm-eval.instructions.md` with applyTo `prompts/**,evals/**,**/llm/**` (optional `.github/skills/llm-eval-ci-regression-gate/SKILL.md`). Claude Code: `.claude/skills/llm-eval-ci-regression-gate/SKILL.md` plus a one-line CLAUDE.md rule that prompt/model changes must pass the eval gate and must not touch the golden set or baseline. Codex: an LLM evals section in root `AGENTS.md` or a nested `evals/AGENTS.md`. Pair with llm-eval-agent-workflow for agent rubrics and gha-oidc-azure-guardrails for keyless Azure OpenAI access; this skill owns the CI gate.",
"body": "# Skill: LLM Eval CI Regression Gate\n\n## Goal\nEvery change that can move model behaviour — prompt text, model or deployment version, retrieval settings, tool schemas, or the code around them — is scored against a versioned golden set in CI, and the pull request fails only on a real regression, not on sampling noise.\n\n## When to apply\n- Repos that ship LLM features (RAG, classifiers, extractors, agents) with prompts or model config under version control\n- Adding or tightening an eval job in GitHub Actions or Jenkins for a Python eval harness (pytest, a custom runner, or an existing eval CLI)\n- Reviews of PRs that touch `prompts/`, model/deployment names, temperature, retrieval top-k, or tool definitions\n\n## Baseline rules\n1. **Golden set lives in Git.** Keep cases in `evals/golden/*.jsonl` with a stable `id`, `input`, expected output or reference, and `tags` (happy-path, edge, safety, past-incident). Version the set; changing it is a reviewed PR, never a side effect of a feature change. No real customer data or PII/PHI — synthesize or redact.\n2. **Two tiers.** A PR tier (roughly 50–200 cases, minutes, bounded cost) runs on pull requests; a full tier (hundreds or more, multi-sample) runs nightly and before release. Trigger the PR tier with path filters on prompts, model config, eval code, and the LLM client package.\n3. **Deterministic checks block; judges earn their way in.** Schema/JSON validity, required fields, exact-match labels, regex or allow-list checks, refusal on safety cases, and latency/token budgets are hard gates. LLM-as-judge metrics start as warnings until they agree with a human-labelled sample; then use a binary pass/fail rubric with structured JSON output, not a 1–10 score.\n4. **Pin everything that moves.** Pin the model/deployment version (and the judge's), API version, temperature, seed where supported, dataset version, and harness version. Record them in the results file so a diff in scores can be traced to a diff in config.\n5. **Compare to a baseline, keep a floor.** Commit `evals/baseline.json` with per-metric aggregates from the last accepted run. Fail when a metric drops more than its tolerance below baseline **or** falls under an absolute floor (safety metrics: floor only, zero tolerance). Updating the baseline is its own reviewed commit with before/after numbers.\n6. **Respect the noise floor.** Run each non-deterministic case N times (3–5 on PRs) and aggregate. On small sets, judge pass-rate deltas with a Wilson interval or a paired comparison against the base branch rather than a raw point difference — a few points on 50 cases is usually noise.\n7. **Gate wiring is least-privilege.** The eval job sets explicit `permissions:` (`contents: read`, plus `pull-requests: write` only if it comments), prefers OIDC to Azure over long-lived keys, reads provider secrets from the environment, and never runs secret-bearing evals on untrusted fork code. Set a timeout and a per-run spend cap; make the job a required status check.\n8. **Evidence on every run.** Write a machine-readable results file (per-case outcome, scores, config pins), upload it as an artifact, and print a short Markdown summary to the job summary: metric, baseline, candidate, delta, verdict, and the worst failing case ids. Exit non-zero on regression.\n9. **Instruction files for coding agents.** Agents editing prompts or model config must run the PR tier locally (or say why they could not), must not edit the golden set or baseline in the same change, and must report the delta table.\n\n## Review checklist\n- [ ] Golden set versioned in Git, tagged, free of real PII/PHI\n- [ ] PR tier path-filtered and bounded; full tier scheduled\n- [ ] Deterministic checks are blocking; judge metrics calibrated or warn-only\n- [ ] Model, judge, temperature, seed, dataset, and harness versions pinned and recorded\n- [ ] Baseline file + per-metric tolerance + absolute floors; safety has zero tolerance\n- [ ] Multi-sample aggregation; small-set deltas judged with an interval, not a point diff\n- [ ] Workflow `permissions:` minimal, OIDC or env secrets, no secrets on fork PRs, timeout + spend cap\n- [ ] Results artifact + job summary; non-zero exit on regression; required check enabled\n- [ ] Agent instructions forbid editing golden set/baseline alongside prompt changes\n\n## Example layout\n```\nevals/\n golden/core.jsonl # versioned cases\n baseline.json # accepted per-metric aggregates\n gate.py # compare results vs baseline, exit 1 on regression\n config.yaml # model, judge, temperature, seed, samples, tolerances\n.github/workflows/llm-eval.yml\n```\n\n## Gate policy sketch (`evals/config.yaml`)\n```yaml\nsamples_per_case: 3\nmetrics:\n json_valid: { floor: 1.00, tolerance: 0.00, blocking: true }\n label_accuracy: { floor: 0.85, tolerance: 0.03, blocking: true }\n safety_refusal: { floor: 1.00, tolerance: 0.00, blocking: true }\n judge_faithful: { floor: 0.75, tolerance: 0.05, blocking: false } # warn until calibrated\n```\n\n## Tool placement\n- **GitHub Copilot:** path-scoped `.github/instructions/llm-eval.instructions.md` with `applyTo: \"prompts/**,evals/**,**/llm/**\"`; optionally the same checklist as `.github/skills/llm-eval-ci-regression-gate/SKILL.md`.\n- **Claude Code:** `.claude/skills/llm-eval-ci-regression-gate/SKILL.md` (frontmatter `name`, `description`) plus one CLAUDE.md line: prompt/model changes must pass `evals/gate.py`; never edit golden set or baseline in the same PR.\n- **Codex:** an \"LLM evals\" section in root `AGENTS.md`, or a nested `evals/AGENTS.md` that applies to that subtree.\n\n## Anti-patterns\n- A single-sample run with a fixed absolute threshold that flips red on noise and gets ignored\n- Bumping the baseline or deleting failing cases in the same PR that caused the drop\n- Unpinned \"latest\" model aliases for the app or the judge\n- Judge scores on a 1–10 scale gating merges with no human calibration\n- Eval job with `write-all` permissions or provider keys exposed to fork PRs\n"
}
]
}
Loading