[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M699JBGRVRXZ0Y96B50406QY":3,"skill-same:01M699JBGRVRXZ0Y96B50406QY":86},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":23,"publishedAt":44,"linkOnly":45,"markdownContent":46,"markdownBody":47,"frontMatter":48,"refName":50,"commitSha":51,"skillDirectory":52,"forksCount":53,"repositoryHtmlUrl":54,"repositoryHomepageUrl":6,"ownerHtmlUrl":55,"ownerBlogUrl":56,"ownerDescription":57,"updatedAt":58,"install":59,"resources":71},"01M699JBGRVRXZ0Y96B50406QY","code-quality",null,"Statically check changed C# against the same deterministic rules github-code-quality[bot] runs on pull requests, so a contributor can fix likely findings before opening the PR and keep the bot's inline comments to a minimum. Activate when a contributor asks to \"check code quality\", \"run code quality on my changes\", \"will the code quality bot complain\", \"pre-check before I open the PR\", \"code quality check\", or similar. Scoped to C#. Reads the diff and compares it against the enumerated csharp-code-quality rule set below — no CodeQL download or build required. This is a fast approximation of a dataflow engine, not a reproduction; report accordingly. Does NOT apply fixes unless explicitly asked.","microsoft\u002FwinappCli","microsoft","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F6154722?v=4","01M698VYDXZ6JW5WH3CRV650R8","Microsoft","01M699J7Q2FM9V32CFV0Q8VPF9",1381,"MIT","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FwinappCli\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Fcode-quality\u002FSKILL.md",[18],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000030","开发工程师","PROFESSION","适用职业",[24,25,26,27,28,29,30,31,32,33,34,35,5,36,37,38,39,40,41,42,43],"code quality","code","quality","open","when","contributor","run code","inline","my","deterministic","activate","fix","bot","SET","codeql","pull","run","csharp","pull requests","github","2026-11-10 10:12:30",false,"---\nname: code-quality\ndescription: Statically check changed C# against the same deterministic rules github-code-quality[bot] runs on pull requests, so a contributor can fix likely findings before opening the PR and keep the bot's inline comments to a minimum. Activate when a contributor asks to \"check code quality\", \"run code quality on my changes\", \"will the code quality bot complain\", \"pre-check before I open the PR\", \"code quality check\", or similar. Scoped to C#. Reads the diff and compares it against the enumerated csharp-code-quality rule set below — no CodeQL download or build required. This is a fast approximation of a dataflow engine, not a reproduction; report accordingly. Does NOT apply fixes unless explicitly asked.\ninfer: true\n---\n\nYou are the **local code-quality pre-check** for `microsoft\u002Fwinappcli`. On pull\nrequests, `github-code-quality[bot]` runs the deterministic CodeQL\n**`csharp-code-quality`** suite and posts each hit as an inline comment. This\nskill reads the contributor's C# diff and flags lines that are likely to trip\nthose same rules, so they can be cleared before pushing.\n\nScope is **C# only** — the language the bot rule-checks in this repo.\n\n**Be honest about what this is.** The bot runs a deterministic dataflow\u002Ftype\nengine; you are pattern-matching a diff by reading it. You will reliably catch the\nsyntactic rules and miss or over-flag the analysis-heavy ones (marked **†**\nbelow — null-flow, disposal escape analysis, \"value never used\", LINQ shape\ndetection). Treat **†** findings as *lower confidence*, and never claim a clean\nresult guarantees zero bot comments. It does not — it means nothing *obvious* is\nleft. This also does not cover the bot's separate AI-powered pass, or C\u002FC++.\n\nDo **not** activate for a single \"is this line okay\" question — that is a direct\nquestion, not a diff-wide pre-check.\n\n## 1. Scope to the changed C# code\n\nFirst find the merge base, so committed *and* still-uncommitted work both count —\ncall it `\u003Cbase>`: `git merge-base origin\u002Fmain HEAD`.\n\n- **Tracked changes** (branch commits plus any staged\u002Funstaged edits):\n  `git --no-pager diff --name-only \u003Cbase>` — diffing the working tree against the\n  merge base, so a later edit to an already-committed file is still seen.\n- **Untracked new files:** `git ls-files --others --exclude-standard -- \"src\u002F*.cs\"`\n  — `git diff` cannot emit hunks for these; read them directly with `view`.\n\nKeep only `*.cs` under `src\\`, and drop files matching the repo's CodeQL exclusion\n`**\u002F*Tests\u002F*.cs` — a `.cs` file **directly inside** a directory whose name ends in\n`Tests` (e.g. `src\\WinApp.Cli.Tests\\Foo.cs`). Mirror that glob exactly: a file\nnested deeper, such as `src\\...\\WinApp.Cli.Tests\\TestApps\\App.xaml.cs`, does **not**\nmatch it, so the bot may scan it — keep those in scope. If nothing survives, say\nso and stop.\n\nThen read the changed lines. For a tracked file:\n`git --no-pager diff --unified=0 \u003Cbase> -- \u003Cfile>`; for an untracked file the whole\nfile is added, so `view` it. Either way `view` each changed region for context.\n**Only flag code inside the changed hunks** — the bot comments on changed lines,\nand pre-existing debt elsewhere is not this PR's problem.\n\n## 2. Check the diff against the rule set\n\nFor every changed hunk, walk the rule tables below and flag each line that\nmatches. For a match, record the `cs\u002F...` id, the exact `file:line`, the offending\nsnippet, and the smallest fix. Prefer precision over volume: if you cannot point\nat the specific line and say what the bot would say, drop it. Apply extra\nskepticism to **†** rules — only raise one when the trigger is visible in the diff\n(e.g. a `new HttpRequestMessage(...)` with no `using` and no `return`\u002Ffield\nassignment), not on a hunch.\n\n### Exception handling\n| Rule | Flags → do instead |\n|---|---|\n| `cs\u002Fcatch-of-all-exceptions` | `catch (Exception)` (or bare `catch`) → catch the specific type you can handle |\n| `cs\u002Fcatch-nullreferenceexception` | catching `NullReferenceException` → fix the deref; don't catch it |\n| `cs\u002Fempty-catch-block` | `catch {}` that swallows → handle, log, or let it propagate |\n| `cs\u002Frethrown-exception-variable` | `throw ex;` (resets stack) → `throw;` |\n\n### Null & dereference — **†**\n| Rule | Flags → do instead |\n|---|---|\n| `cs\u002Fdereferenced-value-may-be-null` **†** | using a value that a prior branch\u002FAPI can leave null → null-check or `?.` |\n| `cs\u002Fdereferenced-value-is-always-null` **†** | dereffing a value provably always null → remove\u002Frepair |\n| `cs\u002Fnull-argument-to-equals` | `x.Equals(null)` → `x is null` |\n\n### Disposal & resources\n| Rule | Flags → do instead |\n|---|---|\n| `cs\u002Flocal-not-disposed` **†** | a local `IDisposable` you own, never disposed → `using` |\n| `cs\u002Fmissed-using-statement` **†** | `Dispose()` in a `finally` you could express as `using` → `using` |\n\n### Equality & hashing\n| Rule | Flags → do instead |\n|---|---|\n| `cs\u002Fgethashcode-is-not-defined` | overriding `Equals` without `GetHashCode` → override both |\n| `cs\u002Fuseless-gethashcode-call` | `GetHashCode()` on a small integral type (e.g. `int`, `enum`) — it just returns the value → drop the redundant call |\n| `cs\u002Fequals-on-arrays` | `array.Equals(other)` (reference eq) → `SequenceEqual` |\n| `cs\u002Fequals-on-unrelated-types` | `Equals` across incomparable types → compare compatible types |\n| `cs\u002Funchecked-cast-in-equals` | unchecked cast of the arg in an `Equals` override → `is`\u002F`as` guard |\n| `cs\u002Frecursive-equals-call` | `Equals` calling itself unboundedly → fix the recursion |\n| `cs\u002Freference-equality-on-valuetypes` | `ReferenceEquals` on value types (always false) → `==`\u002F`Equals` |\n| `cs\u002Fequality-on-floats` | `==` on `double`\u002F`float` → compare with a tolerance |\n| `cs\u002Fcomparison-of-identical-expressions` | a comparison operator with identical operands (`x == x`, `a \u003C a`) → remove or fix the typo |\n\n### Dead & useless code\n| Rule | Flags → do instead |\n|---|---|\n| `cs\u002Fempty-block` | empty `if`\u002Floop body → remove or fill |\n| `cs\u002Fuseless-if-statement` | `if` whose branches do the same thing → collapse |\n| `cs\u002Fconstant-condition` **†** | condition provably always true\u002Ffalse → remove the dead path |\n| `cs\u002Fsimplifiable-boolean-expression` | `x ? true : false`, `!(a == b)` → simplify |\n| `cs\u002Fmissed-ternary-operator` | `if\u002Felse` that only assigns one variable → ternary |\n| `cs\u002Fnested-if-statements` | `if (a) { if (b) … }` with no else → `if (a && b)` |\n| `cs\u002Fuseless-tostring-call` | `.ToString()` on a `string` \u002F in interpolation → drop it |\n| `cs\u002Fcall-to-object-tostring` | default `object.ToString()` (type name) → override or format explicitly |\n| `cs\u002Fself-assignment` | `x = x;` → remove (or fix the intended target) |\n| `cs\u002Funused-label` | a `label:` never targeted → remove |\n| `cs\u002Funused-property-value` **†** | setter that ignores `value` → use it |\n| `cs\u002Fempty-collection` **†** | a collection created empty and then read\u002Fused but never given any elements → add elements or drop the reads |\n| `cs\u002Funused-collection` **†** | a collection filled but never read → remove or use |\n\n### LINQ opportunities — **†**\n| Rule | Flags → do instead |\n|---|---|\n| `cs\u002Flinq\u002Fmissed-where` **†** | `foreach` with a filtering `if` → `.Where(...)` |\n| `cs\u002Flinq\u002Fmissed-select` **†** | `foreach` that only projects → `.Select(...)` |\n| `cs\u002Flinq\u002Fmissed-all` **†** | loop checking a condition holds for all → `.All(...)` |\n| `cs\u002Flinq\u002Fmissed-cast` **†** | loop casting every element → `.Cast\u003CT>()` |\n| `cs\u002Flinq\u002Fmissed-oftype` **†** | loop filtering by type → `.OfType\u003CT>()` |\n| `cs\u002Flinq\u002Fuseless-select` | `.Select(x => x)` → drop it |\n\n### Collections & indexing\n| Rule | Flags → do instead |\n|---|---|\n| `cs\u002Finefficient-containskey` | `ContainsKey` then indexer → `TryGetValue` |\n| `cs\u002Ftest-for-negative-container-size` | `Count \u003C 0` \u002F `Length \u003C 0` (never true) → fix the check |\n| `cs\u002Findex-out-of-bounds` **†** | off-by-one vs `Length`\u002F`Count` → use `\u003C Length` |\n| `cs\u002Fnested-loops-with-same-variable` | nested `for`\u002F`foreach` that reuse the same counter (inner loop also updates `i`) → use a distinct loop variable |\n\n### Concurrency & locking\n| Rule | Flags → do instead |\n|---|---|\n| `cs\u002Flock-this` | `lock (this)` → lock a private `object` |\n| `cs\u002Fempty-lock-statement` | `lock (x) {}` → remove or fill |\n| `cs\u002Funsafe-sync-on-field` | locking a field that is **reassigned inside the lock** (threads then lock different objects) → lock a private `readonly` object |\n| `cs\u002Finconsistent-lock-sequence` **†** | acquiring locks in differing orders → fix ordering |\n| `cs\u002Flocked-wait` **†** | a blocking `.Wait()` (`Task`\u002F`WaitHandle`) while holding a lock — **not** `Monitor.Wait` on the locked object, which correctly requires it → don't block on unrelated waits inside the lock |\n| `cs\u002Fnon-short-circuit` | non-short-circuit `&`\u002F`\\|` on bools whose right operand has a risky access (e.g. a possible null-deref) that `&&`\u002F`\\|\\|` would guard → short-circuit |\n\n### `this`, casts & inheritance\n| Rule | Flags → do instead |\n|---|---|\n| `cs\u002Fcast-of-this-to-type-parameter` | casting `this` to a type param → rethink the API |\n| `cs\u002Fdowncast-of-this` | downcasting `this` to a derived type → virtual method |\n| `cs\u002Ftype-test-of-this` | `this is DerivedType` → virtual method |\n| `cs\u002Fimpossible-array-cast` | array cast that always fails at runtime → fix the type |\n| `cs\u002Fclass-name-matches-base-class` | subclass named like its base → rename |\n| `cs\u002Ffield-masks-base-field` | field shadowing a base field → rename or reuse |\n| `cs\u002Flocal-shadows-member` | local hiding a field\u002Fproperty\u002Fparam → rename |\n\n### API & design smells\n| Rule | Flags → do instead |\n|---|---|\n| `cs\u002Fpath-combine` **†** | `Path.Combine(a, b)` where a later arg is rooted (silently drops earlier) → validate segments |\n| `cs\u002Fcall-to-gc` | `GC.Collect()` → remove; let the runtime manage it |\n| `cs\u002Fcall-to-obsolete-method` | calling `[Obsolete]` API → use the replacement |\n| `cs\u002Fcall-to-unmanaged-code`, `cs\u002Funmanaged-code` | P\u002FInvoke \u002F unsafe surface → review necessity (often expected for CsWin32) |\n| `cs\u002Fclass-implements-icloneable` | `ICloneable` (ambiguous deep\u002Fshallow) → a typed clone method |\n| `cs\u002Fexpose-implementation` **†** | returning\u002Fstoring a reference to an internal mutable array\u002Fcollection that is **later modified** through the alias → return a copy or read-only view |\n| `cs\u002Fstatic-field-written-by-instance` | instance method writing a static field → rethink ownership |\n| `cs\u002Fmissed-readonly-modifier` **†** | a private field written only at its declaration and\u002For in the (static) constructor, never elsewhere → `readonly` |\n| `cs\u002Floss-of-precision` | integer division\u002Fmultiplication whose result is converted to `float`\u002F`double`\u002F`decimal` — precision is already lost before the conversion (e.g. `(double)(a \u002F b)`) → cast an operand first |\n| `cs\u002Finvalid-string-formatting` | format string vs args mismatch → fix placeholders |\n| `cs\u002Fstring-concatenation-in-loop` **†** | `s += …` in a loop → `StringBuilder` |\n| `cs\u002Fstringbuilder-creation-in-loop` **†** | `new StringBuilder()` inside a loop → hoist it out **only if** it doesn't escape the iteration, calling `.Clear()` at the start of each pass; otherwise leave it |\n| `cs\u002Fstringbuilder-initialized-with-character` | `new StringBuilder('x')` (that's capacity!) → `.Append('x')` or `\"x\"` |\n| `cs\u002Fasp\u002Fresponse-write` | `Response.Write` of a single block → not relevant to this CLI; skip unless ASP code appears |\n\n## 3. Report\n\nPrint to stdout. No file output and **no fixes** unless asked.\n\n```markdown\n# Code Quality pre-check — \u003Chead> vs origin\u002Fmain (csharp-code-quality, static)\n\n## Verdict\n\u003Cnothing obvious | N likely finding(s)> — \u003Cone plain sentence>\n\n## Likely bot comments\n### \u003Crule id> — \u003Cshort plain title>   \u003Cmark (lower confidence) for † rules>\n- **What it flags:** \u003Cone sentence>\n- **Where:** `\u003Cpath>:\u003Cline>`\n- **Show me:** \u003Cthe snippet from the diff>\n- **Smallest fix:** \u003Cleast-complex change>\n\n\u003CRepeat per finding, or \"None obvious on your changed lines.\">\n\n## Coverage\n- Static pass over \u003Cn> changed C# file(s) against the 69-rule csharp-code-quality set.\n- This approximates a deterministic engine: analysis-heavy (†) rules may be\n  missed or over-flagged, and the bot's AI pass and C\u002FC++ are out of scope. A\n  clean result means nothing obvious remains, not a guarantee of zero comments.\n```\n\n## If asked to fix\n\nApply the **smallest** change that clears each finding on the changed lines, one\nrule at a time. Prefer the subtractive fix (delete the dead code, drop the\nredundant call) over adding structure. Do not touch pre-existing findings unless\nexplicitly asked.\n\n## Maintaining this skill\n\nThe tables above are a **point-in-time snapshot** of the `csharp-code-quality`\nsuite (69 rules). They will drift as CodeQL releases add or retire queries, so\nregenerate rather than hand-edit. With the CodeQL bundle available, the current\nmembership is:\n\n```powershell\ncodeql resolve queries codeql\u002Fcsharp-queries:codeql-suites\u002Fcsharp-code-quality.qls\n# each resolved .ql file's header carries its @id \u002F @name \u002F @precision\n```\n\nIf that list diverges from the tables, reconcile it — add new rules, remove\nretired ones — and keep the **†** markers on the flow\u002Ftype-analysis queries so\ntheir lower confidence stays visible. If the bot's config changes (languages,\nsuite, scanned paths), update the scope note in step 1 too.\n","You are the **local code-quality pre-check** for `microsoft\u002Fwinappcli`. On pull\nrequests, `github-code-quality[bot]` runs the deterministic CodeQL\n**`csharp-code-quality`** suite and posts each hit as an inline comment. This\nskill reads the contributor's C# diff and flags lines that are likely to trip\nthose same rules, so they can be cleared before pushing.\n\nScope is **C# only** — the language the bot rule-checks in this repo.\n\n**Be honest about what this is.** The bot runs a deterministic dataflow\u002Ftype\nengine; you are pattern-matching a diff by reading it. You will reliably catch the\nsyntactic rules and miss or over-flag the analysis-heavy ones (marked **†**\nbelow — null-flow, disposal escape analysis, \"value never used\", LINQ shape\ndetection). Treat **†** findings as *lower confidence*, and never claim a clean\nresult guarantees zero bot comments. It does not — it means nothing *obvious* is\nleft. This also does not cover the bot's separate AI-powered pass, or C\u002FC++.\n\nDo **not** activate for a single \"is this line okay\" question — that is a direct\nquestion, not a diff-wide pre-check.\n\n## 1. Scope to the changed C# code\n\nFirst find the merge base, so committed *and* still-uncommitted work both count —\ncall it `\u003Cbase>`: `git merge-base origin\u002Fmain HEAD`.\n\n- **Tracked changes** (branch commits plus any staged\u002Funstaged edits):\n  `git --no-pager diff --name-only \u003Cbase>` — diffing the working tree against the\n  merge base, so a later edit to an already-committed file is still seen.\n- **Untracked new files:** `git ls-files --others --exclude-standard -- \"src\u002F*.cs\"`\n  — `git diff` cannot emit hunks for these; read them directly with `view`.\n\nKeep only `*.cs` under `src\\`, and drop files matching the repo's CodeQL exclusion\n`**\u002F*Tests\u002F*.cs` — a `.cs` file **directly inside** a directory whose name ends in\n`Tests` (e.g. `src\\WinApp.Cli.Tests\\Foo.cs`). Mirror that glob exactly: a file\nnested deeper, such as `src\\...\\WinApp.Cli.Tests\\TestApps\\App.xaml.cs`, does **not**\nmatch it, so the bot may scan it — keep those in scope. If nothing survives, say\nso and stop.\n\nThen read the changed lines. For a tracked file:\n`git --no-pager diff --unified=0 \u003Cbase> -- \u003Cfile>`; for an untracked file the whole\nfile is added, so `view` it. Either way `view` each changed region for context.\n**Only flag code inside the changed hunks** — the bot comments on changed lines,\nand pre-existing debt elsewhere is not this PR's problem.\n\n## 2. Check the diff against the rule set\n\nFor every changed hunk, walk the rule tables below and flag each line that\nmatches. For a match, record the `cs\u002F...` id, the exact `file:line`, the offending\nsnippet, and the smallest fix. Prefer precision over volume: if you cannot point\nat the specific line and say what the bot would say, drop it. Apply extra\nskepticism to **†** rules — only raise one when the trigger is visible in the diff\n(e.g. a `new HttpRequestMessage(...)` with no `using` and no `return`\u002Ffield\nassignment), not on a hunch.\n\n### Exception handling\n| Rule | Flags → do instead |\n|---|---|\n| `cs\u002Fcatch-of-all-exceptions` | `catch (Exception)` (or bare `catch`) → catch the specific type you can handle |\n| `cs\u002Fcatch-nullreferenceexception` | catching `NullReferenceException` → fix the deref; don't catch it |\n| `cs\u002Fempty-catch-block` | `catch {}` that swallows → handle, log, or let it propagate |\n| `cs\u002Frethrown-exception-variable` | `throw ex;` (resets stack) → `throw;` |\n\n### Null & dereference — **†**\n| Rule | Flags → do instead |\n|---|---|\n| `cs\u002Fdereferenced-value-may-be-null` **†** | using a value that a prior branch\u002FAPI can leave null → null-check or `?.` |\n| `cs\u002Fdereferenced-value-is-always-null` **†** | dereffing a value provably always null → remove\u002Frepair |\n| `cs\u002Fnull-argument-to-equals` | `x.Equals(null)` → `x is null` |\n\n### Disposal & resources\n| Rule | Flags → do instead |\n|---|---|\n| `cs\u002Flocal-not-disposed` **†** | a local `IDisposable` you own, never disposed → `using` |\n| `cs\u002Fmissed-using-statement` **†** | `Dispose()` in a `finally` you could express as `using` → `using` |\n\n### Equality & hashing\n| Rule | Flags → do instead |\n|---|---|\n| `cs\u002Fgethashcode-is-not-defined` | overriding `Equals` without `GetHashCode` → override both |\n| `cs\u002Fuseless-gethashcode-call` | `GetHashCode()` on a small integral type (e.g. `int`, `enum`) — it just returns the value → drop the redundant call |\n| `cs\u002Fequals-on-arrays` | `array.Equals(other)` (reference eq) → `SequenceEqual` |\n| `cs\u002Fequals-on-unrelated-types` | `Equals` across incomparable types → compare compatible types |\n| `cs\u002Funchecked-cast-in-equals` | unchecked cast of the arg in an `Equals` override → `is`\u002F`as` guard |\n| `cs\u002Frecursive-equals-call` | `Equals` calling itself unboundedly → fix the recursion |\n| `cs\u002Freference-equality-on-valuetypes` | `ReferenceEquals` on value types (always false) → `==`\u002F`Equals` |\n| `cs\u002Fequality-on-floats` | `==` on `double`\u002F`float` → compare with a tolerance |\n| `cs\u002Fcomparison-of-identical-expressions` | a comparison operator with identical operands (`x == x`, `a \u003C a`) → remove or fix the typo |\n\n### Dead & useless code\n| Rule | Flags → do instead |\n|---|---|\n| `cs\u002Fempty-block` | empty `if`\u002Floop body → remove or fill |\n| `cs\u002Fuseless-if-statement` | `if` whose branches do the same thing → collapse |\n| `cs\u002Fconstant-condition` **†** | condition provably always true\u002Ffalse → remove the dead path |\n| `cs\u002Fsimplifiable-boolean-expression` | `x ? true : false`, `!(a == b)` → simplify |\n| `cs\u002Fmissed-ternary-operator` | `if\u002Felse` that only assigns one variable → ternary |\n| `cs\u002Fnested-if-statements` | `if (a) { if (b) … }` with no else → `if (a && b)` |\n| `cs\u002Fuseless-tostring-call` | `.ToString()` on a `string` \u002F in interpolation → drop it |\n| `cs\u002Fcall-to-object-tostring` | default `object.ToString()` (type name) → override or format explicitly |\n| `cs\u002Fself-assignment` | `x = x;` → remove (or fix the intended target) |\n| `cs\u002Funused-label` | a `label:` never targeted → remove |\n| `cs\u002Funused-property-value` **†** | setter that ignores `value` → use it |\n| `cs\u002Fempty-collection` **†** | a collection created empty and then read\u002Fused but never given any elements → add elements or drop the reads |\n| `cs\u002Funused-collection` **†** | a collection filled but never read → remove or use |\n\n### LINQ opportunities — **†**\n| Rule | Flags → do instead |\n|---|---|\n| `cs\u002Flinq\u002Fmissed-where` **†** | `foreach` with a filtering `if` → `.Where(...)` |\n| `cs\u002Flinq\u002Fmissed-select` **†** | `foreach` that only projects → `.Select(...)` |\n| `cs\u002Flinq\u002Fmissed-all` **†** | loop checking a condition holds for all → `.All(...)` |\n| `cs\u002Flinq\u002Fmissed-cast` **†** | loop casting every element → `.Cast\u003CT>()` |\n| `cs\u002Flinq\u002Fmissed-oftype` **†** | loop filtering by type → `.OfType\u003CT>()` |\n| `cs\u002Flinq\u002Fuseless-select` | `.Select(x => x)` → drop it |\n\n### Collections & indexing\n| Rule | Flags → do instead |\n|---|---|\n| `cs\u002Finefficient-containskey` | `ContainsKey` then indexer → `TryGetValue` |\n| `cs\u002Ftest-for-negative-container-size` | `Count \u003C 0` \u002F `Length \u003C 0` (never true) → fix the check |\n| `cs\u002Findex-out-of-bounds` **†** | off-by-one vs `Length`\u002F`Count` → use `\u003C Length` |\n| `cs\u002Fnested-loops-with-same-variable` | nested `for`\u002F`foreach` that reuse the same counter (inner loop also updates `i`) → use a distinct loop variable |\n\n### Concurrency & locking\n| Rule | Flags → do instead |\n|---|---|\n| `cs\u002Flock-this` | `lock (this)` → lock a private `object` |\n| `cs\u002Fempty-lock-statement` | `lock (x) {}` → remove or fill |\n| `cs\u002Funsafe-sync-on-field` | locking a field that is **reassigned inside the lock** (threads then lock different objects) → lock a private `readonly` object |\n| `cs\u002Finconsistent-lock-sequence` **†** | acquiring locks in differing orders → fix ordering |\n| `cs\u002Flocked-wait` **†** | a blocking `.Wait()` (`Task`\u002F`WaitHandle`) while holding a lock — **not** `Monitor.Wait` on the locked object, which correctly requires it → don't block on unrelated waits inside the lock |\n| `cs\u002Fnon-short-circuit` | non-short-circuit `&`\u002F`\\|` on bools whose right operand has a risky access (e.g. a possible null-deref) that `&&`\u002F`\\|\\|` would guard → short-circuit |\n\n### `this`, casts & inheritance\n| Rule | Flags → do instead |\n|---|---|\n| `cs\u002Fcast-of-this-to-type-parameter` | casting `this` to a type param → rethink the API |\n| `cs\u002Fdowncast-of-this` | downcasting `this` to a derived type → virtual method |\n| `cs\u002Ftype-test-of-this` | `this is DerivedType` → virtual method |\n| `cs\u002Fimpossible-array-cast` | array cast that always fails at runtime → fix the type |\n| `cs\u002Fclass-name-matches-base-class` | subclass named like its base → rename |\n| `cs\u002Ffield-masks-base-field` | field shadowing a base field → rename or reuse |\n| `cs\u002Flocal-shadows-member` | local hiding a field\u002Fproperty\u002Fparam → rename |\n\n### API & design smells\n| Rule | Flags → do instead |\n|---|---|\n| `cs\u002Fpath-combine` **†** | `Path.Combine(a, b)` where a later arg is rooted (silently drops earlier) → validate segments |\n| `cs\u002Fcall-to-gc` | `GC.Collect()` → remove; let the runtime manage it |\n| `cs\u002Fcall-to-obsolete-method` | calling `[Obsolete]` API → use the replacement |\n| `cs\u002Fcall-to-unmanaged-code`, `cs\u002Funmanaged-code` | P\u002FInvoke \u002F unsafe surface → review necessity (often expected for CsWin32) |\n| `cs\u002Fclass-implements-icloneable` | `ICloneable` (ambiguous deep\u002Fshallow) → a typed clone method |\n| `cs\u002Fexpose-implementation` **†** | returning\u002Fstoring a reference to an internal mutable array\u002Fcollection that is **later modified** through the alias → return a copy or read-only view |\n| `cs\u002Fstatic-field-written-by-instance` | instance method writing a static field → rethink ownership |\n| `cs\u002Fmissed-readonly-modifier` **†** | a private field written only at its declaration and\u002For in the (static) constructor, never elsewhere → `readonly` |\n| `cs\u002Floss-of-precision` | integer division\u002Fmultiplication whose result is converted to `float`\u002F`double`\u002F`decimal` — precision is already lost before the conversion (e.g. `(double)(a \u002F b)`) → cast an operand first |\n| `cs\u002Finvalid-string-formatting` | format string vs args mismatch → fix placeholders |\n| `cs\u002Fstring-concatenation-in-loop` **†** | `s += …` in a loop → `StringBuilder` |\n| `cs\u002Fstringbuilder-creation-in-loop` **†** | `new StringBuilder()` inside a loop → hoist it out **only if** it doesn't escape the iteration, calling `.Clear()` at the start of each pass; otherwise leave it |\n| `cs\u002Fstringbuilder-initialized-with-character` | `new StringBuilder('x')` (that's capacity!) → `.Append('x')` or `\"x\"` |\n| `cs\u002Fasp\u002Fresponse-write` | `Response.Write` of a single block → not relevant to this CLI; skip unless ASP code appears |\n\n## 3. Report\n\nPrint to stdout. No file output and **no fixes** unless asked.\n\n```markdown\n# Code Quality pre-check — \u003Chead> vs origin\u002Fmain (csharp-code-quality, static)\n\n## Verdict\n\u003Cnothing obvious | N likely finding(s)> — \u003Cone plain sentence>\n\n## Likely bot comments\n### \u003Crule id> — \u003Cshort plain title>   \u003Cmark (lower confidence) for † rules>\n- **What it flags:** \u003Cone sentence>\n- **Where:** `\u003Cpath>:\u003Cline>`\n- **Show me:** \u003Cthe snippet from the diff>\n- **Smallest fix:** \u003Cleast-complex change>\n\n\u003CRepeat per finding, or \"None obvious on your changed lines.\">\n\n## Coverage\n- Static pass over \u003Cn> changed C# file(s) against the 69-rule csharp-code-quality set.\n- This approximates a deterministic engine: analysis-heavy (†) rules may be\n  missed or over-flagged, and the bot's AI pass and C\u002FC++ are out of scope. A\n  clean result means nothing obvious remains, not a guarantee of zero comments.\n```\n\n## If asked to fix\n\nApply the **smallest** change that clears each finding on the changed lines, one\nrule at a time. Prefer the subtractive fix (delete the dead code, drop the\nredundant call) over adding structure. Do not touch pre-existing findings unless\nexplicitly asked.\n\n## Maintaining this skill\n\nThe tables above are a **point-in-time snapshot** of the `csharp-code-quality`\nsuite (69 rules). They will drift as CodeQL releases add or retire queries, so\nregenerate rather than hand-edit. With the CodeQL bundle available, the current\nmembership is:\n\n```powershell\ncodeql resolve queries codeql\u002Fcsharp-queries:codeql-suites\u002Fcsharp-code-quality.qls\n# each resolved .ql file's header carries its @id \u002F @name \u002F @precision\n```\n\nIf that list diverges from the tables, reconcile it — add new rules, remove\nretired ones — and keep the **†** markers on the flow\u002Ftype-analysis queries so\ntheir lower confidence stays visible. If the bot's config changes (languages,\nsuite, scanned paths), update the scope note in step 1 too.\n",{"name":5,"infer":49,"description":7},true,"main","1fe910277860e8dbb38bfbeef7e8bdb039d6ee41",".github\u002Fskills\u002Fcode-quality",96,"https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FwinappCli","https:\u002F\u002Fgithub.com\u002Fmicrosoft","https:\u002F\u002Fopensource.microsoft.com","Open source projects and samples from Microsoft","2026-11-14 07:14:37",{"source":8,"skillName":5,"commands":60,"prompt":70,"zipAvailable":49},[61,64,67],{"tool":62,"command":63},"npx","npx skills add microsoft\u002FwinappCli --skill code-quality",{"tool":65,"command":66},"bunx","bunx skills add microsoft\u002FwinappCli --skill code-quality",{"tool":68,"command":69},"pnpm","pnpm dlx skills add microsoft\u002FwinappCli --skill code-quality","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FwinappCli\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Fcode-quality\u002FSKILL.md",[72,78,82],{"path":73,"resourceType":74,"resourceTypeDesc":75,"sizeBytes":76,"sourceHtmlUrl":77},"scripts\u002Fapple_json.py","SCRIPT","脚本",10314,"https:\u002F\u002Fgithub.com\u002Fmattwag05\u002Fmw-plugins\u002Fblob\u002Fmain\u002Fclient-adapters\u002Fclaude-code\u002Fplugins\u002Fdoc-harvest\u002Fskills\u002Fdoc-harvest\u002Fscripts\u002Fapple_json.py",{"path":79,"resourceType":74,"resourceTypeDesc":75,"sizeBytes":80,"sourceHtmlUrl":81},"scripts\u002Fharvest.py",34174,"https:\u002F\u002Fgithub.com\u002Fmattwag05\u002Fmw-plugins\u002Fblob\u002Fmain\u002Fclient-adapters\u002Fclaude-code\u002Fplugins\u002Fdoc-harvest\u002Fskills\u002Fdoc-harvest\u002Fscripts\u002Fharvest.py",{"path":83,"resourceType":74,"resourceTypeDesc":75,"sizeBytes":84,"sourceHtmlUrl":85},"scripts\u002Fscrapling-fetch.sh",4196,"https:\u002F\u002Fgithub.com\u002Fmattwag05\u002Fmw-plugins\u002Fblob\u002Fmain\u002Fclient-adapters\u002Fclaude-code\u002Fplugins\u002Fdoc-harvest\u002Fskills\u002Fdoc-harvest\u002Fscripts\u002Fscrapling-fetch.sh",[87,112,143,165,186,200],{"skillNo":88,"name":89,"nameZh":6,"description":90,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":91,"categories":92,"keywords":93,"publishedAt":44},"01M699M75MK9AADQV8PQQQ6NEV","winui-wpf-migration","Migrate or port a WPF app to WinUI 3: namespaces (System.Windows to Microsoft.UI.Xaml), control mapping (DataGrid, WrapPanel, TabControl), Dispatcher to DispatcherQueue, imaging, MVVM with CommunityToolkit.Mvvm, ThemeResource. Use when converting WPF code or fixing migration build errors.","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FwinappCli\u002Fblob\u002Fmain\u002Fplugins\u002Fwinui\u002Fagent-plugin\u002Fskills\u002Fwinui-wpf-migration\u002FSKILL.md",[],[94,95,96,97,9,98,99,25,100,101,102,103,104,105,106,107,108,109,110,111,28],"winui wpf migration","winui","wpf","migration","windows","dispatcher","xaml","ui","migrate","system","use","mvvm","app","mapping","port","imaging","errors","namespaces",{"skillNo":113,"name":114,"nameZh":6,"description":115,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":116,"categories":117,"keywords":126,"publishedAt":44},"01M699M4W3GKSVVT9CRR1E3KSW","winui-ui-testing","Write and run automated UI tests for Windows desktop apps (WinUI 3, WPF, WinForms, Win32) with the winapp ui harness: one batch script, assertions, input, file pickers, dialogs, screenshots, locally or in Windows Sandbox. Use when asked for UI tests or to verify a feature end to end.","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FwinappCli\u002Fblob\u002Fmain\u002Fplugins\u002Fwinui\u002Fagent-plugin\u002Fskills\u002Fwinui-ui-testing\u002FSKILL.md",[118,123],{"categoryNo":119,"categoryName":120,"taxonomyType":121,"taxonomyTypeDesc":122},"01JBSEEDCAT000000000000008","测试与质量","SCENARIO","使用场景",{"categoryNo":124,"categoryName":125,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000032","设计师",[127,128,95,101,129,130,131,98,40,132,133,134,135,136,137,138,139,140,141,142,28],"testing","winui ui testing","ui testing","screenshots","sandbox","win32","harness","batch","write","feature","end","apps","input","winforms","desktop apps","for",{"skillNo":144,"name":145,"nameZh":6,"description":146,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":147,"categories":148,"keywords":150,"publishedAt":44},"01M699M2KTEYJZBDW7JBHM94K0","winui-setup","Install and verify WinUI 3 prerequisites — .NET SDK 8.0.100+, WinApp CLI 0.7+, and Developer Mode; identify additional Native AOT and Windows Sandbox requirements. Use when the user asks to set up or repair the toolchain, or when another WinUI skill finds a missing or outdated prerequisite.","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FwinappCli\u002Fblob\u002Fmain\u002Fplugins\u002Fwinui\u002Fagent-plugin\u002Fskills\u002Fwinui-setup\u002FSKILL.md",[149],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},[151,152,95,153,131,154,98,37,155,156,104,157,158,159,160,161,162,163,164,28],"winui setup","setup","cli","sdk","verify","install","up","repair","requirements","missing","native","toolchain","winapp cli","mode",{"skillNo":166,"name":167,"nameZh":6,"description":168,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":169,"categories":170,"keywords":174,"publishedAt":44},"01M699KZWEZ84A4J3291E6R65B","winui-packaging","MSIX packaging, signing, and Microsoft Store publishing for WinUI 3 apps with WinApp CLI 0.7+: project packaging, Native AOT, certificates, self-contained deployment, CI\u002FCD. Use when releasing or publishing a WinUI app. Not for WPF, WinForms, or Electron apps that only reference the Windows App SDK.","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FwinappCli\u002Fblob\u002Fmain\u002Fplugins\u002Fwinui\u002Fagent-plugin\u002Fskills\u002Fwinui-packaging\u002FSKILL.md",[171],{"categoryNo":172,"categoryName":173,"taxonomyType":121,"taxonomyTypeDesc":122},"01JBSEEDCAT000000000000011","运维与部署",[175,95,176,153,154,177,9,178,98,179,180,181,182,183,184,106,138,140,161,185,163,142,28],"winui packaging","packaging","electron","msix","windows app sdk","ci","certificates","only","self","project","CI\u002FCD",{"skillNo":187,"name":188,"nameZh":6,"description":189,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":190,"categories":191,"keywords":192,"publishedAt":44},"01M699KXTHG9FHK4X3JSZ4SV8J","winui-dev-workflow","Create, build, run, and fix build errors in WinUI 3 apps (C# or C++) with WinApp CLI 0.7+: winapp new, winapp run, Native AOT, crash diagnosis. Use for a new WinUI app or a WinUI project that fails to build or crashes. Not for WPF, WinForms, or Electron apps that only reference the Windows App SDK.","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FwinappCli\u002Fblob\u002Fmain\u002Fplugins\u002Fwinui\u002Fagent-plugin\u002Fskills\u002Fwinui-dev-workflow\u002FSKILL.md",[],[193,194,95,195,196,153,154,177,98,197,40,35,182,184,106,198,138,140,161,163,110,199],"workflow","winui dev workflow","dev","dev workflow","create","diagnosis","new",{"skillNo":201,"name":202,"nameZh":6,"description":203,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":204,"categories":205,"keywords":216,"publishedAt":44},"01M699KV0Q6NE5EET5EDBH33NM","winui-design","Read before writing or changing WinUI 3 XAML: choosing controls, pages and navigation, layout, Fluent Design, theming, accessibility, x:Bind, real samples, and checking that APIs exist with winapp find-api. Not for WPF or WinForms UI, even if the app uses the Windows App SDK.","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FwinappCli\u002Fblob\u002Fmain\u002Fplugins\u002Fwinui\u002Fagent-plugin\u002Fskills\u002Fwinui-design\u002FSKILL.md",[206,209,212,213],{"categoryNo":207,"categoryName":208,"taxonomyType":121,"taxonomyTypeDesc":122},"01JBSEEDCAT000000000000015","视觉设计",{"categoryNo":210,"categoryName":211,"taxonomyType":121,"taxonomyTypeDesc":122},"01JBSEEDCAT000000000000018","写作与文案",{"categoryNo":124,"categoryName":125,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":214,"categoryName":215,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000036","内容创作者",[217,218,95,219,154,220,221,98,179,96,100,101,222,223,224,225,226,106,140,227,142,228],"design","winui design","writing","accessibility","fluent","api","read","layout","pages","bind","controls","fluent design"]