Skip to content

Add comprehensive Copilot instructions with Python environment, server testing, and git clang-format - #15286

Merged
CISC merged 17 commits into
masterfrom
copilot/fix-f1657426-6764-497e-98bd-bd55dd7cf87a
Aug 21, 2025
Merged

Add comprehensive Copilot instructions with Python environment, server testing, and git clang-format#15286
CISC merged 17 commits into
masterfrom
copilot/fix-f1657426-6764-497e-98bd-bd55dd7cf87a

Conversation

Copilot AI commented Aug 13, 2025

Copy link
Copy Markdown
Contributor

This PR adds a comprehensive .github/copilot-instructions.md file to onboard AI coding agents to the llama.cpp repository. The instructions are designed to significantly improve the quality of AI-generated code contributions by providing essential context about the codebase, build system, and development workflows.

What's Included

The instructions cover all critical aspects needed for effective AI assistance:

Repository Overview: High-level description of llama.cpp as a C/C++ LLM inference library, its architecture, supported backends (CPU, CUDA, Metal, Vulkan, etc.), and core dependencies.

Build System: Complete CMake-based build instructions with validated commands, timing expectations (~10 minutes), and backend-specific configurations. Includes common build issues and their solutions.

Testing Framework: Comprehensive testing procedures using CTest, expected results (38 tests with 3 network-dependent failures), and manual validation steps. Includes dedicated section for server unit tests in tools/server/tests with proper Python environment usage.

Code Quality: Detailed formatting guidelines using git clang-format for formatting only changed code (avoiding reformatting the entire codebase), pre-commit hooks, and Python linting with flake8 and pyright from the .venv virtual environment.

Python Environment: Instructions for using the provided .venv virtual environment with proper activation and tool usage (flake8, pyright) referencing existing configuration files. Updated to include server test dependencies.

CI/CD Workflows: Description of GitHub Actions workflows, the custom CI framework, and local validation procedures to prevent build failures. Updated workflow includes proper git-clang-format installation.

Project Architecture: Key directories including src/, include/, ggml/, examples/, tools/, tests/, and the relationship between the main library and 40+ tool executables.

Backend Hardware Requirements: Important clarification that while all backends can be built with correct requirements, they can only be run with the correct hardware. Only the CPU backend can be run for testing and validation purposes.

Key Features

  • Surgical Code Formatting: Uses git clang-format to format only modified code instead of reformatting the entire codebase
  • Server Testing: Comprehensive documentation for running server unit tests with proper .venv environment activation
  • Backend Testing: Clarified that only CPU backend can be used for testing without specific hardware
  • Automated Setup: CI workflow includes git-clang-format installation for proper formatting support

Validation

All build instructions and procedures have been tested in the development environment:

  • ✅ Full CMake build completes successfully
  • ✅ Individual target builds work correctly (including llama-server)
  • ✅ Test suite runs with expected results
  • ✅ Built executables function properly
  • git clang-format works correctly for formatting only changed code
  • ✅ Python virtual environment activation works correctly
  • ✅ Server test structure documented and validated

Impact

These instructions will help AI coding agents:

  • Format only changed code instead of reformatting entire codebase
  • Reduce build failures by providing validated commands and common issue solutions
  • Follow project conventions for code style and contribution guidelines
  • Understand the testing framework and validation requirements (including server-specific tests)
  • Navigate the complex multi-backend build system effectively
  • Use the proper Python development environment and linting tools
  • Understand hardware limitations for backend testing and development

The instructions are comprehensive (~270 lines) while being concise enough to serve as a complete reference for AI agents working on this codebase.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits August 13, 2025 07:42
Co-authored-by: CISC <1629204+CISC@users.noreply.github.com>
Co-authored-by: CISC <1629204+CISC@users.noreply.github.com>
Copilot AI changed the title [WIP] Your task is to "onboard" this repository to Copilot coding agent by adding a .github/copilot-instructions.md file in the repository that contains information describing how a coding agent seeing it for the first time can work most efficiently. You wi... Add comprehensive Copilot instructions for improved AI coding assistance Aug 13, 2025
Copilot AI requested a review from CISC August 13, 2025 07:47
@CISC

