Microsoft Learn
Search official Microsoft documentation via the mslearn CLI (@microsoft/learn-cli).
Setup
CODEBLOCK0
If not installed, prefix commands with npx @microsoft/learn-cli instead of mslearn.
Commands
search — Find documentation
CODEBLOCK1
Returns up to 10 results with title, URL, and content excerpt.
code-search — Find working code samples
CODEBLOCK2
Supported languages: csharp, javascript, typescript, python, powershell, java, go, rust, ruby, INLINECODE13
fetch — Get full page content
CODEBLOCK3
When to use which
- 1. User asks a concept/how-to question → INLINECODE14
- User needs code examples or is debugging →
code-search with INLINECODE16 - You already have a docs URL and need details → INLINECODE17
- Search results are too brief →
fetch the URL from search results
Tips
- - Add
--json for machine-readable output when chaining with other tools. - If no results, rephrase with more specific Microsoft product names.
- Prefer
code-search over search when the user is actively writing code.
Microsoft Learn
通过 mslearn CLI(@microsoft/learn-cli)搜索官方 Microsoft 文档。
安装
bash
npm install -g @microsoft/learn-cli
若未安装,请在命令前添加 npx @microsoft/learn-cli 代替 mslearn。
命令
search — 查找文档
bash
mslearn search Azure Functions Python v2 programming model
返回最多 10 条结果,包含标题、URL 和内容摘要。
code-search — 查找工作代码示例
bash
mslearn code-search upload file to blob storage --language csharp
支持的语言:csharp、javascript、typescript、python、powershell、java、go、rust、ruby、php
fetch — 获取完整页面内容
bash
mslearn fetch https://learn.microsoft.com/... [--section heading] [--max-chars 5000]
使用场景选择
- 1. 用户询问概念/操作方法问题 → 使用 search
- 用户需要代码示例或正在调试 → 使用带 --language 参数的 code-search
- 已有文档 URL 并需要详细信息 → 使用 fetch
- 搜索结果过于简略 → 使用 fetch 获取搜索结果中的 URL
提示
- - 与其他工具链式使用时,添加 --json 参数以获取机器可读的输出。
- 若无结果,请使用更具体的 Microsoft 产品名称重新表述。
- 当用户正在编写代码时,优先使用 code-search 而非 search。