$npx -y skills add managedcode/dotnet-skills --skill technology-selectionGuides technology selection and implementation of AI and ML features in .NET 8+ applications using ML.NET, Microsoft.Extensions.AI (MEAI), Microsoft Agent Framework (MAF), GitHub Copilot SDK, ONNX Runtime, and OllamaSharp. Covers the full spectrum from classic ML through modern L
| 1 | # .NET AI and Machine Learning |
| 2 | |
| 3 | ## Inputs |
| 4 | |
| 5 | | Input | Required | Description | |
| 6 | |-------|----------|-------------| |
| 7 | | Task description | Yes | What the AI/ML feature should accomplish (e.g., "classify support tickets", "summarize documents") | |
| 8 | | Data description | Yes | Type and shape of input data (structured/tabular, unstructured text, images, mixed) | |
| 9 | | Deployment constraints | No | Cloud vs. local, latency SLO, cost budget, offline requirements | |
| 10 | | Existing project context | No | Current .csproj, existing packages, target framework | |
| 11 | |
| 12 | ## Workflow |
| 13 | |
| 14 | ### Step 1: Classify the task using the decision tree |
| 15 | |
| 16 | Evaluate the developer's task against this decision tree and select the appropriate technology. State which branch applies and why. |
| 17 | |
| 18 | | Task type | Technology | Rationale | |
| 19 | |-----------|-----------|-----------| |
| 20 | | Structured/tabular data: classification, regression, clustering, anomaly detection, recommendation | **ML.NET** (`Microsoft.ML`) | Reproducible (given a fixed seed and dataset), no cloud dependency, purpose-built models for these tasks | |
| 21 | | Natural language understanding, generation, summarization, reasoning over unstructured text (single prompt → response, no tool calling) | **LLM via Microsoft.Extensions.AI** (`IChatClient`) | Requires language model capabilities beyond pattern matching; no orchestration needed | |
| 22 | | Agentic workflows: tool/function calling, multi-step reasoning, agent loops, multi-agent collaboration | **Microsoft Agent Framework** (`Microsoft.Agents.AI`) built on top of **Microsoft.Extensions.AI** | Requires orchestration, tool dispatch, iteration control, and guardrails that `IChatClient` alone does not provide | |
| 23 | | Building GitHub Copilot extensions, custom agents, or developer workflow tools | **GitHub Copilot SDK** (`GitHub.Copilot.SDK`) | Integrates with the Copilot agent runtime for IDE and CLI extensibility | |
| 24 | | Running a pre-trained or fine-tuned custom model in production | **ONNX Runtime** (`Microsoft.ML.OnnxRuntime`) | Hardware-accelerated inference, model-format agnostic | |
| 25 | | Local/offline LLM inference with no cloud dependency | **OllamaSharp** with local [AI models supported by Ollama](https://ollama.com/search) | Privacy-sensitive, air-gapped, or cost-constrained scenarios | |
| 26 | | Semantic search, RAG, or embedding storage | **Microsoft.Extensions.VectorData.Abstractions** + a vector database provider (e.g., Azure AI Search, Milvus, MongoDB, pgvector, Pinecone, Qdrant, Redis, SQL) | Provider-agnostic abstractions for vector similarity search; pair with a database-specific connector package (many are moving to community toolkits) | |
| 27 | | Ingesting, chunking, and loading documents into a vector store | **Microsoft.Extensions.AI.DataIngestion** (preview) + **Microsoft.Extensions.VectorData.Abstractions** (MEVD) | Handles document parsing, text chunking, embedding generation, and upserting into a vector database; pairs with Microsoft.Extensions.VectorData.Abstractions | |
| 28 | | Both structured ML predictions AND natural language reasoning | **Hybrid**: ML.NET for predictions + LLM for reasoning layer | Keep loosely coupled; ML.NET handles reproducible scoring, LLM adds explanation | |
| 29 | |
| 30 | **Critical rule:** Do NOT use an LLM for tasks that ML.NET handles well (classification on tabular data, regression, clustering). LLMs are slower, more expensive, and non-deterministic for these tasks. |
| 31 | |
| 32 | ### Step 1b: Select the correct library layer |
| 33 | |
| 34 | After identifying the task type, select the right library layer. These libraries form a stack — each builds on the one below it. Using the wrong layer is a major source of non-deterministic agent behavior. |
| 35 | |
| 36 | | Layer | Library | NuGet package | Use when | |
| 37 | |-------|---------|---------------|----------| |
| 38 | | **Abstraction** | Microsoft.Extensions.AI (MEAI) | `Microsoft.Extensions.AI` | You need a provider-agnostic interface for chat, embeddings, or tool calling. This is the foundation — always include it. Use `IChatClient` directly **only** for simple prompt-in/response-out scenarios with no tool calling or agentic loops. If the task |