CISC commented Aug 13, 2025

Copy link
Copy Markdown
Member

@copilot Always activate and use the Python environment located in .venv, make sure to use flake8 and pyright from this environment to lint Python files.

The directory tools/ is also a core directory.

Review instructions based on this new information.

- Add instructions for using .venv Python environment
- Include flake8 and pyright linting tools from virtual environment
- Add tools/ as core directory in project layout
- Reference existing configuration files (.flake8, pyrightconfig.json)

Co-authored-by: CISC <1629204+CISC@users.noreply.github.com>

Copilot AI commented Aug 13, 2025

Copy link
Copy Markdown
Contributor Author

@copilot Always activate and use the Python environment located in .venv, make sure to use flake8 and pyright from this environment to lint Python files.

The directory tools/ is also a core...

Updated the instructions to include:

  1. Python Environment: Added instructions to always activate .venv and use flake8 and pyright from that environment
  2. Tools Directory: Added tools/ as a core directory in the project layout section
  3. Configuration Files: Referenced the existing .flake8 and pyrightconfig.json configuration files

Changes committed in ffcbda3.

Copilot AI changed the title Add comprehensive Copilot instructions for improved AI coding assistance Add comprehensive Copilot instructions with Python environment and tools directory Aug 13, 2025
@github-actions github-actions Bot added the devops improvements to build systems and github actions label Aug 13, 2025
@CISC

CISC commented Aug 13, 2025

Copy link
Copy Markdown
Member

@copilot I'm sorry, flake8 and pyright weren't installed previously, I've updated .venv now, please try again.

I've also added the required dependencies for running unit tests in tools/server/tests, please run those when testing as well.

Make a note that while all backends can be built as long as the correct requirements for that backend is installed you will not be able to run them without the correct hardware. The only backend that can be run for testing etc. is the CPU backend.

…ting

Co-authored-by: CISC <1629204+CISC@users.noreply.github.com>

Copilot AI commented Aug 13, 2025

Copy link
Copy Markdown
Contributor Author

@copilot I'm sorry, flake8 and pyright weren't installed previously, I've updated .venv now, please try again.

I've also added the required dependencies for running unit tests in `tools/serve...

Updated the instructions to address your feedback:

  1. Backend Hardware Note: Added important note that backends can only be run with correct hardware, only CPU backend works for testing
  2. Server Unit Tests: Added section documenting how to run server tests in tools/server/tests with proper .venv activation
  3. Testing Workflow: Updated validation steps to include server tests when modifying server code

The Python environment instructions reference the updated .venv with pytest and related dependencies. Changes committed in ac144ad.

Copilot AI changed the title Add comprehensive Copilot instructions with Python environment and tools directory Add comprehensive Copilot instructions with Python environment, server testing, and backend hardware notes Aug 13, 2025
Comment thread .github/copilot-instructions.md Outdated
Comment thread .github/copilot-instructions.md Outdated
Comment thread .github/copilot-instructions.md Outdated
Comment thread .github/copilot-instructions.md
Comment thread .github/copilot-instructions.md Outdated
Comment thread .github/copilot-instructions.md Outdated
Comment thread .github/workflows/copilot-setup-steps.yml Outdated
Comment thread .github/copilot-instructions.md Outdated
Comment thread .github/copilot-instructions.md Outdated
@CISC

CISC commented Aug 13, 2025

Copy link
Copy Markdown
Member

@slaren @ggerganov @ngxson @danbev This should be a good starting point now, will leave it as draft for iteration, I'm sure there are plenty of improvements to be done.

Comment thread .github/copilot-instructions.md
@CISC

CISC commented Aug 13, 2025

Copy link
Copy Markdown
Member

What is the implication of this file?

