Skip to content

Add AI agent instructions#27856

Merged
edgchen1 merged 21 commits intomainfrom
edgchen1/add_copilot_instructions
Apr 7, 2026
Merged

Add AI agent instructions#27856
edgchen1 merged 21 commits intomainfrom
edgchen1/add_copilot_instructions

Conversation

@edgchen1
Copy link
Copy Markdown
Contributor

@edgchen1 edgchen1 commented Mar 26, 2026

Description

Initial pass at some AI agent instructions for this repo.

Following some conventions:

Add repository instructions for AI agents covering:

  • Build system phases (--update/--build/--test) and key flags
  • High-level architecture (graph, optimizer, session, providers)
  • C++ conventions (error macros, container types, span/string_view preferences)
  • Python conventions and testing patterns
  • C API guidelines and PR expectations

Sourced from existing docs (CONTRIBUTING.md, docs/Coding_Conventions_and_Standards.md, docs/PR_Guidelines.md, docs/C_API_Guidelines.md) and codebase inspection.

Copilot put most of this together.

Motivation and Context

Trying to help AI agents work better in this repo. Just getting some initial instructions in place. We should refine it.

Add repository instructions for GitHub Copilot sessions covering:
- Build system phases (update/build/test) and key flags
- High-level architecture (graph, optimizer, session, providers)
- C++ conventions (error macros, container types, span/string_view)
- Python conventions and testing patterns
- C API guidelines and PR expectations

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@edgchen1
Copy link
Copy Markdown
Contributor Author

edgchen1 commented Mar 26, 2026

FYI - This is what I got when I ran /init in Copilot CLI and then refined it a bit.

also renamed it to AGENTS.md to hopefully make it more general.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new repository-level .github/copilot-instructions.md intended to guide GitHub Copilot sessions with ONNX Runtime-specific build, architecture, coding conventions, C API guidance, and PR expectations.

Changes:

  • Introduces a Copilot instruction document covering build/test/lint workflows and key flags.
  • Summarizes core architecture (graph/optimizer/framework/session/providers) and contrib/training structure.
  • Captures C++/Python/C API conventions and PR guidelines in a single reference.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .github/copilot-instructions.md Outdated
Comment thread .github/copilot-instructions.md Outdated
Comment thread .github/copilot-instructions.md Outdated
Comment thread AGENTS.md Outdated
Comment thread .github/copilot-instructions.md Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread AGENTS.md Outdated
@edgchen1 edgchen1 changed the title Add .github/copilot-instructions.md Add AGENTS.md Mar 26, 2026
@edgchen1 edgchen1 requested a review from Copilot March 26, 2026 18:33
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread AGENTS.md
Comment thread AGENTS.md Outdated
Comment thread AGENTS.md Outdated
@fs-eire
Copy link
Copy Markdown
Contributor

fs-eire commented Mar 26, 2026

I have 2 suggestions:

  • keep it short. the current content seems too long for an AGENTS.md
  • make it multiple files and use the main AGENTS.md and an index, to make it load on demand. (the idea of SKILLs)

Comment thread AGENTS.md
Comment thread AGENTS.md
edgchen1 and others added 4 commits March 30, 2026 18:21
- Add build duration section advising agents to run builds in the
  background and redirect output to a file for long builds
- Document --target and --targets flags for building specific CMake targets
- Add example for building a single target
- Update workflow to mention continuing with other tasks during build

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Advise agents to use an isolated virtual environment before building
or testing, since those processes may install Python dependencies.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@edgchen1 edgchen1 changed the title Add AGENTS.md Add AI agent instructions Mar 31, 2026
@edgchen1
Copy link
Copy Markdown
Contributor Author

@fs-eire @justinchuby thanks for the suggestions of moving some information to skills.

I'm new to this, so I am not sure what the appropriate scope of a skill is.

Copilot came up with some initial skills. I asked it again afterwards:

❯ please take a look at AGENTS.md. do you think any information there would be better suited as a separate skill?

● Read AGENTS.md
  └ 119 lines read

● I think the current AGENTS.md is well-structured as-is. Everything there is appropriate for "always loaded" context — it's concise reference material an agent needs regardless of the task:

   - Architecture Overview — essential context for navigating any code change
   - C++/Python/C API Conventions — coding style rules needed when writing any code
   - Python Environment — lightweight, cross-cutting guidance
   - PR Guidelines — always relevant when preparing changes

  Skills are best for procedural workflows (step-by-step "how to do X") that are only needed on demand. The three existing skills (build, test, lint) fit that pattern well.

  The one section I could see an argument for extracting is C API Conventions — it's only relevant when modifying the public C API, which is a narrow use case. But it's short enough (10 lines) that the context cost of keeping it in AGENTS.md is
  minimal, and making it a skill would add overhead for little benefit.

  Bottom line: I wouldn't move anything out. The file is ~120 lines, which is a reasonable size for always-on context, and everything there has broad applicability.

