Skip to content

Using AI to Work on .NET MAUI

Jakub Florkowski edited this page May 22, 2026 · 12 revisions

This guide helps you use GitHub Copilot effectively when working on the .NET MAUI repository.

Table of Contents


Prerequisites

Before using the AI agents and skills, ensure you have:

  • GitHub Copilot access - Active subscription with CLI or VS Code extension
  • VS Code - With GitHub Copilot extension installed
  • .NET MAUI development environment - See Windows Install or macOS Install
  • Cloned .NET MAUI repository - git clone https://github.com/dotnet/maui.git
  • For Sandbox testing: Android emulator and/or iOS simulator configured

Export Your Chat Sessions

If you use any of our agents or just Copilot in general to work on an issue:

  1. End with a message summarizing your experience
  2. Export the chat session:
    • Copilot CLI: Use /share file to save as markdown or /share gist to create a GitHub gist
    • VS Code: Export as JSON
  3. Attach the exported session to your PR

Custom Agents

The .NET MAUI repository includes specialized AI agents designed to help with specific development tasks. These agents are available through GitHub Copilot and provide expert assistance for common workflows.

How to Use Custom Agents

In VS Code: Custom Agents in VS Code

In GitHub Copilot CLI: GitHub Copilot CLI

Pro Tip: Use Plan Mode for Complex Tasks

For best results with complex tasks like PR reviews, use plan mode first:

  1. Press Shift+Tab to enter plan mode (or use /plan)
  2. Ask Copilot to create a detailed plan for your task
  3. Review and refine the plan
  4. Press Shift+Tab to exit plan mode
  5. Tell Copilot to proceed with the plan

This gives you control over the approach before any actions are taken.

Available Agents

Agent Description Location
PR Review Workflow End-to-end workflow for fixing issues and reviewing PRs .github/skills/pr-review/SKILL.md + Review-PR.ps1
Write Tests Agent Determines test type and invokes appropriate testing skill .github/agents/write-tests-agent.agent.md
Sandbox Agent Manual testing and PR validation with Sandbox app .github/agents/sandbox-agent.agent.md
Learn From PR Agent Extracts lessons from PRs and applies improvements .github/agents/learn-from-pr.agent.md
Agentic Workflows Agent Dispatcher for creating, updating, and debugging gh-aw workflows .github/agents/agentic-workflows.agent.md
MAUI Expert Reviewer Deep 30-dimension code review for the automated pipeline .github/agents/maui-expert-reviewer.md

Purpose: End-to-end workflow for investigating issues and reviewing/working on PRs. Orchestrated by Review-PR.ps1 and the pr-review skill.

When to use: When you need to fix an issue (with or without an existing PR), review a PR with independent analysis, or continue work on an in-progress fix.

The workflow runs these steps:

  1. Gate - Verify tests catch the issue (script-only, no AI)
  2. Pre-Flight - Context gathering from issues/PRs
  3. Try-Fix - 4 AI models explore independent fix alternatives
  4. Report - Expert hardening and final recommendation

Example prompts:

  • fix issue #12345
  • review PR #12345
  • work on issue #12345
  • continue working on #12345

Purpose: Determines what type of tests are needed and invokes the appropriate skill.

When to use: When creating new tests for issues or PRs.

Supported test types:

  • UI Tests - via write-ui-tests skill (visual bugs, user interactions)
  • XAML Tests - via write-xaml-tests skill (XAML parsing, compilation, source generation)

Example prompts:

  • write tests for issue #12345
  • create tests for this PR
  • add test coverage for CollectionView selection

Purpose: Test and validate PR functionality using the Sandbox app with automated deployment and testing.

When to use: When you want to manually verify a fix works on device/simulator, reproduce an issue, or validate PR functionality.

Example prompts:

  • test PR #12345 on Android
  • reproduce issue #12345 in Sandbox
  • test this PR on iOS

Purpose: Extracts lessons from completed PRs and applies improvements to the repository.

When to use: After complex PRs, when agents struggled to find solutions, or to improve instruction files and skills based on lessons learned.

Example prompts:

  • learn from PR #12345 and apply improvements
  • improve repo based on what we learned
  • update skills based on PR

Agentic Workflows Agent

Purpose: Dispatcher for GitHub Agentic Workflows — helps create, update, debug, upgrade, and report on gh-aw workflows.