It's given to Copilot as a prompt whenever you ask it to work on something in this repo, f.ex. assigning an issue to it.

…nstallation to CI

Co-authored-by: CISC <1629204+CISC@users.noreply.github.com>
@CISC

CISC commented Aug 13, 2025

Copy link
Copy Markdown
Member

It's also possible to add separate instructions that apply to given files, see https://docs.github.com/en/copilot/how-tos/configure-custom-instructions/add-repository-instructions#using-one-or-more-instructionsmd-files-1

@EAddario

Copy link
Copy Markdown
Contributor

And so it begins, today is "let me help you onboard AI coding agents to the llama.cpp repository. It will be good for you! I promise!".

Tomorrow, "Bow to me puny humans!"

I for one, welcome our new overlords

@CISC
CISC marked this pull request as ready for review August 19, 2025 11:06
@CISC

CISC commented Aug 19, 2025

Copy link
Copy Markdown
Member

I can't think of anything specific to add, I'm sure there's lots, but probably the only way to really get a feeling for what is needed is by trial.

@CISC
CISC requested a review from slaren August 19, 2025 11:10

@slaren slaren left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I doubt this is not going to save anyone's time, but if you want to experiment with it, go head. Let's just clean this up later if it proves to be useless.

Comment on lines +134 to +138
### Pre-commit Hooks
Run before committing:
```bash
pre-commit run --all-files
```

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't think we have any.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It's the .pre-commit-config.yaml file, ie. basically EditorConfig and flake8.

@CISC
CISC merged commit 245be73 into master Aug 21, 2025
3 checks passed
@CISC
CISC deleted the copilot/fix-f1657426-6764-497e-98bd-bd55dd7cf87a branch August 21, 2025 09:47
qnixsynapse pushed a commit to janhq/llama.cpp that referenced this pull request Aug 22, 2025
* Initial plan

* Initialize copilot instructions exploration

* Add comprehensive .github/copilot-instructions.md file

* Update Python environment and tools directory documentation

- Add instructions for using .venv Python environment
- Include flake8 and pyright linting tools from virtual environment
- Add tools/ as core directory in project layout
- Reference existing configuration files (.flake8, pyrightconfig.json)

* add more python dependencies to .venv

* Update copilot instructions: add backend hardware note and server testing

* Apply suggestions from code review

* Apply suggestions from code review

* Replace clang-format with git clang-format to format only changed code

* Minor formatting improvements: remove extra blank line and add trailing newline

* try installing git-clang-format

* try just clang-format

* Remove --binary flag from git clang-format and add git-clang-format installation to CI

* download 18.x release

* typo--

* remove --binary flag

---------

Co-authored-by: Sigbjørn Skjæret <sigbjorn.skjaeret@scala.com>
blime4 referenced this pull request in blime4/llama.cpp Feb 5, 2026
* Initial plan

* Initialize copilot instructions exploration

* Add comprehensive .github/copilot-instructions.md file

* Update Python environment and tools directory documentation

- Add instructions for using .venv Python environment
- Include flake8 and pyright linting tools from virtual environment
- Add tools/ as core directory in project layout
- Reference existing configuration files (.flake8, pyrightconfig.json)

* add more python dependencies to .venv

* Update copilot instructions: add backend hardware note and server testing

* Apply suggestions from code review

* Apply suggestions from code review

* Replace clang-format with git clang-format to format only changed code

* Minor formatting improvements: remove extra blank line and add trailing newline

* try installing git-clang-format

* try just clang-format

* Remove --binary flag from git clang-format and add git-clang-format installation to CI

* download 18.x release

* typo--

* remove --binary flag

---------

Co-authored-by: Sigbjørn Skjæret <sigbjorn.skjaeret@scala.com>
Seunghhon pushed a commit to Seunghhon/llama.cpp that referenced this pull request Apr 26, 2026
* Initial plan

* Initialize copilot instructions exploration

* Add comprehensive .github/copilot-instructions.md file

* Update Python environment and tools directory documentation

- Add instructions for using .venv Python environment
- Include flake8 and pyright linting tools from virtual environment
- Add tools/ as core directory in project layout
- Reference existing configuration files (.flake8, pyrightconfig.json)

* add more python dependencies to .venv

* Update copilot instructions: add backend hardware note and server testing

* Apply suggestions from code review

* Apply suggestions from code review

* Replace clang-format with git clang-format to format only changed code

* Minor formatting improvements: remove extra blank line and add trailing newline

* try installing git-clang-format

* try just clang-format

* Remove --binary flag from git clang-format and add git-clang-format installation to CI

* download 18.x release

* typo--

* remove --binary flag

---------

Co-authored-by: Sigbjørn Skjæret <sigbjorn.skjaeret@scala.com>
ljubomirj pushed a commit to ljubomirj/llama.cpp that referenced this pull request May 6, 2026
* Initial plan

* Initialize copilot instructions exploration

* Add comprehensive .github/copilot-instructions.md file

* Update Python environment and tools directory documentation

- Add instructions for using .venv Python environment
- Include flake8 and pyright linting tools from virtual environment
- Add tools/ as core directory in project layout
- Reference existing configuration files (.flake8, pyrightconfig.json)

* add more python dependencies to .venv

* Update copilot instructions: add backend hardware note and server testing

* Apply suggestions from code review

* Apply suggestions from code review

* Replace clang-format with git clang-format to format only changed code

* Minor formatting improvements: remove extra blank line and add trailing newline

* try installing git-clang-format

* try just clang-format

* Remove --binary flag from git clang-format and add git-clang-format installation to CI

* download 18.x release

* typo--

* remove --binary flag

---------

Co-authored-by: Sigbjørn Skjæret <sigbjorn.skjaeret@scala.com>
my-other-github-account pushed a commit to my-other-github-account/llama.cpp that referenced this pull request May 15, 2026
* Initial plan

* Initialize copilot instructions exploration

* Add comprehensive .github/copilot-instructions.md file

* Update Python environment and tools directory documentation

- Add instructions for using .venv Python environment
- Include flake8 and pyright linting tools from virtual environment
- Add tools/ as core directory in project layout
- Reference existing configuration files (.flake8, pyrightconfig.json)

* add more python dependencies to .venv

* Update copilot instructions: add backend hardware note and server testing

* Apply suggestions from code review

* Apply suggestions from code review

* Replace clang-format with git clang-format to format only changed code

* Minor formatting improvements: remove extra blank line and add trailing newline

* try installing git-clang-format

* try just clang-format

* Remove --binary flag from git clang-format and add git-clang-format installation to CI

* download 18.x release

* typo--

* remove --binary flag

---------

Co-authored-by: Sigbjørn Skjæret <sigbjorn.skjaeret@scala.com>
my-other-github-account pushed a commit to my-other-github-account/llama.cpp that referenced this pull request May 15, 2026
* Initial plan

* Initialize copilot instructions exploration

* Add comprehensive .github/copilot-instructions.md file

* Update Python environment and tools directory documentation

- Add instructions for using .venv Python environment
- Include flake8 and pyright linting tools from virtual environment
- Add tools/ as core directory in project layout
- Reference existing configuration files (.flake8, pyrightconfig.json)

* add more python dependencies to .venv

* Update copilot instructions: add backend hardware note and server testing

* Apply suggestions from code review

* Apply suggestions from code review

* Replace clang-format with git clang-format to format only changed code

* Minor formatting improvements: remove extra blank line and add trailing newline

* try installing git-clang-format

* try just clang-format

* Remove --binary flag from git clang-format and add git-clang-format installation to CI

* download 18.x release

* typo--

* remove --binary flag

---------

Co-authored-by: Sigbjørn Skjæret <sigbjorn.skjaeret@scala.com>
phibya pushed a commit to ziee-ai/llama.cpp that referenced this pull request May 29, 2026
* Initial plan

* Initialize copilot instructions exploration

