Official agent skill

Exp Mock Usage Analysis

by dotnet in dotnet/skills

Audits .NET test mock usage by tracing each mock setup through the production code's execution path to find dead, unreachable, redundant, or replaceable mocks.

OfficialMITAuto-check passed

Install Exp Mock Usage Analysis

skills CLI
$ npx skills add dotnet/skills --skill exp-mock-usage-analysis -a claude-code

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

GitHub CLI
$ gh skill install dotnet/skills exp-mock-usage-analysis --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-experimental/skills/exp-mock-usage-analysis .claude/skills/exp-mock-usage-analysis && 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
exp-mock-usage-analysis
GitHub stars
5.6k
Used in
1 other repo
Token cost
~1.5k tokens
SKILL.md length
697 words
Files
1
Skills in repo
91
Repo updated
First seen
Licence
MIT

At a glance

Audits .NET test mock usage by tracing each mock setup through the production code's execution path to find dead, unreachable, redundant, or replaceable mocks.

  • Works in 4 steps: Read all provided code → Trace each mock setup through the… → Check for replaceable mocks → …
  • The user asks to audit mock usage
  • SKILL.md covers When to Use, When Not to Use, Inputs and Workflow, plus 2 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Exp Mock Usage Analysis is an agent skill from dotnet/skills, published by the product's own GitHub organization. Audits .NET test mock usage by tracing each mock setup through the production code's execution path to find dead, unreachable, redundant, or replaceable mocks. Use when the user asks to audit mock usage, find unused or unnecessary mock setups, check if mocks are needed, reduce mock duplication or over-mocking, simplify test setup, or review whether mock configurations like ILogger/IOptions should use real implementations instead. Supports Moq, NSubstitute, and FakeItEasy.

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

It works with .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

  • The user asks to audit mock usage
  • Unnecessary mock setups
  • Check if mocks are needed
  • Reduce mock duplication

Example prompts

  • “Use the exp-mock-usage-analysis skill to audit .NET test mock usage by tracing each mock setup through the production code's execution path to find…”
  • “/exp-mock-usage-analysis”

Workflow steps

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

  1. Read all provided code
  2. Trace each mock setup through the production code
  3. Check for replaceable mocks
  4. Report findings

What it can do on your machine

Read from SKILL.md and the folder at commit a660de8. 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.

    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

Exp Mock Usage Analysis loads about 1.5k tokens when it runs. Until then it costs about 125 tokens; SKILL.md has 697 words of instructions outside code blocks.

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

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 a660de8, republished under its MIT licence (© dotnet). 697 words, ~1,463 tokens.

Download SKILL.mdSave it as .claude/skills/exp-mock-usage-analysis/SKILL.md (or your agent's skills folder).
name
exp-mock-usage-analysis
description
Audits .NET test mock usage by tracing each mock setup through the production code's execution path to find dead, unreachable, redundant, or replaceable mocks. Use when the user asks to audit mock usage, find unused or unnecessary mock setups, check if mocks are needed, reduce mock duplication or over-mocking, simplify test setup, or review whether mock configurations like ILogger/IOptions should use real implementations instead. Supports Moq, NSubstitute, and FakeItEasy.
license
MIT

Mock Usage Analysis

Trace each mock setup through the production code's execution path to determine which setups are actually exercised at runtime and which are dead, unreachable, redundant, or replaceable with real implementations.

When to Use

  • User asks to audit, review, or analyze mock usage in .NET tests
  • User wants to find unused, unnecessary, or redundant mock setups
  • User wants to simplify test setup or reduce over-mocking
  • User asks whether mocks of ILogger, IOptions, or similar types are needed

When Not to Use

  • User wants to write new mocks or tests (general testing guidance)
  • User wants to detect non-mock test anti-patterns (use test-anti-patterns)
  • User wants to migrate between mock frameworks (out of scope)

Inputs

InputRequiredDescription
Test codeYesTest files to analyze
Production codeYesCode under test — essential for tracing execution paths

Workflow

Step 1: Read all provided code

Read the test files and always read the production code. You cannot determine whether a mock setup is necessary without understanding the production method's control flow.

Identify the mock framework by scanning for its patterns:

  • Moq: new Mock<T>(), .Setup(...), .Verify(...)
  • NSubstitute: Substitute.For<T>(), .Returns(...), .Received(...)
  • FakeItEasy: A.Fake<T>(), A.CallTo(...), .MustHaveHappened()

Use the correct framework's terminology throughout your analysis.

Step 2: Trace each mock setup through the production code

For each test method, do the following:

  1. Identify every mock setup line (.Setup, .Returns, A.CallTo, etc.)
  2. Read the production method being tested and trace its execution path for the specific inputs used in that test
  3. Determine which mock setups are actually reached during execution
  4. Classify each setup:
ClassificationMeaningExample
UsedThe production code calls this mock during the test's execution pathGetStock setup when Reserve is called and stock is sufficient
UnreachableThe production code returns early, throws, or branches away before reaching this mock callUpdateStock setup when the test expects the method to throw ArgumentOutOfRangeException on the first line
UnusedThe mock method is never called by the production method under test at all, regardless of inputsGetLowStockProducts setup when testing Reserve, which never calls that method
RedundantIdentical mock configurations are duplicated across multiple tests instead of being sharedFive tests each creating new Mock<IPaymentGateway>() with the same default setup

Pay special attention to:

  • Early returns and guard clauses — setups for mocks called after a guard clause are unreachable when the guard triggers
  • Exception throws — if the method throws before using dependencies, all setups for those dependencies are unnecessary
  • Branch-specific logic — if a method dispatches by channel/type, setups for other channels are unused
  • Verify-only tests — tests that only call .Verify/.Received/.MustHaveHappened without asserting on the method's return value
Show full SKILL.md (264 more words)Show less
Step 3: Check for replaceable mocks

Flag mocks of stable framework types that should use real implementations:

  • Mock<ILogger<T>> → NullLogger<T>.Instance (unless log output is asserted)
  • Mock<IOptions<T>> → Options.Create(new T { ... })
  • Mocks of DTOs, records, or value objects → use new T { ... } directly

Explicitly confirm which mocks are correctly placed — external boundaries (databases, HTTP clients, message queues, third-party APIs) and security-sensitive types should remain mocked.

Step 4: Report findings

For each finding, state:

  1. The specific test method and mock setup line
  2. Why the setup is unnecessary (trace the production code path to explain)
  3. A concrete fix — which lines to remove, what to replace them with, or how to extract shared setup

When multiple tests duplicate mock configurations, provide a before/after example showing how to extract shared setup into a fixture or helper method.

Validation

  • Production code was read and execution paths were traced (not just test code reviewed)
  • Every finding references a specific test method and setup line
  • Unreachable setups include an explanation of which production code path makes them unreachable
  • Correctly-placed mocks (external boundaries) are explicitly noted as appropriate
  • Correct framework terminology is used throughout (not mixing Moq/NSubstitute/FakeItEasy terms)

Common Pitfalls

PitfallSolution
Analyzing test code without reading production codeAlways read the production method to trace which mocks are actually called
Flagging mocks for external boundaries (HTTP, DB)These are valid isolation boundaries — keep them mocked
Flagging ILogger mock when log output is assertedOnly flag when the mock is set up but log output is never verified
Using wrong framework terminologyMatch the framework in the code: Moq (Setup/Verify), NSubstitute (Returns/Received), FakeItEasy (A.CallTo/MustHaveHappened)

© 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-experimental/skills/exp-mock-usage-analysis of dotnet/skills.

Open the folder on GitHubat commit a660de8

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

Exp Mock Usage Analysis 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.

Exp Mock Usage Analysis compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Exp Mock Usage Analysis this skilldotnet/skills5.6k1 repos~1.5kAutomated safety check: PassMIT
Minimax DOCXpoco-ai/poco-claw1.4k7 repos~3.9kAutomated safety check: PassMIT
Microsoft Skill CreatorMicrosoftDocs/mcp1.9k3 repos~2.1kAutomated safety check: PassCC-BY-4.0
Speckit ConstitutionWeihanLi/WeihanLi.Common24211 repos~2.1kAutomated safety check: PassApache-2.0
Copilot Session Failure Analysisdotnet/maui23k—~3.4kAutomated safety check: PassMIT
Microsoft Code ReferenceMicrosoftDocs/mcp1.9k4 repos~1.1kAutomated safety check: PassCC-BY-4.0

Similar skills

  • Minimax DOCX

    poco-ai/poco-claw

    Professional DOCX document creation, editing, and formatting using OpenXML SDK (.NET).

    1.4k GitHub starsUsed in 7 repos~3.9k tokens
    Documents & OfficeAuto-check passed
  • Microsoft Skill Creator

    MicrosoftDocs/mcp

    Official

    Create agent skills for Microsoft technologies using official documentation.

    1.9k GitHub starsUsed in 3 repos~2.1k tokens
    Agent WorkflowsAuto-check passed
  • Speckit Constitution

    WeihanLi/WeihanLi.Common

    Create or update the project constitution from interactive or provided principle inputs, ensuring all dependent templates stay in sync.

    242 GitHub starsUsed in 11 repos~2.1k tokens
    DevelopmentAuto-check passed
  • Mines local Copilot CLI session logs for dotnet/maui to rank costly or failing runs, tag recurring failure modes, propose repo edits and emit guard evals.

    23k GitHub stars~3.4k tokensUpdated today
    Agent WorkflowsAuto-check passed
  • Microsoft Code Reference

    MicrosoftDocs/mcp

    Official

    Find working code samples, verify API signatures, and fix Microsoft SDK errors using official docs.

    1.9k GitHub starsUsed in 4 repos~1.1k tokens
    DevelopmentAuto-check passed
  • Official

    Audits and updates os-packages.json files listing the Linux packages each .NET release needs per distro, then regenerates the Markdown from the JSON.

    22k GitHub stars~2.3k tokensUpdated today
    DevelopmentAuto-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

Questions about Exp Mock Usage Analysis

What does Exp Mock Usage Analysis do?

Audits .NET test mock usage by tracing each mock setup through the production code's execution path to find dead, unreachable, redundant, or replaceable mocks. Exp Mock Usage Analysis is an agent skill from dotnet/skills, published by the product's own GitHub organization.NET test mock usage by tracing each mock setup through the production code's execution path to find dead, unreachable, redundant, or replaceable mocks.

When should I use Exp Mock Usage Analysis?

Exp Mock Usage Analysis fits situations like: the user asks to audit mock usage; unnecessary mock setups; check if mocks are needed; reduce mock duplication.

How do I install Exp Mock Usage Analysis in Claude Code?

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

How do I install Exp Mock Usage Analysis in Codex?

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

Can I use Exp Mock Usage Analysis 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 exp-mock-usage-analysis -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/exp-mock-usage-analysis, .gemini/skills/exp-mock-usage-analysis, .github/skills/exp-mock-usage-analysis and .opencode/skills/exp-mock-usage-analysis in your project.

What does Exp Mock Usage Analysis need to run?

SKILL.md names no scripts, command-line tools or credentials: Exp Mock Usage Analysis is instructions for the agent only.

Does Exp Mock Usage Analysis 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 Exp Mock Usage Analysis 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 Exp Mock Usage Analysis use?

Exp Mock Usage Analysis 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 Exp Mock Usage Analysis use?

About 1.5k tokens (SKILL.md is roughly 5.9k 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 Exp Mock Usage Analysis?

Skills that share tags, products or a category with Exp Mock Usage Analysis: Minimax DOCX (poco-ai/poco-claw, 1.4k stars), Microsoft Skill Creator (MicrosoftDocs/mcp, 1.9k stars), Speckit Constitution (WeihanLi/WeihanLi.Common, 242 stars) and Copilot Session Failure Analysis (dotnet/maui, 23k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Exp Mock Usage Analysis?

dotnet (a GitHub organization, an official publisher) maintains it in dotnet/skills, which has 5,576 GitHub stars. The repository holds 91 skills in this directory. The repository was last updated on October 8, 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.