Skip to content

Commit c219709

Browse files
authored
copilot: Provide more project context for the Copilot coding agent (#1207)
* copilot: create .github/copilot-instructions.md This file provides additional context and instructions to GitHub Copilot so it can better understand the codebase and coding conventions. More can be found about this file at the following links: - [Best practices for using Copilot to work on tasks](https://docs.github.com/en/enterprise-cloud@latest/copilot/using-github-copilot/using-copilot-coding-agent-to-work-on-tasks/best-practices-for-using-copilot-to-work-on-taskshttps://docs.github.com/en/enterprise-cloud@latest/copilot/using-github-copilot/using-copilot-coding-agent-to-work-on-tasks/best-practices-for-using-copilot-to-work-on-tasks) - [Adding repository custom instructions for GitHub Copilot](https://docs.github.com/en/enterprise-cloud@latest/copilot/customizing-copilot/adding-repository-custom-instructions-for-github-copilot?tool=webuihttps://docs.github.com/en/enterprise-cloud@latest/copilot/customizing-copilot/adding-repository-custom-instructions-for-github-copilot) * copilot: add copilot-setup-steps.yml This new workflow is done when copilot loads into an environment and enables copilot to be sure it has the proper dependencies before working on changes. Also included in the change are explicit instructions on what to do before reporting back "done".
1 parent 466e4eb commit c219709

File tree

2 files changed

+106
-0
lines changed

2 files changed

+106
-0
lines changed

.github/copilot-instructions.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# GitHub Copilot Instructions for GSL (Guidelines Support Library)
2+
3+
## Project Overview
4+
This repository contains the Guidelines Support Library (GSL), a Microsoft implementation of types and functions
5+
suggested for use by the C++ Core Guidelines. It's a header-only C++ library with emphasis on safety,
6+
correctness, and zero overhead.
7+
8+
## Coding Standards
9+
10+
### General
11+
- Follow C++ Core Guidelines wherever possible
12+
- Use meaningful type, function, and template parameter names
13+
- Keep functions small and focused with clear preconditions/postconditions
14+
- Include comments for complex code, but prefer self-documenting code
15+
- Use the Expects() and Ensures() macros for contract verification
16+
17+
### Style Guidelines
18+
- Use 4 spaces for indentation (not tabs)
19+
- Maximum line length of 100 characters
20+
- Follow GSL naming conventions (lowercase with underscores)
21+
- Keep templates clean and readable with appropriate spacing
22+
- Use C++14 features since this is the minimum standard supported
23+
24+
### Error Handling
25+
- Use Expects() for preconditions and Ensures() for postconditions
26+
- Design for fail-fast semantics (std::terminate) on contract violations
27+
- Template constraints should use static_assert or SFINAE
28+
- Don't throw exceptions from basic operations
29+
30+
### Testing
31+
- Write thorough unit tests for every component using GTest
32+
- Test for all edge cases and error conditions
33+
- Ensure cross-platform compatibility in tests
34+
- Maintain 100% code coverage for changed code
35+
36+
## Project-Specific Conventions
37+
38+
### Architecture
39+
- All public types must be in the gsl namespace
40+
- Design for zero overhead abstractions when possible
41+
- Respect the distinction between Owners and Views
42+
- Maintain backward compatibility with existing GSL code
43+
44+
### Version Control
45+
- Link all PRs to related issues
46+
- Use clear commit messages explaining what and why
47+
- Follow the contribution guidelines documented in CONTRIBUTING.md
48+
- PRs should include appropriate tests with 100% coverage for changed code
49+
50+
### Documentation
51+
- Document all public APIs with clarity on preconditions and postconditions
52+
- Keep header comments up-to-date
53+
- Include examples for complex functionality in docs/headers.md
54+
55+
## Technology Stack
56+
- C++14 (minimum) for core implementation
57+
- CMake build system (3.14+)
58+
- Google Test for unit testing
59+
- Support for multiple compilers (MSVC, GCC, Clang)
60+
61+
## Security Considerations
62+
- Bounds checking is a core principle - enforce it consistently
63+
- Design for safety while minimizing overhead
64+
- Ensure undefined behavior is explicitly detected where possible
65+
66+
## Performance Guidelines
67+
- Optimize for both safety and performance
68+
- Constexpr-enable functions wherever possible
69+
- Avoid hidden allocations
70+
- Use noexcept appropriately for move operations and other performance-critical functions
71+
72+
## Cross-Platform Support
73+
- Code must work across:
74+
- Windows (MSVC)
75+
- Linux (GCC, Clang)
76+
- macOS (AppleClang)
77+
- Android and iOS where applicable
78+
79+
## Copilot Tasks
80+
- You can find the CMake artifacts for C++20 in build-cxx20 and C++14 in build-cxx14.
81+
- Before publishing a PR, verify the following:
82+
- There are no compiler warnings or errors when building the test suite.
83+
- The test suite passes on all supported platforms and compilers.
84+
- The test suite passes for both C++14 and C++20.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: "Copilot Setup Steps"
2+
3+
on: workflow_dispatch
4+
5+
jobs:
6+
copilot-setup-steps:
7+
runs-on: ubuntu-latest
8+
permissions:
9+
contents: read
10+
steps:
11+
- name: Checkout code
12+
uses: actions/checkout@v4
13+
14+
- name: Install Build Dependencies
15+
run: sudo apt-get update && sudo apt-get install -y clang cmake make
16+
17+
- name: Configure CMake (C++14)
18+
run: cmake -B build-cxx14 . -DGSL_CXX_STANDARD=14 -DGSL_TEST=ON -G "Unix Makefiles"
19+
20+
- name: Configure CMake (C++20)
21+
run: cmake -B build-cxx20 . -DGSL_CXX_STANDARD=20 -DGSL_TEST=ON -G "Unix Makefiles"
22+

0 commit comments

Comments
 (0)