RuleStack

Configs

Stacks

Compare

Diff

RuleStack

Configs

Stacks

Compare

Diff

Read API

RuleStack

Configs

Stacks

Compare

Diff

Read API

Configs/Copilot instructions/dotnet/maui

Copilot instructions

.github/instructions/ci-copilot-pipeline-security.instructions.md

Security rules for the Copilot PR-review pipeline. Read before editing.

Copilot instructions

Quality

76/100

Scores the file, not the repository.

Length

594 words

4 headings · 1 code blocks

Repository

23k

— · pushed 0 days ago

Last changed

3 days ago

First indexed 3 days ago.
dotnet/maui/.github/instructions/ci-copilot-pipeline-security.instructions.mdRawGitHub
1---
2description: "Security rules for the Copilot PR-review pipeline. Read before editing."
3applyTo: "eng/pipelines/ci-copilot.yml,eng/scripts/detect-ui-test-categories.ps1,.github/scripts/**,.github/pr-review/**,.github/skills/pr-review/**,.github/skills/verify-tests-fail-without-fix/**,.github/skills/try-fix/**,.github/skills/run-device-tests/**,.github/workflows/review-trigger.yml,.github/workflows/pr-review-queue.yml,.github/workflows/copilot-evaluate-tests.*"
4---
5 
6# CI Copilot pipeline — security rules
7 
8This pipeline runs **untrusted PR code** on AzDO agents with these tokens in scope:
9 
10- `GH_COMMENT_TOKEN` / `GH_TOKEN` — `maui-bot` PAT (post comments, labels, reviews on any PR)
11- `COPILOT_GITHUB_TOKEN` — Copilot CLI install token
12- AzDO GitHub service-connection PAT — repo contents, PRs, checks, workflows
13 
14Once the PR is merged into the worktree, the author controls every `.csproj`, `Directory.Build.targets`, source generator, analyzer, test, `.ps1`, and `.yml` the pipeline subsequently runs.
15 
16## Rules
17 
181. **Per-task `env:` scoping.** Only put tokens a task needs. The Copilot-agent task gets `COPILOT_GITHUB_TOKEN` only — never `GH_TOKEN`. Pass `--secret-env-vars=GH_TOKEN,GITHUB_TOKEN,COPILOT_GITHUB_TOKEN` to the Copilot CLI.
19 
202. **`persistCredentials: false` on every `checkout: self`** unless the task pushes. Default checkout writes the service-connection PAT into `.git/config` as `extraheader`, readable by any subprocess.
21 
223. **Trusted-copy scripts before merging the PR.** Setup task (still on `main`) copies `.github/scripts`, `.github/skills`, `eng/scripts` to `$(Build.ArtifactStagingDirectory)/trusted-github/`, then `chmod -R a-w`. Later tasks invoke scripts from `$TRUSTED/...`, never from the merged worktree. In PowerShell use `$ScriptsDir` / `$SkillsDir` / `$EngScriptsDir` (canonical impl in `Review-PR.ps1`). New post-merge scripts must be added to the Setup copy block.
23 
244. **Strip tokens before invoking PR-controlled code.** Wrap every `dotnet build|test|run|pack`, `msbuild`, `dotnet cake`, `BuildAndRun*.ps1`, `Run-DeviceTests.ps1`, `Invoke-UITestWithRetry.ps1` in `Invoke-WithoutGhTokens { ... }` (defined in `Review-PR.ps1` and `verify-tests-fail.ps1` — saves/clears/restores `GH_TOKEN`, `GITHUB_TOKEN`, `COPILOT_GITHUB_TOKEN`). **Wrap as close to the subprocess as possible, not at the outer trusted-script boundary** — a trusted script may itself need `gh` for metadata (e.g., `verify-tests-fail.ps1` calls `Detect-TestsInDiff.ps1` which uses `gh api`), so wrapping the whole script breaks its detection path. Wrap only the line that launches the PR-controlled process. Exception: scripts that ONLY call `gh` for PR metadata (`Detect-TestsInDiff.ps1`, `Find-RegressionRisks.ps1`, `detect-ui-test-categories.ps1`) don't need wrapping at all — they keep the token.
25 
265. **Cross-phase signal files in `$(Agent.TempDirectory)`** (or `$TRUSTED`), never `$RepoRoot/...`. PR code can overwrite anything in the worktree, including a gate verdict. Readers must not silently fall back to a worktree path if the trusted one is missing.
27 
286. **Strip `##vso[...]` from PR-controlled stdout.** Pipe through `tr -d '\r' | sed -E 's/##vso\[[^]]*\]//g'` — bare `sed` misses CRLF lines and the agent will execute the directive.
29 
307. **`gh-aw` workflows.** Pin compiler version (≥ v0.68.4 strips `pull-requests: write` per `gh-aw#28767`). Regenerate `.lock.yml` with `gh aw compile` in the **same commit** as any `.md` frontmatter edit (stale lock ⇒ all dispatches fail). `workflow_dispatch` triggers must restore trusted `.github/` from main (see `Checkout-GhAwPr.ps1`).
31 
328. **No token republish.** Don't `setvariable` a token (visible to every later task, even with `issecret=true`). Don't write tokens to worktree files. Don't echo token names.
33 
34## Review checklist
35 
36- [ ] New `checkout: self` has `persistCredentials: false`.
37- [ ] New `env:` block lists only the tokens that task needs; Copilot task has no `GH_TOKEN`.
38- [ ] New post-merge script invoked via `$ScriptsDir` / `$SkillsDir` / `$EngScriptsDir`, not `$RepoRoot/...`, AND added to Setup copy block.
39- [ ] New invocation of PR-controlled code (`dotnet test|build|run`, `BuildAndRun*`, `Run-DeviceTests`, `Invoke-UITestWithRetry`) is wrapped in `Invoke-WithoutGhTokens` AT THE CALL SITE (not at an outer boundary).
40- [ ] New cross-phase state file lives under `$(Agent.TempDirectory)` / `$TRUSTED`.
41- [ ] New PR-stdout pipe uses `tr -d '\r' | sed -E 's/##vso\[[^]]*\]//g'`.
42- [ ] Edited `.github/workflows/*.md` has matching `.lock.yml` regenerated in same commit.
43 
44## Grep these during review
45 
46```bash
47git grep -nE 'dotnet (test|build|run|pack)' eng/pipelines/ci-copilot.yml .github/scripts .github/skills | grep -v Invoke-WithoutGhTokens
48git grep -nE 'Join-Path \$RepoRoot ".*\.(ps1|sh)"' .github/scripts .github/skills
49git grep -nA1 'checkout: self' eng/pipelines/ci-copilot.yml | grep -v persistCredentials
50git grep -nE 'Set-Content.*\$RepoRoot.*(gate-result|sentinel|verdict)' .github/scripts .github/skills
51git grep -nE 'sed.*##vso' eng/pipelines/ci-copilot.yml | grep -v 'tr -d'
52```
53 