if you have other ideas about what should be moved into a skill, or just removed from AGENTS.md, please let me know.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .agents/skills/ort-test/SKILL.md Outdated
Comment thread .agents/skills/ort-test/SKILL.md Outdated
Comment thread .agents/skills/ort-build/SKILL.md Outdated
Comment thread AGENTS.md Outdated
@justinchuby
Copy link
Copy Markdown
Contributor

@fs-eire @justinchuby thanks for the suggestions of moving some information to skills.

I'm new to this, so I am not sure what the appropriate scope of a skill is.

Copilot came up with some initial skills. I asked it again afterwards:

❯ please take a look at AGENTS.md. do you think any information there would be better suited as a separate skill?

● Read AGENTS.md
  └ 119 lines read

● I think the current AGENTS.md is well-structured as-is. Everything there is appropriate for "always loaded" context — it's concise reference material an agent needs regardless of the task:

   - Architecture Overview — essential context for navigating any code change
   - C++/Python/C API Conventions — coding style rules needed when writing any code
   - Python Environment — lightweight, cross-cutting guidance
   - PR Guidelines — always relevant when preparing changes

  Skills are best for procedural workflows (step-by-step "how to do X") that are only needed on demand. The three existing skills (build, test, lint) fit that pattern well.

  The one section I could see an argument for extracting is C API Conventions — it's only relevant when modifying the public C API, which is a narrow use case. But it's short enough (10 lines) that the context cost of keeping it in AGENTS.md is
  minimal, and making it a skill would add overhead for little benefit.

  Bottom line: I wouldn't move anything out. The file is ~120 lines, which is a reasonable size for always-on context, and everything there has broad applicability.

if you have other ideas about what should be moved into a skill, or just removed from AGENTS.md, please let me know.

That sounds reasonable. As this grow we can then split. I think of topics like "how to create a new kernel for an op", etc. belonging to a skill.

Comment thread .agents/skills/ort-lint/SKILL.md Outdated
Comment thread .agents/skills/ort-lint/SKILL.md Outdated
Comment thread .agents/skills/ort-test/SKILL.md Outdated
Comment thread AGENTS.md
justinchuby
justinchuby previously approved these changes Apr 1, 2026
edgchen1 and others added 5 commits April 1, 2026 19:52
- AGENTS.md: Broaden contrib ops registration to list all EP-specific files
- ort-build: Update --use_cuda flag docs, add build output path details,
  consolidate and streamline content
- ort-test: Fix macOS platform name, add VS multi-config path info,
  consolidate and streamline content
- ort-lint: Add coding standards doc reference, 80-char line preference,
  consolidate and streamline content

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Merge Python Environment and Python Conventions under one heading
- Add coding standards doc reference and 80-char aim to C++ style
- Trim verbose source paths from container types
- Consolidate C API header locations
- Minor wording and formatting cleanup

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Fix CMake file discovery wording (mix of globs and explicit lists)
- Note that --target requires --build

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Comment thread .agents/skills/ort-lint/SKILL.md
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .agents/skills/ort-test/SKILL.md
Comment thread .agents/skills/ort-build/SKILL.md
Comment thread .agents/skills/ort-test/SKILL.md
When --test is explicitly provided, the build script only runs the test
phase. Add a note that this assumes a prior successful build.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@edgchen1 edgchen1 enabled auto-merge (squash) April 7, 2026 23:20
@edgchen1 edgchen1 merged commit c2e040a into main Apr 7, 2026
105 of 108 checks passed
@edgchen1 edgchen1 deleted the edgchen1/add_copilot_instructions branch April 7, 2026 23:54
vraspar added a commit that referenced this pull request Apr 9, 2026
### Description

Add a pre-commit [git
hook](https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks) that
runs lintrunner on staged files, catching lint and formatting issues
before they reach CI.

The hook runs lintrunner in check-only mode (no auto-fix) to avoid
issues with partial staging. If lint issues are found, the commit is
blocked and the developer is prompted to run `lintrunner -a` to fix.

The hook is opt-in. Contributors enable it with: `git config
core.hooksPath .githooks`

### Motivation and Context

Follow-up from #27856.
Catching lint issues at commit time saves CI cycles and review time.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants