agentleFS
MicrosoftKnown publishermicrosoft/react-native-windows-samples/.github/copilot-instructions.md

react-native-windows-samples

Copilot instructions544 starsChanged 15 months agoMITView on GitHub

This repository contains React Native samples, components, and templates for Windows, macOS, and Duo. It serves as a companion to the main React Native for Windows and React Native for macOS repositories. Setup a sample: Build and run: For native modules:

  • Installs packages

The file

Show its rules and text

We split this copilot-instructions.md into the rules it gives an agent

23 rules. About 0 are common, 20 are distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈20

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Follow React Native Windows System Requirements

    line 32
  2. Distinctive:

    TypeScript/JavaScript: Use ESLint and Prettier configurations from sample projects

    line 110
  3. Distinctive:

    C++: Follow Microsoft C++ coding standards

    line 111
  4. Distinctive:

    C#: Follow .NET coding conventions

    line 112
  5. Distinctive:

    Follow platform-specific testing practices

    line 123
  6. Very specific:

    Create folder in samples/ with PascalCase name

    line 130
  7. Distinctive:

    Add README.md with setup/run instructions

    line 132
  8. Distinctive:

    Update root README.md sample table

    line 133
  9. Distinctive:

    Add to CI workflows if appropriate

    line 134
  10. Very specific:

    Update React Native and RNW versions in package.json

    line 137
  11. Distinctive:

    Test across all supported platforms

    line 140
  12. Distinctive:

    C++/WinRT: Use Visual Studio for IntelliSense and debugging

    line 144
  13. Distinctive:

    Bridge Integration: Test JS-native communication thoroughly

    line 146
  14. Distinctive:

    Ensure Windows SDK and Visual Studio components are installed

    line 159
  15. Distinctive:

    Check React Native and RNW version compatibility

    line 160
  16. Very specific:

    Verify platform target (x86/x64/ARM64) matches your system

    line 161
  17. Distinctive:

    Ensure all dependencies are properly installed

    line 166
  18. Distinctive:

    Verify module registration in native code

    line 170
  19. Distinctive:

    Ensure proper export from native modules

    line 172
  20. Distinctive:

    Cross-platform compatibility: Test on multiple platforms when applicable

    line 177
  21. Distinctive:

    Dependencies: Use stable, widely-supported packages

    line 179
  22. Distinctive:

    Performance: Consider Windows-specific performance implications

    line 180
  23. Distinctive:

    Accessibility: Follow Windows accessibility guidelines

    line 181

≈ “Common” is an estimate: at least 1 in 5 of the 1,644 Copilot instructions files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
copilot-instructions.md

Copilot Instructions for React Native Windows Samples

Repository Overview

This repository contains React Native samples, components, and templates for Windows, macOS, and Duo. It serves as a companion to the main React Native for Windows and React Native for macOS repositories.

Repository Structure

├── samples/                    # Current React Native Windows samples
│   ├── Calculator/            # Calculator sample with C++/WinRT, C#, and Fabric implementations
│   ├── NativeModuleSample/    # Native module and component examples
│   └── ContinuousIntegration/ # CI/CD pipeline configurations
├── samples-old/               # Legacy samples for older RN versions
├── website/                   # Documentation website (Docusaurus)
├── docs/                      # Additional documentation
└── .github/                   # GitHub workflows and templates

Technology Stack

  • React Native for Windows (RNW): Target version 0.79+
  • Languages: TypeScript/JavaScript, C++/WinRT, C#
  • Build Tools: MSBuild, npm/yarn, React Native CLI
  • Platforms: Windows (x86, x64, ARM64), macOS, Android Emulator (Duo)
  • Testing: Jest, React Native testing tools
  • CI/CD: GitHub Actions with cross-platform builds

Development Environment

Prerequisites

Common Commands

Setup a sample:

cd samples/[SampleName]/[Implementation]
npm install  # or yarn install

Build and run:

npx @react-native-community/cli@latest run-windows

For native modules:

npx @react-native-community/cli@latest run-windows --no-autolink --no-deploy

Sample Projects

Calculator

  • Location: samples/Calculator/
  • Implementations:
    • cppwinrt/ - C++/WinRT implementation
    • csharp/ - C# implementation
    • fabric/ - New Architecture (Fabric) implementation
  • Purpose: Demonstrates basic RNW app structure and platform-specific implementations

