Microsoft Code Reference

Microsoft Code Reference

Looks up Microsoft API references and official code samples through Microsoft Learn tools to verify SDK calls and catch hallucinated methods.

Skill files1 file
SKILL.md100 lines
1
---
2
name: microsoft-code-reference
3
description: Look up Microsoft API references, find working code samples, and verify SDK code is correct. Use when working with Azure SDKs, .NET libraries, or Microsoft APIs—to find the right method, check parameters, get working examples, or troubleshoot errors. Catches hallucinated methods, wrong signatures, and deprecated patterns by querying official docs.
4
compatibility: Works best with Microsoft Learn MCP Server (https://learn.microsoft.com/api/mcp). Can also use the mslearn CLI as a fallback.
5
---
6
7
# Microsoft Code Reference
8
9
## Tools
10
11
| Need | Tool | Example |
12
|------|------|---------|
13
| API method/class lookup | `microsoft_docs_search` | `"BlobClient UploadAsync Azure.Storage.Blobs"` |
14
| Working code sample | `microsoft_code_sample_search` | `query: "upload blob managed identity", language: "python"` |
15
| Full API reference | `microsoft_docs_fetch` | Fetch URL from `microsoft_docs_search` (for overloads, full signatures) |
16
17
## Finding Code Samples
18
19
Use `microsoft_code_sample_search` to get official, working examples:
20
21
```
22
microsoft_code_sample_search(query: "upload file to blob storage", language: "csharp")
23
microsoft_code_sample_search(query: "authenticate with managed identity", language: "python")
24
microsoft_code_sample_search(query: "send message service bus", language: "javascript")
25
```
26
27
**When to use:**
28
- Before writing code—find a working pattern to follow
29
- After errors—compare your code against a known-good sample
30
- Unsure of initialization/setup—samples show complete context
31
32
## API Lookups
33
34
```
35
# Verify method exists (include namespace for precision)
36
"BlobClient UploadAsync Azure.Storage.Blobs"
37
"GraphServiceClient Users Microsoft.Graph"
38
39
# Find class/interface
40
"DefaultAzureCredential class Azure.Identity"
41
42
# Find correct package
43
"Azure Blob Storage NuGet package"
44
"azure-storage-blob pip package"
45
```
46
47
Fetch full page when method has multiple overloads or you need complete parameter details.
48
49
## Error Troubleshooting
50
51
Use `microsoft_code_sample_search` to find working code samples and compare with your implementation. For specific errors, use `microsoft_docs_search` and `microsoft_docs_fetch`:
52
53
| Error Type | Query |
54
|------------|-------|
55
| Method not found | `"[ClassName] methods [Namespace]"` |
56
| Type not found | `"[TypeName] NuGet package namespace"` |
57
| Wrong signature | `"[ClassName] [MethodName] overloads"` → fetch full page |
58
| Deprecated warning | `"[OldType] migration v12"` |
59
| Auth failure | `"DefaultAzureCredential troubleshooting"` |
60
| 403 Forbidden | `"[ServiceName] RBAC permissions"` |
61
62
## When to Verify
63
64
Always verify when:
65
- Method name seems "too convenient" (`UploadFile` vs actual `Upload`)
66
- Mixing SDK versions (v11 `CloudBlobClient` vs v12 `BlobServiceClient`)
67
- Package name doesn't follow conventions (`Azure.*` for .NET, `azure-*` for Python)
68
- Using an API for the first time
69
70
## Validation Workflow
71
72
Before generating code using Microsoft SDKs, verify it's correct:
73
74
1. **Confirm method or package exists** — `microsoft_docs_search(query: "[ClassName] [MethodName] [Namespace]")`
75
2. **Fetch full details** (for overloads/complex params) — `microsoft_docs_fetch(url: "...")`
76
3. **Find working sample** — `microsoft_code_sample_search(query: "[task]", language: "[lang]")`
77
78
For simple lookups, step 1 alone may suffice. For complex API usage, complete all three steps.
79
80
## CLI Alternative
81
82
If the Learn MCP server is not available, use the `mslearn` CLI from a terminal or shell (for example, Bash, PowerShell, or cmd) instead:
83
84
```sh
85
# Run directly (no install needed)
86
npx @microsoft/learn-cli search "BlobClient UploadAsync Azure.Storage.Blobs"
87
88
# Or install globally, then run
89
npm install -g @microsoft/learn-cli
90
mslearn search "BlobClient UploadAsync Azure.Storage.Blobs"
91
```
92
93
| MCP Tool | CLI Command |
94
|----------|-------------|
95
| `microsoft_docs_search(query: "...")` | `mslearn search "..."` |
96
| `microsoft_code_sample_search(query: "...", language: "...")` | `mslearn code-search "..." --language ...` |
97
| `microsoft_docs_fetch(url: "...")` | `mslearn fetch "..."` |
98
99
Pass `--json` to `search` or `code-search` to get raw JSON output for further processing.
100

© GitHub, Inc. · MIT · source · posted by @OpenSourceBuffGuy on promptparty.com

@OpenSourceBuffGuy

I find openly licensed prompts and post them here.

0 followers · 13,408 prompts

More by @OpenSourceBuffGuy

See all
Overhead portrait of a girl lying in snow prompt image

Overhead portrait of a girl lying in snow

Creates an overhead portrait of a girl in a school blazer lying in fresh snow, using a JSON spec that keeps the reference face and sets camera, outfit and soft overcast light.

image-prompt, json-prompt, nano-banana, reference-image, face-reference, negative-prompt, photorealistic, portrait, woman, close-up, high-angle, winter, soft-lighting, natural-light, bokeh, moody, editorial, vertical-format, muted-colors, limited-palette, film-grain, cinematic, structured-output, for-photographers, for-artists

Morning skincare ritual ending on serum hero shot prompt image

Morning skincare ritual ending on serum hero shot

Produces a 15-second skincare commercial from an uploaded storyboard, with eight timed match-cut shots ending on a serum hero shot.

video-prompt, video-ad, product-video, multi-shot, timed-beats, scene-transitions, camera-movement, macro, reference-image, storyboard, character-consistency, skincare, beauty, advertising, photorealistic, cinematic, natural-light, woman, hailuo, tracking-shot, slow-motion, for-marketers, long-form

Isometric Floating Country Map Dioramas prompt image

Isometric Floating Country Map Dioramas

Draws an isometric miniature diorama of a country as a single floating map, split into regions with their own climates and architecture, joined by winding roads.

image-prompt, nano-banana, isometric, maps, miniature, landscape, architecture, placeholders, template, photorealistic, cinematic, soft-lighting, landmarks, geography, 3d-render, negative-prompt, architectural-rendering, aerial-view, high-angle, travel, vibrant-colors

Reviews

Loading reviews…

Discussion

Loading comments…