-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Using AI to Work on .NET MAUI
This guide helps you use GitHub Copilot effectively when working on the .NET MAUI repository.
- Prerequisites - What you need before starting
- Custom Agents - Specialized agents for specific MAUI tasks
- Reusable Skills - Modular capabilities for common workflows
- Using Copilot with Git - Let Copilot handle your git operations
- Troubleshooting - Common issues and solutions
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
If you use any of our agents or just Copilot in general to work on an issue:
- End with a message summarizing your experience
- Export the chat session:
-
Copilot CLI: Use
/share fileto save as markdown or/share gistto create a GitHub gist - VS Code: Export as JSON
-
Copilot CLI: Use
- Attach the exported session to your PR
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.
In VS Code: Custom Agents in VS Code
In GitHub Copilot CLI: GitHub Copilot CLI
For best results with complex tasks like PR reviews, use plan mode first:
- Press
Shift+Tabto enter plan mode (or use/plan) - Ask Copilot to create a detailed plan for your task
- Review and refine the plan
- Press
Shift+Tabto exit plan mode - Tell Copilot to proceed with the plan
This gives you control over the approach before any actions are taken.
| Agent | Description | Location |
|---|---|---|
| PR Agent | End-to-end workflow for fixing issues and reviewing PRs | .github/agents/pr.md |
| Write Tests Agent | Determines test type and invokes appropriate testing skill | .github/agents/write-tests-agent.md |
| Sandbox Agent | Manual testing and PR validation with Sandbox app | .github/agents/sandbox-agent.md |
| Learn From PR Agent | Extracts lessons from PRs and applies improvements | .github/agents/learn-from-pr.md |
Purpose: End-to-end workflow for investigating issues and reviewing/working on PRs.
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 PR Agent uses a 5-phase workflow:
- Pre-Flight - Context gathering from issues/PRs
- Tests - Create or verify reproduction tests exist
- Gate - Verify tests catch the issue (mandatory checkpoint)
-
Fix - Explore fix alternatives using
try-fixskill - Report - Create PR or write review report
Example prompts:
fix issue #12345review PR #12345work on issue #12345continue 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-testsskill (visual bugs, user interactions) -
XAML Tests - via
write-xaml-testsskill (XAML parsing, compilation, source generation)
Example prompts:
write tests for issue #12345create tests for this PRadd 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 Androidreproduce issue #12345 in Sandboxtest 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 improvementsimprove repo based on what we learnedupdate skills based on PR
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.
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
| 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 | 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 |
| Skill | Purpose | Example Use |
|---|---|---|
| try-fix | Attempts ONE alternative fix, tests it, reports results | Used by PR agent in Fix phase |
| pr-finalize | Verifies PR title/description match implementation | finalize PR #12345 |
| pr-build-status | Retrieves Azure DevOps build info and Helix logs | check build status for PR #12345 |
| Skill | Purpose | Example Use |
|---|---|---|
| find-reviewable-pr | Finds PRs that need review, prioritized by importance | find PRs to review |
| 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? |
| Skill | Purpose | Example Use |
|---|---|---|
| ai-summary-comment | Posts/updates progress comments on PRs | Used by agents to report status |
See Agent Skills Reference for detailed documentation on each skill, including scripts, parameters, and examples.
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.
All agent and skill definitions live in the .github/ directory:
.github/
├── agents/ # Custom agent definitions
│ ├── pr.md # PR Agent (Phases 1-3)
│ ├── pr/post-gate.md # PR Agent (Phases 4-5)
│ ├── sandbox-agent.md # Sandbox testing agent
│ ├── write-tests-agent.md # Test writing agent
│ └── learn-from-pr.md # Learning agent
│
├── skills/ # Reusable skills
│ ├── ai-summary-comment/ # PR comment posting
│ ├── find-reviewable-pr/ # PR discovery
│ ├── issue-triage/ # Issue triage
│ ├── learn-from-pr/ # PR analysis
│ ├── pr-build-status/ # Build status retrieval
│ ├── pr-finalize/ # PR finalization
│ ├── run-device-tests/ # Device 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 guidance
│ ├── uitests.instructions.md
│ ├── xaml-unittests.instructions.md
│ ├── sandbox.instructions.md
│ └── ...
│
└── copilot-instructions.md # Main repository instructions
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?"
- 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
Before running tests or agents:
- Build the MSBuild tasks first:
dotnet build Microsoft.Maui.BuildTasks.slnf - Ensure you have the correct .NET SDK (check
global.json)
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.
For long workflows, use plan mode to maintain control:
-
Shift+Tabto enter plan mode - Create a plan for your task
- Execute in smaller steps
You can also use /share file to save progress before continuing.