* Add comprehensive .github/copilot-instructions.md file

* Update Python environment and tools directory documentation

- Add instructions for using .venv Python environment
- Include flake8 and pyright linting tools from virtual environment
- Add tools/ as core directory in project layout
- Reference existing configuration files (.flake8, pyrightconfig.json)

* add more python dependencies to .venv

* Update copilot instructions: add backend hardware note and server testing

* Apply suggestions from code review

* Apply suggestions from code review

* Replace clang-format with git clang-format to format only changed code

* Minor formatting improvements: remove extra blank line and add trailing newline

* try installing git-clang-format

* try just clang-format

* Remove --binary flag from git clang-format and add git-clang-format installation to CI

* download 18.x release

* typo--

* remove --binary flag

---------

Co-authored-by: Sigbjørn Skjæret <sigbjorn.skjaeret@scala.com>
fewtarius pushed a commit to fewtarius/CachyLLama that referenced this pull request May 30, 2026
* Initial plan

* Initialize copilot instructions exploration

* Add comprehensive .github/copilot-instructions.md file

* Update Python environment and tools directory documentation

- Add instructions for using .venv Python environment
- Include flake8 and pyright linting tools from virtual environment
- Add tools/ as core directory in project layout
- Reference existing configuration files (.flake8, pyrightconfig.json)

* add more python dependencies to .venv

* Update copilot instructions: add backend hardware note and server testing

* Apply suggestions from code review

* Apply suggestions from code review

* Replace clang-format with git clang-format to format only changed code

* Minor formatting improvements: remove extra blank line and add trailing newline

* try installing git-clang-format

* try just clang-format

* Remove --binary flag from git clang-format and add git-clang-format installation to CI

* download 18.x release

* typo--

* remove --binary flag

---------

Co-authored-by: Sigbjørn Skjæret <sigbjorn.skjaeret@scala.com>
fukuro-kun pushed a commit to fukuro-kun/fukuro-llama-cpp-turboquant that referenced this pull request Jul 5, 2026
* Initial plan

* Initialize copilot instructions exploration

* Add comprehensive .github/copilot-instructions.md file

* Update Python environment and tools directory documentation

- Add instructions for using .venv Python environment
- Include flake8 and pyright linting tools from virtual environment
- Add tools/ as core directory in project layout
- Reference existing configuration files (.flake8, pyrightconfig.json)

* add more python dependencies to .venv

* Update copilot instructions: add backend hardware note and server testing

* Apply suggestions from code review

* Apply suggestions from code review

* Replace clang-format with git clang-format to format only changed code

* Minor formatting improvements: remove extra blank line and add trailing newline

* try installing git-clang-format

* try just clang-format

* Remove --binary flag from git clang-format and add git-clang-format installation to CI

* download 18.x release

* typo--

* remove --binary flag

---------

Co-authored-by: Sigbjørn Skjæret <sigbjorn.skjaeret@scala.com>
MrLordCat referenced this pull request in MrLordCat/llama.cpp-with-GUI Jul 16, 2026
* Initial plan

* Initialize copilot instructions exploration

* Add comprehensive .github/copilot-instructions.md file

* Update Python environment and tools directory documentation

- Add instructions for using .venv Python environment
- Include flake8 and pyright linting tools from virtual environment
- Add tools/ as core directory in project layout
- Reference existing configuration files (.flake8, pyrightconfig.json)

* add more python dependencies to .venv

* Update copilot instructions: add backend hardware note and server testing

* Apply suggestions from code review

* Apply suggestions from code review

* Replace clang-format with git clang-format to format only changed code

* Minor formatting improvements: remove extra blank line and add trailing newline

* try installing git-clang-format

* try just clang-format

* Remove --binary flag from git clang-format and add git-clang-format installation to CI

* download 18.x release

* typo--

* remove --binary flag

---------

Co-authored-by: Sigbjørn Skjæret <sigbjorn.skjaeret@scala.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

devops improvements to build systems and github actions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants