[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6BXTZG02Q1NDM2AGQ9PCM5C":3,"skill-same:01M6BXTZG02Q1NDM2AGQ9PCM5C":87},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":8,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":10,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":16,"sourceHtmlUrl":17,"categories":18,"keywords":29,"publishedAt":43,"linkOnly":44,"markdownContent":45,"markdownBody":46,"frontMatter":47,"refName":48,"commitSha":49,"skillDirectory":50,"forksCount":14,"repositoryHtmlUrl":51,"repositoryHomepageUrl":52,"ownerHtmlUrl":53,"ownerBlogUrl":54,"ownerDescription":55,"updatedAt":56,"install":57,"resources":70},"01M6BXTZG02Q1NDM2AGQ9PCM5C","csharp-refactoring","C#\u002F.NET 代码安全重构","Safely refactors C#\u002F.NET code without changing behavior: rename, move, extract, inline, merge, consolidate, deduplicate, split, or modernize, including partial or generated declarations, public APIs, serialization and reflection names, friend assemblies, conditional compilation, and multi-targeted projects. Use when a request asks for a refactor, or calls a feature, bug fix, upgrade, or public nullability change a refactor and the behavior-changing part must be separated or declined. Not for ordinary feature or bug fixes, standalone framework or package upgrades, adding tests, or formatting-only work.","在不改变行为的前提下安全地重构 C#\u002F.NET 代码：重命名、移动、提取、内联、合并、整合、去重、拆分或现代化改造，涵盖分部声明或生成的声明、公共 API、序列化和反射名称、友元程序集、条件编译以及多目标项目。当请求要求重构，或把某个功能、错误修复、升级或公共可空性变更称为重构时使用；此时必须把会改变行为的部分分离出来或予以拒绝。不适用于普通的功能或错误修复、独立的框架或包升级、添加测试，或仅涉及格式的工作。","Cratis\u002FSpecifications","Cratis","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F16456213?v=4","01M6BXRH290K4C8RS4PTKK3HXQ","01M6BXRH6YXJMJ3140T8TVBSB4",1,"MIT","https:\u002F\u002Fgithub.com\u002FCratis\u002FSpecifications\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Fcsharp-refactoring\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FCratis\u002FSpecifications\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Fcsharp-refactoring\u002FSKILL.md",[19,24],{"categoryNo":20,"categoryName":21,"taxonomyType":22,"taxonomyTypeDesc":23},"01M8BQ6TQZN6R52WBJ9H8NRMQM","软件开发工程师","PROFESSION","适用职业",{"categoryNo":25,"categoryName":26,"taxonomyType":27,"taxonomyTypeDesc":28},"01M8BT7QVANT4709358VEJK53E","代码实现","SCENARIO","使用场景",[30,31,32,33,34,35,36,37,38,39,40,41,42],"csharp refactoring","csharp","refactoring","change","merge","code","framework","package","deduplicate","serialization","refactor","bug fix","projects","2026-11-10 10:12:30",false,"---\nname: csharp-refactoring\ndescription: 'Safely refactors C#\u002F.NET code without changing behavior: rename, move, extract, inline, merge, consolidate, deduplicate, split, or modernize, including partial or generated declarations, public APIs, serialization and reflection names, friend assemblies, conditional compilation, and multi-targeted projects. Use when a request asks for a refactor, or calls a feature, bug fix, upgrade, or public nullability change a refactor and the behavior-changing part must be separated or declined. Not for ordinary feature or bug fixes, standalone framework or package upgrades, adding tests, or formatting-only work.'\nlicense: MIT\n---\n\u003C!-- cratis-ai-managed: skills\u002Fcsharp-refactoring\u002FSKILL.md -->\n\n\u003C!-- Modified by Cratis from dotnet's original (MIT): frontmatter, applicability, navigation and the changes listed in NOTICE. Upstream: https:\u002F\u002Fgithub.com\u002Fdotnet\u002Fskills (plugins\u002Fdotnet\u002Fskills\u002Fcsharp-refactoring\u002FSKILL.md; see NOTICE) -->\n\n# C# Refactoring (behavior-preserving)\n\nCratis rules in `.cratis\u002Fai\u002Frules\u002F` (including `csharp.md`, `specs.csharp.md`, and `orleans.md`) and the `cratis-*` skills win where they differ.\n\nA refactor changes **structure**, never observable **behavior**. Do the edit with binding-aware tools,\nthen confirm behavior held with a build + the relevant tests. Keep the effort proportional to the change:\na one-line local rename does not need the ceremony a public multi-targeted change does.\n\n## Mandatory gate: classify before validation or editing\n\nRead only enough repository context to classify **each requested operation**. Do this before restoring,\nbuilding, or making an edit. Classification precedence is:\n\n- If the request explicitly asks for at least one separable behavior-preserving operation, complete\n  that structural work and defer only the behavior-changing or contract-changing operations. Do not\n  invent or infer structural work to avoid the stop response.\n- If the structural and behavior-changing parts cannot be separated, use the whole-request stop\n  response and state why they are inseparable.\n- Otherwise, use the whole-request stop response only when **every** requested operation is outside\n  behavior-preserving refactoring.\n\nFor a whole request that is outside behavior-preserving refactoring:\n\n1. State: `Not a behavior-preserving refactor: \u003Cspecific reason>.`\n2. State: `No files changed.`\n3. State: `Next workflow: \u003Cworkflow>.` Then stop. Do not add manual implementation steps, alternatives,\n   an offer to proceed without the workflow, or a follow-up question — even when that workflow is unavailable.\n\n| Requested as a \"refactor\" | Classification and action |\n|---|---|\n| Framework or NuGet version change | **Upgrade.** Do not edit or validate the upgrade here; hand off to the repository's upgrade workflow. |\n| New capability, flag, endpoint, tier, or behavior | **Feature.** Do not implement it here; hand off to the repository's feature workflow. |\n| Threshold, rate, output, or bug-result change | **Behavior change.** Defer it and hand off to the repository's bug-fix or behavior-change workflow; still complete any clearly separable structural operation. |\n| Tighten or loosen a shipped\u002Fpublic nullable annotation | **Source-contract change.** Leave the declaration and API record unchanged; hand off to the repository's API-contract workflow. |\n\nFor a mixed request, never stop after classification. Perform the separable structural operation,\nexplicitly defer the behavior\u002Fcontract change, and never state `No files changed.` after completing\nstructural work. Never modify tests to make an unauthorized behavior change appear preserved.\n\n## Work only in the current workspace\n\nUse the current agent workspace as the boundary. If it is a Git checkout, resolve its repository root\n(`git rev-parse --show-toplevel`) and stay inside it. If Git metadata is absent, treat the current working\ndirectory and its subdirectories as the boundary, and use a solution or project named in the request\ninside it; Git is not a prerequisite for a refactor. Resolve prompt-provided relative paths inside that\nboundary.\n\nSearch and edit only that workspace. Never use filesystem-wide search or select a similarly named clone,\nanother worktree, build output, or unrelated temporary directory because a file also exists there. If a\nnamed path is absent, stop and report the mismatch instead of guessing another workspace. If a tool rejects\nan in-workspace path for a mechanical reason such as path form or unsupported tool root, retry through\nanother in-workspace mechanism. If the rejection is a permission or policy denial, report it instead of\nworking around it. Never search outside the boundary.\n\n## Rename \u002F move by bindings, not text\n\nThe #1 way a \"rename\" silently corrupts code is editing textual matches (comments, strings, unrelated\noverloads) instead of real **bindings**. Find every binding reference first, then edit semantically. Use\nthe strongest tool available: an IDE\u002FRoslyn workspace refactoring, then the C# LSP the\n[`dotnet` plugin declares](https:\u002F\u002Fgithub.com\u002Fdotnet\u002Fskills\u002Fblob\u002Fmain\u002Fplugins\u002Fdotnet\u002Flsp.json)\n(`findReferences`, `goToDefinition`, `incomingCalls`, `rename` code action), then analyzer code-fixes \u002F\nRoslynator, then compiler-validated edits (edit the true bindings, rebuild, let the compiler flag misses).\nPlain find\u002Freplace only when scope is provably tiny and every hit is verified. Include **every** `partial`\ndeclaration, and edit the generator input, never generated (`*.g.cs`) output.\n\nFor the operation → Roslyn-provider mapping and representative PRs, see\n[references\u002Foperation-catalog.md](references\u002Foperation-catalog.md).\n\n## Consolidate toward the existing source of truth\n\nWhen de-duplicating, preserve the ownership direction stated by the code or request. If `B` duplicates\nan implementation already owned by `A`, keep `A` canonical and make `B` delegate to it; do not invert\nthe dependency merely because either direction compiles. Preserve public compatibility wrappers when\nthe duplicate surface is shipped, and migrate only in-repo callers that are safe to move.\n\n## Decisions that change the edit\n\nUse the first matching row instead of applying the requested operation mechanically:\n\n| Situation | Do | Never |\n|---|---|---|\n| Inline an internal, unshipped pass-through wrapper | Migrate every binding reference to the target, remove the wrapper, then compile to catch misses. | Keep dead indirection \"for compatibility\" when no compatibility boundary exists. |\n| Inline or remove a shipped\u002Fpublic wrapper | Migrate ordinary in-repo callers, but retain an `[Obsolete]` forwarding entry point unless the request explicitly authorizes a breaking change. | Delete a shipped API merely because all current source callers were migrated. |\n| Rename a member reached by a string, reflection, DI, or configuration | Rename binding-based callers; preserve the observed external name with a forwarding shim or metadata, and exercise the old-name path. | Rewrite an external\u002Fconfigured name just to make the new source name consistent. |\n| Extract duplicated logic whose callers pass different values | Extract the algorithm and pass each caller's existing inputs through unchanged. | Collapse distinct inputs, evaluation order, rounding, or side effects into one caller's version. |\n| Rename code compiled under `#if` or multiple TFMs | Update every source branch and validate each target framework explicitly. | Treat a green default-target build as evidence for unbuilt branches. |\n| Merge near-identical types | Parameterize only the values that differ, migrate every construction site, and preserve each old value exactly. If the old types are internal\u002Funshipped and the request says to merge into one type, delete their declarations. | Retain unnecessary aliases, static holders, factories, or wrapper types that leave the requested merge incomplete; introduce a new hierarchy or behavior. |\n\n## Preserve contracts beyond C# call sites\n\nCompilation proves binding compatibility, not every external contract. Before renaming or moving a\ntype\u002Fmember, check whether its name or metadata is observed by serialization, reflection, dependency\ninjection, configuration binding, source generators, P\u002FInvoke, or `dynamic`.\n\n| Boundary | Required decision |\n|---|---|\n| Serialized\u002Fconfiguration name | Preserve the external name with the repository's existing mechanism (for example, `JsonPropertyName`) while migrating C# callers; run a focused round-trip or payload test. |\n| Public nullable annotation | The mandatory classification gate applies: leave it unchanged and hand off as a source-contract change. |\n| Uncovered reflection or runtime lookup | Do not guess that a compile-clean rename is safe. Preserve the observed name or stop and report the unverified runtime boundary. |\n\n## Verify proportionally\n\nConfirm behavior is preserved after the edit — scaled to blast radius, not a fixed ceremony:\n\n- **Local \u002F private** (method-local or `private` member, one file, single target framework, no public\n  surface, no `partial`\u002Fgenerated\u002F`#if`): skip a separate baseline unless the tree is already suspect.\n  Make the edit, then run the narrowest build and relevant tests once. Let the compiler catch missed\n  references.\n- **Cross-boundary** (public\u002Fshipped symbol, multi-targeted project, `#if`\u002Fplatform branches, or\n  `partial`\u002Fgenerated code): establish a baseline, then run an explicit build and the relevant tests for\n  **each** target framework after the edit (a test command's implicit build is not separate build evidence;\n  a green default build can hide a break on another TFM), and run the hazards check below.\n\nUse the repo's own build\u002Ftest workflow when it documents one (`README`\u002F`CONTRIBUTING`, `build.*`, `eng\u002F`,\n`global.json`, `.github\u002Fworkflows`); its instructions win over any generic command.\n\n### Typical workflow (one operation)\n1. Choose one named refactoring operation and keep the step focused on that operation only.\n2. Find true binding references (`findReferences`\u002F`goToDefinition`\u002Frename) and include all `partial` declarations.\n3. Establish a baseline first only for a cross-boundary change or a tree not already known green.\n4. Apply the change via the most semantics-aware tool available; avoid blind find\u002Freplace when possible.\n5. Rebuild and run the relevant tests. If the gate goes red, report the failure and repair or reassess only\n  your edit; never discard unrelated worktree changes.\n\nOtherwise:\n```bash\ndotnet build   # 0 errors\ndotnet test    # stays green; same pass count as before\n```\n\nOne operation per step; never mix a refactor and a behavior change in the same step. On red, stop and report the failure; repair only your edit without discarding unrelated worktree changes.\n\n## Final response contract\n\nKeep the handoff concise and evidence-based:\n\n- **Refactor:** name the structural operation and the symbols\u002Ffiles changed.\n- **Preserved:** name the behavior or compatibility boundary and the mechanism that preserved it.\n- **Validation:** report the exact commands and observed result; never claim success after a failed restore,\n  build, target framework, or test run.\n- **Deferred:** for a mixed request, name the behavior\u002Fcontract change intentionally left undone and its\n  correct next workflow. Omit this line when nothing was deferred.\n\n## Cross-boundary hazards (only when it touches a boundary)\n\nIf — and only if — the change touches a **public** symbol, a **multi-targeted** project, or\n`partial`\u002Fgenerated code, some breaks won't show up as a failing test. Search the repo for the surface\nthat governs the symbol (don't assume): the public-API gate (`PublicAPI.Shipped\u002FUnshipped.txt` for\nPublicApiAnalyzers, and\u002For `ApiCompat`\u002F`\u003CEnablePackageValidation>` — not interchangeable),\n`\u003CTargetFrameworks>`\u002F`#if` branches, and `InternalsVisibleTo`. Moving a public type to another assembly\nneeds `[TypeForwardedTo]` in the original assembly; a move within one assembly does not. A public\n*rename* needs an `[Obsolete]` shim, not a forwarder. For a provably local\u002Fprivate change, skip these\nchecks.\n\n## Stop an in-scope refactor when\n\n- The baseline is already red (you can't prove you preserved behavior).\n- The requested structural change would alter a public\u002Fshipped API and no compatibility shim or forwarder\n  can preserve it. Report the boundary. Use the gate's handoff format when no structural work was completed;\n  after separable work, put the incompatible operation on the `Deferred:` line instead. Do not ask to make\n  the breaking change.\n- Equivalence depends on runtime behavior tests don't cover (reflection, DI, serialization, `dynamic`,\n  P\u002FInvoke) — report the unverified boundary instead of claiming behavior was preserved.\n\n## Contracts the compiler cannot see in Cratis code\n\nPreserve `[EventType]` identifiers and type names of persisted events, generated TypeScript proxies of Arc commands\u002Fqueries, `[Alias]`\u002Fserializer ids in Orleans, and public API of framework packages (semver).\n","\u003C!-- cratis-ai-managed: skills\u002Fcsharp-refactoring\u002FSKILL.md -->\n\n\u003C!-- Modified by Cratis from dotnet's original (MIT): frontmatter, applicability, navigation and the changes listed in NOTICE. Upstream: https:\u002F\u002Fgithub.com\u002Fdotnet\u002Fskills (plugins\u002Fdotnet\u002Fskills\u002Fcsharp-refactoring\u002FSKILL.md; see NOTICE) -->\n\n# C# Refactoring (behavior-preserving)\n\nCratis rules in `.cratis\u002Fai\u002Frules\u002F` (including `csharp.md`, `specs.csharp.md`, and `orleans.md`) and the `cratis-*` skills win where they differ.\n\nA refactor changes **structure**, never observable **behavior**. Do the edit with binding-aware tools,\nthen confirm behavior held with a build + the relevant tests. Keep the effort proportional to the change:\na one-line local rename does not need the ceremony a public multi-targeted change does.\n\n## Mandatory gate: classify before validation or editing\n\nRead only enough repository context to classify **each requested operation**. Do this before restoring,\nbuilding, or making an edit. Classification precedence is:\n\n- If the request explicitly asks for at least one separable behavior-preserving operation, complete\n  that structural work and defer only the behavior-changing or contract-changing operations. Do not\n  invent or infer structural work to avoid the stop response.\n- If the structural and behavior-changing parts cannot be separated, use the whole-request stop\n  response and state why they are inseparable.\n- Otherwise, use the whole-request stop response only when **every** requested operation is outside\n  behavior-preserving refactoring.\n\nFor a whole request that is outside behavior-preserving refactoring:\n\n1. State: `Not a behavior-preserving refactor: \u003Cspecific reason>.`\n2. State: `No files changed.`\n3. State: `Next workflow: \u003Cworkflow>.` Then stop. Do not add manual implementation steps, alternatives,\n   an offer to proceed without the workflow, or a follow-up question — even when that workflow is unavailable.\n\n| Requested as a \"refactor\" | Classification and action |\n|---|---|\n| Framework or NuGet version change | **Upgrade.** Do not edit or validate the upgrade here; hand off to the repository's upgrade workflow. |\n| New capability, flag, endpoint, tier, or behavior | **Feature.** Do not implement it here; hand off to the repository's feature workflow. |\n| Threshold, rate, output, or bug-result change | **Behavior change.** Defer it and hand off to the repository's bug-fix or behavior-change workflow; still complete any clearly separable structural operation. |\n| Tighten or loosen a shipped\u002Fpublic nullable annotation | **Source-contract change.** Leave the declaration and API record unchanged; hand off to the repository's API-contract workflow. |\n\nFor a mixed request, never stop after classification. Perform the separable structural operation,\nexplicitly defer the behavior\u002Fcontract change, and never state `No files changed.` after completing\nstructural work. Never modify tests to make an unauthorized behavior change appear preserved.\n\n## Work only in the current workspace\n\nUse the current agent workspace as the boundary. If it is a Git checkout, resolve its repository root\n(`git rev-parse --show-toplevel`) and stay inside it. If Git metadata is absent, treat the current working\ndirectory and its subdirectories as the boundary, and use a solution or project named in the request\ninside it; Git is not a prerequisite for a refactor. Resolve prompt-provided relative paths inside that\nboundary.\n\nSearch and edit only that workspace. Never use filesystem-wide search or select a similarly named clone,\nanother worktree, build output, or unrelated temporary directory because a file also exists there. If a\nnamed path is absent, stop and report the mismatch instead of guessing another workspace. If a tool rejects\nan in-workspace path for a mechanical reason such as path form or unsupported tool root, retry through\nanother in-workspace mechanism. If the rejection is a permission or policy denial, report it instead of\nworking around it. Never search outside the boundary.\n\n## Rename \u002F move by bindings, not text\n\nThe #1 way a \"rename\" silently corrupts code is editing textual matches (comments, strings, unrelated\noverloads) instead of real **bindings**. Find every binding reference first, then edit semantically. Use\nthe strongest tool available: an IDE\u002FRoslyn workspace refactoring, then the C# LSP the\n[`dotnet` plugin declares](https:\u002F\u002Fgithub.com\u002Fdotnet\u002Fskills\u002Fblob\u002Fmain\u002Fplugins\u002Fdotnet\u002Flsp.json)\n(`findReferences`, `goToDefinition`, `incomingCalls`, `rename` code action), then analyzer code-fixes \u002F\nRoslynator, then compiler-validated edits (edit the true bindings, rebuild, let the compiler flag misses).\nPlain find\u002Freplace only when scope is provably tiny and every hit is verified. Include **every** `partial`\ndeclaration, and edit the generator input, never generated (`*.g.cs`) output.\n\nFor the operation → Roslyn-provider mapping and representative PRs, see\n[references\u002Foperation-catalog.md](references\u002Foperation-catalog.md).\n\n## Consolidate toward the existing source of truth\n\nWhen de-duplicating, preserve the ownership direction stated by the code or request. If `B` duplicates\nan implementation already owned by `A`, keep `A` canonical and make `B` delegate to it; do not invert\nthe dependency merely because either direction compiles. Preserve public compatibility wrappers when\nthe duplicate surface is shipped, and migrate only in-repo callers that are safe to move.\n\n## Decisions that change the edit\n\nUse the first matching row instead of applying the requested operation mechanically:\n\n| Situation | Do | Never |\n|---|---|---|\n| Inline an internal, unshipped pass-through wrapper | Migrate every binding reference to the target, remove the wrapper, then compile to catch misses. | Keep dead indirection \"for compatibility\" when no compatibility boundary exists. |\n| Inline or remove a shipped\u002Fpublic wrapper | Migrate ordinary in-repo callers, but retain an `[Obsolete]` forwarding entry point unless the request explicitly authorizes a breaking change. | Delete a shipped API merely because all current source callers were migrated. |\n| Rename a member reached by a string, reflection, DI, or configuration | Rename binding-based callers; preserve the observed external name with a forwarding shim or metadata, and exercise the old-name path. | Rewrite an external\u002Fconfigured name just to make the new source name consistent. |\n| Extract duplicated logic whose callers pass different values | Extract the algorithm and pass each caller's existing inputs through unchanged. | Collapse distinct inputs, evaluation order, rounding, or side effects into one caller's version. |\n| Rename code compiled under `#if` or multiple TFMs | Update every source branch and validate each target framework explicitly. | Treat a green default-target build as evidence for unbuilt branches. |\n| Merge near-identical types | Parameterize only the values that differ, migrate every construction site, and preserve each old value exactly. If the old types are internal\u002Funshipped and the request says to merge into one type, delete their declarations. | Retain unnecessary aliases, static holders, factories, or wrapper types that leave the requested merge incomplete; introduce a new hierarchy or behavior. |\n\n## Preserve contracts beyond C# call sites\n\nCompilation proves binding compatibility, not every external contract. Before renaming or moving a\ntype\u002Fmember, check whether its name or metadata is observed by serialization, reflection, dependency\ninjection, configuration binding, source generators, P\u002FInvoke, or `dynamic`.\n\n| Boundary | Required decision |\n|---|---|\n| Serialized\u002Fconfiguration name | Preserve the external name with the repository's existing mechanism (for example, `JsonPropertyName`) while migrating C# callers; run a focused round-trip or payload test. |\n| Public nullable annotation | The mandatory classification gate applies: leave it unchanged and hand off as a source-contract change. |\n| Uncovered reflection or runtime lookup | Do not guess that a compile-clean rename is safe. Preserve the observed name or stop and report the unverified runtime boundary. |\n\n## Verify proportionally\n\nConfirm behavior is preserved after the edit — scaled to blast radius, not a fixed ceremony:\n\n- **Local \u002F private** (method-local or `private` member, one file, single target framework, no public\n  surface, no `partial`\u002Fgenerated\u002F`#if`): skip a separate baseline unless the tree is already suspect.\n  Make the edit, then run the narrowest build and relevant tests once. Let the compiler catch missed\n  references.\n- **Cross-boundary** (public\u002Fshipped symbol, multi-targeted project, `#if`\u002Fplatform branches, or\n  `partial`\u002Fgenerated code): establish a baseline, then run an explicit build and the relevant tests for\n  **each** target framework after the edit (a test command's implicit build is not separate build evidence;\n  a green default build can hide a break on another TFM), and run the hazards check below.\n\nUse the repo's own build\u002Ftest workflow when it documents one (`README`\u002F`CONTRIBUTING`, `build.*`, `eng\u002F`,\n`global.json`, `.github\u002Fworkflows`); its instructions win over any generic command.\n\n### Typical workflow (one operation)\n1. Choose one named refactoring operation and keep the step focused on that operation only.\n2. Find true binding references (`findReferences`\u002F`goToDefinition`\u002Frename) and include all `partial` declarations.\n3. Establish a baseline first only for a cross-boundary change or a tree not already known green.\n4. Apply the change via the most semantics-aware tool available; avoid blind find\u002Freplace when possible.\n5. Rebuild and run the relevant tests. If the gate goes red, report the failure and repair or reassess only\n  your edit; never discard unrelated worktree changes.\n\nOtherwise:\n```bash\ndotnet build   # 0 errors\ndotnet test    # stays green; same pass count as before\n```\n\nOne operation per step; never mix a refactor and a behavior change in the same step. On red, stop and report the failure; repair only your edit without discarding unrelated worktree changes.\n\n## Final response contract\n\nKeep the handoff concise and evidence-based:\n\n- **Refactor:** name the structural operation and the symbols\u002Ffiles changed.\n- **Preserved:** name the behavior or compatibility boundary and the mechanism that preserved it.\n- **Validation:** report the exact commands and observed result; never claim success after a failed restore,\n  build, target framework, or test run.\n- **Deferred:** for a mixed request, name the behavior\u002Fcontract change intentionally left undone and its\n  correct next workflow. Omit this line when nothing was deferred.\n\n## Cross-boundary hazards (only when it touches a boundary)\n\nIf — and only if — the change touches a **public** symbol, a **multi-targeted** project, or\n`partial`\u002Fgenerated code, some breaks won't show up as a failing test. Search the repo for the surface\nthat governs the symbol (don't assume): the public-API gate (`PublicAPI.Shipped\u002FUnshipped.txt` for\nPublicApiAnalyzers, and\u002For `ApiCompat`\u002F`\u003CEnablePackageValidation>` — not interchangeable),\n`\u003CTargetFrameworks>`\u002F`#if` branches, and `InternalsVisibleTo`. Moving a public type to another assembly\nneeds `[TypeForwardedTo]` in the original assembly; a move within one assembly does not. A public\n*rename* needs an `[Obsolete]` shim, not a forwarder. For a provably local\u002Fprivate change, skip these\nchecks.\n\n## Stop an in-scope refactor when\n\n- The baseline is already red (you can't prove you preserved behavior).\n- The requested structural change would alter a public\u002Fshipped API and no compatibility shim or forwarder\n  can preserve it. Report the boundary. Use the gate's handoff format when no structural work was completed;\n  after separable work, put the incompatible operation on the `Deferred:` line instead. Do not ask to make\n  the breaking change.\n- Equivalence depends on runtime behavior tests don't cover (reflection, DI, serialization, `dynamic`,\n  P\u002FInvoke) — report the unverified boundary instead of claiming behavior was preserved.\n\n## Contracts the compiler cannot see in Cratis code\n\nPreserve `[EventType]` identifiers and type names of persisted events, generated TypeScript proxies of Arc commands\u002Fqueries, `[Alias]`\u002Fserializer ids in Orleans, and public API of framework packages (semver).\n",{"name":5,"license":15,"description":7},"main","c392076c8b3fae3b8b31e7d5684d71f9be75e8bb",".cratis\u002Fai\u002Fskills\u002Fcsharp-refactoring","https:\u002F\u002Fgithub.com\u002FCratis\u002FSpecifications","https:\u002F\u002Fwww.cratis.io\u002Fspecifications\u002F","https:\u002F\u002Fgithub.com\u002FCratis","https:\u002F\u002Fwww.cratis.io","Open-source (MIT) event sourcing and CQRS for .NET and beyond: Chronicle, Arc, Components and Screenplay.","2026-11-14 15:53:54",{"source":9,"skillName":5,"commands":58,"prompt":68,"zipAvailable":69},[59,62,65],{"tool":60,"command":61},"npx","npx skills add Cratis\u002FSpecifications --skill csharp-refactoring",{"tool":63,"command":64},"bunx","bunx skills add Cratis\u002FSpecifications --skill csharp-refactoring",{"tool":66,"command":67},"pnpm","pnpm dlx skills add Cratis\u002FSpecifications --skill csharp-refactoring","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FCratis\u002FSpecifications\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Fcsharp-refactoring\u002FSKILL.md",true,[71,75,81],{"path":72,"resourceType":72,"resourceTypeDesc":73,"sizeBytes":74,"sourceHtmlUrl":16},"LICENSE","许可证",1171,{"path":76,"resourceType":77,"resourceTypeDesc":78,"sizeBytes":79,"sourceHtmlUrl":80},"NOTICE","OTHER","其他",1159,"https:\u002F\u002Fgithub.com\u002FCratis\u002FSpecifications\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Fcsharp-refactoring\u002FNOTICE",{"path":82,"resourceType":83,"resourceTypeDesc":84,"sizeBytes":85,"sourceHtmlUrl":86},"references\u002Foperation-catalog.md","REFERENCE","参考文档",2943,"https:\u002F\u002Fgithub.com\u002FCratis\u002FSpecifications\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Fcsharp-refactoring\u002Freferences\u002Foperation-catalog.md",[88,109,131,162,187,204],{"skillNo":89,"name":90,"nameZh":91,"description":92,"descriptionZh":93,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":10,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":94,"sourceHtmlUrl":95,"categories":96,"keywords":101,"publishedAt":43},"01M6BXWPJZ1W4FTAZ7N0B718XQ","vectorization",".NET SIMD 向量化代码","Designs, implements, optimizes, and reviews SIMD code in .NET: vectorizing scalar loops with TensorPrimitives, Vector64, Vector128, Vector256, Vector512, or hardware intrinsics, and reviewing existing SIMD code, including the generic Vector type, for contract equivalence, tail handling, memory safety, portability, fallbacks, and measured performance. Use when a .NET loop or SIMD routine is being written or reviewed. Not for performance work unrelated to SIMD.","设计、实现、优化和审查 .NET 中的 SIMD 代码：使用 TensorPrimitives、Vector64、Vector128、Vector256、Vector512 或硬件内部函数将标量循环向量化，并审查现有 SIMD 代码（包括泛型 Vector 类型）的契约等价性、尾部处理、内存安全性、可移植性、回退方案和实测性能。当正在编写或审查 .NET 循环或 SIMD 例程时使用。不用于与 SIMD 无关的性能工作。","https:\u002F\u002Fgithub.com\u002FCratis\u002FSpecifications\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Fvectorization\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FCratis\u002FSpecifications\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Fvectorization\u002FSKILL.md",[97,98],{"categoryNo":20,"categoryName":21,"taxonomyType":22,"taxonomyTypeDesc":23},{"categoryNo":99,"categoryName":100,"taxonomyType":27,"taxonomyTypeDesc":28},"01M8C796JZ1YCTM2B2X7TKEWZZ","性能剖析与优化",[90,102,103,104,105,35,106,107,108],"loop","Safety","simd","vector","performance","memory safety","memory",{"skillNo":110,"name":111,"nameZh":112,"description":113,"descriptionZh":114,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":10,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":115,"sourceHtmlUrl":116,"categories":117,"keywords":122,"publishedAt":43},"01M6BXWKDP8VKEXE9WN5R8R1E0","target-authoring","MSBuild自定义目标编写","Canonical patterns for writing custom MSBuild targets: DependsOnTargets versus BeforeTargets and AfterTargets, the Build-to-CoreBuild three-level pattern, and the XxxDependsOn chain-extension pattern. Use when diagnosing or fixing custom-target anti-patterns: Directory.Build.targets redefining SDK targets, targets that replace CompileDependsOn instead of extending it, Outputs versus Returns misuse that returns stale results, missing Inputs\u002FOutputs causing needless rebuilds, or missing FileWrites registration. Not for incremental build tuning or general anti-pattern review (use the msbuild skill), or non-MSBuild build systems.","编写自定义 MSBuild target 的规范模式：DependsOnTargets 与 BeforeTargets、AfterTargets 的区别，Build-to-CoreBuild 三级模式，以及 XxxDependsOn 链式扩展模式。用于诊断或修复自定义 target 的反模式：Directory.Build.targets 重新定义 SDK target、target 替换而非扩展 CompileDependsOn、Outputs 与 Returns 误用导致返回过期结果、缺少 Inputs\u002FOutputs 导致不必要的重新构建，或缺少 FileWrites 注册。不适用于增量构建调优或一般反模式审查（使用 msbuild 技能），也不适用于非 MSBuild 构建系统。","https:\u002F\u002Fgithub.com\u002FCratis\u002FSpecifications\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Ftarget-authoring\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FCratis\u002FSpecifications\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Ftarget-authoring\u002FSKILL.md",[118,119],{"categoryNo":20,"categoryName":21,"taxonomyType":22,"taxonomyTypeDesc":23},{"categoryNo":120,"categoryName":121,"taxonomyType":27,"taxonomyTypeDesc":28},"01M8BSTR9G4A4GZ0VB2DFN9490","开发环境与工具链管理",[123,124,125,126,127,128,129,130],"target authoring","msbuild","tuning","incremental build","sdk","review","directory","writing",{"skillNo":132,"name":133,"nameZh":134,"description":135,"descriptionZh":136,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":10,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":137,"sourceHtmlUrl":138,"categories":139,"keywords":146,"publishedAt":43},"01M6BXWG0724RVJDEE4SQBEF8P","run-tests",".NET测试命令执行","Chooses and runs the repository-compatible .NET test command: classic, VSTest, bridged MTP, or native MTP syntax for MSTest, xUnit, NUnit, and TUnit. Use before running .NET tests or answering with a test command or flags: run the tests, one test, class, category, trait or target framework, combined filters, --filter-query, --no-build, --diag, TRX, coverage collection, crash or hang dumps, filter errors, or unrecognized options. Not for platform identification alone (use platform-detection), writing or debugging test code, interpreting a coverage report (use coverage-analysis), CI investigation, migration, or a persistent hot-reload loop.","选择并运行与仓库兼容的 .NET 测试命令：针对 MSTest、xUnit、NUnit 和 TUnit 的 classic、VSTest、bridged MTP 或 native MTP 语法。在运行 .NET 测试或需要给出测试命令\u002F标志时使用：运行全部测试、单个测试、测试类、类别、trait 或目标框架、组合筛选器、--filter-query、--no-build、--diag、TRX、覆盖率收集、崩溃或挂起转储、筛选错误或无法识别的选项。不适用于仅做平台识别（使用 platform-detection）、编写或调试测试代码、解读覆盖率报告（使用 coverage-analysis）、CI 调查、迁移或持续的热重载循环。","https:\u002F\u002Fgithub.com\u002FCratis\u002FSpecifications\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Frun-tests\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FCratis\u002FSpecifications\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Frun-tests\u002FSKILL.md",[140,143],{"categoryNo":141,"categoryName":142,"taxonomyType":22,"taxonomyTypeDesc":23},"01M8BQGD5WG86P4AQ5GPSSKBFR","测试工程师",{"categoryNo":144,"categoryName":145,"taxonomyType":27,"taxonomyTypeDesc":28},"01M8BQJH394GT47X57A9Q8G7HX","测试与质量保障",[147,148,149,150,151,152,36,153,35,154,155,156,157,130,158,159,160,102,161],"run tests","run","collection","detection","ci","repository","report","debugging","mtp","mstest","test","analysis","xunit","nunit","investigation",{"skillNo":163,"name":164,"nameZh":165,"description":166,"descriptionZh":167,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":10,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":168,"sourceHtmlUrl":169,"categories":170,"keywords":173,"publishedAt":43},"01M6BXWCTS8TECDKSYFJT9C445","profiling",".NET 性能剖析","Uses the free official .NET diagnostics CLI tools for profiling and runtime investigation in a repository: CPU, GC pressure, allocation growth, exception storms, lock contention, and slow code. Use when a .NET application needs performance or runtime profiling. Not for replacing realistic performance or load tests with ad-hoc tracing, production heap collection without a pause-risk plan, crash dumps (use dump-collect), or benchmark design (use microbenchmarking).","使用免费的官方 .NET 诊断 CLI 工具在代码仓库中进行性能剖析和运行时调查：CPU、GC 压力、分配增长、异常风暴、锁竞争和慢代码。当 .NET 应用程序需要性能或运行时剖析时使用。不适用于用临时跟踪替代真实的性能或负载测试、无暂停风险计划的生产堆内存采集、崩溃转储（使用 dump-collect），或基准测试设计（使用 microbenchmarking）。","https:\u002F\u002Fgithub.com\u002FCratis\u002FSpecifications\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Fprofiling\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FCratis\u002FSpecifications\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Fprofiling\u002FSKILL.md",[171,172],{"categoryNo":20,"categoryName":21,"taxonomyType":22,"taxonomyTypeDesc":23},{"categoryNo":99,"categoryName":100,"taxonomyType":27,"taxonomyTypeDesc":28},[164,149,174,175,161,176,106,177,178,152,179,180,181,35,182,183,184,185,186],"microbenchmarking","plan","Tools","risk","Production","collect","tracing","benchmark","diagnostics","official","first","cli","design",{"skillNo":188,"name":189,"nameZh":190,"description":191,"descriptionZh":192,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":10,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":193,"sourceHtmlUrl":194,"categories":195,"keywords":198,"publishedAt":43},"01M6BXW9N4G1NTMKNVBECTM2GM","platform-detection",".NET 测试平台识别","Identifies a .NET project's test platform, framework, command mode, and SDK-style versus classic project system, resolving global.json, project, packages.config, Directory.Build.props, and Directory.Packages.props precedence for MSTest, xUnit, NUnit, and TUnit. Use when asking \"which test platform or framework?\", \"VSTest or MTP?\", or \"what runner does this project use?\", including bridge settings, UseVSTest opt-outs, and conflicting VSTest\u002FMTP configuration. Not for running or filtering tests, commands, flags, TRX, dumps, or test-command errors (use run-tests), or for hot-reload or migration requests.","识别 .NET 项目的测试平台、框架、命令模式，以及 SDK 样式与经典项目系统，并解析 global.json、项目文件、packages.config、Directory.Build.props 和 Directory.Packages.props 对 MSTest、xUnit、NUnit 和 TUnit 的优先级。当询问“使用哪种测试平台或框架”“VSTest 还是 MTP”或“该项目使用什么测试运行器”时使用，包括桥接设置、UseVSTest 退出选项，以及 VSTest\u002FMTP 配置冲突。不适用于运行或筛选测试、命令、标志、TRX、转储或测试命令错误（使用 run-tests），也不适用于热重载或迁移请求。","https:\u002F\u002Fgithub.com\u002FCratis\u002FSpecifications\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Fplatform-detection\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FCratis\u002FSpecifications\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Fplatform-detection\u002FSKILL.md",[196,197],{"categoryNo":141,"categoryName":142,"taxonomyType":22,"taxonomyTypeDesc":23},{"categoryNo":144,"categoryName":145,"taxonomyType":27,"taxonomyTypeDesc":28},[199,150,155,156,157,127,129,200,159,160,201,202,36,148,203],"platform detection","config","json","system","packages",{"skillNo":205,"name":206,"nameZh":207,"description":208,"descriptionZh":209,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":10,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":210,"sourceHtmlUrl":211,"categories":212,"keywords":219,"publishedAt":43},"01M6BXW4VVFJH0WDPATWMFE9TY","orleans","Orleans 分布式系统设计","Designs Microsoft Orleans systems from each primitive's purpose and failure model: grains, digital twins, state versus databases, transactions, messaging, streams, timers, reminders, Durable Jobs, stateless workers, grain services, startup, and hosting. Use when a task needs an Orleans design decision: inspect version and topology, choose the primitive, implement, and validate. Not for other actor stacks, batch processing, relational-only CRUD, or advice without an Orleans decision.","从每种原语的用途和失效模型出发设计 Microsoft Orleans 系统：grain、数字孪生、状态与数据库、事务、消息传递、流（streams）、计时器（timers）、提醒（reminders）、Durable Jobs（持久作业）、无状态工作进程、grain 服务、启动与托管。当任务需要做出 Orleans 设计决策时使用：检查版本与拓扑、选择原语、实现并验证。不适用于其他 actor 技术栈、批处理、纯关系型 CRUD，或不涉及 Orleans 决策的建议。","https:\u002F\u002Fgithub.com\u002FCratis\u002FSpecifications\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Forleans\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FCratis\u002FSpecifications\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Forleans\u002FSKILL.md",[213,216],{"categoryNo":214,"categoryName":215,"taxonomyType":22,"taxonomyTypeDesc":23},"01M8C4ZVS0ZJKF2T2G58PW5VR2","系统架构师",{"categoryNo":217,"categoryName":218,"taxonomyType":27,"taxonomyTypeDesc":28},"01M8C535MHXGXDSGN98VJTMCSK","系统架构设计模式",[206,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,186],"startup","decision","choose","model","crud","transactions","services","topology","messaging","batch","state","reminders","validate","microsoft","implement"]