Official agent skill

Testability Obstacle

by dotnet in dotnet/skills

MUST USE for C/.NET deterministic tests that require the smallest production seam for DateTime/Task.Delay/File/Environment/Guid/Random, static API preservation, nested/parallel overrides, or no real…

OfficialMITAuto-check passedTesting & QA

Install Testability Obstacle

skills CLI
$ npx skills add dotnet/skills --skill testability-obstacle -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install dotnet/skills testability-obstacle --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/dotnet/skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/plugins/dotnet-test/skills/testability-obstacle .claude/skills/testability-obstacle && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
testability-obstacle
GitHub stars
5.6k
Used in
1 other repo
Token cost
~3.6k tokens
SKILL.md length
1,848 words
Files
1
Skills in repo
91
Repo updated
First seen
Licence
MIT

At a glance

MUST USE for C/.NET deterministic tests that require the smallest production seam for DateTime/Task.Delay/File/Environment/Guid/Random, static API preservation, nested/parallel overrides, or no real…

  • Works in 6 steps: Prove the obstacle → Select the smallest safe seam → Preserve behavior and API shape → …
  • C/.NET deterministic tests that require the smallest production seam for DateTime/Task.Delay/File/Environment/Guid/Random
  • SKILL.md covers When to Use, When Not to Use, Inputs and Workflow, plus 3 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Testability Obstacle is an agent skill from dotnet/skills, published by the product's own GitHub organization. MUST USE for C/.NET deterministic tests that require the smallest production seam for DateTime/Task.Delay/File/Environment/Guid/Random, static API preservation, nested/parallel overrides, or no real I/O. USE ONLY when the target workspace contains C source plus a .csproj or .sln. DO NOT USE for audits, bulk migration, code that already has an injectable seam, or an explicit migration to a user-named existing abstraction (migrate-static-to-wrapper). Use instead of general test generation when the requested test is…

Its SKILL.md is about 3.6k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Testing & QA, covering Test generation. It works with C# and .NET. The repository describes itself as: Repository for skills to assist AI coding agents with .NET and C. The licence is MIT.

When your agent uses it

  • C/.NET deterministic tests that require the smallest production seam for DateTime/Task.Delay/File/Environment/Guid/Random
  • Static API preservation
  • Nested/parallel overrides
  • Code that already has an injectable seam

Example prompts

  • “/testability-obstacle”

Workflow steps

6 steps, taken from the step headings in SKILL.md.

  1. Prove the obstacle
  2. Select the smallest safe seam
  3. Preserve behavior and API shape
  4. Keep production defaults wired
  5. Write deterministic tests
  6. Verify the complete path

What it can do on your machine

Read from SKILL.md and the folder at commit 8d670fa. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are csharp).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Testability Obstacle loads about 3.6k tokens when it runs. Until then it costs about 153 tokens; SKILL.md has 1,848 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~153
When it runs · the whole SKILL.md, loaded when a task matches
~3.6k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from dotnet/skills at commit 8d670fa, republished under its MIT licence (© dotnet). 1,848 words, ~3,599 tokens.