When to use: When you need to work with the automated workflow infrastructure (.github/workflows/*.md files and their generated .lock.yml files).

Example prompts:

  • create a new agentic workflow
  • debug the agentic-labeler workflow
  • upgrade all workflows to latest gh-aw version

Note: This agent has disable-model-invocation: true — it routes to specific prompt templates rather than generating solutions itself.


MAUI Expert Reviewer

Purpose: Deep PR reviewer that evaluates code across 30 dimensions covering layout, handlers, platform specifics, performance, API design, CollectionView, navigation, XAML, accessibility, and regression patterns.

When to use: Primarily used internally by the code-review skill and the automated PR review pipeline. Can also be invoked directly for thorough per-dimension analysis.

Capabilities:

  • Runs per-dimension sub-agent evaluation in parallel
  • Writes inline findings as structured JSON
  • Covers MAUI-specific patterns that general code review misses

Reusable Skills

Skills are modular capabilities that provide specialized functionality for common workflows. Think of them as building blocks that can be used directly or composed by agents to accomplish larger tasks.

Why Skills?

Skills encapsulate expert knowledge about specific tasks - like writing UI tests, verifying test quality, or exploring fix alternatives. They:

  • Reduce errors by encoding best practices and conventions
  • Save time by automating repetitive workflows
  • Ensure consistency across different contributors
  • Enable agents to perform complex multi-step operations

Skills vs Agents

Aspect Skills Agents
Scope Single-purpose operations Multi-phase workflows
State Stateless Track state across phases
Invoke Direct request or by agents Delegate to agent
Output Specific result (tests, analysis, status) Complete solution with documentation
Example "Verify these tests fail" "Fix issue #12345 end-to-end"

Skill Categories

🧪 Testing Skills

Skill Purpose Example Use
write-ui-tests Creates UI tests for GitHub issues write UI test for issue #12345
write-xaml-tests Creates XAML unit tests for parsing/compilation write XAML test for binding issue
verify-tests-fail-without-fix Verifies tests actually catch the bug Used by agents after test creation
run-device-tests Runs device tests locally on iOS/Android/Windows run Button tests on iOS
run-helix-tests Submits and monitors unit tests on Helix infrastructure run XAML unit tests on Helix
run-integration-tests Builds, packs, and runs integration tests locally run integration tests
evaluate-pr-tests Evaluates test quality, coverage, and appropriateness evaluate tests on PR #12345

🔍 PR Review Skills

Skill Purpose Example Use
pr-review End-to-end PR reviewer (Pre-Flight → Try-Fix → Report) review PR #12345
code-review Standalone deep code review with MAUI-specific rules code review PR #12345
try-fix Attempts ONE alternative fix, tests it, reports results Used by pr-review in Try-Fix phase
pr-finalize Verifies PR title/description match implementation finalize PR #12345
find-reviewable-pr Finds PRs that need review, prioritized by importance find PRs to review

📋 Triage & Discovery Skills

Skill Purpose Example Use
issue-triage Queries and triages open issues one at a time triage Android issues
learn-from-pr Analyzes PRs for lessons learned (analysis only) what can we learn from PR #12345?
find-regression-risk Detects regression risks by comparing PR changes to recent bug fixes Used by automated pipeline

🔧 CI & Infrastructure Skills

Skill Purpose Example Use
azdo-build-investigator Investigates Azure DevOps CI failures, Helix logs, binlogs investigate CI failure on PR #12345
agentic-labeler Auto-labels issues/PRs with area-* and platform/* labels Used by automated workflow
dependency-flow MAUI dependency flow, channel conventions, and feed lookups feeds for .NET MAUI 10.0

See Agent Skills Reference for detailed documentation on each skill, including scripts, parameters, and examples.


Automated Workflows

The repository uses GitHub Agentic Workflows (gh-aw) to automate routine tasks. Each workflow has a source .md file and a generated .lock.yml file — always edit the .md file and run gh aw compile to regenerate the lock file.

Workflow Source Purpose
Agentic Labeler .github/workflows/agentic-labeler.md Auto-labels issues and PRs with area-* and platform/* labels based on content
Evaluate Tests .github/workflows/copilot-evaluate-tests.md Evaluates test quality and coverage on PRs that add or modify tests (triggered by /evaluate-tests slash command)
Daily Repo Status .github/workflows/daily-repo-status.md Generates daily repo activity summaries and insights

⚠️ Never edit .lock.yml files directly. Edit the .md source, then run gh aw compile and commit both files together.


Instruction Files

Instruction files provide context-specific coding guidance that Copilot automatically uses when working with matching file patterns. They're located in .github/instructions/ and cover:

Category Files Topics
Handlers handler-patterns, collectionview-* (4 files) Mapper rules, lifecycle, null-safety, platform-specific CollectionView guidance
Platform android, safe-area-ios, threading-async Android coding rules, iOS safe area behavior, threading/async patterns
Testing uitests, xaml-unittests, helix-device-tests, integration-tests, sandbox Test authoring guidelines per test type
Performance performance-hotpaths, layout-system Hot-path optimization, layout measure/arrange contract
API public-api, templates PublicAPI.Unshipped.txt management, template editing rules

These files are automatically loaded based on glob patterns matching the files you're editing. See .github/copilot-instructions.md for the full pattern-to-file mapping.


Using Copilot with Git

GitHub Copilot can handle git operations for you - committing changes, squashing commits, rebasing branches, resolving conflicts, and creating PR descriptions.

See the Using Copilot with Git Guide for detailed examples and prompts.


Repository Structure

All agent and skill definitions live in the .github/ directory:

.github/
├── agents/                              # Custom agent definitions
│   ├── agentic-workflows.agent.md       # Agentic Workflows dispatcher
│   ├── write-tests-agent.agent.md       # Test writing agent
│   ├── sandbox-agent.agent.md           # Sandbox testing agent
│   ├── learn-from-pr.agent.md           # Learning agent
│   └── maui-expert-reviewer.md          # 30-dimension PR reviewer
│
├── skills/                              # Reusable skills
│   ├── agentic-labeler/                 # Auto-labeling
│   ├── azdo-build-investigator/         # CI failure investigation
│   ├── code-review/                     # Deep code review
│   ├── dependency-flow/                 # Dependency flow & feeds
│   ├── evaluate-pr-tests/               # Test quality evaluation
│   ├── find-regression-risk/            # Regression risk detection
│   ├── find-reviewable-pr/              # PR discovery
│   ├── issue-triage/                    # Issue triage
│   ├── learn-from-pr/                   # PR analysis
│   ├── pr-finalize/                     # PR finalization
│   ├── pr-review/                       # End-to-end PR review orchestrator
│   ├── run-device-tests/                # Device test execution
│   ├── run-helix-tests/                 # Helix test submission
│   ├── run-integration-tests/           # Integration test execution
│   ├── try-fix/                         # Fix exploration
│   ├── verify-tests-fail-without-fix/   # Test verification
│   ├── write-ui-tests/                  # UI test creation
│   └── write-xaml-tests/                # XAML test creation
│
├── instructions/                        # Context-specific coding guidance
│   ├── uitests.instructions.md
│   ├── xaml-unittests.instructions.md
│   ├── sandbox.instructions.md
│   ├── handler-patterns.instructions.md
│   └── ... (17 files total)
│
├── pr-review/                           # PR review phase instructions
│   ├── pr-preflight.md                  # Pre-flight context gathering
│   ├── pr-gate.md                       # Gate verification rules
│   └── pr-report.md                     # Report generation
│
├── scripts/                             # Orchestration scripts
│   ├── Review-PR.ps1                    # PR review pipeline orchestrator
│   ├── BuildAndRunHostApp.ps1           # UI test host app builder
│   ├── BuildAndRunSandbox.ps1           # Sandbox app builder
│   ├── Find-RegressionRisks.ps1         # Regression risk detector
│   ├── EstablishBrokenBaseline.ps1      # Baseline management for try-fix
│   ├── post-ai-summary-comment.ps1      # Posts AI review summary to PR
│   └── shared/                          # Shared utilities
│
├── workflows/                           # GitHub Agentic Workflows (gh-aw)
│   ├── agentic-labeler.md               # Auto-labeling workflow
│   ├── copilot-evaluate-tests.md        # Test evaluation workflow
│   └── daily-repo-status.md             # Daily status report
│
└── copilot-instructions.md              # Main repository instructions

Troubleshooting

Agent seems stuck or taking too long

Long-running operations are normal:

  • PR Agent full workflow: 25-60 minutes total
  • Test verification: 5-15 minutes per platform
  • Sandbox builds: 5-10 minutes first build

If truly stuck, check if there's a prompt waiting for input. You can also try: "what's the current status?"

Tests won't fail (can't reproduce the bug)

  • Verify you're testing on the correct platform
  • Check if the reproduction steps from the issue are complete
  • Try asking: "show me the test scenario and what it's checking"
  • If tests pass when they shouldn't, the test scenario may not match the bug

Build failures

Before running tests or agents:

  1. Build the MSBuild tasks first: dotnet build Microsoft.Maui.BuildTasks.slnf
  2. Ensure you have the correct .NET SDK (check global.json)

Gate phase keeps failing

Gate fails when tests don't properly catch the bug. Common causes:

  • Tests pass without the fix (tests don't reproduce the bug)
  • Tests fail with the fix (fix doesn't work)
  • Wrong platform being tested

Ask: "why did Gate fail?" for specific guidance.

Session times out or gets confused

For long workflows, use plan mode to maintain control:

  1. Shift+Tab to enter plan mode
  2. Create a plan for your task
  3. Execute in smaller steps

You can also use /share file to save progress before continuing.

Clone this wiki locally