Commands it names

  • git grep -nE 'dotnet (test|build|run|pack)' eng/pipelines/ci-copilot.yml .github/scripts .github/skills | grep -v Invoke-WithoutGhTokens
  • git grep -nE 'Join-Path \$RepoRoot ".*\.(ps1|sh)"' .github/scripts .github/skills
  • git grep -nA1 'checkout: self' eng/pipelines/ci-copilot.yml | grep -v persistCredentials
  • git grep -nE 'Set-Content.*\$RepoRoot.*(gate-result|sentinel|verdict)' .github/scripts .github/skills
  • git grep -nE 'sed.*##vso' eng/pipelines/ci-copilot.yml | grep -v 'tr -d'
  • dotnet build|test|run|pack
  • dotnet cake
  • gh-aw
  • gh-aw#28767
  • gh aw compile
  • dotnet test|build|run

Sections

  • CI Copilot pipeline — security rules
  • Rules
  • Review checklist
  • Grep these during review

What it covers

git-prsecuritydeploymentdo-notagent-behaviour

Stack — with the evidence

csharp

(1.00)

dotnet

(1.00)

swift

(0.60)

github-actions

(0.60)

Glob targeting

  • eng/pipelines/ci-copilot.yml
  • eng/scripts/detect-ui-test-categories.ps1
  • .github/scripts/**
  • .github/pr-review/**
  • .github/skills/pr-review/**
  • .github/skills/verify-tests-fail-without-fix/**
  • .github/skills/try-fix/**
  • .github/skills/run-device-tests/**
  • .github/workflows/review-trigger.yml
  • .github/workflows/pr-review-queue.yml
  • .github/workflows/copilot-evaluate-tests.*

Format

Copilot instructions

Two layers: one always-on repo file, plus optional glob-scoped instruction files. Lives under .github/ rather than the repo root, which is the tell that it is aimed at the GitHub platform surface as much as the editor.

What the corpus says about it

Repository

Owner
dotnet
Language
—
License
—
Archived
no

All configs in this repo

Also in dotnet/maui

Diff this repo’s formats

One repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?

The other instruction files in this repository
RepositoryFormatStackCoversScoreChanged
dotnet/maui.github/copilot-instructions.md · 23kCopilot instructionscsharpdotnet+2setuptestlint-formatstyle+676/1003 days ago
dotnet/maui.github/instructions/handler-patterns.instructions.md · 23kCopilot instructionscsharpdotnet+2styledo-not55/1003 days ago
dotnet/maui.github/instructions/android.instructions.md · 23kCopilot instructionscsharpdotnet+2buildstyle70/1003 days ago
dotnet/maui.github/instructions/collectionview-android.instructions.md · 23kCopilot instructionscsharpdotnet+2stylearchperformanceagent-behaviour52/1003 days ago
dotnet/maui.github/instructions/collectionview-handler-detection.instructions.md · 23kCopilot instructionscsharpdotnet+2stylegitdo-not73/1003 days ago
dotnet/maui.github/instructions/collectionview-ios.instructions.md · 23kCopilot instructionscsharpdotnet+2styleperformance48/1003 days ago
dotnet/maui.github/instructions/collectionview-windows.instructions.md · 23kCopilot instructionscsharpdotnet+2stylearch52/1003 days ago
dotnet/maui.github/instructions/helix-device-tests.instructions.md · 23kCopilot instructionscsharpdotnet+2setupbuildtestarch74/1003 days ago
dotnet/maui.github/instructions/integration-tests.instructions.md · 23kCopilot instructionscsharpdotnet+2setupteststyledo-not92/1003 days ago
dotnet/maui.github/instructions/layout-system.instructions.md · 23kCopilot instructionscsharpdotnet+2archapiperformancedo-not55/1003 days ago
dotnet/maui.github/instructions/performance-hotpaths.instructions.md · 23kCopilot instructionscsharpdotnet+2styleperformancedo-not55/1003 days ago
dotnet/maui.github/instructions/public-api.instructions.md · 23kCopilot instructionscsharpdotnet+2apido-not59/1003 days ago
dotnet/maui.github/instructions/safe-area-ios.instructions.md · 23kCopilot instructionscsharpdotnet+2stylegit43/1003 days ago
dotnet/maui.github/instructions/sandbox.instructions.md · 23kCopilot instructionscsharpdotnet+2buildteststyletesting-strategy+481/1003 days ago
dotnet/maui.github/instructions/templates.instructions.md · 23kCopilot instructionscsharpdotnet+2buildteststylearch+192/1003 days ago
dotnet/maui.github/instructions/threading-async.instructions.md · 23kCopilot instructionscsharpdotnet+2styleui48/1003 days ago
dotnet/maui.github/instructions/uitests.instructions.md · 23kCopilot instructionscsharpdotnet+2setupbuildteststyle+579/1003 days ago
dotnet/maui.github/instructions/xaml-unittests.instructions.md · 23kCopilot instructionscsharpdotnet+2teststyledocs70/1003 days ago
Diff against .github/copilot-instructions.md Diff against .github/instructions/handler-patterns.instructions.md Diff against .github/instructions/android.instructions.md Diff against .github/instructions/collectionview-android.instructions.md Diff against .github/instructions/collectionview-handler-detection.instructions.md Diff against .github/instructions/collectionview-ios.instructions.md Diff against .github/instructions/collectionview-windows.instructions.md Diff against .github/instructions/helix-device-tests.instructions.md Diff against .github/instructions/integration-tests.instructions.md Diff against .github/instructions/layout-system.instructions.md Diff against .github/instructions/performance-hotpaths.instructions.md Diff against .github/instructions/public-api.instructions.md Diff against .github/instructions/safe-area-ios.instructions.md Diff against .github/instructions/sandbox.instructions.md Diff against .github/instructions/templates.instructions.md Diff against .github/instructions/threading-async.instructions.md Diff against .github/instructions/uitests.instructions.md Diff against .github/instructions/xaml-unittests.instructions.md

Similar configs

Same format, overlapping stack, ranked by quality.

Same format, overlapping stack, ranked by quality
RepositoryFormatStackCoversScoreChanged
dotnet/roslyn.github/instructions/Compiler.instructions.md · 21kCopilot instructionscsharpdotnet+1buildteststylearch+399/1003 days ago
dotnet/roslyn.github/copilot-instructions.md · 21kCopilot instructionscsharpdotnet+1buildteststylearch+397/1003 days ago
ardalis/CleanArchitecture.github/copilot-instructions.md · 18kCopilot instructionscsharpdotnet+1buildteststylearch+496/1003 days ago
dotnet/maui.github/instructions/templates.instructions.md · 23kCopilot instructionscsharpdotnet+2buildteststylearch+192/1003 days ago
dotnet/maui.github/instructions/integration-tests.instructions.md · 23kCopilot instructionscsharpdotnet+2setupteststyledo-not92/1003 days ago
microsoft/WSL.github/copilot-instructions.md · 33kCopilot instructionscsharpcpp+2setupbuildtestlint-format+788/1003 days ago
we-promise/sure.github/copilot-instructions.md · 9.3kCopilot instructionsrubyrails+13setuptestlint-formatstyle+1088/1002 days ago
PowerShell/PowerShell.github/instructions/start-native-execution.instructions.md · 55kCopilot instructionscsharpdotnet+1buildstylearchgit+186/1003 days ago
RuleStack

Built by

Kynth Studio

Directory

Configs
Stacks
Compare formats
Diff two configs
Best AGENTS.md examples

Formats

AGENTS.md
CLAUDE.md
Cursor rules
Copilot instructions

Reference

Read API
Corpus health
Privacy Policy
Terms

RuleStack

RuleStack

Built by

Kynth Studio

Directory

Configs
Stacks
Compare formats
Diff two configs
Best AGENTS.md examples

Formats

AGENTS.md
CLAUDE.md
Cursor rules
Copilot instructions

Reference

Read API
Corpus health
Privacy Policy
Terms

RuleStack

RuleStack

Built by

Kynth Studio

Directory

Configs
Stacks
Compare formats
Diff two configs
Best AGENTS.md examples

Formats

AGENTS.md
CLAUDE.md
Cursor rules
Copilot instructions

Reference

Read API
Corpus health
Privacy Policy
Terms

RuleStack