agentleFS
MicrosoftKnown publishermicrosoft/windows-rs/.github/copilot-instructions.md

windows-rs

Copilot instructions13k starsChanged 58 days agoApache-2.0View on GitHub

Read this file at the start of every session. It contains the essential commands, conventions, and architecture knowledge needed to work on this repository. Do not create git commits automatically. The maintainer reviews all changes first and handles commits manually. Make changes locally, run fmt/clippy/tests to verify, and report back. Cargo workspace (resolver = "3"). Members are globbed from: - crates/libs/* - the published/library crates (windows, windows-sys, windows-core, plus windows-bindgen, metadata, rdl, and the newer reactor/canvas/webview/window crates). See docs/readme.md for…

Trending

Quiet since July.about the whole repository

Dec 2025: 0 mentionsJan 2026: 0 mentionsFeb 2026: 1 mentionMar 2026: 0 mentionsApr 2026: 0 mentionsMay 2026: 3 mentionsJun 2026: 2 mentionsJul 2026: 1 mentionAug 2026: 0 mentionsSep 2026: 0 mentionsOct 2026: 0 mentionsNov 2026: 0 mentions
Dec 2025Jun 2026Nov 2026
Mentions a month of the microsoft/windows-rs repository that our weekly crawl found. There is no adoption data for this file yet.

Who's talking about microsoft/windows-rs

The biggest 5 of 41 mentions linking to the repository that our crawl found. Each line is their own headline.

See all 41

Talked about on Bluesky, GitHub and Hacker News (41 times).

On Bluesky · 18

13 more on Bluesky

On GitHub · 17

12 more on GitHub

On Hacker News · 6

1 more on Hacker News

The file

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

10 rules. About 0 are common, 1 is distinctive, and 9 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 9

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Read this file at the start of every session.

    line 3
  2. Very specific:

    Do not create git commits automatically.

    line 8
  3. Very specific:

    After regenerating, always verify: cargo check -p <affected-crate> --quiet

    line 130
  4. Very specific:

    Panics: Use panic! only for invariant violations.

    line 163
  5. Very specific:

    No thread_local! in app code: - keep state in components and pass shared values through typed contexts.

    line 166
  6. Very specific:

    When making changes to a crate, update its docs/crates/<crate>.md page and its readme.md as needed.

    line 184
  7. Very specific:

    ASCII punctuation only: Use - for dashes (never em/en-dashes), ...

    line 194
  8. Very specific:

    No LLM tells: Avoid the vocabulary and tics that mark agent-written text: faithful, corpus, ledger, crucially, notably, essentially, …

    line 200
  9. Very specific:

    No decorative formatting: No box-drawing banner comments (// -- Title ------), no duplicated doc paragraphs (a real copy-paste tell), no …

    line 206
  10. Very specific:

    Describe the code as it is,: not its history. Avoid churn narration (used to, previously, an earlier version, no longer) unless it …

    line 210

≈ “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 windows-rs

Read this file at the start of every session. It contains the essential commands, conventions, and architecture knowledge needed to work on this repository.

Workflow

Do not create git commits automatically. The maintainer reviews all changes first and handles commits manually. Make changes locally, run fmt/clippy/tests to verify, and report back.

Repository Layout

Cargo workspace (resolver = "3"). Members are globbed from:

  • crates/libs/* - the published/library crates (windows, windows-sys, windows-core, plus windows-bindgen, metadata, rdl, and the newer reactor/canvas/webview/window crates). See docs/readme.md for the full categorized crate index, and docs/crates/<crate>.md per crate.
  • crates/tools/* - code generators and CI helpers, run via cargo run -p tool-*.
  • crates/tests/*/* - test crates; crates/tests/libs/<crate> mirrors each library crate (e.g. test_reactor, test-webview). Crate names are test_<dir>.
  • crates/samples/*/* - runnable examples.

The crates fall into rough groups (see docs/readme.md for the authoritative list): core & errors (windows-core, windows-result, windows-strings); values & collections (numerics, collections, reference, time); async & threading (future, threading); system services (registry, services, version); COM macros & linking (implement, interface, link); UI & graphics (reactor, canvas, webview, window, animation, reactor-setup); codegen & metadata tooling (bindgen, metadata, rdl, cppwinrt); and the full API projection (windows, windows-sys).

Before Finalizing Changes

cargo fmt --all

CI enforces rustfmt. Always format before finalizing changes. On Windows, the workspace-wide command may exceed the process command-line limit; use cargo fmt -p <crate> for each affected crate instead.

Build & Test Commands

Core crates

cargo check -p windows-core --quiet
cargo check -p windows --quiet
cargo clippy -p <crate> --all-targets
cargo test -p <crate>

# Run a single test by name filter
cargo test -p <crate> <test_name_substring>

CI sets RUSTFLAGS: -D warnings, so any warning fails the build. Workspace-wide lints are configured in the root Cargo.toml ([workspace.lints]) - clippy lints like uninlined_format_args, redundant_clone, and semicolon_if_nothing_returned are promoted to warnings and therefore enforced.

Reactor

# Refresh WinUI metadata after changing Windows App SDK or WebView2 pins
cargo run -p tool-reactor-metadata --quiet

# Regenerate Reactor code after editing schema.toml or tool-reactor source
cargo run -p tool-reactor --quiet

# Regenerate bindings (after editing filter .txt files)
cargo run -p tool-bindings --quiet

# Verify reactor compiles
cargo check -p windows-reactor --quiet

# Unit tests (headless, fast)
cargo test -p windows-reactor --all-features --quiet

# Integration tests (launches WinUI window)
cargo run -p test-reactor-selftest
cargo run -p test-reactor-selftest -- --headless    # CI mode
cargo run -p test-reactor-selftest --bin application_menu
cargo run -p test-reactor-selftest --bin canvas_integration
cargo run -p test-reactor-selftest --bin webview_integration
cargo run -p test-reactor-selftest --bin window_state

# Clippy
cargo clippy -p windows-reactor --all-targets

Canvas

cargo check -p windows-canvas --quiet
cargo test -p windows-canvas --quiet
cargo clippy -p windows-canvas --all-targets

Full workspace

cargo run -p tool-clippy-all    # runs clippy across all crates

Code Generation Pipeline

Never hand-edit generated files. Generated outputs are committed, and CI fails if regenerating produces a diff (the gen workflow runs each cargo run -p tool-* and rejects any change; the test workflow likewise fails if tests modify tracked files). After editing generators or filters, re-run the tool and commit the result.

The core windows / windows-sys crates are generated from Windows metadata (.winmd) via windows-bindgen (driven by tool-package). windows-metadata and windows-rdl support reading/authoring that metadata. The reactor / canvas / webview pipelines layer on top:

  1. tool-reactor-metadata - refreshes committed WinUI / Windows App SDK / WebView2 .winmd metadata and generates extras.winmd.
  2. tool-reactor - reads crates/tools/reactor/src/schema.toml plus the shared WinUI metadata -> generates Reactor declarations, native projection code, the Reactor native bindings, and the canvas Reactor bridge bindings.
  3. tool-bindings - reads filter .txt files from crates/tools/bindings/src/ -> runs windows-bindgen -> generates bindings.rs in each crate:
    • crates/libs/canvas/src/bindings.rs (from canvas.txt)
    • crates/libs/time/src/bindings.rs, numerics, reference, etc.
  4. tool-package - generates the published windows and windows-sys package crates using --package mode (per-namespace files + Cargo.toml features).
  5. After regenerating, always verify: cargo check -p <affected-crate> --quiet

Key Architecture Facts

Crate relationships

  • windows-core is the foundation - almost everything depends on it.
  • windows is the umbrella crate that re-exports from windows-core, windows-numerics, windows-time, windows-collections, windows-reference, etc.
  • windows-reactor depends on windows-core (not windows) and uses minimal bindings generated with --minimal --flat mode.
  • windows-canvas similarly uses minimal bindings for D2D/DXGI/DWrite/WIC.
  • windows-animation wraps Win32 UIAnimation Manager COM APIs.

Reactor architecture

  • WinUI backend ownership is split across crates/libs/reactor/src/native/winui.rs and crates/libs/reactor/src/native/winui/.
  • The TOML config (crates/tools/reactor/src/schema.toml) declares 79 WinUI controls. Keys are WinUI metadata names; the tool infers types, setter patterns, and event handlers from .winmd files.
  • COM casts: classes Deref to their default interface (zero-cost). Only cast to non-default parent interfaces. The Param trait handles parent-class conversions automatically.

Canvas architecture

  • Canvas wraps D2D/DXGI behind safe Rust types (GpuDevice, SwapChain, DrawingSession, PathBuilder).
  • animated_canvas() (reactor feature) renders on UI thread via CompositionTarget::Rendering.
  • Device-lost recovery is automatic.

Conventions

  • Panics: Use panic! only for invariant violations. Use diag:: helpers for missing features (warn in debug, no-op in release).
  • .unwrap() over .expect("...") - the panic hook provides full context.
  • No thread_local! in app code - keep state in components and pass shared values through typed contexts. thread_local! is reserved for framework plumbing.
  • Test naming: Reactor unit tests live in windows-reactor; live WinUI coverage lives in test-reactor-selftest. Canvas tests use WARP software rendering.

Documentation

The docs/ folder has one page per crate:

  • docs/crates/<crate>.md - a single page per crate covering both usage and internals (how the crate is built and maintained: codegen pipeline, generated files, conventions). It links to the crate's own readme.md for the user-facing intro and quick example.
  • crates/libs/<crate>/readme.md - the user-facing introduction with a quick example (also the crates.io / docs.rs landing).
  • docs/readme.md - the documentation hub and crate index.

docs/ also holds contributing.md, code_of_conduct.md, and security.md.

When making changes to a crate, update its docs/crates/<crate>.md page and its readme.md as needed. For example, windows-reactor changes touch docs/crates/windows-reactor.md (codegen, TOML, threading, COM pitfalls, plus the conceptual overview) and crates/libs/reactor/readme.md (getting started and the quick example).

Writing Style for Docs and Comments

These rules were established while cleaning up the docs and code comments and apply to all Markdown (.md) and Rust comments/doc-comments across the repo. Keep new writing consistent with them.

  • ASCII punctuation only. Use - for dashes (never em/en-dashes), ... for ellipsis, -> for arrows, <=/>=/!= for comparisons, and straight quotes. Drop the section sign from standard references (write ECMA-335 II.22, C11 6.4.4.1, not \u00a7...). The only non-ASCII that stays is genuine test data (e.g. a Greek-letter string literal exercising UTF-8 handling).
  • 100-column wrap. Hard-wrap Markdown prose and long comment blocks at 100 columns. Keep the wrap consistent within a file - do not mix wrapped and unwrapped paragraphs.
  • No LLM tells. Avoid the vocabulary and tics that mark agent-written text: faithful, corpus, ledger, crucially, notably, essentially, robust, seamless, comprehensive, deliberately, simply, under the hood, that said, importantly, conceptually, effectively, single source of truth, industry-standard, first-class, leverage, utilize, Note that .... Say the concrete thing instead. ergonomic and rustdoc **bold** are fine.
  • No decorative formatting. No box-drawing banner comments (// -- Title ------), no duplicated doc paragraphs (a real copy-paste tell), no filler that restates the code.
  • Prefer tables over wordy paragraphs where the content is a set of parallel cases (rules, mappings, options).
  • Describe the code as it is, not its history. Avoid churn narration (used to, previously, an earlier version, no longer) unless it describes real runtime behavior, not codebase edits.
  • Do not edit generated files to satisfy these rules; only hand-written sources.

Open Investigations / TODO

Enduring record of known issues so they are not lost between sessions. Add findings here; remove or mark done as they are addressed. Cite code by file + symbol name, not line number - line numbers go stale fast.

Repo-wide dead-code / quality audit (2026-07)

Open items across the hand-written crates (reactor, bindgen, rdl, clang, canvas, metadata, webview, core) that need a design decision or a larger change. Any bindgen source change must be proven output-neutral by running the tool-* generators and confirming git diff shows no generated-file changes (the gen workflow enforces this).

Duplication / refactor candidates

LocationIssue
metadata merge/mod.rs write_type vs merge/remap.rs write_typeTwo ~60-line structurally identical functions; the remap copy's comment says it mirrors merge::write_type. Any new ECMA table must be added to both, with no compiler guard.
canvas session.rs gradient-stop + bitmap-properties buildersDuplicated ABI-stop and bitmap-properties construction across the brush paths.
bindgen types/interface.rs + cpp_interface.rs local fn combineDuplicate local helper.
canvas color.rs DARK_SLATE_BLUErgb(0.05, 0.05, 0.1) does not match the CSS color of that name (public API used by samples).

Coverage gaps

AreaGap
metadata Remapper (merge/remap.rs)No tests anywhere; routing/split_apis logic is exercised only in the live build, so a regression yields a malformed namespaced winmd with no failing test.
webviewprocess-failed, download, and deferral paths untested.

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.