[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M79Y5KAF5MJM6HJRY8PS27XD":3,"skill-same:01M79Y5KAF5MJM6HJRY8PS27XD":48},{"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":26,"commitSha":27,"skillDirectory":28,"forksCount":29,"repositoryHtmlUrl":30,"repositoryHomepageUrl":6,"ownerHtmlUrl":31,"ownerBlogUrl":32,"ownerDescription":33,"updatedAt":34,"install":35,"resources":47},"01M79Y5KAF5MJM6HJRY8PS27XD","generate-testability-wrappers",null,"Generate C# testability wrappers and their DI registration. 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. 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. Exclude static detection (detect-static-dependencies), migration to an existing\u002Fregistered abstraction (after wrapper creation, the user invokes \u002Fdeniz-dotnet-general:migrate-static-to-wrapper separately), behavior-test requests whose seam is still open, and general interface design.","Blind-Striker\u002Fagent-skills-and-plugins","Blind-Striker","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F1965259?v=4","01M79WFXTE5PH0C1VB7B54ANMN","Deniz İrgin","01M79WFXV5KZ5GST1K8G035DM5",1,"MIT","https:\u002F\u002Fgithub.com\u002FBlind-Striker\u002Fagent-skills-and-plugins\u002Fblob\u002Fmaster\u002Fplugins\u002Fdeniz-dotnet-general\u002Fskills\u002Fgenerate-testability-wrappers\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: generate-testability-wrappers\ndescription: >\n  Generate C# testability wrappers and their DI registration. Use only when C#\n  source calls an ambient\u002Fstatic dependency and no injectable seam exists:\n  first-time TimeProvider, IHttpClientFactory, or System.IO.Abstractions\n  adoption; minimal Environment\u002FConsole\u002FProcess wrappers; IProcessRunner; DI\n  registration; or an ambient seam that preserves a static API. DO NOT USE when\n  the target already consumes an injected interface or built-in abstraction such\n  as IFileSystem or TimeProvider, even if the request says \"generate a wrapper\";\n  no new wrapper is needed. Exclude static detection\n  (detect-static-dependencies), migration to an existing\u002Fregistered abstraction\n  (after wrapper creation, the user invokes\n  \u002Fdeniz-dotnet-general:migrate-static-to-wrapper separately), behavior-test requests\n  whose seam is still open, and general interface design.\nlicense: MIT\ndisable-model-invocation: true\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 (after wrapper creation, the user\n  invokes `\u002Fdeniz-dotnet-general:migrate-static-to-wrapper` separately)\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\nAn existing manual factory passes the real dependency explicitly (for example,\n`new ExpirationPolicy(TimeProvider.System)`). Do not move that responsibility into\nan optional constructor parameter or add an optional provider parameter to the\nfactory.\n\nConstructor injection through a public constructor is the default. Only when all\nthree hold, take the narrower branch: the type is released public API, the user\nhas not authorized an API change, and the exact test assembly is known. Then keep\nthe public parameterless constructor as the real-dependency default, make the\ninjecting constructor `internal`, and add `InternalsVisibleTo` for that one\ntest assembly, or follow an existing friend-assembly convention. Outside that\nbranch, add no `InternalsVisibleTo`.\n\nWrite every generated test in the test project's existing framework,\nglobal-using, and assertion conventions, with the framework packages it already\nreferences; the examples in this skill use xUnit-style assertions. Never add a\nhand-rolled `FactAttribute`, a substitute test-framework type, or unrelated\ntest-project plumbing to make a test compile.\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(() => s_override.Value = previous);\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() =>\n            Interlocked.Exchange(ref _restore, null)?.Invoke();\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\nStore the provider or value itself in `AsyncLocal\u003CT>`. Do not put a mutable\nstack, list, or other shared collection in the slot: child execution contexts\ncan inherit the same object and corrupt each other's nesting. When the provider\nis mutable, create a fresh provider inside each parallel flow rather than\nmutating one inherited from a parent context.\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\nTest nested restoration across exception unwinding. Observe the outer value\nafter the exception leaves the inner `using` scope but before disposing the\nouter scope:\n\n```csharp\nvar outerTime = new DateTime(2026, 1, 1, 0, 0, 0, DateTimeKind.Utc);\nvar innerTime = outerTime.AddDays(1);\nusing var outer = Clock.Override(outerTime);\n\nAssert.Equal(outerTime, Clock.UtcNow);\nAssert.Throws\u003CInvalidOperationException>(() =>\n{\n    using var inner = Clock.Override(innerTime);\n    Assert.Equal(innerTime, Clock.UtcNow);\n    throw new InvalidOperationException(\"test\");\n});\nAssert.Equal(outerTime, Clock.UtcNow);\n```\n\nAlso overlap two async flows that each establish a fresh override and assert\nthat each sees only its own value. The nested test catches an inner dispose that\nclears the slot; the parallel test catches cross-flow leakage.\n\nOn .NET 8+, do not wrap delays. The BCL already accepts a `TimeProvider`:\n\n| Ambient operation | Replacement |\n|-------------------|-------------|\n| `Task.Delay(delay, token)` | `Task.Delay(delay, timeProvider, token)` |\n| `new CancellationTokenSource(delay)` | `new CancellationTokenSource(delay, timeProvider)` |\n| `PeriodicTimer(period)` | `new PeriodicTimer(period, timeProvider)` when the target framework provides it |\n\nTest delayed behavior by starting the operation and proving it is incomplete\nbefore advancing `FakeTimeProvider`. For a deadline, advance to immediately\nbefore the boundary and assert that the task is still incomplete before\nadvancing across it. Never wait for wall-clock time.\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- [ ] Nested exception unwinding restores the outer override and overlapping async flows remain isolated\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 (after wrapper creation, the user\n  invokes `\u002Fdeniz-dotnet-general:migrate-static-to-wrapper` separately)\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\nAn existing manual factory passes the real dependency explicitly (for example,\n`new ExpirationPolicy(TimeProvider.System)`). Do not move that responsibility into\nan optional constructor parameter or add an optional provider parameter to the\nfactory.\n\nConstructor injection through a public constructor is the default. Only when all\nthree hold, take the narrower branch: the type is released public API, the user\nhas not authorized an API change, and the exact test assembly is known. Then keep\nthe public parameterless constructor as the real-dependency default, make the\ninjecting constructor `internal`, and add `InternalsVisibleTo` for that one\ntest assembly, or follow an existing friend-assembly convention. Outside that\nbranch, add no `InternalsVisibleTo`.\n\nWrite every generated test in the test project's existing framework,\nglobal-using, and assertion conventions, with the framework packages it already\nreferences; the examples in this skill use xUnit-style assertions. Never add a\nhand-rolled `FactAttribute`, a substitute test-framework type, or unrelated\ntest-project plumbing to make a test compile.\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(() => s_override.Value = previous);\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() =>\n            Interlocked.Exchange(ref _restore, null)?.Invoke();\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\nStore the provider or value itself in `AsyncLocal\u003CT>`. Do not put a mutable\nstack, list, or other shared collection in the slot: child execution contexts\ncan inherit the same object and corrupt each other's nesting. When the provider\nis mutable, create a fresh provider inside each parallel flow rather than\nmutating one inherited from a parent context.\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\nTest nested restoration across exception unwinding. Observe the outer value\nafter the exception leaves the inner `using` scope but before disposing the\nouter scope:\n\n```csharp\nvar outerTime = new DateTime(2026, 1, 1, 0, 0, 0, DateTimeKind.Utc);\nvar innerTime = outerTime.AddDays(1);\nusing var outer = Clock.Override(outerTime);\n\nAssert.Equal(outerTime, Clock.UtcNow);\nAssert.Throws\u003CInvalidOperationException>(() =>\n{\n    using var inner = Clock.Override(innerTime);\n    Assert.Equal(innerTime, Clock.UtcNow);\n    throw new InvalidOperationException(\"test\");\n});\nAssert.Equal(outerTime, Clock.UtcNow);\n```\n\nAlso overlap two async flows that each establish a fresh override and assert\nthat each sees only its own value. The nested test catches an inner dispose that\nclears the slot; the parallel test catches cross-flow leakage.\n\nOn .NET 8+, do not wrap delays. The BCL already accepts a `TimeProvider`:\n\n| Ambient operation | Replacement |\n|-------------------|-------------|\n| `Task.Delay(delay, token)` | `Task.Delay(delay, timeProvider, token)` |\n| `new CancellationTokenSource(delay)` | `new CancellationTokenSource(delay, timeProvider)` |\n| `PeriodicTimer(period)` | `new PeriodicTimer(period, timeProvider)` when the target framework provides it |\n\nTest delayed behavior by starting the operation and proving it is incomplete\nbefore advancing `FakeTimeProvider`. For a deadline, advance to immediately\nbefore the boundary and assert that the task is still incomplete before\nadvancing across it. Never wait for wall-clock time.\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- [ ] Nested exception unwinding restores the outer override and overlapping async flows remain isolated\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":15,"description":24,"disable-model-invocation":25},"Generate C# testability wrappers and their DI registration. 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. 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. Exclude static detection (detect-static-dependencies), migration to an existing\u002Fregistered abstraction (after wrapper creation, the user invokes \u002Fdeniz-dotnet-general:migrate-static-to-wrapper separately), behavior-test requests whose seam is still open, and general interface design.\n",true,"master","b30b1c1908dbc56a8184128f18803053d762ccb5","plugins\u002Fdeniz-dotnet-general\u002Fskills\u002Fgenerate-testability-wrappers",0,"https:\u002F\u002Fgithub.com\u002FBlind-Striker\u002Fagent-skills-and-plugins","https:\u002F\u002Fgithub.com\u002FBlind-Striker","denizirgin.com","VP of Engineering - \r\n@armutcom @homeruntech @prontopro\r\n |  Speaker \r\n@CodeFiction\r\n, http:\u002F\u002Fcodefiction.tech | Developer, gamer, blogger, maiden iron fan","2026-11-13 00:23:18",{"source":8,"skillName":5,"commands":36,"prompt":46,"zipAvailable":25},[37,40,43],{"tool":38,"command":39},"npx","npx skills add Blind-Striker\u002Fagent-skills-and-plugins --skill generate-testability-wrappers",{"tool":41,"command":42},"bunx","bunx skills add Blind-Striker\u002Fagent-skills-and-plugins --skill generate-testability-wrappers",{"tool":44,"command":45},"pnpm","pnpm dlx skills add Blind-Striker\u002Fagent-skills-and-plugins --skill generate-testability-wrappers","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FBlind-Striker\u002Fagent-skills-and-plugins\u002Fblob\u002Fmaster\u002Fplugins\u002Fdeniz-dotnet-general\u002Fskills\u002Fgenerate-testability-wrappers\u002FSKILL.md",[],[49,56,63,70,77,84],{"skillNo":50,"name":51,"nameZh":6,"description":52,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":53,"categories":54,"keywords":55,"publishedAt":19},"01M79YGWBJ52PHMSTKJ3RJ3AWR","writing-tunit-tests","Write tests in TUnit — the attributes, the async assertion model, data-driven cases, lifecycle hooks, and the parallelism rules. USE FOR writing or fixing a test in a TUnit project, translating a test idea into TUnit syntax, or reviewing TUnit test code for API mistakes. DO NOT USE FOR deciding what to test, judging whether a test is any good, or running tests.","https:\u002F\u002Fgithub.com\u002FBlind-Striker\u002Fagent-skills-and-plugins\u002Fblob\u002Fmaster\u002Fskills\u002Fdeniz-dotnet-general\u002Fwriting-tunit-tests\u002FSKILL.md",[],[],{"skillNo":57,"name":58,"nameZh":6,"description":59,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":60,"categories":61,"keywords":62,"publishedAt":19},"01M79YGR3Y9RCRS6TD71D0KKP8","dotnet-walls","Walls for a .NET change in a repository without its own quality gates — pinned, ephemeral analyzer, format, clone and scanner commands for the verify step, their identity ratchet, and the build traps. Use during a walls preflight, or when a worker's verify step needs .NET quality gates.","https:\u002F\u002Fgithub.com\u002FBlind-Striker\u002Fagent-skills-and-plugins\u002Fblob\u002Fmaster\u002Fskills\u002Fdeniz-dotnet-general\u002Fdotnet-walls\u002FSKILL.md",[],[],{"skillNo":64,"name":65,"nameZh":6,"description":66,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":67,"categories":68,"keywords":69,"publishedAt":19},"01M79YGFNJBST7D803NQW3SBYM","csharp-15","Write, review and modernize C# 15 (.NET 11) code correctly. Covers every C# 15 feature - collection expression arguments (`[with(...), ...]`), union types (`union`, `[Union]`, `IUnion`, custom unions), closed class hierarchies (`closed`), extension indexers, labeled `break`\u002F`continue`, non-virtual static interface members on runtimes without default interface methods, and the preview memory-safety model (`unsafe(expr)`, `safe`, requires-unsafe members). Use when code targets net11.0 or LangVersion 15\u002Fpreview, when the user mentions any of these features, when replacing marker interfaces, OneOf-style results, `goto`\u002Fflag loop exits or capacity\u002Fcomparer boilerplate, or when the build reports CS8121, CS8509, CS8655, CS8510, CS0121\u002FCS0411 on a `with(...)` element, CS9370, CS9380 or CS9363.","https:\u002F\u002Fgithub.com\u002FBlind-Striker\u002Fagent-skills-and-plugins\u002Fblob\u002Fmaster\u002Fskills\u002Fdeniz-dotnet-general\u002Fcsharp-15\u002FSKILL.md",[],[],{"skillNo":71,"name":72,"nameZh":6,"description":73,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":74,"categories":75,"keywords":76,"publishedAt":19},"01M79YGAV031473HSX6FN87ENH","verified-waves","Run one task as verified multi-agent waves. Plans the fan-out, sends findings to fresh skeptics, keeps a ledger, and reports N of M done; small tasks stay solo.","https:\u002F\u002Fgithub.com\u002FBlind-Striker\u002Fagent-skills-and-plugins\u002Fblob\u002Fmaster\u002Fskills\u002Fdeniz-coordination\u002Fverified-waves\u002FSKILL.md",[],[],{"skillNo":78,"name":79,"nameZh":6,"description":80,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":81,"categories":82,"keywords":83,"publishedAt":19},"01M79YG6QXNND4WRPP3GATSY8J","harness","The bundled dispatch harness, which runs a task file on worker models through OpenCode or Codex, fences their writes, escalates their asks to the operator, settles each result from git and its verify commands, and records every step in a ledger. Its commands, task file, modes and write fence, configuration, runs and their recovery, ledger and exit codes.","https:\u002F\u002Fgithub.com\u002FBlind-Striker\u002Fagent-skills-and-plugins\u002Fblob\u002Fmaster\u002Fskills\u002Fdeniz-coordination\u002Fharness\u002FSKILL.md",[],[],{"skillNo":85,"name":86,"nameZh":6,"description":87,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":88,"categories":89,"keywords":90,"publishedAt":19},"01M79YG2P5S91SDTA5912XJ4FV","delegating-to-worker-models","Use when you hand off implementation, a plan, research a decision will rely on, or a review, and you brief the worker and check what comes back. A subagent that searches, reads in parallel, or keeps your context small is ordinary tool use. Covers what stays with you, the mechanism, assigning work by strength, the walls preflight, prompts without contradictions, the worker contract and model profiles, evidence from your own run, review, and the fix-up loop.","https:\u002F\u002Fgithub.com\u002FBlind-Striker\u002Fagent-skills-and-plugins\u002Fblob\u002Fmaster\u002Fskills\u002Fdeniz-coordination\u002Fdelegating-to-worker-models\u002FSKILL.md",[],[]]