doc: add GitHub Copilot custom instructions#5499
doc: add GitHub Copilot custom instructions#5499ekyooo wants to merge 1 commit intoiovisor:masterfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Adds repository-level GitHub Copilot guidance tailored to BCC’s eBPF safety requirements and subsystem conventions, aiming to improve consistency and catch verifier/safety issues during AI-assisted reviews.
Changes:
- Introduces global Copilot instructions plus path-scoped review instructions for
tools/,libbpf-tools/,src/cc/, andexamples/. - Adds two on-demand prompt templates for PR review and BPF safety checking.
- Adds a PR template checklist emphasizing commit hygiene and documentation requirements (especially for new tools).
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| .github/copilot-instructions.md | Global Copilot review principles, safety rules, and new-tool documentation requirements |
| .github/instructions/tools.instructions.md | Path-scoped review rules for Python/BCC tools |
| .github/instructions/libbpf-tools.instructions.md | Path-scoped review rules for libbpf CO-RE tools |
| .github/instructions/core.instructions.md | Path-scoped review rules for core src/cc library changes |
| .github/instructions/examples.instructions.md | Path-scoped review rules for educational examples |
| .github/prompts/review-pr.prompt.md | Prompt template for consistent PR review output/checklist |
| .github/prompts/check-bpf-safety.prompt.md | Prompt template for focused verifier/safety checks on BPF C code |
| .github/PULL_REQUEST_TEMPLATE.md | Contributor-facing checklist and note about optional Copilot review |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 8 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Without BCC-specific context, Copilot misses eBPF safety issues (NULL checks, 512-byte stack limit) and inconsistently enforces project conventions during code review. - copilot-instructions.md: global BPF safety rules, doc requirements - instructions/*.instructions.md: path-specific rules per subsystem (tools/, libbpf-tools/, src/cc/, examples/) - instructions/instructions.instructions.md: self-referential rule for authoring instruction files - prompts/: review-pr and check-bpf-safety for on-demand review - PULL_REQUEST_TEMPLATE.md: author checklist for commits and new tools
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| - MUST NOT break public C++ APIs without a deprecation cycle. | ||
| - When changing a C++ function signature, MUST update `src/python/bcc/__init__.py` ctypes bindings. | ||
| - MUST NULL-check every `malloc()`, `calloc()`, `realloc()`, and `strdup()` call. |
There was a problem hiding this comment.
src/python/bcc/__init__.py doesn’t appear to be where the libbcc ctypes function signatures are defined; those argtypes/restype bindings live in src/python/bcc/libbcc.py (and __init__.py mostly wraps higher-level APIs). This rule should point to libbcc.py (and any wrapper call sites) so reviewers update the correct bindings when C/C++ signatures change.
|
|
||
| ## API & ABI Stability | ||
|
|
||
| - Deprecate gracefully: add `[[deprecated(...)]]` and a one-time `fprintf(stderr, "Warning: …")` in the old function body |
There was a problem hiding this comment.
This deprecation guidance introduces [[deprecated(...)]] + a runtime fprintf warning, but the repo doesn’t currently use [[deprecated]] anywhere. Consider aligning with existing deprecation patterns (e.g., __attribute__((deprecated("...")))) or documenting that this is a new convention and ensuring it matches the project’s supported compilers/standards.
| - Deprecate gracefully: add `[[deprecated(...)]]` and a one-time `fprintf(stderr, "Warning: …")` in the old function body | |
| - Deprecate gracefully: use the project’s existing deprecation attribute (for example, `__attribute__((deprecated("…")))`) and a one-time `fprintf(stderr, "Warning: …")` in the old function body |
| ## Step 2: General Checks (All PRs) | ||
|
|
||
| ### Commit Message | ||
| - [ ] Has correct prefix (e.g., `tools/toolname:`, `libbpf-tools/toolname:`, `src/cc:`, `doc:`, `build:`, `tests/python:`) |
There was a problem hiding this comment.
This prompt’s commit-prefix examples omit ci: but .github/copilot-instructions.md includes it. Consider using the same prefix list in both places so reviewers/authors aren’t given conflicting guidance.
| - [ ] Has correct prefix (e.g., `tools/toolname:`, `libbpf-tools/toolname:`, `src/cc:`, `doc:`, `build:`, `tests/python:`) | |
| - [ ] Has correct prefix (e.g., `tools/toolname:`, `libbpf-tools/toolname:`, `src/cc:`, `doc:`, `build:`, `tests/python:`, `ci:`) |
|
|
||
| ### Style Checks | ||
|
|
||
| - **Python:** `scripts/py-style-check.sh` (pycodestyle, ignore E123/E125/E126/E127/E128/E302) |
There was a problem hiding this comment.
scripts/py-style-check.sh does more than run pycodestyle: it also fails on executable tools/ and examples/ Python files that don’t use the #!/usr/bin/python shebang. Consider mentioning that shebang/executable-bit check here so contributors aren’t surprised when style checks fail.
| - **Python:** `scripts/py-style-check.sh` (pycodestyle, ignore E123/E125/E126/E127/E128/E302) | |
| - **Python:** `scripts/py-style-check.sh` (runs `pycodestyle` ignoring E123/E125/E126/E127/E128/E302, and also fails on executable `tools/` and `examples/` Python files that don’t use the `#!/usr/bin/python` shebang) |
Without BCC-specific context, Copilot misses eBPF safety issues (NULL checks, 512-byte stack limit) and inconsistently enforces project conventions during code review.