Skip to content

doc: add GitHub Copilot custom instructions#5499

Draft
ekyooo wants to merge 1 commit intoiovisor:masterfrom
ekyooo:prompt_v2
Draft

doc: add GitHub Copilot custom instructions#5499
ekyooo wants to merge 1 commit intoiovisor:masterfrom
ekyooo:prompt_v2

Conversation

@ekyooo
Copy link
Copy Markdown
Collaborator

@ekyooo ekyooo commented Apr 1, 2026

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/)
  • prompts/: review-pr and check-bpf-safety for on-demand review
  • PULL_REQUEST_TEMPLATE.md: author checklist for commits and new tools

Copilot AI review requested due to automatic review settings April 1, 2026 06:50
@ekyooo ekyooo requested a review from brendangregg as a code owner April 1, 2026 06:50
Copy link
Copy Markdown

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 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/, and examples/.
  • 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.

@ekyooo ekyooo marked this pull request as draft April 1, 2026 07:12
@ekyooo ekyooo requested a review from Copilot April 1, 2026 23:48
Copy link
Copy Markdown

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 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
Copy link
Copy Markdown

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

Comment on lines +10 to +12
- 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.
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.

## API & ABI Stability

- Deprecate gracefully: add `[[deprecated(...)]]` and a one-time `fprintf(stderr, "Warning: …")` in the old function body
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
- 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

Copilot uses AI. Check for mistakes.
## Step 2: General Checks (All PRs)

### Commit Message
- [ ] Has correct prefix (e.g., `tools/toolname:`, `libbpf-tools/toolname:`, `src/cc:`, `doc:`, `build:`, `tests/python:`)
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
- [ ] 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:`)

Copilot uses AI. Check for mistakes.

### Style Checks

- **Python:** `scripts/py-style-check.sh` (pycodestyle, ignore E123/E125/E126/E127/E128/E302)
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
- **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)

Copilot uses AI. Check for mistakes.
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.

2 participants