{
  "schema": "https://ai-atoms.com/schemas/skill-v1.json",
  "type": "skill",
  "id": "skill/code-testing-agent",
  "version": "1.0.1",
  "name": "code-testing-agent",
  "description": "ALWAYS USE whenever asked to write, add, or generate unit tests for existing code, including one helper, function, class, or missing regression case as well as project-wide suites. Also use for \"cover this untested method\", scaffolding tests where none exist, sparse workspaces, classic packages.config MSTest, and extending healthy suites. Focused requests use a proportional direct workflow; broad requests use the full pipeline. DO NOT USE for only running/diagnosing tests, coverage/audits, a test blocked on a missing production seam (testability-obstacle), or correcting supplied MSTest assertions, attributes, lifecycle, or configuration without designing new cases (writing-mstest-tests).",
  "system_prompt_fragment": "# Code Testing Generation Skill\n\nAn AI-powered skill that generates comprehensive, workable unit tests for any programming language using a coordinated multi-agent pipeline.\n\n## When to Use This Skill\n\nUse this skill when you need to:\n\n- Generate unit tests for an entire project or specific files\n- Improve test coverage for existing codebases\n- Create test files that follow project conventions\n- Write tests that actually compile and pass\n- Add tests for new features or untested code\n\n## When Not to Use\n\n- Running or executing existing tests (use the `run-tests` skill)\n- Migrating between test frameworks (use migration skills)\n- Writing tests specifically for MSTest patterns (use `writing-mstest-tests`)\n- Debugging failing test logic\n\n## How It Works\n\nThis skill coordinates multiple specialized agents in a **Research → Plan → Implement** pipeline:\n\n### Pipeline Overview\n\n```text\n┌─────────────────────────────────────────────────────────────┐\n│                     TEST GENERATOR                          │\n│  Coordinates the full pipeline and manages state            │\n└─────────────────────┬───────────────────────────────────────┘\n                      │\n        ┌─────────────┼─────────────┐\n        ▼             ▼             ▼\n┌───────────┐  ┌───────────┐  ┌───────────────┐\n│ RESEARCHER│  │  PLANNER  │  │  IMPLEMENTER  │\n│           │  │           │  │               │\n│ Analyzes  │  │ Creates   │  │ Writes tests  │\n│ codebase  │→ │ phased    │→ │ per phase     │\n│           │  │ plan      │  │               │\n└───────────┘  └───────────┘  └───────┬───────┘\n                                      │\n                    ┌─────────┬───────┼───────────┐\n                    ▼         ▼       ▼           ▼\n              ┌─────────┐ ┌───────┐ ┌───────┐ ┌───────┐\n              │ BUILDER │ │TESTER │ │ FIXER │ │LINTER │\n              │         │ │       │ │       │ │       │\n              │ Compiles│ │ Runs  │ │ Fixes │ │Formats│\n              │ code    │ │ tests │ │ errors│ │ code  │\n              └─────────┘ └───────┘ └───────┘ └───────┘\n```\n\n## Step-by-Step Instructions\n\n### Step 1: Determine the user request\n\nMake sure you understand what user is asking and for what scope.\nWhen the user does not express strong requirements for test style, coverage goals, or conventions, source the guidelines from [unit-test-generation.prompt.md](unit-test-generation.prompt.md). This prompt provides best practices for discovering conventions, parameterization strategies, coverage goals (aim for 80%), and language-specific patterns.\n\n### Step 2: Invoke the Test Generator\n\nStart by calling the `code-testing-generator` agent with your test generation request:\n\n```text\nGenerate unit tests for [path or description of what to test], following the [unit-test-generation.prompt.md](unit-test-generation.prompt.md) guidelines\n```\n\nThe Test Generator will manage the entire pipeline automatically.\n\n### Step 3: Research Phase (Automatic)\n\nThe `code-testing-researcher` agent analyzes your codebase to understand:\n\n- **Language & Framework**: Detects C#, TypeScript, Python, Go, Rust, Java, etc.\n- **Testing Framework**: Identifies MSTest, xUnit, Jest, pytest, go test, etc.\n- **Project Structure**: Maps source files, existing tests, and dependencies\n- **Build Commands**: Discovers how to build and test the project\n\nOutput: `.testagent/research.md`\n\n### Step 4: Planning Phase (Automatic)\n\nThe `code-testing-planner` agent creates a structured implementation plan:\n\n- Groups files into logical phases (2-5 phases typical)\n- Prioritizes by complexity and dependencies\n- Specifies test cases for each file\n- Defines success criteria per phase\n\nOutput: `.testagent/plan.md`\n\n### Step 5: Implementation Phase (Automatic)\n\nThe `code-testing-implementer` agent executes each phase sequentially:\n\n1. **Read** source files to understand the API\n2. **Write** test files following project patterns\n3. **Build** using the `code-testing-builder` sub-agent to verify compilation\n4. **Test** using the `code-testing-tester` sub-agent to verify tests pass\n5. **Fix** using the `code-testing-fixer` sub-agent if errors occur\n6. **Lint** using the `code-testing-linter` sub-agent for code formatting\n\nEach phase completes before the next begins, ensuring incremental progress.\n\n### Coverage Types\n\n- **Happy path**: Valid inputs produce expected outputs\n- **Edge cases**: Empty values, boundaries, special characters\n- **Error cases**: Invalid inputs, null handling, exceptions\n\n## State Management\n\nAll pipeline state is stored in `.testagent/` folder:\n\n| File                     | Purpose                      |\n| ------------------------ | ---------------------------- |\n| `.testagent/research.md` | Codebase analysis results    |\n| `.testagent/plan.md`     | Phased implementation plan   |\n| `.testagent/status.md`   | Progress tracking (optional) |\n\n## Examples\n\n### Strategy Selection\n\nThe generator picks a strategy based on request scope:\n\n| User Request | Strategy | Why |\n|---|---|---|\n| \"Generate tests for `src/services/UserService.ts`\" | **Direct** | Single file, small scope — write tests immediately, skip sub-agents |\n| \"Add unit tests for my billing project\" | **Single pass** | Moderate scope — one Research → Plan → Implement cycle covers it |\n| \"Achieve 80% coverage across the entire solution\" | **Iterative** | Large scope — multiple R→P→I cycles, each narrowing remaining gaps |\n\n### Pipeline Walkthrough\n\nGiven a request like *\"Generate unit tests for my InvoiceService\"*, the pipeline produces:\n\n1. **Research** → `.testagent/research.md` containing detected language/framework, build commands, files to test ranked by priority, and existing test inventory\n2. **Plan** → `.testagent/plan.md` containing phased approach with specific methods and test scenarios (happy path, edge cases, error cases) for each file\n3. **Implement** → Test files written, built, and verified per phase. Fix cycle runs automatically if build/test errors occur\n4. **Validate** → Full workspace build + full test run to catch cross-project issues\n5. **Report** → Summary of tests created, pass/fail counts, coverage notes, and next steps\n\n### Language-Specific Examples\n\nThe `code-testing-extensions` skill provides concrete, filled-in examples for each pipeline phase showing real source code, real research output, real plans, and real generated tests. Call the `code-testing-extensions` skill to discover available extension files, then read:\n\n- **`dotnet-examples.md`** — MSTest example with InvoiceService: research output, plan output, generated test file, fix cycle walkthrough, and final report\n\n## Agent Reference\n\n| Agent                      | Purpose              |\n| -------------------------- | -------------------- |\n| `code-testing-generator`   | Coordinates pipeline |\n| `code-testing-researcher`  | Analyzes codebase    |\n| `code-testing-planner`     | Creates test plan    |\n| `code-testing-implementer` | Writes test files    |\n| `code-testing-builder`     | Compiles code        |\n| `code-testing-tester`      | Runs tests           |\n| `code-testing-fixer`       | Fixes errors         |\n| `code-testing-linter`      | Formats code         |\n\n## Requirements\n\n- Project must have a build/test system configured\n- Testing framework should be installed (or installable)\n- VS Code with GitHub Copilot extension\n\n## Troubleshooting\n\n### Tests don't compile\n\nThe `code-testing-fixer` agent will attempt to resolve compilation errors. Check `.testagent/plan.md` for the expected test structure. Call the `code-testing-extensions` skill and read the language-specific extension file for error code references (e.g., `dotnet.md` for .NET).\n\n### Tests fail\n\nMost failures in generated tests are caused by **wrong expected values in assertions**, not production code bugs:\n\n1. Read the actual test output\n2. Read the production code to understand correct behavior\n3. Fix the assertion, not the production code\n4. Never mark tests `[Ignore]` or `[Skip]` just to make them pass\n\n### Wrong testing framework detected\n\nSpecify your preferred framework in the initial request: \"Generate Jest tests for...\"\n\n### Environment-dependent tests fail\n\nTests that depend on external services, network endpoints, specific ports, or precise timing will fail in CI environments. Focus on unit tests with mocked dependencies instead.\n\n### Build fails on full solution\n\nDuring phase implementation, build only the specific test project for speed. After all phases, run a full non-incremental workspace build to catch cross-project errors.",
  "applicable_domains": [
    "code",
    "dotnet",
    "engineering"
  ],
  "invocation": [
    "/code-testing-agent"
  ],
  "tags": [
    "dotnet-test",
    "dotnet",
    "csharp",
    "microsoft"
  ],
  "authored_by": "anthropics",
  "source_url": "https://github.com/dotnet/skills/blob/main/plugins/dotnet-test/skills/code-testing-agent/SKILL.md",
  "lifecycle": "stable",
  "category": "dotnet",
  "provenance": {
    "source": "dotnet/skills",
    "source_url": "https://github.com/dotnet/skills/blob/main/plugins/dotnet-test/skills/code-testing-agent/SKILL.md",
    "author": "Microsoft / .NET Foundation",
    "license": "MIT",
    "notes": "Imported by scripts/import-anthropic-skills.py."
  }
}