[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M75MWGK0MEAV4KTADW64F3QQ":3,"skill-same:01M75MWGK0MEAV4KTADW64F3QQ":47},{"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":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":25,"commitSha":26,"skillDirectory":27,"forksCount":28,"repositoryHtmlUrl":29,"repositoryHomepageUrl":6,"ownerHtmlUrl":30,"ownerBlogUrl":31,"ownerDescription":6,"updatedAt":32,"install":33,"resources":46},"01M75MWGK0MEAV4KTADW64F3QQ","migrate-static-to-wrapper",null,"Use when asked to migrate, replace, or make testable existing C# static calls with a named wrapper or built-in abstraction: DateTime.UtcNow\u002FNow or DateTimeOffset.UtcNow to TimeProvider\u002FIClock, File.* to IFileSystem or an existing store such as ITextFileStore, and Environment.* to an existing reader such as IEnvironmentReader. Covers scoped files\u002Fprojects, constructor injection, replacing temp-file or process-environment tests with fakes, \"already registered\" abstractions, and static classes whose callers\u002Fsignatures must stay unchanged. Preserves DateTimeKind and call count. DO NOT USE for finding statics (detect-static-dependencies), choosing\u002Fdesigning a new wrapper (generate-testability-wrappers), behavior tests with no chosen seam (testability-obstacle), or test-framework migration.","stanfish06\u002Fskillquarium","stanfish06","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F93099613?v=4","01M75F1CK4ZW109ZK3T26VN52F","Zhiyuan","01M75F1CM53VH6F79DZ8GXKKES",12,"MIT","https:\u002F\u002Fgithub.com\u002Fstanfish06\u002Fskillquarium\u002Fblob\u002Fmaster\u002Fskills\u002Fmigrate-static-to-wrapper\u002FSKILL.md",[],[],"2026-11-12 13:55:43",false,"---\nname: migrate-static-to-wrapper\ndescription: >\n  Use when asked to migrate, replace, or make testable existing C# static calls with a\n  named wrapper or built-in abstraction: DateTime.UtcNow\u002FNow or DateTimeOffset.UtcNow to\n  TimeProvider\u002FIClock, File.* to IFileSystem or an existing store such as ITextFileStore,\n  and Environment.* to an existing reader such as IEnvironmentReader. Covers scoped\n  files\u002Fprojects, constructor injection, replacing temp-file or process-environment tests\n  with fakes, \"already registered\" abstractions, and static classes whose\n  callers\u002Fsignatures must stay unchanged. Preserves DateTimeKind and call count. DO NOT\n  USE for finding statics (detect-static-dependencies), choosing\u002Fdesigning a new wrapper\n  (generate-testability-wrappers), behavior tests with no chosen seam\n  (testability-obstacle), or test-framework migration.\nlicense: MIT\n---\n\n# Migrate Static to Wrapper\n\nPerform mechanical, codemod-style replacement of static dependency call sites with calls to injected wrapper interfaces or built-in abstractions. Operates on a bounded scope (single file, project, or namespace) so migrations can be done incrementally.\n\n## When to Use\n\n- After wrappers have been generated (via `generate-testability-wrappers`) or built-in abstractions identified\n- Migrating `DateTime.UtcNow` → `TimeProvider.GetUtcNow()` across a project\n- Migrating `File.*` → `IFileSystem.File.*` across a namespace\n- Adding constructor injection for the new abstraction to affected classes\n- Making a `static` utility class testable by adding an ambient seam (Step 3) while its existing call sites keep\n  compiling unchanged\n- Incremental migration: one project or namespace at a time\n- Updating affected tests with fakes when the requested migration names the\n  replacement abstraction\n\n## When Not to Use\n\n- No wrapper or abstraction exists yet and one must be designed from scratch (use `generate-testability-wrappers` first).\n  A built-in abstraction such as `TimeProvider` or `IFileSystem` always counts as existing.\n- The user wants to detect statics, not migrate them (use `detect-static-dependencies`)\n- Migrating between test frameworks (use the appropriate migration skill)\n- The user primarily asks for a deterministic behavior test and has not selected\n  the production seam (use `testability-obstacle`)\n\n> A class that is `static`, or a project with no DI container, is **not** a reason to skip this skill — that is exactly\n> what the ambient seam in Step 3 is for. Use it whenever the call sites must keep compiling unchanged.\n\n## Inputs\n\n| Input | Required | Description |\n|-------|----------|-------------|\n| Static pattern | No | Infer from the request and discovered call sites (e.g., `DateTime.UtcNow`, `File.ReadAllText`) |\n| Replacement abstraction | No | Infer from the request and existing project abstractions; stop only when no named\u002Fexisting abstraction is available |\n| Scope | No | Infer from the requested file\u002Fproject\u002Fnamespace, otherwise discover the narrowest relevant workspace scope |\n| Injection strategy | No | `constructor` (default), `primary-constructor`, or `ambient` |\n\n## Workflow\n\n### Non-negotiable migration boundaries\n\n- **Missing abstraction means stop.** If the named interface\u002Fpackage is absent and\n  the request only authorizes call-site replacement, do not add a package, invent\n  a local lookalike interface, or edit production code. Report the exact missing\n  prerequisite and the authorization needed to continue.\n- **One source read stays one replacement read.** Do not hoist or coalesce calls,\n  even when sharing a captured timestamp looks cleaner.\n- **The requested scope is exhaustive and exclusive.** Replace every named call\n  in scope and no adjacent member or file.\n- **Repository-backed requests require repository work.** Start by discovering\n  files from the current workspace. Do not claim the repository is unavailable\n  or ask the user for a path or file contents until workspace-relative discovery\n  found no target. Do not say work was implemented unless the diff proves it.\n- **Discovered workspace files must be completed in this turn when permitted.**\n  Use a host-native shell reader (`sed`\u002F`cat` or `Get-Content`) only after a\n  confirmed reader availability, transport, or path-normalization failure and\n  only after verifying the canonical path remains inside the current workspace.\n  Stop on content-exclusion, permission\u002Fpolicy, workspace-boundary, or unknown\n  read failures. Use a shell edit fallback only for a confirmed editor\n  availability, transport, or path-normalization failure, never for a stale\n  context, concurrent change, permission\u002Fpolicy denial, or path-boundary error.\n  Before fallback, resolve the canonical path inside the current workspace,\n  freshly read the file, and require an anchored replacement with the expected\n  old text and exact match count; abort if either changed. Then re-open the file,\n  inspect the diff, and validate. Do not ask the user to paste a readable\n  discovered file or report a proposed patch as completed work.\n\n### Step 1: Verify prerequisites\n\nBefore modifying any code:\n\n1. **Confirm the wrapper\u002Fabstraction exists**: Check that the interface or built-in abstraction is available in the project. For `TimeProvider`, verify the target framework is .NET 8+ or `Microsoft.Bcl.TimeProvider` is referenced. For `System.IO.Abstractions`, verify the NuGet package is referenced. A package that could provide an abstraction is not the same as an abstraction already available to this project.\n\n2. **Trace production composition**: Check `Program.cs`, `Startup.cs`, factories,\n   and manual construction sites before editing. An explicit migration to an\n   available seam includes the minimal constructor\u002Fcaller\u002Fregistration changes\n   needed to keep that scope runnable, unless the user forbids those edits.\n   Register `TimeProvider.System` in an existing DI host when the new dependency\n   is not already registered; update manual callers instead of introducing DI\n   to a library. Missing packages or new wrapper design still require separate\n   authorization. Do not stop after an injectable class while leaving its real\n   construction path broken.\n\n3. **Identify all files in scope**: List the `.cs` files that will be modified. Exclude test projects, `obj\u002F`, `bin\u002F`, and generated code.\n\n4. **Lock and count the member set before editing**: Use the exact member named\n   by the user, or infer the smallest unambiguous set from the request and\n   discovered call sites. Record that set, then search every member and capture\n   the file\u002Fline inventory. Do not change the set mid-edit or infer counts from\n   a partial read.\n\n### Step 2: Plan the migration for each file\n\n**Migrate exactly what was asked — nothing adjacent.** If the user named a member (`DateTime.UtcNow`), migrate only that member and leave siblings such as `DateTime.Now` untouched. If the user named files, do not touch other files. Preserve a call site whose comment or name marks it as deliberate (e.g. `\u002F\u002F intentional local time`) unless the user explicitly names that site and requests a semantics-preserving migration. List everything you deliberately left alone under \"Remaining (out of scope)\" so the user can ask for it in a follow-up; suggesting is fine, silently widening the scope is not.\n\nFor each file containing the static pattern, determine:\n\n1. **Which class(es) contain the call sites** — identify the class declarations\n2. **Whether the class already has the dependency injected** — check constructors for existing `TimeProvider`, `IFileSystem`, etc. parameters\n3. **The replacement expression** for each call site\n\n#### Replacement mapping\n\n| Category | Original | DI replacement |\n|----------|----------|----------------|\n| Time | `DateTime.Now` | `_timeProvider.GetLocalNow().LocalDateTime` |\n| Time | `DateTime.UtcNow` | `_timeProvider.GetUtcNow().UtcDateTime` |\n| Time | `DateTime.Today` | `_timeProvider.GetLocalNow().LocalDateTime.Date` |\n| Time | `DateTimeOffset.Now` | `_timeProvider.GetLocalNow()` |\n| Time | `DateTimeOffset.UtcNow` | `_timeProvider.GetUtcNow()` |\n| File | `File.ReadAllText(path)` | `_fileSystem.File.ReadAllText(path)` |\n| File | `File.WriteAllText(path, text)` | `_fileSystem.File.WriteAllText(path, text)` |\n| File | `File.Exists(path)` | `_fileSystem.File.Exists(path)` |\n| File | `Directory.Exists(path)` | `_fileSystem.Directory.Exists(path)` |\n| Env | `Environment.GetEnvironmentVariable(name)` | `_env.GetEnvironmentVariable(name)` |\n| Console | `Console.WriteLine(msg)` | `_console.WriteLine(msg)` |\n| Process | `Process.Start(info)` | `_processRunner.Start(info)` |\n\nApply the same pattern for other members in each category.\n\n> **Preserve `DateTimeKind` — this is the most common silent regression.** `TimeProvider.GetUtcNow()` \u002F `GetLocalNow()` return a `DateTimeOffset`. Converting back to `DateTime` **must keep the original `Kind`**, otherwise you introduce a behavioral change even though the code still compiles:\n>\n> - `DateTime.UtcNow` has `Kind == Utc` → use `.UtcDateTime` (**not** `.DateTime`, which yields `Kind == Unspecified`).\n> - `DateTime.Now` has `Kind == Local` → use `.LocalDateTime` (**not** `.DateTime`).\n> - When a call site consumes a `DateTimeOffset` directly (a field\u002Fparameter\u002Freturn already typed `DateTimeOffset`), drop the `.UtcDateTime`\u002F`.LocalDateTime` suffix and assign the `DateTimeOffset` as-is — don't force it back through `DateTime`.\n>\n> Match the **target member's type**: if the surrounding field\u002Fproperty is `DateTime`, keep it `DateTime` (via the Kind-correct property above); do not change it to `DateTimeOffset` as part of a \"mechanical\" migration — that is a design change, not a delegation.\n>\n> Preserve the **number, order, and location of reads** as well as the value type.\n> Replace each original clock read in place with one provider read. Do not hoist,\n> cache, or coalesce two reads into a shared `now` local, even when they are in the\n> same object initializer or method. Two consecutive `DateTime.UtcNow` calls could\n> observe different instants; making `CreatedAt` and `ExpiresAt` derive from one\n> captured value is a behavior change, not a mechanical migration. Reuse a value\n> only when the original code already captured and reused one.\n\n### Step 3: Add constructor injection\n\nAdd the new dependency following the class's existing pattern:\n\n- **Primary constructor** (C# 12+): Add parameter to primary constructor: `public class OrderProcessor(ILogger\u003COrderProcessor> logger, TimeProvider timeProvider)`\n- **Traditional constructor**: Add `private readonly` field + constructor parameter, matching the existing field naming convention (`_camelCase` or `m_camelCase`)\n\n#### Static classes: use ambient context (no constructor injection)\n\nA `static` class with only static members **cannot** receive constructor injection — adding an instance constructor or instance field would break it. Do **not** convert it to a non-static class just to inject the dependency; that changes its design and every call site. Instead, apply a scoped ambient seam that defaults to the real implementation and can be overridden without leaking process-global state.\n\nWhen the user wants to keep the class static, the ambient seam below **is the answer** — present it as *the* solution and implement it directly. Do **not** hedge by offering \"convert it to a non-static class\" or \"pass `TimeProvider` as a method parameter\" as co-equal alternatives; those change the class's design or public API and are not what was asked. Lead with the seam, then note the parallelism trade-off.\n\n```csharp\npublic static class TimestampFormatter\n{\n  private static readonly AsyncLocal\u003CTimeProvider?> s_clock = new();\n\n  private static TimeProvider Clock => s_clock.Value ?? TimeProvider.System;\n\n  public static string Now() => Clock.GetUtcNow().ToString(\"O\");\n\n  public static IDisposable OverrideClock(TimeProvider clock)\n  {\n      ArgumentNullException.ThrowIfNull(clock);\n      var previous = s_clock.Value;\n      s_clock.Value = clock;\n      return new Scope(() => s_clock.Value = previous);\n  }\n\n  private sealed class Scope : IDisposable\n  {\n      private Action? _restore;\n\n      public Scope(Action restore)\n      {\n          _restore = restore;\n      }\n\n      public void Dispose() => Interlocked.Exchange(ref _restore, null)?.Invoke();\n  }\n}\n```\n\n- Production reads `TimeProvider.System` whenever no override is active; no startup mutation is required.\n- Tests create a fresh fake\u002Fprovider per async flow and dispose the returned scope. Nested disposal restores the outer provider.\n- `AsyncLocal\u003CT>` keeps independently established test flows isolated across `await`. Do not store a mutable stack\u002Flist in the slot or mutate one fake inherited by multiple child flows.\n- Add focused tests for substitution, nested restoration, and parallel async isolation. A build-only check does not prove this seam.\n- The same shape works for other statics (`IFileSystem`, custom wrappers): store the abstraction value in `AsyncLocal\u003CT>`, default to the real implementation, and restore the previous value from the scope.\n\n### Step 4: Replace call sites\n\nPerform each replacement mechanically. For each call site:\n\n1. Replace the static call with the wrapper call\n2. Preserve the surrounding expression structure and evaluation order; one\n   original dependency read remains one wrapper read\n3. Add required `using` directives if not already present\n\nAfter editing, repeat the exact search and require zero occurrences in every\nin-scope production file. Re-open each changed file and compare the result to\nthe pre-edit inventory. A summary count is not evidence if one method was\nsilently missed.\n\nAlso verify the exclusive side of the scope: search or compare every file the\nuser explicitly said to leave alone and require its original static calls and\ncontent to remain. For a single-file migration, report both numbers even when\nthey are small: `N\u002FN` in-scope calls replaced and `M` named out-of-scope calls\npreserved.\n\n#### Adding using directives\n\n| Abstraction | Using directive |\n|------------|-----------------|\n| `TimeProvider` | None (in `System` namespace) |\n| `IFileSystem` | `using System.IO.Abstractions;` |\n| `IHttpClientFactory` | `using System.Net.Http;` (usually already present) |\n| Custom wrappers | `using \u003Cwrapper namespace>;` |\n\n### Step 5: Update affected test files\n\nIf test files exist for the migrated classes:\n\n1. **Update constructor calls** — add the new parameter to test class instantiation\n2. **Use test doubles**:\n   - `TimeProvider` → `new FakeTimeProvider()` from `Microsoft.Extensions.TimeProvider.Testing`\n   - `IFileSystem` → `new MockFileSystem()` from `System.IO.Abstractions.TestingHelpers`\n   - Custom wrappers → `new Mock\u003CIWrapperName>()` or hand-rolled fake\n\nPreserve every observable branch that depended on the original static result. For\nexample, migrating `Environment.GetEnvironmentVariable(name) ?? \"production\"`\nrequires tests for both a configured value and `null`\u002Fmissing input selecting the\nfallback. A fake-only happy path is not enough to prove a mechanical migration.\nWhen tests already exist, preserve their framework and assertion style, but make\nthe replacement dependency observable: include at least one configured\u002Ffake\nvalue assertion and one fallback or error-path assertion where the original\nstatic API exposed both outcomes. Merely making the old tests compile is not\ncomplete migration evidence.\n\nWhen the request explicitly converts affected unit tests away from real file or\nenvironment access, prove those tests no longer touch the process-global\ndependency: search them for temp-file, real-disk, or environment-mutation APIs\nafter editing. Preserve intentional integration tests outside that requested\nscope. Report the deterministic fake's configured and fallback\u002Ferror cases\nrather than only saying that a fake was added.\n\n### Step 6: Build verification\n\nAfter all changes in the current scope, build the affected production project\nand run the narrowest affected test project whenever tests exist or were\nchanged:\n\n```bash\ndotnet build \u003Cproject.csproj>\ndotnet test \u003Caffected-test-project.csproj>\n```\n\n**Report the build result you actually observed.** Only write \"build succeeded\" when the command exited 0; if it failed — including restore\u002FNuGet failures such as \"assets file not found\" — say so, quote the error, and either fix it (`dotnet restore`, add the missing package) or hand the user a precise blocker. A false success claim is worse than an unfinished migration.\n\nIf the build fails:\n- **Missing using**: Add the required `using` directive\n- **Missing NuGet package**: add it only when dependency changes were explicitly authorized; otherwise report the unmet prerequisite and stop\n- **Constructor mismatch in tests**: Update test instantiation (Step 5)\n- **Ambiguous call**: Fully qualify the wrapper call\n\nDo not substitute a successful build for the requested test run. When migration\nchanges constructor calls, fakes, process-global state, or real I\u002FO, only the\ntargeted tests prove the complete path. If the test command is blocked, report\nthat blocker rather than claiming the migration is fully validated.\n\n### Step 7: Report changes\n\nSummarize what was done. Even for one production file and one test file, include\nthe exact in-scope replacement count, the named out-of-scope files or calls\nverified unchanged, and the targeted build\u002Ftest result:\n\n```\n## Migration Summary\n\n**Pattern**: DateTime.UtcNow → TimeProvider.GetUtcNow()\n**Scope**: MyProject\u002FServices\u002F\n\n### Files Modified (production)\n| File | Call Sites Replaced | Injection Added |\n|------|--------------------:|:----------------|\n| OrderProcessor.cs | 3 | Yes (constructor) |\n| NotificationService.cs | 1 | Yes (primary ctor) |\n\n### Files Modified (tests)\n| File | Change |\n|------|--------|\n| OrderProcessorTests.cs | Added FakeTimeProvider parameter |\n\n### Remaining (out of scope)\n- MyProject\u002FLegacy\u002F — 8 call sites not migrated (different namespace)\n```\n\n## Validation\n\n- [ ] All call sites in scope were replaced (none missed)\n- [ ] A before\u002Fafter exact-member search proves the in-scope occurrence count\n      reached zero\n- [ ] No call site outside the requested member\u002Ffile scope was modified\n- [ ] Call sites documented as intentional were left untouched and reported unless\n      the user explicitly named them for semantics-preserving migration\n- [ ] Constructor injection added to all affected classes\n- [ ] Field naming follows existing class conventions\n- [ ] Required `using` directives added\n- [ ] Required NuGet packages referenced\n- [ ] Build succeeds after migration, and the reported result matches the actual command exit code\n- [ ] Test files updated with appropriate test doubles\n- [ ] Existing configured, fallback\u002Fnull, and error branches still have direct test evidence\n- [ ] The affected targeted tests ran successfully when tests exist or changed\n- [ ] No behavioral changes introduced (wrapper delegates directly to the static)\n- [ ] Static reads were replaced one-for-one; none were hoisted, cached, or coalesced\n- [ ] `DateTimeKind` preserved — former `DateTime.UtcNow` stays `Utc` (`.UtcDateTime`), former `DateTime.Now` stays `Local` (`.LocalDateTime`)\n\n## Common Pitfalls\n\n| Pitfall | Solution |\n|---------|----------|\n| Replacing statics in test code | Only replace in production code; tests should use fakes\u002Fmocks |\n| Breaking static classes | Static classes can't have constructors — use the ambient context seam (Step 3) instead of converting them to non-static |\n| Missing `FakeTimeProvider` NuGet | Add `Microsoft.Extensions.TimeProvider.Testing` to test project |\n| Replacing a `DateTime` value with `.DateTime` off a `DateTimeOffset` | `DateTimeOffset.DateTime` returns `Kind == Unspecified` — use `.UtcDateTime` (for former `DateTime.UtcNow`) or `.LocalDateTime` (for former `DateTime.Now`) to preserve the original `DateTimeKind`. Only change the field\u002Freturn type to `DateTimeOffset` if the user asked for it. |\n| Capturing one provider value for multiple original clock reads | Replace each read in place. Coalescing reads changes observable timing even when it looks cleaner. |\n| Migrating too much at once | Stick to the defined scope — one project or namespace per run |\n| Migrating `DateTime.Now` when only `UtcNow` was requested | Respect the literal request; list the other call sites as out-of-scope suggestions instead of rewriting them |\n| Claiming \"Build succeeded\" after a failed restore | Read the exit code and output; report the real failure and fix it or surface it as a blocker |\n| Adding a package during a call-site-only migration | Stop and request authorization or run wrapper\u002Fadoption setup first |\n| Forgetting production composition | Verify DI registration, manual construction, or the ambient production default before replacing call sites |\n","# Migrate Static to Wrapper\n\nPerform mechanical, codemod-style replacement of static dependency call sites with calls to injected wrapper interfaces or built-in abstractions. Operates on a bounded scope (single file, project, or namespace) so migrations can be done incrementally.\n\n## When to Use\n\n- After wrappers have been generated (via `generate-testability-wrappers`) or built-in abstractions identified\n- Migrating `DateTime.UtcNow` → `TimeProvider.GetUtcNow()` across a project\n- Migrating `File.*` → `IFileSystem.File.*` across a namespace\n- Adding constructor injection for the new abstraction to affected classes\n- Making a `static` utility class testable by adding an ambient seam (Step 3) while its existing call sites keep\n  compiling unchanged\n- Incremental migration: one project or namespace at a time\n- Updating affected tests with fakes when the requested migration names the\n  replacement abstraction\n\n## When Not to Use\n\n- No wrapper or abstraction exists yet and one must be designed from scratch (use `generate-testability-wrappers` first).\n  A built-in abstraction such as `TimeProvider` or `IFileSystem` always counts as existing.\n- The user wants to detect statics, not migrate them (use `detect-static-dependencies`)\n- Migrating between test frameworks (use the appropriate migration skill)\n- The user primarily asks for a deterministic behavior test and has not selected\n  the production seam (use `testability-obstacle`)\n\n> A class that is `static`, or a project with no DI container, is **not** a reason to skip this skill — that is exactly\n> what the ambient seam in Step 3 is for. Use it whenever the call sites must keep compiling unchanged.\n\n## Inputs\n\n| Input | Required | Description |\n|-------|----------|-------------|\n| Static pattern | No | Infer from the request and discovered call sites (e.g., `DateTime.UtcNow`, `File.ReadAllText`) |\n| Replacement abstraction | No | Infer from the request and existing project abstractions; stop only when no named\u002Fexisting abstraction is available |\n| Scope | No | Infer from the requested file\u002Fproject\u002Fnamespace, otherwise discover the narrowest relevant workspace scope |\n| Injection strategy | No | `constructor` (default), `primary-constructor`, or `ambient` |\n\n## Workflow\n\n### Non-negotiable migration boundaries\n\n- **Missing abstraction means stop.** If the named interface\u002Fpackage is absent and\n  the request only authorizes call-site replacement, do not add a package, invent\n  a local lookalike interface, or edit production code. Report the exact missing\n  prerequisite and the authorization needed to continue.\n- **One source read stays one replacement read.** Do not hoist or coalesce calls,\n  even when sharing a captured timestamp looks cleaner.\n- **The requested scope is exhaustive and exclusive.** Replace every named call\n  in scope and no adjacent member or file.\n- **Repository-backed requests require repository work.** Start by discovering\n  files from the current workspace. Do not claim the repository is unavailable\n  or ask the user for a path or file contents until workspace-relative discovery\n  found no target. Do not say work was implemented unless the diff proves it.\n- **Discovered workspace files must be completed in this turn when permitted.**\n  Use a host-native shell reader (`sed`\u002F`cat` or `Get-Content`) only after a\n  confirmed reader availability, transport, or path-normalization failure and\n  only after verifying the canonical path remains inside the current workspace.\n  Stop on content-exclusion, permission\u002Fpolicy, workspace-boundary, or unknown\n  read failures. Use a shell edit fallback only for a confirmed editor\n  availability, transport, or path-normalization failure, never for a stale\n  context, concurrent change, permission\u002Fpolicy denial, or path-boundary error.\n  Before fallback, resolve the canonical path inside the current workspace,\n  freshly read the file, and require an anchored replacement with the expected\n  old text and exact match count; abort if either changed. Then re-open the file,\n  inspect the diff, and validate. Do not ask the user to paste a readable\n  discovered file or report a proposed patch as completed work.\n\n### Step 1: Verify prerequisites\n\nBefore modifying any code:\n\n1. **Confirm the wrapper\u002Fabstraction exists**: Check that the interface or built-in abstraction is available in the project. For `TimeProvider`, verify the target framework is .NET 8+ or `Microsoft.Bcl.TimeProvider` is referenced. For `System.IO.Abstractions`, verify the NuGet package is referenced. A package that could provide an abstraction is not the same as an abstraction already available to this project.\n\n2. **Trace production composition**: Check `Program.cs`, `Startup.cs`, factories,\n   and manual construction sites before editing. An explicit migration to an\n   available seam includes the minimal constructor\u002Fcaller\u002Fregistration changes\n   needed to keep that scope runnable, unless the user forbids those edits.\n   Register `TimeProvider.System` in an existing DI host when the new dependency\n   is not already registered; update manual callers instead of introducing DI\n   to a library. Missing packages or new wrapper design still require separate\n   authorization. Do not stop after an injectable class while leaving its real\n   construction path broken.\n\n3. **Identify all files in scope**: List the `.cs` files that will be modified. Exclude test projects, `obj\u002F`, `bin\u002F`, and generated code.\n\n4. **Lock and count the member set before editing**: Use the exact member named\n   by the user, or infer the smallest unambiguous set from the request and\n   discovered call sites. Record that set, then search every member and capture\n   the file\u002Fline inventory. Do not change the set mid-edit or infer counts from\n   a partial read.\n\n### Step 2: Plan the migration for each file\n\n**Migrate exactly what was asked — nothing adjacent.** If the user named a member (`DateTime.UtcNow`), migrate only that member and leave siblings such as `DateTime.Now` untouched. If the user named files, do not touch other files. Preserve a call site whose comment or name marks it as deliberate (e.g. `\u002F\u002F intentional local time`) unless the user explicitly names that site and requests a semantics-preserving migration. List everything you deliberately left alone under \"Remaining (out of scope)\" so the user can ask for it in a follow-up; suggesting is fine, silently widening the scope is not.\n\nFor each file containing the static pattern, determine:\n\n1. **Which class(es) contain the call sites** — identify the class declarations\n2. **Whether the class already has the dependency injected** — check constructors for existing `TimeProvider`, `IFileSystem`, etc. parameters\n3. **The replacement expression** for each call site\n\n#### Replacement mapping\n\n| Category | Original | DI replacement |\n|----------|----------|----------------|\n| Time | `DateTime.Now` | `_timeProvider.GetLocalNow().LocalDateTime` |\n| Time | `DateTime.UtcNow` | `_timeProvider.GetUtcNow().UtcDateTime` |\n| Time | `DateTime.Today` | `_timeProvider.GetLocalNow().LocalDateTime.Date` |\n| Time | `DateTimeOffset.Now` | `_timeProvider.GetLocalNow()` |\n| Time | `DateTimeOffset.UtcNow` | `_timeProvider.GetUtcNow()` |\n| File | `File.ReadAllText(path)` | `_fileSystem.File.ReadAllText(path)` |\n| File | `File.WriteAllText(path, text)` | `_fileSystem.File.WriteAllText(path, text)` |\n| File | `File.Exists(path)` | `_fileSystem.File.Exists(path)` |\n| File | `Directory.Exists(path)` | `_fileSystem.Directory.Exists(path)` |\n| Env | `Environment.GetEnvironmentVariable(name)` | `_env.GetEnvironmentVariable(name)` |\n| Console | `Console.WriteLine(msg)` | `_console.WriteLine(msg)` |\n| Process | `Process.Start(info)` | `_processRunner.Start(info)` |\n\nApply the same pattern for other members in each category.\n\n> **Preserve `DateTimeKind` — this is the most common silent regression.** `TimeProvider.GetUtcNow()` \u002F `GetLocalNow()` return a `DateTimeOffset`. Converting back to `DateTime` **must keep the original `Kind`**, otherwise you introduce a behavioral change even though the code still compiles:\n>\n> - `DateTime.UtcNow` has `Kind == Utc` → use `.UtcDateTime` (**not** `.DateTime`, which yields `Kind == Unspecified`).\n> - `DateTime.Now` has `Kind == Local` → use `.LocalDateTime` (**not** `.DateTime`).\n> - When a call site consumes a `DateTimeOffset` directly (a field\u002Fparameter\u002Freturn already typed `DateTimeOffset`), drop the `.UtcDateTime`\u002F`.LocalDateTime` suffix and assign the `DateTimeOffset` as-is — don't force it back through `DateTime`.\n>\n> Match the **target member's type**: if the surrounding field\u002Fproperty is `DateTime`, keep it `DateTime` (via the Kind-correct property above); do not change it to `DateTimeOffset` as part of a \"mechanical\" migration — that is a design change, not a delegation.\n>\n> Preserve the **number, order, and location of reads** as well as the value type.\n> Replace each original clock read in place with one provider read. Do not hoist,\n> cache, or coalesce two reads into a shared `now` local, even when they are in the\n> same object initializer or method. Two consecutive `DateTime.UtcNow` calls could\n> observe different instants; making `CreatedAt` and `ExpiresAt` derive from one\n> captured value is a behavior change, not a mechanical migration. Reuse a value\n> only when the original code already captured and reused one.\n\n### Step 3: Add constructor injection\n\nAdd the new dependency following the class's existing pattern:\n\n- **Primary constructor** (C# 12+): Add parameter to primary constructor: `public class OrderProcessor(ILogger\u003COrderProcessor> logger, TimeProvider timeProvider)`\n- **Traditional constructor**: Add `private readonly` field + constructor parameter, matching the existing field naming convention (`_camelCase` or `m_camelCase`)\n\n#### Static classes: use ambient context (no constructor injection)\n\nA `static` class with only static members **cannot** receive constructor injection — adding an instance constructor or instance field would break it. Do **not** convert it to a non-static class just to inject the dependency; that changes its design and every call site. Instead, apply a scoped ambient seam that defaults to the real implementation and can be overridden without leaking process-global state.\n\nWhen the user wants to keep the class static, the ambient seam below **is the answer** — present it as *the* solution and implement it directly. Do **not** hedge by offering \"convert it to a non-static class\" or \"pass `TimeProvider` as a method parameter\" as co-equal alternatives; those change the class's design or public API and are not what was asked. Lead with the seam, then note the parallelism trade-off.\n\n```csharp\npublic static class TimestampFormatter\n{\n  private static readonly AsyncLocal\u003CTimeProvider?> s_clock = new();\n\n  private static TimeProvider Clock => s_clock.Value ?? TimeProvider.System;\n\n  public static string Now() => Clock.GetUtcNow().ToString(\"O\");\n\n  public static IDisposable OverrideClock(TimeProvider clock)\n  {\n      ArgumentNullException.ThrowIfNull(clock);\n      var previous = s_clock.Value;\n      s_clock.Value = clock;\n      return new Scope(() => s_clock.Value = previous);\n  }\n\n  private sealed class Scope : IDisposable\n  {\n      private Action? _restore;\n\n      public Scope(Action restore)\n      {\n          _restore = restore;\n      }\n\n      public void Dispose() => Interlocked.Exchange(ref _restore, null)?.Invoke();\n  }\n}\n```\n\n- Production reads `TimeProvider.System` whenever no override is active; no startup mutation is required.\n- Tests create a fresh fake\u002Fprovider per async flow and dispose the returned scope. Nested disposal restores the outer provider.\n- `AsyncLocal\u003CT>` keeps independently established test flows isolated across `await`. Do not store a mutable stack\u002Flist in the slot or mutate one fake inherited by multiple child flows.\n- Add focused tests for substitution, nested restoration, and parallel async isolation. A build-only check does not prove this seam.\n- The same shape works for other statics (`IFileSystem`, custom wrappers): store the abstraction value in `AsyncLocal\u003CT>`, default to the real implementation, and restore the previous value from the scope.\n\n### Step 4: Replace call sites\n\nPerform each replacement mechanically. For each call site:\n\n1. Replace the static call with the wrapper call\n2. Preserve the surrounding expression structure and evaluation order; one\n   original dependency read remains one wrapper read\n3. Add required `using` directives if not already present\n\nAfter editing, repeat the exact search and require zero occurrences in every\nin-scope production file. Re-open each changed file and compare the result to\nthe pre-edit inventory. A summary count is not evidence if one method was\nsilently missed.\n\nAlso verify the exclusive side of the scope: search or compare every file the\nuser explicitly said to leave alone and require its original static calls and\ncontent to remain. For a single-file migration, report both numbers even when\nthey are small: `N\u002FN` in-scope calls replaced and `M` named out-of-scope calls\npreserved.\n\n#### Adding using directives\n\n| Abstraction | Using directive |\n|------------|-----------------|\n| `TimeProvider` | None (in `System` namespace) |\n| `IFileSystem` | `using System.IO.Abstractions;` |\n| `IHttpClientFactory` | `using System.Net.Http;` (usually already present) |\n| Custom wrappers | `using \u003Cwrapper namespace>;` |\n\n### Step 5: Update affected test files\n\nIf test files exist for the migrated classes:\n\n1. **Update constructor calls** — add the new parameter to test class instantiation\n2. **Use test doubles**:\n   - `TimeProvider` → `new FakeTimeProvider()` from `Microsoft.Extensions.TimeProvider.Testing`\n   - `IFileSystem` → `new MockFileSystem()` from `System.IO.Abstractions.TestingHelpers`\n   - Custom wrappers → `new Mock\u003CIWrapperName>()` or hand-rolled fake\n\nPreserve every observable branch that depended on the original static result. For\nexample, migrating `Environment.GetEnvironmentVariable(name) ?? \"production\"`\nrequires tests for both a configured value and `null`\u002Fmissing input selecting the\nfallback. A fake-only happy path is not enough to prove a mechanical migration.\nWhen tests already exist, preserve their framework and assertion style, but make\nthe replacement dependency observable: include at least one configured\u002Ffake\nvalue assertion and one fallback or error-path assertion where the original\nstatic API exposed both outcomes. Merely making the old tests compile is not\ncomplete migration evidence.\n\nWhen the request explicitly converts affected unit tests away from real file or\nenvironment access, prove those tests no longer touch the process-global\ndependency: search them for temp-file, real-disk, or environment-mutation APIs\nafter editing. Preserve intentional integration tests outside that requested\nscope. Report the deterministic fake's configured and fallback\u002Ferror cases\nrather than only saying that a fake was added.\n\n### Step 6: Build verification\n\nAfter all changes in the current scope, build the affected production project\nand run the narrowest affected test project whenever tests exist or were\nchanged:\n\n```bash\ndotnet build \u003Cproject.csproj>\ndotnet test \u003Caffected-test-project.csproj>\n```\n\n**Report the build result you actually observed.** Only write \"build succeeded\" when the command exited 0; if it failed — including restore\u002FNuGet failures such as \"assets file not found\" — say so, quote the error, and either fix it (`dotnet restore`, add the missing package) or hand the user a precise blocker. A false success claim is worse than an unfinished migration.\n\nIf the build fails:\n- **Missing using**: Add the required `using` directive\n- **Missing NuGet package**: add it only when dependency changes were explicitly authorized; otherwise report the unmet prerequisite and stop\n- **Constructor mismatch in tests**: Update test instantiation (Step 5)\n- **Ambiguous call**: Fully qualify the wrapper call\n\nDo not substitute a successful build for the requested test run. When migration\nchanges constructor calls, fakes, process-global state, or real I\u002FO, only the\ntargeted tests prove the complete path. If the test command is blocked, report\nthat blocker rather than claiming the migration is fully validated.\n\n### Step 7: Report changes\n\nSummarize what was done. Even for one production file and one test file, include\nthe exact in-scope replacement count, the named out-of-scope files or calls\nverified unchanged, and the targeted build\u002Ftest result:\n\n```\n## Migration Summary\n\n**Pattern**: DateTime.UtcNow → TimeProvider.GetUtcNow()\n**Scope**: MyProject\u002FServices\u002F\n\n### Files Modified (production)\n| File | Call Sites Replaced | Injection Added |\n|------|--------------------:|:----------------|\n| OrderProcessor.cs | 3 | Yes (constructor) |\n| NotificationService.cs | 1 | Yes (primary ctor) |\n\n### Files Modified (tests)\n| File | Change |\n|------|--------|\n| OrderProcessorTests.cs | Added FakeTimeProvider parameter |\n\n### Remaining (out of scope)\n- MyProject\u002FLegacy\u002F — 8 call sites not migrated (different namespace)\n```\n\n## Validation\n\n- [ ] All call sites in scope were replaced (none missed)\n- [ ] A before\u002Fafter exact-member search proves the in-scope occurrence count\n      reached zero\n- [ ] No call site outside the requested member\u002Ffile scope was modified\n- [ ] Call sites documented as intentional were left untouched and reported unless\n      the user explicitly named them for semantics-preserving migration\n- [ ] Constructor injection added to all affected classes\n- [ ] Field naming follows existing class conventions\n- [ ] Required `using` directives added\n- [ ] Required NuGet packages referenced\n- [ ] Build succeeds after migration, and the reported result matches the actual command exit code\n- [ ] Test files updated with appropriate test doubles\n- [ ] Existing configured, fallback\u002Fnull, and error branches still have direct test evidence\n- [ ] The affected targeted tests ran successfully when tests exist or changed\n- [ ] No behavioral changes introduced (wrapper delegates directly to the static)\n- [ ] Static reads were replaced one-for-one; none were hoisted, cached, or coalesced\n- [ ] `DateTimeKind` preserved — former `DateTime.UtcNow` stays `Utc` (`.UtcDateTime`), former `DateTime.Now` stays `Local` (`.LocalDateTime`)\n\n## Common Pitfalls\n\n| Pitfall | Solution |\n|---------|----------|\n| Replacing statics in test code | Only replace in production code; tests should use fakes\u002Fmocks |\n| Breaking static classes | Static classes can't have constructors — use the ambient context seam (Step 3) instead of converting them to non-static |\n| Missing `FakeTimeProvider` NuGet | Add `Microsoft.Extensions.TimeProvider.Testing` to test project |\n| Replacing a `DateTime` value with `.DateTime` off a `DateTimeOffset` | `DateTimeOffset.DateTime` returns `Kind == Unspecified` — use `.UtcDateTime` (for former `DateTime.UtcNow`) or `.LocalDateTime` (for former `DateTime.Now`) to preserve the original `DateTimeKind`. Only change the field\u002Freturn type to `DateTimeOffset` if the user asked for it. |\n| Capturing one provider value for multiple original clock reads | Replace each read in place. Coalescing reads changes observable timing even when it looks cleaner. |\n| Migrating too much at once | Stick to the defined scope — one project or namespace per run |\n| Migrating `DateTime.Now` when only `UtcNow` was requested | Respect the literal request; list the other call sites as out-of-scope suggestions instead of rewriting them |\n| Claiming \"Build succeeded\" after a failed restore | Read the exit code and output; report the real failure and fix it or surface it as a blocker |\n| Adding a package during a call-site-only migration | Stop and request authorization or run wrapper\u002Fadoption setup first |\n| Forgetting production composition | Verify DI registration, manual construction, or the ambient production default before replacing call sites |\n",{"name":5,"license":15,"description":24},"Use when asked to migrate, replace, or make testable existing C# static calls with a named wrapper or built-in abstraction: DateTime.UtcNow\u002FNow or DateTimeOffset.UtcNow to TimeProvider\u002FIClock, File.* to IFileSystem or an existing store such as ITextFileStore, and Environment.* to an existing reader such as IEnvironmentReader. Covers scoped files\u002Fprojects, constructor injection, replacing temp-file or process-environment tests with fakes, \"already registered\" abstractions, and static classes whose callers\u002Fsignatures must stay unchanged. Preserves DateTimeKind and call count. DO NOT USE for finding statics (detect-static-dependencies), choosing\u002Fdesigning a new wrapper (generate-testability-wrappers), behavior tests with no chosen seam (testability-obstacle), or test-framework migration.\n","master","49e49abf2f670d429e0b7e2c0349739c3fdd5cbe","skills\u002Fmigrate-static-to-wrapper",5,"https:\u002F\u002Fgithub.com\u002Fstanfish06\u002Fskillquarium","https:\u002F\u002Fgithub.com\u002Fstanfish06","https:\u002F\u002Fwww.stanfish.dev\u002F","2026-11-14 21:31:37",{"source":8,"skillName":5,"commands":34,"prompt":44,"zipAvailable":45},[35,38,41],{"tool":36,"command":37},"npx","npx skills add stanfish06\u002Fskillquarium --skill migrate-static-to-wrapper",{"tool":39,"command":40},"bunx","bunx skills add stanfish06\u002Fskillquarium --skill migrate-static-to-wrapper",{"tool":42,"command":43},"pnpm","pnpm dlx skills add stanfish06\u002Fskillquarium --skill migrate-static-to-wrapper","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fstanfish06\u002Fskillquarium\u002Fblob\u002Fmaster\u002Fskills\u002Fmigrate-static-to-wrapper\u002FSKILL.md",true,[],[48,55,64,71,78,85],{"skillNo":49,"name":50,"nameZh":6,"description":51,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":52,"categories":53,"keywords":54,"publishedAt":19},"01M76ZJTRVA456GD7K8Y3EP82H","zarr-python","Stores and queries chunked N-D scientific arrays with Zarr-Python 3, including codecs, sharding, S3\u002FGCS storage, and NumPy\u002FDask\u002FXarray integration. Use for array layout, bounded I\u002FO, format migration, or scientific metadata preservation.","https:\u002F\u002Fgithub.com\u002Fstanfish06\u002Fskillquarium\u002Fblob\u002Fmaster\u002Fskills\u002Fzarr-python\u002FSKILL.md",[],[],{"skillNo":56,"name":57,"nameZh":6,"description":58,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":59,"licenseFileUrl":60,"sourceHtmlUrl":61,"categories":62,"keywords":63,"publishedAt":19},"01M76ZJQZ15Q1HKC5V85NHE325","yeet","Publish local changes to GitHub by confirming scope, committing intentionally, pushing the branch, and opening a draft PR through the GitHub app from this plugin, with `gh` used only as a fallback where connector coverage is insufficient.","Apache-2.0","https:\u002F\u002Fgithub.com\u002Fstanfish06\u002Fskillquarium\u002Fblob\u002Fmaster\u002Fskills\u002Fyeet\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fstanfish06\u002Fskillquarium\u002Fblob\u002Fmaster\u002Fskills\u002Fyeet\u002FSKILL.md",[],[],{"skillNo":65,"name":66,"nameZh":6,"description":67,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":59,"licenseFileUrl":6,"sourceHtmlUrl":68,"categories":69,"keywords":70,"publishedAt":19},"01M76ZJ8ASZ4QYQ70Y6SBA4Z4S","xarray","N-dimensional labeled arrays and datasets in Python. Built on top of NumPy and Dask. It introduces labels in the form of dimensions, coordinates, and attributes on top of raw NumPy-like arrays, making data analysis in physical sciences more intuitive and less error-prone. Use for working with multi-dimensional scientific data, NetCDF\u002FGRIB\u002FZarr files, climate\u002Fweather\u002Foceanographic datasets, remote sensing, geospatial imaging, large out-of-memory datasets with Dask, and labeled array operations.","https:\u002F\u002Fgithub.com\u002Fstanfish06\u002Fskillquarium\u002Fblob\u002Fmaster\u002Fskills\u002Fxarray\u002FSKILL.md",[],[],{"skillNo":72,"name":73,"nameZh":6,"description":74,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":75,"categories":76,"keywords":77,"publishedAt":19},"01M76ZHFBXD6VXPQ02VCEG202B","writing-mstest-tests","Use when asked to fix, rewrite, update, improve, modernize, show corrected code for, or explain existing MSTest tests or MSTest-specific configuration. Use for \"review\" when corrected code or edits are wanted, even for one pasted assertion or passing tests with bad failure output. Covers expected\u002Factual labels; generic Boolean, collection, string, numeric, null, identity, exception, hard-cast, and object[] checks; TestContext\u002Flifecycle; timeout\u002Fcancellation; OS\u002FCI conditions, retry, cleanup, parallelization, MSTest.Sdk project setup, and MSTESTxxxx. Honor the installed MSTest version. DO NOT USE to design new test cases (code-testing), perform report-only audits, create project files rather than explain MSTest setup, run tests, migrate frameworks, or handle non-MSTest\u002Fnon-.NET code.","https:\u002F\u002Fgithub.com\u002Fstanfish06\u002Fskillquarium\u002Fblob\u002Fmaster\u002Fskills\u002Fwriting-mstest-tests\u002FSKILL.md",[],[],{"skillNo":79,"name":80,"nameZh":6,"description":81,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":82,"categories":83,"keywords":84,"publishedAt":19},"01M76ZDFDF4N88RH6HSYGS7GP2","wgs-prs","End-to-end WGS to polygenic risk score pipeline. Takes paired-end FASTQ files (or a pre-existing VCF) through nf-core\u002Fsarek for variant calling, applies VCF QC (normalisation, hard filtering, Ti\u002FTv and Het\u002FHom checks), then computes polygenic risk scores via the PGS Catalog. Fills the FASTQ to VCF gap upstream of the gwas-prs skill.","https:\u002F\u002Fgithub.com\u002Fstanfish06\u002Fskillquarium\u002Fblob\u002Fmaster\u002Fskills\u002Fwgs-prs\u002FSKILL.md",[],[],{"skillNo":86,"name":87,"nameZh":6,"description":88,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":59,"licenseFileUrl":89,"sourceHtmlUrl":90,"categories":91,"keywords":92,"publishedAt":19},"01M76ZCC1SC68J42QK4MDC8RCG","webapp-testing","Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.","https:\u002F\u002Fgithub.com\u002Fstanfish06\u002Fskillquarium\u002Fblob\u002Fmaster\u002Fskills\u002Fwebapp-testing\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fstanfish06\u002Fskillquarium\u002Fblob\u002Fmaster\u002Fskills\u002Fwebapp-testing\u002FSKILL.md",[],[]]