agentleFS
openvinotoolkitopenvinotoolkit/openvino.genai/.github/copilot-instructions.md

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
  1. Distinctive:

    Follow these rules when writing, modifying, or reviewing code in this repository.

    line 7
  2. Common:

    Don't adjust config values silently or with a warning.

    line 11
  3. Very specific:

    Use OPENVINO_ASSERT(condition, ...) for checks instead of if + OPENVINO_THROW(...) or throw.

    line 12
  4. Common:

    Don't remove an existing exception or error path, and don't turn it into a warning or a no-op.

    line 14
  5. Common:

    Don't add try/catch blocks just to be safe.

    line 15
  6. Distinctive:

    When you move code into a new function, keep its behavior the same.

    line 18
  7. Very specific:

    Use model-neutral public names: Talker, not Qwen3OmniTalker.

    line 24
  8. Very specific:

    Use the same base name for related public entities across layers, for example enum/class VisionPreprocess and env var VISION_PREPROCESS.

    line 25
  9. Distinctive:

    Keep the public API small.

    line 26
  10. Very specific:

    Don't use deprecated APIs in new code, tests or samples.

    line 27
  11. Very specific:

    Don't flag ABI breaks: ABI stability isn't required.

    line 28
  12. Very specific:

    Don't deep-copy tensor data or large containers without need (rule 6 is the exception).

    line 32
  13. Very specific:

    Avoid dynamic_cast in hot paths (inference loops).

    line 33
  14. Very specific:

    Don't write using namespace std;.

    line 34
  15. Very specific:

    Add a comment to every const_cast that says why the write is safe.

    line 36
  16. Very specific:

    Don't add unused non-public functions or constructors, except in debug_utils.hpp.

    line 37
  17. Distinctive:

    Before adding a helper, search the repository for an existing one.

    line 40
  18. Distinctive:

    Don't limit the code to a specific device unless the feature needs it.

    line 41
  19. Distinctive:

    Write comments about the current code.

    line 46
  20. Distinctive:

    Avoid ambiguous words like "some" or "capable".

    line 47
  21. Very specific:

    Start new source files with the copyright header and the current year, for example Copyright (C) 2026 Intel Corporation and …

    line 49
  22. Distinctive:

    Don't commit one-off scripts (repro, debug, local conversion) that CI, tests and docs don't use.

    line 50
  23. Very specific:

    Add tests for new features and bug fixes: Python tests in tests/python_tests, JS tests in src/js/tests.

    line 55
  24. Distinctive:

    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 …

    line 59
  25. Very specific:

    Use pytest.mark.parametrize instead of near-duplicate tests.

    line 60
  26. Very specific:

    Keep tests cheap: a small max_new_tokens and pipelines in module-scoped fixtures.

    line 62
  27. Very specific:

    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 …

    line 63
  28. Very specific:

    Add a new component to .github/labeler.yml, .github/components.yml and .github/CODEOWNERS when a new use case is introduced.

    line 67
  29. Distinctive:

    Avoid adding new samples unless there is a strong, clearly justified reason.

    line 71
  30. Distinctive:

    Add tests for new samples.

    line 72
  31. Very specific:

    Keep command-line arguments minimal: required inputs are positional, and other values are hardcoded with a comment.

    line 73
  32. Distinctive:

    Update the C++ and Python versions of a sample, its README and the docs examples together.

    line 74
  33. Distinctive:

    Use all available cores for building code from source.

    line 79
  34. Distinctive:

    When performing a code review on a Pull Request, additionally follow this protocol:

    line 83
  35. Distinctive:

    If the documentation is updated, PR description MUST include a link to the corresponding documentation deployed on the fork.

    line 86
  36. Distinctive:

    If a PR aims to improve accuracy or performance, the PR description must include corresponding metrics.

    line 88

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
copilot-instructions.md

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

  1. Don't adjust config values silently or with a warning. Throw an exception instead.
  2. Use OPENVINO_ASSERT(condition, ...) for checks instead of if + OPENVINO_THROW(...) or throw. Use OPENVINO_THROW(...) only when the exception is unconditional.
  3. 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.
  4. 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.
  5. 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.
  6. An output ov::Tensor from InferRequest::get_tensor() is a view into the request's buffer, and the next infer() on that request overwrites it. Flag such a tensor that is kept (in a member, a cache or chat history) and read after the next infer() without a deep copy of its data. Copying the ov::Tensor handle still shares the buffer. Reusing an input tensor from get_tensor() is fine.
  7. tensor.data<T>() checks the element type internally, so don't ask for an assert on get_element_type() before it.
  8. When you move code into a new function, keep its behavior the same.

