Skip to content

Examples and guides for using the OpenAI API

Add mandatory docs-editor review gate (#2862)

Vaibhav Srivastavd9e5840b4b4e
diff --git a/.codex/skills/docs-editor/SKILL.md b/.codex/skills/docs-editor/SKILL.md
new file mode 100644
index 00000000..223ded9d
--- /dev/null
+++ b/.codex/skills/docs-editor/SKILL.md
@@ -0,0 +1,84 @@
+---
+name: docs-editor
+description: Review and edit OpenAI Cookbook notebooks, Markdown, and MDX for technical accuracy, clarity, grammar, consistency, runnable examples, and repository publication requirements. Use for editorial reviews, pre-merge documentation checks, or notebook Markdown-cell sweeps in openai-cookbook.
+---
+
+# OpenAI Cookbook docs editor
+
+## Objective
+
+Review Cookbook content conservatively. Improve correctness and readability without changing the author's intent, inventing facts, or creating unrelated churn.
+
+## Workflow
+
+### 1. Define the scope
+
+- Prefer explicit paths or the files changed in the pull request.
+- For pull requests, review changed `.md` and `.mdx` files plus Markdown cells in changed `.ipynb` files.
+- Review `registry.yaml` and `authors.yaml` when content is added, moved, removed, or attributed to a new author.
+- Stay within the requested content. Do not turn a focused review into a repository-wide rewrite.
+
+### 2. Protect notebook integrity
+
+- When the request is editorial, edit only notebook Markdown cells.
+- Preserve code cells, outputs, execution counts, attachments, cell order, cell IDs, and notebook and cell metadata.
+- Avoid reserializing an entire notebook for a small prose change. Inspect the diff for unintended JSON churn.
+- Do not execute notebook code unless the user requests it or code changes are in scope. Markdown-only edits require structural validation, not calls to external services.
+- Never add hard-coded secrets. Document required environment variables such as `OPENAI_API_KEY`.
+
+### 3. Review the content
+
+Load `resources/style-guide.md` and check:
+
+- Technical claims, API names, model names, identifiers, commands, paths, and URLs.
+- Agreement between prose, code, sample inputs, and expected outputs.
+- Prerequisites, dependencies, environment variables, and steps needed to run an example.
+- File and notebook names, headings, lists, numbering, cross-references, and links.
+- Grammar, spelling, punctuation, terminology, capitalization, and concise wording.
+- Publication metadata in `registry.yaml` and author metadata in `authors.yaml` when applicable.
+
+Verify uncertain technical claims from an authoritative source or flag them for review. Do not guess.
+
+### 4. Prioritize findings
+
+Use the repository's review bar:
+
+- **P0**: Broken notebook JSON; hard-coded secrets; materially false or unsafe guidance; or any repository-defined P0 issue, including naming violations, typos, broken links, inconsistent formatting, placeholder identifiers, undocumented environment variables, or out-of-sync publication metadata.
+- **P1**: Misleading instructions, prose that contradicts code or output, missing prerequisites, or a required link that does not work.
+- **P2**: Clear improvements to grammar, consistency, organization, or readability that do not affect correctness.
+- **P3**: Optional polish with little effect on comprehension.
+
+### 5. Make safe edits
+
+- Fix obvious typos, grammar, punctuation, broken local references, and clear prose/code mismatches.
+- Keep changes minimal, local, and reversible.
+- Preserve exact literals, code identifiers, commands, values, counts, conditions, modality, negation, and uncertainty markers.
+- Tighten prose only when meaning stays unchanged. Prefer concrete nouns, strong verbs, short introductions, and direct instructions.
+- Flag any change that depends on product knowledge or could alter meaning instead of guessing.
+- Do not make file-wide formatting or stylistic changes solely for uniformity.
+
+### 6. Validate the result
+
+For any changed notebook, run the repository validator:
+
+```bash
+env -u VIRTUAL_ENV uv run --with nbformat python .github/scripts/check_notebooks.py
+```
+
+Then:
+
+- Run `git diff --check`.
+- Inspect the diff and confirm that notebook changes are limited to intended Markdown cells.
+- Run an available YAML linter if `registry.yaml` or `authors.yaml` changed.
+- Run the relevant example or test only when executable content changed and its dependencies are available.
+
+### 7. Report the review
+
+Provide:
+
+- A short summary of the scope and edits.
+- Auto-fixed items.
+- Remaining findings grouped by priority with file and cell or line references.
+- The validation commands run and their results.
+
+If no issues remain, say so explicitly.
diff --git a/.codex/skills/docs-editor/resources/style-guide.md b/.codex/skills/docs-editor/resources/style-guide.md
new file mode 100644
index 00000000..3fd8e510
--- /dev/null
+++ b/.codex/skills/docs-editor/resources/style-guide.md
@@ -0,0 +1,80 @@
+# OpenAI Cookbook editorial checklist
+
+Use this checklist for articles and notebook Markdown cells in `openai-cookbook`. Apply only the rules relevant to the content under review.
+
+## Audience and purpose
+
+- Write for developers who want to understand and run an OpenAI API example.
+- State the task or outcome early. Keep background material only when it helps the reader use the example correctly.
+- Assume general programming knowledge, but explain Cookbook-specific setup, choices, and tradeoffs.
+- Avoid promotional language, vague praise, and claims that the example does not demonstrate.
+
+## Technical accuracy
+
+- Match API, model, method, parameter, field, file, and environment-variable names exactly.
+- Keep prose consistent with the code, sample inputs, outputs, diagrams, and nearby cells.
+- Check counts, ordered steps, cross-references, defaults, constraints, and stated results.
+- Do not infer a correction when the intended fact is unclear. Preserve the source and flag it for review.
+- Use authoritative sources to verify uncertain product behavior.
+- Do not imply that an optional step is required or that a required step is optional.
+
+## Runnable examples
+
+- List prerequisites and dependencies that readers need before running the example.
+- Document required environment variables. Never hard-code API keys, tokens, credentials, or other secrets.
+- Keep setup instructions in the same order that readers perform them.
+- Introduce code with the goal or reason for the step; do not narrate every line.
+- Use realistic inputs and clearly label placeholders.
+- Show expected output only when it helps readers verify success, and keep it consistent with the code.
+- Keep external-service calls and other opt-in behavior clearly labeled.
+
+## Notebook integrity
+
+- Edit Markdown cells only during an editorial pass.
+- Preserve code cells, outputs, execution counts, attachments, cell IDs, cell order, and metadata.
+- Keep notebook JSON valid and avoid whole-file reserialization for a small prose edit.
+- Keep each Markdown cell focused. Split or merge cells only when the structure is genuinely confusing and the request permits it.
+- Use Markdown headings in a logical hierarchy without skipping levels unnecessarily.
+
+## Prose
+
+- Lead with the point. Prefer concrete nouns and strong verbs.
+- Use direct instructions and address the reader as “you” when helpful.
+- Prefer active voice, but keep passive voice when the actor is unknown or unimportant.
+- Remove throat-clearing, repeated conclusions, filler, and ornamental transitions.
+- Keep paragraphs short enough to scan and use lists for genuinely parallel items.
+- Use numbered lists for ordered procedures and bullets for unordered groups.
+- Keep sibling headings and list items parallel.
+- Use sentence-style capitalization for headings and do not end headings with periods.
+- Preserve useful warmth and explanation; do not flatten the content into terse fragments.
+
+## Terminology and formatting
+
+- Use exact product terminology and consistent capitalization.
+- Format commands, options, environment variables, paths, filenames, code identifiers, and literal values with backticks.
+- Match the capitalization and spelling used by the language or API.
+- Expand uncommon abbreviations on first use unless the surrounding audience clearly knows them.
+- Use inclusive, precise language and neutral role terms.
+- Do not replace a technically precise term merely to vary wording.
+
+## Links and assets
+
+- Prefer descriptive link text over “here” or a pasted URL.
+- Verify local links, anchors, image paths, and referenced notebook or article paths.
+- Use stable, authoritative external links when available.
+- Give images meaningful alt text unless they are purely decorative.
+- Keep diagrams, screenshots, captions, and prose consistent.
+
+## Publication metadata
+
+- Add or update `registry.yaml` for new, moved, renamed, or removed published content.
+- Confirm registry paths, dates, tags, and titles match the content.
+- Add or update `authors.yaml` when introducing or changing author attribution.
+- Check that filenames follow the repository's naming conventions and clearly describe the content.
+
+## Final review
+
+- Read each edited passage in context, not only as an isolated diff hunk.
+- Confirm no factual meaning, literal value, condition, negation, or uncertainty changed unintentionally.
+- Confirm all repository-defined P0 issues are fixed.
+- Run the notebook structural validator for changed notebooks and inspect the final diff for unintended changes.
diff --git a/AGENTS.md b/AGENTS.md
index 4b14a4b7..90bb3789 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -25,6 +25,8 @@ Execute notebooks top-to-bottom after installing dependencies and clear lingerin
Use concise, imperative commit messages that describe the change scope (e.g., "Add agent portfolio collaboration demo"). Every PR should provide a summary, motivation, and self-review, and must tick the registry and authors checklist from `.github/pull_request_template.md`. Link issues when applicable and attach screenshots or output snippets for UI-heavy content. Confirm CI notebook validation passes locally before requesting review.
+Before a pull request is merged, run the repository's `docs-editor` skill on every changed article, Markdown or MDX file, and notebook Markdown cell. For editorial notebook changes, preserve code cells, outputs, execution counts, attachments, cell order, and metadata. Fix safe issues, rerun the relevant checks, and resolve or explicitly document all remaining P0 and P1 findings in the pull request.
+
## Metadata & Publication Workflow
New or relocated content must have an entry in `registry.yaml` with an accurate path, date, and tag set so the static site generator includes it. When collaborating, coordinate author slugs in `authors.yaml` to avoid duplicates, and run `python -m yaml lint registry.yaml` (or your preferred YAML linter) to catch syntax errors before submitting.