NativeModuleSample

  • Location: samples/NativeModuleSample/
  • Purpose: Shows how to create native modules and components
  • Key Features: C++ native module examples, platform-specific APIs

ContinuousIntegration

  • Location: samples/ContinuousIntegration/
  • Purpose: Provides CI/CD pipeline templates for different RNW versions
  • Includes: GitHub Actions workflows, Azure DevOps pipelines

Build System

GitHub Actions Workflows

  • CI (ci.yml): Builds all samples across platforms weekly
  • CI Upgrade (ci-upgrade.yml): Tests sample upgrades
  • PR (pr.yml): Validates pull request changes
  • Website Publish: Deploys documentation website

Build Matrix

  • Configurations: Debug, Release
  • Platforms: x86, x64, ARM64
  • Sample Types: Apps, Native Modules

Code Patterns and Conventions

File Structure (Typical RNW Project)

├── android/           # Android platform files
├── ios/              # iOS platform files  
├── windows/          # Windows platform files
├── App.tsx           # Main app component
├── index.js          # Entry point
├── package.json      # Dependencies and scripts
├── metro.config.js   # Metro bundler configuration
└── tsconfig.json     # TypeScript configuration

Naming Conventions

  • Sample folders: PascalCase (e.g., Calculator, NativeModuleSample)
  • Implementation subfolders: lowercase (e.g., cppwinrt, csharp, fabric)
  • React components: PascalCase with .tsx extension
  • Native files: Follow platform conventions (C++: .cpp/.h, C#: .cs)

Code Style

  • TypeScript/JavaScript: Use ESLint and Prettier configurations from sample projects
  • C++: Follow Microsoft C++ coding standards
  • C#: Follow .NET coding conventions
  • Indentation: 2 spaces for JS/TS, 4 spaces for C++/C#

Testing Approach

JavaScript/TypeScript Testing

  • Framework: Jest with React Native testing utilities
  • Location: __tests__/ directories in each sample
  • Run: npm test or yarn test

Native Code Testing

  • Follow platform-specific testing practices
  • Integration tests through React Native bridge
  • Manual testing via sample applications

Common Development Tasks

Adding a New Sample

  1. Create folder in samples/ with PascalCase name
  2. Include implementations in subfolders (cppwinrt, csharp, etc.)
  3. Add README.md with setup/run instructions
  4. Update root README.md sample table
  5. Add to CI workflows if appropriate

Upgrading Samples

  1. Update React Native and RNW versions in package.json
  2. Run npx @react-native-community/cli@latest init --template react-native@latest
  3. Merge changes carefully, preserving sample-specific code
  4. Test across all supported platforms
  5. Update documentation

Working with Native Code

  • C++/WinRT: Use Visual Studio for IntelliSense and debugging
  • C#: Leverage Visual Studio's C# tools
  • Bridge Integration: Test JS-native communication thoroughly
  • Platform APIs: Reference WinRT documentation for Windows-specific features

Documentation

  • Main docs: docs/ directory and website
  • Sample docs: Individual README.md files
  • API references: Link to main RNW repository docs
  • Contributing: See CONTRIBUTING.md for guidelines

Troubleshooting Common Issues

Build Failures

  • Ensure Windows SDK and Visual Studio components are installed
  • Check React Native and RNW version compatibility
  • Verify platform target (x86/x64/ARM64) matches your system
  • Clear Metro cache: npx react-native start --reset-cache

Metro Bundle Issues

  • Check metro.config.js configuration
  • Ensure all dependencies are properly installed
  • Restart Metro server with cache reset

Native Module Loading

  • Verify module registration in native code
  • Check autolink configuration
  • Ensure proper export from native modules

Best Practices for Contributors

  1. Follow existing patterns: Match the structure and style of existing samples
  2. Cross-platform compatibility: Test on multiple platforms when applicable
  3. Documentation: Include clear README files and inline comments
  4. Dependencies: Use stable, widely-supported packages
  5. Performance: Consider Windows-specific performance implications
  6. Accessibility: Follow Windows accessibility guidelines
  7. Testing: Include both unit tests and integration examples

Related Resources

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.