Download SKILL.mdSave it as .claude/skills/testability-obstacle/SKILL.md (or your agent's skills folder).
name
testability-obstacle
description
MUST USE for C#/.NET deterministic tests that require the smallest production seam for DateTime/Task.Delay/File/Environment/Guid/Random, static API preservation, nested/parallel overrides, or no real I/O. USE ONLY when the target workspace contains C# source plus a .csproj or .sln. DO NOT USE for audits, bulk migration, code that already has an injectable seam, or an explicit migration to a user-named existing abstraction (migrate-static-to-wrapper). Use instead of general test generation when the requested test is impossible without a production edit and seam selection is still open.
license
MIT

Resolve a Testability Obstacle

Introduce the smallest behavior-preserving seam needed to test a specific C# behavior, then add deterministic tests that prove both the behavior and the seam. The production edit is a means to the requested test, not an invitation to redesign adjacent code.

When to Use

  • A requested test would otherwise read/write the real filesystem.
  • Behavior depends on the current time, delay, random value, environment, console, process, or another ambient dependency.
  • The user explicitly permits or requests a safe production seam.
  • Existing tests cannot control a dependency without process-global mutation.

When Not to Use

  • The dependency is already injected or passed as an argument. Write tests with a fake through the existing seam using code-testing-agent.
  • The user wants a repository-wide testability audit. Use detect-static-dependencies.
  • The user wants wrappers generated but not call sites/tests changed. Use generate-testability-wrappers.
  • The user requests a broad mechanical migration. Use migrate-static-to-wrapper, then generate tests separately.
  • The user already selected an existing replacement such as TimeProvider or IFileSystem and asks to migrate call sites to it. Use migrate-static-to-wrapper, which also updates affected tests.
  • The code is not C#/.NET.

Inputs

InputRequiredDescription
Behavior to testYesThe method/workflow and expected observable behavior
Target scopeNoDiscover the narrowest relevant file/project when omitted
Allowed production changesNoDefault to the minimum internal/constructor seam

Workflow

Step 1: Prove the obstacle

Read the target production path and its existing tests. Identify the exact ambient operation preventing a deterministic test and the behavior that must remain unchanged. Do not run a repository-wide static scan for a single-class request.

If an adequate seam already exists, stop refactoring and use it. This skill adds no value when a fake can already be supplied.

Step 2: Select the smallest safe seam

Choose by dependency and repository constraints:

DependencyPreferred seam
Current time / timersInject TimeProvider; use FakeTimeProvider in tests
FilesystemExisting repository abstraction; for one write/read operation use an injected delegate when conventions allow, otherwise a one-member interface or an already accepted System.IO.Abstractions
HTTPExisting typed HttpClient/handler or IHttpClientFactory seam
RandomnessOne final generated value: inject Func<int> and keep range selection in the real default; inject Func<int, int, int> only when range arguments are behavior the test must verify; multiple operations/state: inject Random or a minimal generator interface
Environment/console/processMinimal interface containing only members used by the target

The scoped AsyncLocal<T> rule applies to every static API that must retain its public static shape — clocks, filesystem access, environment lookups, identity generation, and randomness. The scope captures and restores the previous value; never implement Dispose() as an unconditional assignment to null. Store the provider/value itself in AsyncLocal<T>. Do not put a mutable Stack<T>, list, or other shared mutable collection in the slot: child execution contexts can inherit the same object and corrupt each other's nesting. When the provider itself is mutable (for example an in-memory store or fake time provider), establish a fresh provider inside each parallel flow rather than mutating one inherited instance from a parent context.

Constructor injection is the default for instance classes. Reuse the repository's DI and naming conventions, but do not add a DI container to a class library just to satisfy this workflow.

Preserve the existing public construction surface unless the user authorizes an API change. Keep a public parameterless constructor as the real-dependency default and place a test-only delegate/provider constructor at the narrowest visibility the test project can reach. Do not turn the seam into a new public optional parameter merely for test convenience.

For a static class or a public API that cannot change, use a scoped ambient seam only when constructor/parameter injection is impossible. The override must:

  • flow across await (AsyncLocal<T>, not [ThreadStatic]);
  • return IDisposable and restore the previous value, including nested scopes;
  • default to the real production dependency;
  • avoid a process-global mutable fake that makes tests non-parallel.

Use built-in fake-time-aware overloads instead of inventing an IDelay wrapper:

Ambient operationReplacement
Task.Delay(delay, token)Task.Delay(delay, timeProvider, token)
new CancellationTokenSource(delay)new CancellationTokenSource(delay, timeProvider)
PeriodicTimer(period)new PeriodicTimer(period, timeProvider) when the target framework provides it

Test delayed behavior by starting the operation, proving it is incomplete, advancing FakeTimeProvider, then awaiting it. For a deadline or boundary, advance to immediately before the deadline and assert the task is still incomplete before advancing across it; an immediate post-start assertion alone does not prove the boundary. Never wait for wall-clock time.

For a nested ambient override, each scope captures the value active when it starts and restores that value exactly once. Dispose scopes in LIFO order with using/finally; never reset the slot unconditionally to null. Tests must observe the outer value after an inner scope ends normally and, when requested, after an exception unwinds the inner scope. Use distinct values so clearing the slot cannot accidentally pass. Also overlap independent async flows and assert that each sees only its own fresh override. Do not mutate process environment variables to test an environment seam.

csharp
var previous = s_provider.Value;
s_provider.Value = provider;
return new RestoreScope(() => s_provider.Value = previous);
Step 3: Preserve behavior and API shape

Keep the production change mechanical:

  • Wrap only members used by the target behavior.
  • Default implementations delegate directly to the original API.
  • Preserve exceptions, path handling, time zone, and DateTime.Kind.
  • Keep existing public signatures unless the user explicitly permits an API change.
  • Do not move business logic into the wrapper or fix unrelated production bugs.

Deterministic serialized text is a deliberate exception to preserving ambient platform formatting. If the user asks for exact reproducible output across platforms, use the format's explicit separator (use literal \n when none is specified) and assert that literal content. Keep Environment.NewLine only when platform-native output is part of the existing contract.

For time replacements:

  • DateTime.UtcNow -> timeProvider.GetUtcNow().UtcDateTime
  • DateTime.Now -> timeProvider.GetLocalNow().LocalDateTime
  • DateTimeOffset.UtcNow -> timeProvider.GetUtcNow()
  • DateTimeOffset.Now -> timeProvider.GetLocalNow()
Step 4: Keep production defaults wired

Update every composition root or constructor call affected by the seam. Production must still use real time/filesystem/etc. by default. If the project uses DI, register the default implementation with the lifetime matching repository conventions. If it does not use DI, compose explicitly; do not introduce a container. An existing manual factory must pass the real dependency explicitly (for example, new ExpirationPolicy(TimeProvider.System)). Do not move responsibility into an optional constructor or add an optional provider parameter to the factory.

Build the affected production project before writing tests. A compile failure here is a seam problem, not a test problem.

Show full SKILL.md (809 more words)Show less
Step 5: Write deterministic tests

Use the repository's existing test project. If none exists, invoke scaffold-dotnet-test-project first.

Tests must supply controlled dependencies:

  • fixed/advanced time rather than wall-clock waiting;
  • an in-memory fake filesystem or hand-rolled fake rather than temp/real files;
  • no environment mutation, external process, console input, or network.

Before authoring a test, inspect its test project and follow the existing framework, global-using, and assertion conventions. Use the framework packages already referenced by that project; never add a hand-rolled FactAttribute, a substitute test-framework type, or unrelated test-project plumbing to make a test compile.

Assert the requested business result and at least one interaction/state observable that proves the fake dependency drove the path. Include a production-default test only when it can remain deterministic; never touch the real filesystem merely to prove the adapter delegates.

Cover every explicitly requested behavior and edge case. A theory or shared helper may keep the suite compact, but do not drop a case to minimize test count or replace retained tests with a smaller set. The seam should be minimal; the verification should still be complete.

Choose the narrowest seam that supports the behavior. A single File.WriteAllText call can be an injected Action<string, string> with a real default; do not create an interface, implementation, friend-assembly setting, and extra project wiring unless repository conventions or multiple operations justify them.

Preserve the public API surface as well as existing signatures. Do not add a public dependency-injecting constructor solely for tests. When a class currently has only its implicit public parameterless constructor and the exact test assembly is known, keep that constructor behavior and make the test-only constructor internal; an InternalsVisibleTo entry is justified in this narrow case because it prevents the seam from becoming public API. Prefer an existing repository friend-assembly convention when one is present.

Do not add InternalsVisibleTo when an existing public seam already accepts the fake or the test project can otherwise supply it. Friend-assembly access is justified only when the chosen minimum constructor/delegate seam must remain internal to preserve the public API and the exact test assembly is known.

Step 6: Verify the complete path

Run the affected production build and the narrowest targeted test command. Run a repository-level test command only when the user requested broad validation, the repository contract requires that entry point, or the seam changes shared composition used beyond the target. Re-read the diff and confirm:

  1. every production change is required by the seam;
  2. no real ambient resource is used by the new tests;
  3. current-time semantics and public behavior are preserved;
  4. existing tests were not replaced or duplicated.

Inspect the test summary, not only the exit code. Zero discovered tests, a build without the requested test run, or any failing/erroring test means the task is incomplete. Fix discovery/execution and rerun before reporting success. When a new test does not compile, correct its imports, assertion overload, or async test shape against the existing test framework before changing the production seam; do not emulate missing framework APIs in source. For a static ambient seam, completion requires executed tests for substitution, nested restoration, exception restoration when requested, and overlapping async-flow isolation; production compilation alone is never sufficient. Capture the passing test count or requested test names in the handoff. If no test was discovered or the output does not prove execution, correct the project/test source and rerun rather than reporting the seam as validated.

Output Contract

Provide a compact Requirement | Evidence table. Cite the production seam, production default wiring, exact test names, and passing commands. If a package restore or build blocks validation, report that blocker rather than claiming the tests pass.

Validation

  • The original obstacle was concrete and in the requested path.
  • An existing seam was reused when available.
  • The new abstraction exposes only members required by the target behavior.
  • Production defaults still delegate to the original dependency.
  • The seam did not enlarge the public API when an internal test seam was sufficient.
  • Time conversions preserve local/UTC and DateTime.Kind semantics.
  • Static ambient overrides are async-safe, scoped, nested, and reversible.
  • New tests use fixed/in-memory dependencies and no real I/O or wall clock.
  • Production build and targeted/repository tests pass with at least one requested test discovered.

Common Pitfalls

PitfallCorrective action
Refactoring before proving a blockerReuse an existing seam and write the test directly
Wrapping an entire static APIExpose only members exercised by the target
Converting UtcNow with .DateTimeUse .UtcDateTime to preserve DateTimeKind.Utc
Mutable static fake shared by testsUse constructor injection or a scoped AsyncLocal<T> override
Adding DI to a library with no containerCompose the dependency explicitly
Using temp files as a shortcutSupply an in-memory fake; the scenario requires no real I/O
Stopping after the refactor buildsWrite and run the behavior tests that justified the seam
Reporting a zero-test run as successFix discovery and require the requested tests to execute and pass

© dotnet, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in plugins/dotnet-test/skills/testability-obstacle of dotnet/skills.

Open the folder on GitHubat commit 8d670fa

Used in 1 other repository

We found 2 copies of this SKILL.md (exact, near-identical or edited) in other folders, from 1 other GitHub owner. This page covers the copy in dotnet/skills, which our catalogue first saw on October 7, 2026.

Compare with similar skills

Testability Obstacle next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Testability Obstacle compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Testability Obstacle this skilldotnet/skills5.6k1 repos~3.6kAutomated safety check: PassMIT
ScottPlot Test RunnerScottPlot/ScottPlot6.8k—~308Automated safety check: PassMIT
Macios CI Failure Inspectordotnet/macios2.9k—~2.3kAutomated safety check: PassCustom licence
Playwright Rollmicrosoft/playwright-dotnet3k—~1.9kAutomated safety check: PassMIT
Fix Random CI Test Failuredotnet/macios2.9k—~1.3kAutomated safety check: PassCustom licence
Test Firstdeanhume/html-minifier142—~876Automated safety check: PassMIT

Similar skills

  • ScottPlot Test Runner

    ScottPlot/ScottPlot

    Run or add ScottPlot 5 tests. Use for unit-test and cookbook-test work; unless explicitly asked otherwise, restrict manual test execution to the Unit Tests…

    6.8k GitHub stars~308 tokensUpdated 1 mo ago
    Testing & QAAuto-check passed
  • Official

    Investigate and triage CI failures for dotnet/macios from Azure DevOps build URLs.

    2.9k GitHub stars~2.3k tokensUpdated today
    Testing & QAAuto-check passed
  • Playwright Roll

    microsoft/playwright-dotnet

    Official

    Roll Playwright .NET to a new version

    3k GitHub stars~1.9k tokensUpdated yesterday
    Testing & QAAuto-check passed
  • Official

    Investigate and fix flaky/random CI test failures in dotnet/macios.

    2.9k GitHub stars~1.3k tokensUpdated today
    Testing & QAAuto-check passed
  • Test First

    deanhume/html-minifier

    Enforces a strict test-driven development (TDD) workflow for the HTML Minifier repo.

    142 GitHub stars~876 tokensUpdated 20 days ago
    Testing & QAAuto-check passed
  • Aspire

    SSWConsulting/SSW.VerticalSliceArchitecture

    A skill your agent uses when the user is working with an Aspire distributed application and needs to operate the AppHost or its resources through the Aspire CLI: start, restart, stop, or wait on the…

    407 GitHub starsUsed in 1 repo~2k tokens
    Testing & QAAuto-check passed

More from dotnet/skills

All 91 skills in this repo
  • Official

    Resolves .NET runtime frames in Apple .ips crash logs to function names, source files and line numbers using dSYM symbols, atos and the Microsoft symbol server.

    5.6k GitHub starsUsed in 1 repo~2.4k tokens
    Auto-check passed
  • Official

    Resolves native crash frames from .NET Android tombstones to function names, source files and line numbers using BuildIds, Microsoft's symbol server and llvm-symbolizer.

    5.6k GitHub starsUsed in 1 repo~2.1k tokens
    Auto-check passed
  • Official

    Scans C# and .NET code for about 50 performance anti-patterns and reports prioritized findings with concrete fixes, at a scan depth you choose.

    5.6k GitHub starsUsed in 3 repos~3.1k tokens
    Auto-check passed
  • Official

    Statically pairs source files with test files to list code that no test references, using Roslyn for C# or tree-sitter for many languages, with no build.

    5.6k GitHub starsUsed in 1 repo~3.3k tokens
    Auto-check passed
  • Microbenchmarking

    dotnet/skills

    Official

    Activate this skill when BenchmarkDotNet (BDN) is involved in the task — creating, running, configuring, or reviewing BDN benchmarks.

    5.6k GitHub starsUsed in 3 repos~3.3k tokens
    Auto-check passed
  • Official

    Makes .NET projects compatible with Native AOT and trimming by resolving IL trim and AOT analyzer warnings through annotations rather than suppressions.

    5.6k GitHub starsUsed in 2 repos~4.2k tokens
    Auto-check passed

Works with

Categories

Questions about Testability Obstacle

What does Testability Obstacle do?

MUST USE for C/.NET deterministic tests that require the smallest production seam for DateTime/Task.Delay/File/Environment/Guid/Random, static API preservation, nested/parallel overrides, or no real…. Testability Obstacle is an agent skill from dotnet/skills, published by the product's own GitHub organization.Delay/File/Environment/Guid/Random, static API preservation, nested/parallel overrides, or no real I/O.

When should I use Testability Obstacle?

Testability Obstacle fits situations like: C/.NET deterministic tests that require the smallest production seam for DateTime/Task.Delay/File/Environment/Guid/Random; static API preservation; nested/parallel overrides; code that already has an injectable seam.

How do I install Testability Obstacle in Claude Code?

Run `npx skills add dotnet/skills --skill testability-obstacle -a claude-code`. Or copy the skill folder (plugins/dotnet-test/skills/testability-obstacle in dotnet/skills) into .claude/skills/testability-obstacle in your project. Claude Code loads it when a task matches its description.

How do I install Testability Obstacle in Codex?

Run `npx skills add dotnet/skills --skill testability-obstacle -a codex`. Or copy the skill folder (plugins/dotnet-test/skills/testability-obstacle in dotnet/skills) into .agents/skills/testability-obstacle in your project. Codex loads it when a task matches its description.

Can I use Testability Obstacle in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add dotnet/skills --skill testability-obstacle -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/testability-obstacle, .gemini/skills/testability-obstacle, .github/skills/testability-obstacle and .opencode/skills/testability-obstacle in your project.

What does Testability Obstacle need to run?

SKILL.md names no scripts, command-line tools or credentials: Testability Obstacle is instructions for the agent only.

Does Testability Obstacle access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Testability Obstacle safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Testability Obstacle use?

Testability Obstacle is published under the MIT licence (declared in SKILL.md). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Testability Obstacle use?

About 3.6k tokens (SKILL.md is roughly 14k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Testability Obstacle?

Skills that share tags, products or a category with Testability Obstacle: ScottPlot Test Runner (ScottPlot/ScottPlot, 6.8k stars), Macios CI Failure Inspector (dotnet/macios, 2.9k stars), Playwright Roll (microsoft/playwright-dotnet, 3k stars) and Fix Random CI Test Failure (dotnet/macios, 2.9k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Testability Obstacle?

dotnet (a GitHub organization, an official publisher) maintains it in dotnet/skills, which has 5,568 GitHub stars. The repository holds 91 skills in this directory. The repository was last updated on October 7, 2026.

Source: dotnet/skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.