Public API and bindings

  1. When the public C++ API in src/cpp/include changes, make the same change in the Python bindings in src/python: overloads, constructors (including std::filesystem::path), argument names, defaults, getters and setters. .pyi stubs are enforced by tests, so no review comments needed. Check src/c and src/js if they wrap the changed API.
  2. Give new public APIs docstrings in the C++ header and the Python binding, and documentation in site/docs.
  3. Use model-neutral public names: Talker, not Qwen3OmniTalker.
  4. Use the same base name for related public entities across layers, for example enum/class VisionPreprocess and env var VISION_PREPROCESS. Flag two public names for the same thing.
  5. Keep the public API small. Flag new public getters, setters, flags or env vars that the change doesn't need.
  6. Don't use deprecated APIs in new code, tests or samples. For example, use generate() with ChatHistory instead of start_chat() and finish_chat().
  7. Don't flag ABI breaks: ABI stability isn't required. Source compatibility is: flag public API in src/cpp/include or the bindings that is removed, renamed or loses a default argument.

C++

  1. Don't deep-copy tensor data or large containers without need (rule 6 is the exception). Pass ov::Tensor and other non-trivial objects by const&. Take an argument that is moved from as &&. A by-value ov::Tensor shares its data, so don't call it a deep copy.
  2. Avoid dynamic_cast in hot paths (inference loops). Use static_cast or redesign if the type is known.
  3. Don't write using namespace std;. Don't use auto for primitive types where it hides the type. Use const and constexpr wherever possible.
  4. 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.
  5. Add a comment to every const_cast that says why the write is safe.
  6. 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.
  7. Flag a new non-public, non-void function whose return value no caller uses. Public API in src/cpp/include and the bindings has callers outside the repository.
  8. Never include debug_utils.hpp.
  9. Before adding a helper, search the repository for an existing one. Extract code that the change repeats.
  10. Don't limit the code to a specific device unless the feature needs it.
  11. Report an algorithmic branch choice (log or warning) once, not in every place that sees it.

Comments and files

  1. 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".
  2. Avoid ambiguous words like "some" or "capable".
  3. Point permalinks to a commit, not a branch.
  4. Start new source files with the copyright header and the current year, for example Copyright (C) 2026 Intel Corporation and SPDX-License-Identifier: Apache-2.0.
  5. Don't commit one-off scripts (repro, debug, local conversion) that CI, tests and docs don't use.
  6. Make removals complete: no stale docs, empty config sections or leftover initializers. The PR description says why the code was removed.

Tests and CI

  1. Add tests for new features and bug fixes: Python tests in tests/python_tests, JS tests in src/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.
  2. 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/workflows never enables. Tests marked real_models or nightly are excluded from CI on purpose; don't flag them.
  3. For a new model architecture, add a tiny-random model to the functional and sample tests. If no such model exists yet, a follow-up with a linked ticket is fine.
  4. 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.
  5. 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.
  6. Use pytest.mark.parametrize instead of near-duplicate tests.
  7. Link a ticket (CVS-### or a GitHub issue) in every skip and xfail.
  8. Keep tests cheap: a small max_new_tokens and pipelines in module-scoped fixtures. Put a new test suite in its own file instead of growing large files such as test_vlm_pipeline.py.
  9. 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 has one.
  10. Make workflow -m filters match the pytest markers of the tests they should run.
  11. Pin new dependencies in tests/python_tests/requirements.txt to an exact version or commit, never *.
  12. When a dependency release breaks something, exclude that version with != instead of adding a new upper cap. Dependabot updates the existing <= caps in tools/, samples/ and the repository root; don't flag them. A new dependency in tools/ may use the same >=x,<=y form.
  13. Add a new component to .github/labeler.yml, .github/components.yml and .github/CODEOWNERS when a new use case is introduced.

Samples and docs

  1. Avoid adding new samples unless there is a strong, clearly justified reason.
  2. Add tests for new samples.
  3. Keep command-line arguments minimal: required inputs are positional, and other values are hardcoded with a comment. An optional device argument and the optional flags that sibling samples already use are allowed.
  4. Update the C++ and Python versions of a sample, its README and the docs examples together.
  5. 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

  1. 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:

  1. 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.
  2. If the documentation is updated, PR description MUST include a link to the corresponding documentation deployed on the fork.
  3. PR description must be up to date and include all information about the changes.
  4. 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.
  5. A PR has one purpose. Flag hunks unrelated to it: reformatting, edits to unrelated comments, submodule bumps, extra features.

Download now (ZIP)

  • 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.

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.