{
  "schema": "https://ai-atoms.com/schemas/skill-v1.json",
  "type": "skill",
  "id": "skill/mtp-hot-reload",
  "version": "1.0.1",
  "name": "mtp-hot-reload",
  "description": "Set up or recover MTP hot reload for a long-lived edit/re-run loop. Use for \"hot reload tests\", \"dotnet run or dotnet test for hot reload\", a host that keeps running, unsupported/rude edits, or a watch-based VSTest fallback. Covers setup, run/watch, restarts, filters, and the VSTest no-mutation fallback. Never mutate VSTest for hot reload. For one-time runs, exact commands, filter errors, TRX/dumps, or merely a failing test, use run-tests. Excludes writing/debugging tests, CI, and Test Explorer hot reload.",
  "system_prompt_fragment": "# MTP Hot Reload for Iterative Test Fixing\n\nSet up and use Microsoft Testing Platform hot reload to rapidly iterate fixes on failing tests without rebuilding between each change.\n\n## When to Use\n\n- User has one or more failing tests and wants to iterate fixes quickly\n- User wants to avoid rebuild overhead while fixing test code or production code\n- User asks about hot reload for tests or speeding up the test-fix loop\n- User needs to set up MTP hot reload in their project\n\n## When Not to Use\n\n- User needs to write new tests from scratch (use general coding assistance)\n- User needs to diagnose why a test is failing (use diagnostic skills)\n- User wants Visual Studio Test Explorer hot reload (different feature, built into VS)\n- Project uses VSTest -- hot reload requires Microsoft Testing Platform (MTP)\n- User needs CI/CD pipeline configuration\n\n## Inputs\n\n| Input | Required | Description |\n|-------|----------|-------------|\n| Test project path | No | Path to the test project (.csproj). Defaults to current directory. |\n| Failing test name or filter | No | Specific test(s) to iterate on |\n\n## Workflow\n\n### Step 1: Verify the project uses Microsoft Testing Platform\n\nHot reload requires MTP. It does **not** work with VSTest.\n\nFollow the detection procedure in the `platform-detection` skill to determine the test platform.\n\nIf the project uses VSTest, inform the user that MTP hot reload is not available and suggest migrating to MTP first (see `migrate-vstest-to-mtp`), or using Visual Studio's built-in Test Explorer hot reload feature instead.\n\n### Step 2: Add the hot reload NuGet package\n\nInstall the `Microsoft.Testing.Extensions.HotReload` package:\n\n```shell\ndotnet add <project-path> package Microsoft.Testing.Extensions.HotReload\n```\n\n> **Note**: When using `Microsoft.Testing.Platform.MSBuild` (included transitively by MSTest, NUnit, and xUnit runners), the extension is auto-registered when you install its NuGet package -- no code changes needed.\n\n### Step 3: Enable hot reload\n\nHot reload is activated by setting the `TESTINGPLATFORM_HOTRELOAD_ENABLED` environment variable to `1`.\n\n**Option A -- Set it in the shell before running tests:**\n\n```shell\n# PowerShell\n$env:TESTINGPLATFORM_HOTRELOAD_ENABLED = \"1\"\n\n# bash/zsh\nexport TESTINGPLATFORM_HOTRELOAD_ENABLED=1\n```\n\n**Option B -- Add it to `launchSettings.json` (recommended for repeatable use):**\n\nCreate or update `Properties/launchSettings.json` in the test project:\n\n```json\n{\n  \"profiles\": {\n    \"<ProjectName>\": {\n      \"commandName\": \"Project\",\n      \"environmentVariables\": {\n        \"TESTINGPLATFORM_HOTRELOAD_ENABLED\": \"1\"\n      }\n    }\n  }\n}\n```\n\n### Step 4: Run the tests with hot reload\n\nRun the test project directly (not through `dotnet test`) to use hot reload in console mode:\n\n```shell\ndotnet run --project <project-path>\n```\n\nTo filter to specific failing tests, pass the filter after `--`. The syntax depends on the test framework -- see the `filter-syntax` skill for full details. Quick examples:\n\n| Framework | Filter syntax |\n|-----------|--------------|\n| MSTest | `dotnet run --project <path> -- --filter \"FullyQualifiedName~TestMethodName\"` |\n| NUnit | `dotnet run --project <path> -- --filter \"FullyQualifiedName~TestMethodName\"` |\n| xUnit v3 | `dotnet run --project <path> -- --filter-method \"*TestMethodName\"` |\n| TUnit | `dotnet run --project <path> -- --treenode-filter \"/*/*/ClassName/TestMethodName\"` |\n\nThe test host will start, run the tests, and **remain running** waiting for code changes.\n\n### Step 5: Iterate on the fix\n\n1. Edit the source code (test code or production code) in your editor\n2. The test host detects the changes and re-runs the affected tests automatically\n3. Review the updated results in the console\n4. Repeat until all targeted tests pass\n\n> **Important**: Hot reload currently works in **console mode only**. There is no support for hot reload in Test Explorer for Visual Studio or Visual Studio Code.\n\n### Step 6: Finalize\n\nOnce all tests pass:\n\n1. Stop the test host (Ctrl+C)\n2. Run a full `dotnet test` to confirm all tests pass with a clean build\n3. Optionally remove `TESTINGPLATFORM_HOTRELOAD_ENABLED` from the environment or keep `launchSettings.json` for future use\n\n## Validation\n\n- [ ] Project uses Microsoft Testing Platform (not VSTest)\n- [ ] `Microsoft.Testing.Extensions.HotReload` package is installed\n- [ ] `TESTINGPLATFORM_HOTRELOAD_ENABLED` environment variable is set to `1`\n- [ ] Tests run and the host remains active waiting for changes\n- [ ] Code changes are picked up without manual restart\n\n## Common Pitfalls\n\n| Pitfall | Solution |\n|---------|----------|\n| Using `dotnet test` instead of `dotnet run` | Hot reload requires `dotnet run --project <path>` to run the test host directly in console mode |\n| Project uses VSTest, not MTP | Hot reload requires MTP. Migrate to MTP first or use VS Test Explorer hot reload |\n| Forgetting to set the environment variable | Set `TESTINGPLATFORM_HOTRELOAD_ENABLED=1` before running |\n| Expecting Test Explorer integration | Console mode only -- no VS/VS Code Test Explorer support |\n| Making unsupported code changes (rude edits) | Some changes (adding new types, changing method signatures) require a restart. Stop and re-run |",
  "applicable_domains": [
    "code",
    "dotnet",
    "engineering"
  ],
  "invocation": [
    "/mtp-hot-reload"
  ],
  "tags": [
    "dotnet-test",
    "dotnet",
    "csharp",
    "microsoft"
  ],
  "authored_by": "anthropics",
  "source_url": "https://github.com/dotnet/skills/blob/main/plugins/dotnet-test/skills/mtp-hot-reload/SKILL.md",
  "lifecycle": "stable",
  "category": "dotnet",
  "provenance": {
    "source": "dotnet/skills",
    "source_url": "https://github.com/dotnet/skills/blob/main/plugins/dotnet-test/skills/mtp-hot-reload/SKILL.md",
    "author": "Microsoft / .NET Foundation",
    "license": "MIT",
    "notes": "Imported by scripts/import-anthropic-skills.py."
  }
}