openvino.genai
Copilot instructions608 starsChanged 34 days agoApache-2.0View on GitHub
OpenVINO GenAI is a C++17 library (ov::genai, public headers in src/cpp/include) with Python (pybind11, src/python), C (src/c) and JS (src/js) bindings. When reviewing, comment only on issues a maintainer would ask to fix. Skip formatting that linters already check. Follow these rules when writing, modifying, or reviewing code in this repository. Rules are grouped by topic.
We split this copilot-instructions.md into the rules it gives an agent
36 rules. About 3 are common, 16 are distinctive, and 17 are very specific to this project.
≈3
Common · estimate
Many files like this have a rule of this kind.
≈16
Distinctive · estimate
This author's own choices. Worth a look.
17
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 7
Follow these rules when writing, modifying, or reviewing code in this repository.
- Common: line 11
Don't adjust config values silently or with a warning.
- Very specific: line 12
Use OPENVINO_ASSERT(condition, ...) for checks instead of if + OPENVINO_THROW(...) or throw.
- Common: line 14
Don't remove an existing exception or error path, and don't turn it into a warning or a no-op.
- Common: line 15
Don't add try/catch blocks just to be safe.
- Distinctive: line 18
When you move code into a new function, keep its behavior the same.
- Very specific: line 24
Use model-neutral public names: Talker, not Qwen3OmniTalker.
- Very specific: line 25
Use the same base name for related public entities across layers, for example enum/class VisionPreprocess and env var VISION_PREPROCESS.
- Distinctive: line 26
Keep the public API small.
- Very specific: line 27
Don't use deprecated APIs in new code, tests or samples.
- Very specific: line 28
Don't flag ABI breaks: ABI stability isn't required.
- Very specific: line 32
Don't deep-copy tensor data or large containers without need (rule 6 is the exception).
- Very specific: line 33
Avoid dynamic_cast in hot paths (inference loops).
- Very specific: line 34
Don't write using namespace std;.
- Very specific: line 36
Add a comment to every const_cast that says why the write is safe.
- Very specific: line 37
Don't add unused non-public functions or constructors, except in debug_utils.hpp.
- Distinctive: line 40
Before adding a helper, search the repository for an existing one.
- Distinctive: line 41
Don't limit the code to a specific device unless the feature needs it.
- Distinctive: line 46
Write comments about the current code.
- Distinctive: line 47
Avoid ambiguous words like "some" or "capable".
- Very specific: line 49
Start new source files with the copyright header and the current year, for example Copyright (C) 2026 Intel Corporation and …
- Distinctive: line 50
Don't commit one-off scripts (repro, debug, local conversion) that CI, tests and docs don't use.
- Very specific: line 55
Add tests for new features and bug fixes: Python tests in tests/python_tests, JS tests in src/js/tests.
- Distinctive: line 59
Test each new option to show its effect: the output changes, or for a performance option, the output stays the same and the option is …
- Very specific: line 60
Use pytest.mark.parametrize instead of near-duplicate tests.
- Very specific: line 62
Keep tests cheap: a small max_new_tokens and pipelines in module-scoped fixtures.
- Very specific: line 63
Add a new test file to every matching file in .github/workflows/test_matrices: wheel_tests.yml or samples_tests.yml in each OS folder that …
- Very specific: line 67
Add a new component to .github/labeler.yml, .github/components.yml and .github/CODEOWNERS when a new use case is introduced.
- Distinctive: line 71
Avoid adding new samples unless there is a strong, clearly justified reason.
- Distinctive: line 72
Add tests for new samples.
- Very specific: line 73
Keep command-line arguments minimal: required inputs are positional, and other values are hardcoded with a comment.
- Distinctive: line 74
Update the C++ and Python versions of a sample, its README and the docs examples together.
- Distinctive: line 79
Use all available cores for building code from source.
- Distinctive: line 83
When performing a code review on a Pull Request, additionally follow this protocol:
- Distinctive: line 86
If the documentation is updated, PR description MUST include a link to the corresponding documentation deployed on the fork.
- Distinctive: line 88
If a PR aims to improve accuracy or performance, the PR description must include corresponding metrics.
≈ “Common” is an estimate: at least 1 in 5 of the 3,669 Copilot instructions files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
OpenVINO GenAI Copilot Instructions
OpenVINO GenAI is a C++17 library (ov::genai, public headers in src/cpp/include) with Python (pybind11, src/python), C (src/c) and JS (src/js) bindings. When reviewing, comment only on issues a maintainer would ask to fix. Skip formatting that linters already check.
General Coding Guidelines
Follow these rules when writing, modifying, or reviewing code in this repository. Rules are grouped by topic.
Correctness
- Don't adjust config values silently or with a warning. Throw an exception instead.
- Use
OPENVINO_ASSERT(condition, ...)for checks instead ofif+OPENVINO_THROW(...)orthrow. UseOPENVINO_THROW(...)only when the exception is unconditional. - In checks on user input, the error message names the wrong value and the expected one. Don't add a comment that repeats the message.
- Don't remove an existing exception or error path, and don't turn it into a warning or a no-op. This doesn't apply to a PR that supports a case the check used to reject and tests that case.
- Don't add try/catch blocks just to be safe. Catch only an exception that is expected and handled. Catch-all blocks at the C and JS binding boundaries, which turn exceptions into status codes or JS errors, are expected.
- An output
ov::TensorfromInferRequest::get_tensor()is a view into the request's buffer, and the nextinfer()on that request overwrites it. Flag such a tensor that is kept (in a member, a cache or chat history) and read after the nextinfer()without a deep copy of its data. Copying theov::Tensorhandle still shares the buffer. Reusing an input tensor fromget_tensor()is fine. tensor.data<T>()checks the element type internally, so don't ask for an assert onget_element_type()before it.- When you move code into a new function, keep its behavior the same.
Public API and bindings
- When the public C++ API in
src/cpp/includechanges, make the same change in the Python bindings insrc/python: overloads, constructors (includingstd::filesystem::path), argument names, defaults, getters and setters..pyistubs are enforced by tests, so no review comments needed. Checksrc/candsrc/jsif they wrap the changed API. - Give new public APIs docstrings in the C++ header and the Python binding, and documentation in
site/docs. - Use model-neutral public names:
Talker, notQwen3OmniTalker. - Use the same base name for related public entities across layers, for example enum/class
VisionPreprocessand env varVISION_PREPROCESS. Flag two public names for the same thing. - Keep the public API small. Flag new public getters, setters, flags or env vars that the change doesn't need.
- Don't use deprecated APIs in new code, tests or samples. For example, use
generate()withChatHistoryinstead ofstart_chat()andfinish_chat(). - Don't flag ABI breaks: ABI stability isn't required. Source compatibility is: flag public API in
src/cpp/includeor the bindings that is removed, renamed or loses a default argument.
C++
- Don't deep-copy tensor data or large containers without need (rule 6 is the exception). Pass
ov::Tensorand other non-trivial objects byconst&. Take an argument that is moved from as&&. A by-valueov::Tensorshares its data, so don't call it a deep copy. - Avoid
dynamic_castin hot paths (inference loops). Usestatic_castor redesign if the type is known. - Don't write
using namespace std;. Don't useautofor primitive types where it hides the type. Useconstandconstexprwherever possible. - Initialize members in the constructor's member initializer list, not in its body. When initial container values are known, use brace-initialization instead of inserting into an empty container.
- Add a comment to every
const_castthat says why the write is safe. - Don't add unused non-public functions or constructors, except in
debug_utils.hpp. Don't add a parameter that no caller or override uses. - Flag a new non-public, non-
voidfunction whose return value no caller uses. Public API insrc/cpp/includeand the bindings has callers outside the repository. - Never include
debug_utils.hpp. - Before adding a helper, search the repository for an existing one. Extract code that the change repeats.
- Don't limit the code to a specific device unless the feature needs it.
- Report an algorithmic branch choice (log or warning) once, not in every place that sees it.
Comments and files
- Write comments about the current code. When a comment refers to other code, name the function. Avoid vague references such as "upstream" or "the two".
- Avoid ambiguous words like "some" or "capable".
- Point permalinks to a commit, not a branch.
- Start new source files with the copyright header and the current year, for example
Copyright (C) 2026 Intel CorporationandSPDX-License-Identifier: Apache-2.0. - Don't commit one-off scripts (repro, debug, local conversion) that CI, tests and docs don't use.
- Make removals complete: no stale docs, empty config sections or leftover initializers. The PR description says why the code was removed.
Tests and CI
- Add tests for new features and bug fixes: Python tests in
tests/python_tests, JS tests insrc/js/tests. C++ tests are optional. Documentation, CI, sample-only and xfail-only changes don't need new tests. Don't ask for tests of test utilities or of tokenizer behavior. - Flag new tests that never run in CI. GitHub Actions runs tests only on CPU, and on NPU through NPUW with CPU fallback. So tests that need GPU or real NPU hardware never run, and neither do tests that depend on env vars or models that
.github/workflowsnever enables. Tests markedreal_modelsornightlyare excluded from CI on purpose; don't flag them. - For a new model architecture, add a
tiny-randommodel to the functional and sample tests. If no such model exists yet, a follow-up with a linked ticket is fine. - Repeated runs and greedy decoding on CPU are reproducible. Compare their results with exact equality and an exact
max_new_tokens. Use a tolerance only for real floats and for sampled outputs compared with a reference. - Test each new option to show its effect: the output changes, or for a performance option, the output stays the same and the option is applied.
- Use
pytest.mark.parametrizeinstead of near-duplicate tests. - Link a ticket (CVS-### or a GitHub issue) in every skip and xfail.
- Keep tests cheap: a small
max_new_tokensand pipelines in module-scoped fixtures. Put a new test suite in its own file instead of growing large files such astest_vlm_pipeline.py. - Add a new test file to every matching file in
.github/workflows/test_matrices:wheel_tests.ymlorsamples_tests.ymlin each OS folder that has one. - Make workflow
-mfilters match the pytest markers of the tests they should run. - Pin new dependencies in
tests/python_tests/requirements.txtto an exact version or commit, never*. - When a dependency release breaks something, exclude that version with
!=instead of adding a new upper cap. Dependabot updates the existing<=caps intools/,samples/and the repository root; don't flag them. A new dependency intools/may use the same>=x,<=yform. - Add a new component to
.github/labeler.yml,.github/components.ymland.github/CODEOWNERSwhen a new use case is introduced.
Samples and docs
- Avoid adding new samples unless there is a strong, clearly justified reason.
- Add tests for new samples.
- Keep command-line arguments minimal: required inputs are positional, and other values are hardcoded with a comment. An optional
deviceargument and the optional flags that sibling samples already use are allowed. - Update the C++ and Python versions of a sample, its README and the docs examples together.
- Samples are minimal demos. Don't ask them to handle edge cases such as malformed input, integer overflow in argument parsing or platform-specific file APIs.
Build
- Use all available cores for building code from source.
Code Review Instructions for PRs
When performing a code review on a Pull Request, additionally follow this protocol:
- PR description must be aligned with ./pull_request_template.md and its checklist must be filled out. If not, request the author to update the description and checklist before proceeding with the review. Individual items can be marked as N/A in the checklist.
- If the documentation is updated, PR description MUST include a link to the corresponding documentation deployed on the fork.
- PR description must be up to date and include all information about the changes.
- If a PR aims to improve accuracy or performance, the PR description must include corresponding metrics. Performance-oriented PRs require both accuracy and performance metrics.
- A PR has one purpose. Flag hunks unrelated to it: reformatting, edits to unrelated comments, submodule bumps, extra features.
Where files are headingNew Copilot instructions files have more rules about branches and pull requests, and fewer about code style.
Of the Copilot instructions files we read, the 2,297 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository8 other files it gives its agents.
- generate-release-notesSkill
- llm-bench-fail-analyzerSkill
- model-checkerSkill
- open-prSkill
- tests-and-cacheSkill
- update-docsSkill
- vlm-model-enablerSkill
- wwb-fail-analyzerSkill
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

