[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7CV8JK6KVF1HS1J30K01RST":3,"skill-same:01M7CV8JK6KVF1HS1J30K01RST":46},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":21,"frontMatter":22,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":13,"repositoryHtmlUrl":27,"repositoryHomepageUrl":6,"ownerHtmlUrl":28,"ownerBlogUrl":29,"ownerDescription":30,"updatedAt":31,"install":32,"resources":45},"01M7CV8JK6KVF1HS1J30K01RST","generate-testability-wrappers",null,"DO NOT USE when the target already consumes an injected interface or built-in abstraction such as IFileSystem or TimeProvider, even if the request says \"generate a wrapper\"; no new wrapper is needed. Use only when C# source calls an ambient\u002Fstatic dependency and no injectable seam exists: first-time TimeProvider, IHttpClientFactory, or System.IO.Abstractions adoption; minimal Environment\u002FConsole\u002FProcess wrappers; IProcessRunner; DI registration; or an ambient seam that preserves a static API. Exclude static detection (detect-static-dependencies), migration to an existing\u002Fregistered abstraction (migrate-static-to-wrapper), one blocked behavior plus deterministic tests (testability-obstacle), and general interface design.","deadmade\u002Fdead-agent-skills","deadmade","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F130925709?v=4","01M7CTQ65AGYR4J9K9TX0YR9V3","01M7CTQ66B4VMJFEDZP4EKKE6K",0,"MIT","https:\u002F\u002Fgithub.com\u002Fdeadmade\u002Fdead-agent-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fopt-in\u002Fimplementation\u002Fcsharp-skills\u002Flibrary\u002Fgenerate-testability-wrappers\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: generate-testability-wrappers\ndescription: >\n  DO NOT USE when the target already consumes an injected interface or built-in\n  abstraction such as IFileSystem or TimeProvider, even if the request says\n  \"generate a wrapper\"; no new wrapper is needed. Use only when C# source calls\n  an ambient\u002Fstatic dependency and no injectable seam exists: first-time\n  TimeProvider, IHttpClientFactory, or System.IO.Abstractions adoption; minimal\n  Environment\u002FConsole\u002FProcess wrappers; IProcessRunner; DI registration; or an\n  ambient seam that preserves a static API. Exclude static detection\n  (detect-static-dependencies), migration to an existing\u002Fregistered abstraction\n  (migrate-static-to-wrapper), one blocked behavior plus deterministic tests\n  (testability-obstacle), and general interface design.\nlicense: MIT\n---\n\n# Generate Testability Wrappers\n\nGenerate wrapper interfaces, default implementations, and DI service registration code for untestable static dependencies. For statics that already have .NET built-in abstractions (`TimeProvider`, `IHttpClientFactory`), guide adoption of the built-in. For statics without built-in alternatives, generate custom minimal wrappers.\n\n## When to Use\n\n- After running `detect-static-dependencies` and identifying which statics to wrap\n- When the user asks to make a class testable by replacing statics with injected abstractions\n- When adopting `TimeProvider` (.NET 8+) or `System.IO.Abstractions`\n- When creating a custom wrapper for `Environment.*`, `Console.*`, or `Process.*`\n- When a released static API needs an ambient seam because signatures cannot change\n\n## When Not to Use\n\n- The user wants to find statics first (use `detect-static-dependencies`)\n- The user wants to bulk-replace call sites (use `migrate-static-to-wrapper`)\n- The static is already behind an interface\n\nIf the target already consumes an injected interface or built-in abstraction, stop:\ndo not add a second wrapper, project, registration, or test around that seam.\n\n> A missing DI package does not by itself force an ambient seam. For an\n> instantiable class, prefer constructor injection and compose it explicitly or\n> show the requested registration. Use Step 5 when the API is static and its\n> signatures must stay static, or when the user explicitly forbids caller\n> construction\u002FDI changes.\n\n## Inputs\n\n| Input | Required | Description |\n|-------|----------|-------------|\n| Static category | Yes | Which category: `time`, `filesystem`, `environment`, `network`, `console`, `process` |\n| Target framework | Yes | The `TargetFramework` from `.csproj` (affects which built-in abstractions exist) |\n| Composition | No | Existing DI framework, explicit\u002Fmanual construction, or immutable static API |\n| Namespace | No | Target namespace for generated wrapper code |\n\n## Workflow\n\n### Step 1: Determine the abstraction strategy\n\nBased on the category and target framework:\n\n| Category | .NET 8+ | .NET 6-7 | .NET Framework |\n|----------|---------|----------|----------------|\n| Time | `TimeProvider` (built-in) | `TimeProvider` via `Microsoft.Bcl.TimeProvider` NuGet | Custom `ISystemClock` |\n| File system | `System.IO.Abstractions` (NuGet) | Same | Same |\n| HTTP | `IHttpClientFactory` (built-in) | Same | Same |\n| Environment | Custom `IEnvironmentProvider` | Same | Same |\n| Console | Custom `IConsole` | Same | Same |\n| Process | Custom `IProcessRunner` | Same | Same |\n\nThe table picks *which abstraction*. How it reaches the code under test is a\nseparate axis:\n\n- instantiable class: constructor injection, even if current callers compose the\n  object manually;\n- existing container: add compile-ready registration following its conventions;\n- public static API\u002Fsignatures that cannot change: Step 5's ambient seam.\n\nCheck for a host builder, `IServiceCollection`, existing registrations, and\nconstruction sites. Do not infer \"must remain static\" merely because the project\ncurrently has no container.\n\n### Step 2: Generate built-in abstraction adoption (Time, HTTP)\n\n#### TimeProvider (.NET 8+)\n\nNo wrapper code needed. Complete all four parts: production registration,\nconstructor injection, a `FakeTimeProvider` test, and the testing package.\n\n1. Register in DI:\n```csharp\nbuilder.Services.AddSingleton(TimeProvider.System);\n```\n\n2. Inject into classes:\n```csharp\npublic class OrderProcessor(TimeProvider timeProvider)\n{\n    public bool IsExpired(Order order)\n        => timeProvider.GetUtcNow() > order.ExpiresAt;\n}\n```\n\n3. Test with `FakeTimeProvider`:\n```csharp\n\u002F\u002F Requires Microsoft.Extensions.TimeProvider.Testing NuGet\nvar fakeTime = new FakeTimeProvider(new DateTimeOffset(2026, 1, 15, 0, 0, 0, TimeSpan.Zero));\nvar processor = new OrderProcessor(fakeTime);\nfakeTime.Advance(TimeSpan.FromDays(1));\nAssert.True(processor.IsExpired(order));\n```\n\nThe assertion must prove a time-dependent result after the fake is pinned or\nadvanced. Merely constructing `FakeTimeProvider` is not a test. When the project\nhas no container but the target is an instantiable class, inject\n`TimeProvider` anyway and show explicit production construction with\n`TimeProvider.System`; do not replace it with a custom static clock.\n\nBefore calling the adoption complete, verify the repository contains or the\nanswer supplies every required artifact: the testing package reference, the\nproduction composition\u002Fregistration, every affected constructor call, and a\nrunnable fake-time test. A code fragment that omits one of those integration\npoints is guidance, not a completed adoption.\n\n#### TimeProvider (pre-.NET 8)\n\nGuide: install `Microsoft.Bcl.TimeProvider` NuGet. Same API as above.\n\n#### IHttpClientFactory\n\nNo wrapper code needed. Register a typed client via\n`builder.Services.AddHttpClient\u003CMyService>()` and inject `HttpClient` directly\ninto the class constructor. Preserve cancellation by passing the caller's token\nto the HTTP operation.\n\nFor tests, provide a complete fake `HttpMessageHandler` whose `SendAsync`\nreturns a deterministic `HttpResponseMessage`, construct `HttpClient` with that\nhandler, and exercise the typed client without network access. Compile and run\nthe focused test when the task asks for implementation; do not stop at a\nschematic handler method.\n\nWhen production uses a typed-client registration, test that same registration\npipeline: configure its primary handler in `ServiceCollection`, resolve the typed\nclient, and call it. A test that manually constructs `HttpClient` proves the class\nbut not the DI registration the task asked to adopt.\n\n### Step 3: Generate custom wrappers (Environment, Console, Process)\n\nFor categories without built-in abstractions, follow this template:\n\n#### Interface — define the minimal surface\n\nOnly include methods that were actually detected in the codebase. Do NOT generate a wrapper for every possible member — wrap only what is used.\n\nPrefer a stateless operation-shaped interface. For example, if a caller only\nneeds to start a process, wait, and return its exit code, expose one `Run`\noperation rather than a stateful wrapper that leaks `Process` lifecycle.\n\n```csharp\nnamespace \u003CNamespace>;\n\n\u002F\u002F\u002F \u003Csummary>\n\u002F\u002F\u002F Abstraction over \u003Cstatic class> for testability. \n\u002F\u002F\u002F \u003C\u002Fsummary>\npublic interface I\u003CWrapperName>\n{\n    \u002F\u002F One method per detected static call\n    \u003Creturn type> \u003CMethodName>(\u003Cparameters>);\n}\n```\n\n#### Default implementation — delegate to the real static\n\n```csharp\nnamespace \u003CNamespace>;\n\n\u002F\u002F\u002F \u003Csummary>\n\u002F\u002F\u002F Default implementation that delegates to \u003Cstatic class>.\n\u002F\u002F\u002F \u003C\u002Fsummary>\npublic sealed class \u003CWrapperName> : I\u003CWrapperName>\n{\n    public \u003Creturn type> \u003CMethodName>(\u003Cparameters>)\n        => \u003CStaticClass>.\u003CMethod>(\u003Carguments>);\n}\n```\n\n#### DI registration\n\n```csharp\n\u002F\u002F In Program.cs or Startup.cs:\nbuilder.Services.AddSingleton\u003CI\u003CWrapperName>, \u003CWrapperName>>();\n```\n\nTreat registration as a deliverable, not a sentence in the summary. Add it to\nthe repository's existing registration surface when one exists. Otherwise show\nthe exact compile-ready statement and identify where the caller should place\nit. Stateless delegating wrappers are singleton; if state must be retained,\nexplain why a shorter lifetime is required.\n\n### Step 4: Generate file system wrapper adoption\n\nPrefer the established `System.IO.Abstractions` NuGet package over custom wrappers:\n\n1. Install the package:\n```\ndotnet add package System.IO.Abstractions\n```\n\n2. Register in DI:\n```csharp\nbuilder.Services.AddSingleton\u003CIFileSystem, FileSystem>();\n```\n\n3. Inject `IFileSystem` into classes:\n```csharp\npublic class ConfigLoader(IFileSystem fileSystem)\n{\n    public string LoadConfig(string path)\n        => fileSystem.File.ReadAllText(path);\n}\n```\n\n4. Test with `MockFileSystem`:\n```\ndotnet add \u003CTestProject> package System.IO.Abstractions.TestingHelpers\n```\n```csharp\nvar mockFs = new MockFileSystem(new Dictionary\u003Cstring, MockFileData>\n{\n    { \"\u002Fconfig.json\", new MockFileData(\"{\\\"key\\\": \\\"value\\\"}\") }\n});\nvar loader = new ConfigLoader(mockFs);\nAssert.Equal(\"{\\\"key\\\": \\\"value\\\"}\", loader.LoadConfig(\"\u002Fconfig.json\"));\n```\n\nPackage-first adoption is exclusive: add both package references, use\n`IFileSystem` in production, register or explicitly compose `FileSystem`, and\nseed `MockFileSystem` before exercising the consumer. Do not also generate a\nsecond custom filesystem interface, and do not present an unseeded mock whose\ntest could pass without proving the requested read\u002Fwrite behavior.\n\n### Step 5: Generate a signature-preserving ambient context\n\nUse this pattern when the API must remain static or its released signatures\ncannot accept a dependency:\n\n```csharp\npublic static class Clock\n{\n    private static readonly AsyncLocal\u003CFunc\u003CDateTime>?> s_override = new();\n    public static DateTime UtcNow\n        => s_override.Value?.Invoke() ?? TimeProvider.System.GetUtcNow().UtcDateTime;\n\n    internal static IDisposable Override(DateTime fixedUtcTime)\n    {\n        if (fixedUtcTime.Kind != DateTimeKind.Utc)\n            throw new ArgumentException(\"The override must be UTC.\", nameof(fixedUtcTime));\n\n        var previous = s_override.Value;\n        s_override.Value = () => fixedUtcTime;\n        return new Scope(previous);\n    }\n    private sealed class Scope : IDisposable\n    {\n        private readonly Func\u003CDateTime>? _previous;\n        private bool _disposed;\n\n        public Scope(Func\u003CDateTime>? previous)\n        {\n            _previous = previous;\n        }\n\n        public void Dispose()\n        {\n            if (_disposed)\n                return;\n\n            s_override.Value = _previous;\n            _disposed = true;\n        }\n    }\n}\n```\n\nKey trade-offs: `AsyncLocal\u003CT>` ensures parallel tests don't interfere; production cost is one null check per call; the `static readonly` field is essentially free.\n\nThree properties this pattern must keep, because each has broken a real migration:\n\n- **Scope the override and make it reversible.** Return an `IDisposable` that restores the previous value, so a test cannot leak a pinned time into the next one. A bare setter, or a manual `try`\u002F`finally` at each call site, puts that burden on every test author.\n- **Use `AsyncLocal\u003CT>`, never `[ThreadStatic]`.** `[ThreadStatic]` does not flow across `await`, so the override silently disappears mid-test.\n- **Preserve the semantics of the member you are replacing.** Substituting `DateTime.UtcNow` with a local-time source changes the `DateTimeKind` every existing caller and stored value depends on — pair `UtcNow` with `GetUtcNow()`, and `Now` with `GetLocalNow()`.\n- **Prove the test assembly can reach the override.** An `internal` override is\n  inaccessible from a separate test assembly unless the production project adds\n  the exact `InternalsVisibleTo` for that test assembly. Otherwise use an\n  already-public seam only when a public API change is authorized. Never show a\n  test calling an inaccessible member.\n\nThe same shape works for non-time statics: swap `TimeProvider.System.GetUtcNow()` for the real static call and keep the override slot, the disposable scope, and the original semantics.\n\n### Step 6: Place generated files\n\nGenerate files following the project's existing conventions:\n- If there is an `Abstractions\u002F` or `Interfaces\u002F` folder, place the interface there\n- If there is an `Infrastructure\u002F` or `Services\u002F` folder, place the implementation there\n- Otherwise, create files next to the code that uses the static\n\nAlways generate:\n1. The interface file (or adoption instructions for built-in abstractions)\n2. The default implementation file\n3. The compile-ready DI registration, applied to an existing registration\n   surface or shown at the exact composition point.\n4. A deterministic substitution example or focused test that exercises the\n   consumer without the ambient resource.\n\nSkip registration entirely on the ambient-seam path: there is no container to\nregister into, and offering one anyway is the failure mode that made a user ask\nfor the seam in the first place.\n\nBefore reporting completion, verify the delivered output contains every item\nthe prompt requested. In particular, do not summarize \"singleton registration\"\nwhen no registration code was added or shown, and do not claim testability\nwithout demonstrating how the consumer receives a fake.\nFor console wrappers, exercise the consumer with a fake that both captures the\nprompt and supplies the returned input; a build or banner-only run does not prove\nthe prompt flow.\n\n## Validation\n\n- [ ] Generated interface only wraps statics that were actually detected (not speculative)\n- [ ] Default implementation delegates to the real static with no behavior changes\n- [ ] DI registration uses `AddSingleton` for stateless wrappers, `AddTransient` for stateful ones\n- [ ] NuGet packages are recommended where established libraries exist (System.IO.Abstractions, etc.)\n- [ ] For .NET 8+, `TimeProvider` is recommended over custom `ISystemClock`\n- [ ] TimeProvider adoption includes injection, production composition,\n      `FakeTimeProvider`, its testing package, and an assertion on a\n      time-dependent result\n- [ ] HTTP adoption includes a complete fake-handler test and preserves\n      cancellation\n- [ ] On injection paths, registration or explicit composition is compile-ready,\n      and a fake demonstrates the consumer without the real ambient dependency\n- [ ] Ambient context pattern includes `AsyncLocal\u003CT>`, a scoped `IDisposable` that restores the previous value, and trade-off explanation\n- [ ] On the ambient-seam path, no `IServiceCollection` registration is proposed, the separate test assembly can reach the override, and the replaced member's return type and semantics (`UtcNow` vs `Now`, and its `DateTimeKind`) are preserved\n\n## Common Pitfalls\n\n| Pitfall | Solution |\n|---------|----------|\n| Treating \"no DI package\" as \"must be ambient\" | Inject into instantiable classes and compose explicitly; reserve Step 5 for static\u002Fsignature-preserving APIs |\n| Wrapping ALL members of a static class | Only wrap methods actually called in the codebase |\n| Custom time wrapper on .NET 8+ | Use built-in `TimeProvider` instead |\n| Custom file system wrapper | Prefer `System.IO.Abstractions` NuGet — battle-tested, complete |\n| Registering scoped when singleton suffices | Stateless wrappers should be `AddSingleton` |\n| Forgetting test helper packages | `Microsoft.Extensions.TimeProvider.Testing` for time, `System.IO.Abstractions.TestingHelpers` for filesystem |\n| Ambient context without `AsyncLocal` | Non-async `[ThreadStatic]` breaks with `async`\u002F`await` — always use `AsyncLocal\u003CT>` |\n| Showing an internal ambient override to external tests | Add the exact friend assembly or use an authorized public seam; compile the test project |\n","# Generate Testability Wrappers\n\nGenerate wrapper interfaces, default implementations, and DI service registration code for untestable static dependencies. For statics that already have .NET built-in abstractions (`TimeProvider`, `IHttpClientFactory`), guide adoption of the built-in. For statics without built-in alternatives, generate custom minimal wrappers.\n\n## When to Use\n\n- After running `detect-static-dependencies` and identifying which statics to wrap\n- When the user asks to make a class testable by replacing statics with injected abstractions\n- When adopting `TimeProvider` (.NET 8+) or `System.IO.Abstractions`\n- When creating a custom wrapper for `Environment.*`, `Console.*`, or `Process.*`\n- When a released static API needs an ambient seam because signatures cannot change\n\n## When Not to Use\n\n- The user wants to find statics first (use `detect-static-dependencies`)\n- The user wants to bulk-replace call sites (use `migrate-static-to-wrapper`)\n- The static is already behind an interface\n\nIf the target already consumes an injected interface or built-in abstraction, stop:\ndo not add a second wrapper, project, registration, or test around that seam.\n\n> A missing DI package does not by itself force an ambient seam. For an\n> instantiable class, prefer constructor injection and compose it explicitly or\n> show the requested registration. Use Step 5 when the API is static and its\n> signatures must stay static, or when the user explicitly forbids caller\n> construction\u002FDI changes.\n\n## Inputs\n\n| Input | Required | Description |\n|-------|----------|-------------|\n| Static category | Yes | Which category: `time`, `filesystem`, `environment`, `network`, `console`, `process` |\n| Target framework | Yes | The `TargetFramework` from `.csproj` (affects which built-in abstractions exist) |\n| Composition | No | Existing DI framework, explicit\u002Fmanual construction, or immutable static API |\n| Namespace | No | Target namespace for generated wrapper code |\n\n## Workflow\n\n### Step 1: Determine the abstraction strategy\n\nBased on the category and target framework:\n\n| Category | .NET 8+ | .NET 6-7 | .NET Framework |\n|----------|---------|----------|----------------|\n| Time | `TimeProvider` (built-in) | `TimeProvider` via `Microsoft.Bcl.TimeProvider` NuGet | Custom `ISystemClock` |\n| File system | `System.IO.Abstractions` (NuGet) | Same | Same |\n| HTTP | `IHttpClientFactory` (built-in) | Same | Same |\n| Environment | Custom `IEnvironmentProvider` | Same | Same |\n| Console | Custom `IConsole` | Same | Same |\n| Process | Custom `IProcessRunner` | Same | Same |\n\nThe table picks *which abstraction*. How it reaches the code under test is a\nseparate axis:\n\n- instantiable class: constructor injection, even if current callers compose the\n  object manually;\n- existing container: add compile-ready registration following its conventions;\n- public static API\u002Fsignatures that cannot change: Step 5's ambient seam.\n\nCheck for a host builder, `IServiceCollection`, existing registrations, and\nconstruction sites. Do not infer \"must remain static\" merely because the project\ncurrently has no container.\n\n### Step 2: Generate built-in abstraction adoption (Time, HTTP)\n\n#### TimeProvider (.NET 8+)\n\nNo wrapper code needed. Complete all four parts: production registration,\nconstructor injection, a `FakeTimeProvider` test, and the testing package.\n\n1. Register in DI:\n```csharp\nbuilder.Services.AddSingleton(TimeProvider.System);\n```\n\n2. Inject into classes:\n```csharp\npublic class OrderProcessor(TimeProvider timeProvider)\n{\n    public bool IsExpired(Order order)\n        => timeProvider.GetUtcNow() > order.ExpiresAt;\n}\n```\n\n3. Test with `FakeTimeProvider`:\n```csharp\n\u002F\u002F Requires Microsoft.Extensions.TimeProvider.Testing NuGet\nvar fakeTime = new FakeTimeProvider(new DateTimeOffset(2026, 1, 15, 0, 0, 0, TimeSpan.Zero));\nvar processor = new OrderProcessor(fakeTime);\nfakeTime.Advance(TimeSpan.FromDays(1));\nAssert.True(processor.IsExpired(order));\n```\n\nThe assertion must prove a time-dependent result after the fake is pinned or\nadvanced. Merely constructing `FakeTimeProvider` is not a test. When the project\nhas no container but the target is an instantiable class, inject\n`TimeProvider` anyway and show explicit production construction with\n`TimeProvider.System`; do not replace it with a custom static clock.\n\nBefore calling the adoption complete, verify the repository contains or the\nanswer supplies every required artifact: the testing package reference, the\nproduction composition\u002Fregistration, every affected constructor call, and a\nrunnable fake-time test. A code fragment that omits one of those integration\npoints is guidance, not a completed adoption.\n\n#### TimeProvider (pre-.NET 8)\n\nGuide: install `Microsoft.Bcl.TimeProvider` NuGet. Same API as above.\n\n#### IHttpClientFactory\n\nNo wrapper code needed. Register a typed client via\n`builder.Services.AddHttpClient\u003CMyService>()` and inject `HttpClient` directly\ninto the class constructor. Preserve cancellation by passing the caller's token\nto the HTTP operation.\n\nFor tests, provide a complete fake `HttpMessageHandler` whose `SendAsync`\nreturns a deterministic `HttpResponseMessage`, construct `HttpClient` with that\nhandler, and exercise the typed client without network access. Compile and run\nthe focused test when the task asks for implementation; do not stop at a\nschematic handler method.\n\nWhen production uses a typed-client registration, test that same registration\npipeline: configure its primary handler in `ServiceCollection`, resolve the typed\nclient, and call it. A test that manually constructs `HttpClient` proves the class\nbut not the DI registration the task asked to adopt.\n\n### Step 3: Generate custom wrappers (Environment, Console, Process)\n\nFor categories without built-in abstractions, follow this template:\n\n#### Interface — define the minimal surface\n\nOnly include methods that were actually detected in the codebase. Do NOT generate a wrapper for every possible member — wrap only what is used.\n\nPrefer a stateless operation-shaped interface. For example, if a caller only\nneeds to start a process, wait, and return its exit code, expose one `Run`\noperation rather than a stateful wrapper that leaks `Process` lifecycle.\n\n```csharp\nnamespace \u003CNamespace>;\n\n\u002F\u002F\u002F \u003Csummary>\n\u002F\u002F\u002F Abstraction over \u003Cstatic class> for testability. \n\u002F\u002F\u002F \u003C\u002Fsummary>\npublic interface I\u003CWrapperName>\n{\n    \u002F\u002F One method per detected static call\n    \u003Creturn type> \u003CMethodName>(\u003Cparameters>);\n}\n```\n\n#### Default implementation — delegate to the real static\n\n```csharp\nnamespace \u003CNamespace>;\n\n\u002F\u002F\u002F \u003Csummary>\n\u002F\u002F\u002F Default implementation that delegates to \u003Cstatic class>.\n\u002F\u002F\u002F \u003C\u002Fsummary>\npublic sealed class \u003CWrapperName> : I\u003CWrapperName>\n{\n    public \u003Creturn type> \u003CMethodName>(\u003Cparameters>)\n        => \u003CStaticClass>.\u003CMethod>(\u003Carguments>);\n}\n```\n\n#### DI registration\n\n```csharp\n\u002F\u002F In Program.cs or Startup.cs:\nbuilder.Services.AddSingleton\u003CI\u003CWrapperName>, \u003CWrapperName>>();\n```\n\nTreat registration as a deliverable, not a sentence in the summary. Add it to\nthe repository's existing registration surface when one exists. Otherwise show\nthe exact compile-ready statement and identify where the caller should place\nit. Stateless delegating wrappers are singleton; if state must be retained,\nexplain why a shorter lifetime is required.\n\n### Step 4: Generate file system wrapper adoption\n\nPrefer the established `System.IO.Abstractions` NuGet package over custom wrappers:\n\n1. Install the package:\n```\ndotnet add package System.IO.Abstractions\n```\n\n2. Register in DI:\n```csharp\nbuilder.Services.AddSingleton\u003CIFileSystem, FileSystem>();\n```\n\n3. Inject `IFileSystem` into classes:\n```csharp\npublic class ConfigLoader(IFileSystem fileSystem)\n{\n    public string LoadConfig(string path)\n        => fileSystem.File.ReadAllText(path);\n}\n```\n\n4. Test with `MockFileSystem`:\n```\ndotnet add \u003CTestProject> package System.IO.Abstractions.TestingHelpers\n```\n```csharp\nvar mockFs = new MockFileSystem(new Dictionary\u003Cstring, MockFileData>\n{\n    { \"\u002Fconfig.json\", new MockFileData(\"{\\\"key\\\": \\\"value\\\"}\") }\n});\nvar loader = new ConfigLoader(mockFs);\nAssert.Equal(\"{\\\"key\\\": \\\"value\\\"}\", loader.LoadConfig(\"\u002Fconfig.json\"));\n```\n\nPackage-first adoption is exclusive: add both package references, use\n`IFileSystem` in production, register or explicitly compose `FileSystem`, and\nseed `MockFileSystem` before exercising the consumer. Do not also generate a\nsecond custom filesystem interface, and do not present an unseeded mock whose\ntest could pass without proving the requested read\u002Fwrite behavior.\n\n### Step 5: Generate a signature-preserving ambient context\n\nUse this pattern when the API must remain static or its released signatures\ncannot accept a dependency:\n\n```csharp\npublic static class Clock\n{\n    private static readonly AsyncLocal\u003CFunc\u003CDateTime>?> s_override = new();\n    public static DateTime UtcNow\n        => s_override.Value?.Invoke() ?? TimeProvider.System.GetUtcNow().UtcDateTime;\n\n    internal static IDisposable Override(DateTime fixedUtcTime)\n    {\n        if (fixedUtcTime.Kind != DateTimeKind.Utc)\n            throw new ArgumentException(\"The override must be UTC.\", nameof(fixedUtcTime));\n\n        var previous = s_override.Value;\n        s_override.Value = () => fixedUtcTime;\n        return new Scope(previous);\n    }\n    private sealed class Scope : IDisposable\n    {\n        private readonly Func\u003CDateTime>? _previous;\n        private bool _disposed;\n\n        public Scope(Func\u003CDateTime>? previous)\n        {\n            _previous = previous;\n        }\n\n        public void Dispose()\n        {\n            if (_disposed)\n                return;\n\n            s_override.Value = _previous;\n            _disposed = true;\n        }\n    }\n}\n```\n\nKey trade-offs: `AsyncLocal\u003CT>` ensures parallel tests don't interfere; production cost is one null check per call; the `static readonly` field is essentially free.\n\nThree properties this pattern must keep, because each has broken a real migration:\n\n- **Scope the override and make it reversible.** Return an `IDisposable` that restores the previous value, so a test cannot leak a pinned time into the next one. A bare setter, or a manual `try`\u002F`finally` at each call site, puts that burden on every test author.\n- **Use `AsyncLocal\u003CT>`, never `[ThreadStatic]`.** `[ThreadStatic]` does not flow across `await`, so the override silently disappears mid-test.\n- **Preserve the semantics of the member you are replacing.** Substituting `DateTime.UtcNow` with a local-time source changes the `DateTimeKind` every existing caller and stored value depends on — pair `UtcNow` with `GetUtcNow()`, and `Now` with `GetLocalNow()`.\n- **Prove the test assembly can reach the override.** An `internal` override is\n  inaccessible from a separate test assembly unless the production project adds\n  the exact `InternalsVisibleTo` for that test assembly. Otherwise use an\n  already-public seam only when a public API change is authorized. Never show a\n  test calling an inaccessible member.\n\nThe same shape works for non-time statics: swap `TimeProvider.System.GetUtcNow()` for the real static call and keep the override slot, the disposable scope, and the original semantics.\n\n### Step 6: Place generated files\n\nGenerate files following the project's existing conventions:\n- If there is an `Abstractions\u002F` or `Interfaces\u002F` folder, place the interface there\n- If there is an `Infrastructure\u002F` or `Services\u002F` folder, place the implementation there\n- Otherwise, create files next to the code that uses the static\n\nAlways generate:\n1. The interface file (or adoption instructions for built-in abstractions)\n2. The default implementation file\n3. The compile-ready DI registration, applied to an existing registration\n   surface or shown at the exact composition point.\n4. A deterministic substitution example or focused test that exercises the\n   consumer without the ambient resource.\n\nSkip registration entirely on the ambient-seam path: there is no container to\nregister into, and offering one anyway is the failure mode that made a user ask\nfor the seam in the first place.\n\nBefore reporting completion, verify the delivered output contains every item\nthe prompt requested. In particular, do not summarize \"singleton registration\"\nwhen no registration code was added or shown, and do not claim testability\nwithout demonstrating how the consumer receives a fake.\nFor console wrappers, exercise the consumer with a fake that both captures the\nprompt and supplies the returned input; a build or banner-only run does not prove\nthe prompt flow.\n\n## Validation\n\n- [ ] Generated interface only wraps statics that were actually detected (not speculative)\n- [ ] Default implementation delegates to the real static with no behavior changes\n- [ ] DI registration uses `AddSingleton` for stateless wrappers, `AddTransient` for stateful ones\n- [ ] NuGet packages are recommended where established libraries exist (System.IO.Abstractions, etc.)\n- [ ] For .NET 8+, `TimeProvider` is recommended over custom `ISystemClock`\n- [ ] TimeProvider adoption includes injection, production composition,\n      `FakeTimeProvider`, its testing package, and an assertion on a\n      time-dependent result\n- [ ] HTTP adoption includes a complete fake-handler test and preserves\n      cancellation\n- [ ] On injection paths, registration or explicit composition is compile-ready,\n      and a fake demonstrates the consumer without the real ambient dependency\n- [ ] Ambient context pattern includes `AsyncLocal\u003CT>`, a scoped `IDisposable` that restores the previous value, and trade-off explanation\n- [ ] On the ambient-seam path, no `IServiceCollection` registration is proposed, the separate test assembly can reach the override, and the replaced member's return type and semantics (`UtcNow` vs `Now`, and its `DateTimeKind`) are preserved\n\n## Common Pitfalls\n\n| Pitfall | Solution |\n|---------|----------|\n| Treating \"no DI package\" as \"must be ambient\" | Inject into instantiable classes and compose explicitly; reserve Step 5 for static\u002Fsignature-preserving APIs |\n| Wrapping ALL members of a static class | Only wrap methods actually called in the codebase |\n| Custom time wrapper on .NET 8+ | Use built-in `TimeProvider` instead |\n| Custom file system wrapper | Prefer `System.IO.Abstractions` NuGet — battle-tested, complete |\n| Registering scoped when singleton suffices | Stateless wrappers should be `AddSingleton` |\n| Forgetting test helper packages | `Microsoft.Extensions.TimeProvider.Testing` for time, `System.IO.Abstractions.TestingHelpers` for filesystem |\n| Ambient context without `AsyncLocal` | Non-async `[ThreadStatic]` breaks with `async`\u002F`await` — always use `AsyncLocal\u003CT>` |\n| Showing an internal ambient override to external tests | Add the exact friend assembly or use an authorized public seam; compile the test project |\n",{"name":5,"license":14,"description":23},"DO NOT USE when the target already consumes an injected interface or built-in abstraction such as IFileSystem or TimeProvider, even if the request says \"generate a wrapper\"; no new wrapper is needed. Use only when C# source calls an ambient\u002Fstatic dependency and no injectable seam exists: first-time TimeProvider, IHttpClientFactory, or System.IO.Abstractions adoption; minimal Environment\u002FConsole\u002FProcess wrappers; IProcessRunner; DI registration; or an ambient seam that preserves a static API. Exclude static detection (detect-static-dependencies), migration to an existing\u002Fregistered abstraction (migrate-static-to-wrapper), one blocked behavior plus deterministic tests (testability-obstacle), and general interface design.\n","main","ccab8dffc0ecc173838f51e4c5f0d3b51a704f41","plugins\u002Fopt-in\u002Fimplementation\u002Fcsharp-skills\u002Flibrary\u002Fgenerate-testability-wrappers","https:\u002F\u002Fgithub.com\u002Fdeadmade\u002Fdead-agent-skills","https:\u002F\u002Fgithub.com\u002Fdeadmade","https:\u002F\u002Fdeadmade.github.io\u002F","Blood, an Ocean of blood","2026-11-14 02:03:31",{"source":8,"skillName":5,"commands":33,"prompt":43,"zipAvailable":44},[34,37,40],{"tool":35,"command":36},"npx","npx skills add deadmade\u002Fdead-agent-skills --skill generate-testability-wrappers",{"tool":38,"command":39},"bunx","bunx skills add deadmade\u002Fdead-agent-skills --skill generate-testability-wrappers",{"tool":41,"command":42},"pnpm","pnpm dlx skills add deadmade\u002Fdead-agent-skills --skill generate-testability-wrappers","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fdeadmade\u002Fdead-agent-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fopt-in\u002Fimplementation\u002Fcsharp-skills\u002Flibrary\u002Fgenerate-testability-wrappers\u002FSKILL.md",true,[],[47,54,63,71,78,85],{"skillNo":48,"name":49,"nameZh":6,"description":50,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":51,"categories":52,"keywords":53,"publishedAt":18},"01M7CVRBFTXSTTQ7F5P6PJEFYA","rust-best-practices","Guide for writing idiomatic Rust code based on Apollo GraphQL's best practices handbook. Use this skill when: (1) writing new Rust code or functions, (2) reviewing or refactoring existing Rust code, (3) deciding between borrowing vs cloning or ownership patterns, (4) implementing error handling with Result types, (5) optimizing Rust code for performance, (6) writing tests or documentation for Rust projects.","https:\u002F\u002Fgithub.com\u002Fdeadmade\u002Fdead-agent-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fopt-in\u002Fimplementation\u002Frust-skills\u002Fskills\u002Frust-best-practices\u002FSKILL.md",[],[],{"skillNo":55,"name":56,"nameZh":6,"description":57,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":58,"licenseFileUrl":59,"sourceHtmlUrl":60,"categories":61,"keywords":62,"publishedAt":18},"01M7CVR0W7B8EGTNPSPA7FPC4Z","postgres-database-migration","Use this skill for planning, testing, and safely executing PostgreSQL schema migrations — especially when working with production data or shared databases.\n\n**Trigger when user asks to:**\n- Test a schema migration before applying it to production\n- Add, remove, or rename columns safely on a live table\n- Change a column's data type without downtime\n- Add or drop indexes, constraints, or foreign keys on large tables\n- Understand which ALTER TABLE operations lock the table\n- Roll back a failed migration\n- Plan a zero-downtime migration strategy\n- Fork a database to test a migration safely\n\nCovers: lock-level reference for every common DDL operation, safe migration patterns, fork-based testing, zero-downtime column changes, index creation, constraint addition, backfill strategies, pre\u002Fpost-migration validation, and rollback planning.","Apache-2.0","https:\u002F\u002Fgithub.com\u002Fdeadmade\u002Fdead-agent-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fopt-in\u002Fimplementation\u002Fpostgres\u002Fskills\u002Fpostgres-database-migration\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fdeadmade\u002Fdead-agent-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fopt-in\u002Fimplementation\u002Fpostgres\u002Fskills\u002Fpostgres-database-migration\u002FSKILL.md",[],[],{"skillNo":64,"name":65,"nameZh":6,"description":66,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":58,"licenseFileUrl":67,"sourceHtmlUrl":68,"categories":69,"keywords":70,"publishedAt":18},"01M7CVQWK20ASAZN5VETZC8J99","postgres-best-practices","Best practices and guidelines for working with Postgres. Covers schema design, indexing strategies, query optimization, migrations, and common pitfalls. Use when writing SQL, designing database schemas, optimizing queries, or setting up a Postgres database.","https:\u002F\u002Fgithub.com\u002Fdeadmade\u002Fdead-agent-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fopt-in\u002Fimplementation\u002Fpostgres\u002Fskills\u002Fpostgres-best-practices\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fdeadmade\u002Fdead-agent-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fopt-in\u002Fimplementation\u002Fpostgres\u002Fskills\u002Fpostgres-best-practices\u002FSKILL.md",[],[],{"skillNo":72,"name":73,"nameZh":6,"description":74,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":75,"categories":76,"keywords":77,"publishedAt":18},"01M7CVQ5CY7AQHY7A2Y99RE6A7","writing-mstest-tests","ALWAYS 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\u002Fdeadmade\u002Fdead-agent-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fopt-in\u002Fimplementation\u002Fcsharp-skills\u002Flibrary\u002Fwriting-mstest-tests\u002FSKILL.md",[],[],{"skillNo":79,"name":80,"nameZh":6,"description":81,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":82,"categories":83,"keywords":84,"publishedAt":18},"01M7CVPWJZ63GB0810F0SCGZ1K","winforms-expert","Create, modify, debug, or review Windows Forms applications only when the request contains a concrete Windows Forms marker. USE FOR: WinForms, Windows Forms, System.Windows.Forms, WinForms Form or UserControl designer files (*.Designer.cs or *.Designer.vb), Visual Studio WinForms Designer, TableLayoutPanel, BindingSource, DataGridView, Control.InvokeAsync, component-tray ownership, or custom control serialization. DO NOT USE FOR: WPF or WPF XAML, including Window.InputBindings, KeyBinding, commands, or DataContext; .NET MAUI; Avalonia; or any request where none of the listed Windows Forms markers is present.","https:\u002F\u002Fgithub.com\u002Fdeadmade\u002Fdead-agent-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fopt-in\u002Fimplementation\u002Fcsharp-skills\u002Flibrary\u002Fwinforms-expert\u002FSKILL.md",[],[],{"skillNo":86,"name":87,"nameZh":6,"description":88,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":89,"categories":90,"keywords":91,"publishedAt":18},"01M7CVPR0QFZ1HMJ6GZRBQAQ7W","vectorization","Design, implement, optimize, and review SIMD code in .NET. USE FOR: vectorizing scalar loops with TensorPrimitives, Vector64\u002F128\u002F256\u002F512, or platform hardware intrinsics; reviewing existing SIMD code, including the generic Vector type, for contract equivalence, tail handling, memory safety, portability, fallbacks, and measured performance. DO NOT USE FOR: performance work unrelated to SIMD or vectorization.","https:\u002F\u002Fgithub.com\u002Fdeadmade\u002Fdead-agent-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fopt-in\u002Fimplementation\u002Fcsharp-skills\u002Flibrary\u002Fvectorization\u002FSKILL.md",[],[]]