How to Use Prompts with the GitHub Copilot SDK
How to Use Prompts with the GitHub Copilot SDK
The GitHub Copilot SDK (announced January 2026, technical preview) brings Copilotβs agentic loop to any applicationβnot just VS Code or the CLI. Available for Node.js, Python, Go, and .NET, it lets you embed the same agent runtime that powers Copilot Chat into your own apps.
This article focuses on how SDK-based applications consume the same prompt engineering artifacts documented throughout this series: prompt files, instruction files, agent definitions, skills, and MCP servers. If youβve been following articles 01β13, everything youβve learned applies directly to SDK apps.
Table of Contents
- π― What the SDK is and how it differs
- ποΈ Architecture overview
- β‘ Setting up the SDK
- π Prompt file consumption in SDK apps
- π€ Agent definitions and skill files
- π Instruction files for behavioral constraints
- π MCP server integration
- ποΈ Multi-model routing
- πΎ Memory and persistence
- π§ Practical example: documentation review agent
- β οΈ Limitations and considerations
- π― Conclusion
- π References
π― What the SDK is and how it differs
Editor vs. SDK: two surfaces, one prompt format
The key insight for prompt engineers is simple: the SDK consumes the same files you already write.
| Surface | How you interact | Prompt discovery | Tool access |
|---|---|---|---|
| VS Code | Chat panel, slash commands | /promptName from .github/prompts/ |
Built-in + MCP servers |
| Copilot CLI | Terminal commands | Workspace scanning | Built-in + MCP servers |
| SDK Apps | Programmatic API calls | Workspace scanning via SDK client | Custom tools + MCP servers |
The SDK doesnβt introduce a new prompt format. It reuses .prompt.md, .agent.md, .instructions.md, and SKILL.md files exactly as documented in articles 01β06 of this series.
Whatβs different
The SDK surface lacks an editor UI, which means:
- β No
#filereferences (thereβs no file picker) - β No slash commands or hashtag commands (thereβs no chat input with autocomplete)
- β No chat modes (Agent, Plan, Ask, Edit)
- β Prompts are loaded programmatically or via workspace scanning
- β All behavioral rules from instruction files still apply
- β MCP servers work identically
ποΈ Architecture overview
The SDK uses a client-server architecture where your application communicates with the Copilot CLI running in server mode:
βββββββββββββββββββββββββββ
β Your Application β
β (Node.js/Python/Go/.NET) β
ββββββββββ¬βββββββββββββββββ
β JSON-RPC
βΌ
βββββββββββββββββββββββββββ
β Copilot CLI β
β (server mode) β
β β
β βββββββββββββββββββββ β
β β Prompt Files β β
β β Agent Definitions β β
β β Instruction Files β β
β β MCP Servers β β
β βββββββββββββββββββββ β
ββββββββββ¬βββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββ
β Copilot API β Models β
β (GPT-5, Claude, etc.) β
βββββββββββββββββββββββββββ
The SDK manages the CLI process lifecycle automatically. The CLI performs workspace scanning to discover your prompt engineering artifactsβjust as it would when running in terminal mode.
β‘ Setting up the SDK
Prerequisites
- GitHub Copilot subscription β Required (free tier available with limited usage)
- Copilot CLI β Must be installed separately; the SDK communicates with it in server mode
- Supported runtime β Node.js 18+, Python 3.10+, Go 1.21+, or .NET 8.0+
Installation
# Node.js / TypeScript
npm install @github/copilot-sdk
# Python
pip install github-copilot-sdk
# Go
go get github.com/github/copilot-sdk/go
# .NET
dotnet add package GitHub.Copilot.SDKQuick start (TypeScript)
import { CopilotClient } from "@github/copilot-sdk";
// Initialize and start the client
const client = new CopilotClient();
await client.start();
// Create a session with a specific model
const session = await client.createSession({
model: "gpt-5",
});
// Send a prompt
const response = await session.send({
prompt: "Review this code for security vulnerabilities",
});Quick start (Python)
from github_copilot_sdk import CopilotClient
# Initialize and start the client
client = CopilotClient()
await client.start()
# Create a session
session = await client.create_session(model="claude-sonnet-4")
# Send a prompt
response = await session.send(
prompt="Analyze this architecture for scalability issues"
)Quick start (.NET)
using GitHub.Copilot.SDK;
// Initialize and start the client
var client = new CopilotClient();
await client.StartAsync();
// Create a session
var session = await client.CreateSessionAsync(new SessionOptions
{
Model = "gpt-5"
});
// Send a prompt
var response = await session.SendAsync("Review this code for security issues");π Prompt file consumption in SDK apps
Workspace detection
When the SDK client starts, the CLI server scans the workspace for prompt files. The scanning follows the same rules documented in article 01:
.github/prompts/*.prompt.mdβ Workspace prompt files.github/instructions/*.instructions.mdβ Path-specific instruction files.github/copilot-instructions.mdβ Repo-level instructions.github/agents/*.agent.mdβ Agent definitions.github/skills/*/SKILL.mdβ Agent skills
Loading prompts programmatically
The most common pattern in SDK apps is to load prompt content directly rather than relying on slash commands:
import { readFileSync } from "fs";
import { CopilotClient } from "@github/copilot-sdk";
// Load your prompt file content
const promptContent = readFileSync(
".github/prompts/security-review.prompt.md",
"utf-8"
);
const client = new CopilotClient();
await client.start();
const session = await client.createSession({ model: "gpt-5" });
// Send the prompt content as a message
await session.send({ prompt: promptContent });YAML frontmatter in SDK context
The YAML frontmatter fields in .prompt.md files behave differently in SDK apps:
| Field | VS Code behavior | SDK behavior |
|---|---|---|
name |
Sets slash command name | Used for identification only |
description |
Shown in picker | Metadata only |
agent |
Sets chat mode | Agent definitions still applied |
model |
Sets session model | Respected if session allows override |
tools |
Restricts available tools | Restricts available tools β |
The tools field is particularly important for SDK appsβit provides the same tool restriction behavior as in VS Code, ensuring your prompts donβt access tools they shouldnβt.
π€ Agent definitions and skill files
Using agents with the SDK
Agent definitions (.agent.md) work in SDK apps by defining specialized personas with restricted tool sets. The SDK client can switch between agents just as VS Code switches chat modes:
const session = await client.createSession({
model: "claude-opus-4.6",
agent: "security-reviewer", // References .github/agents/security-reviewer.agent.md
});The agentβs system prompt, tool restrictions, and behavioral instructions are automatically loaded from the .agent.md file. All the agent design patterns from article 04 apply directly.
Using skills with the SDK
Agent Skills (SKILL.md) are automatically discovered by the CLIβs workspace scanning. The SDK client can invoke skills that match the userβs intent:
// The CLI automatically matches skills based on the prompt content
await session.send({
prompt: "Create a new article following our documentation standards",
// The CLI identifies and loads the matching SKILL.md
});For details on creating effective skills, see article 06.
π Instruction files for behavioral constraints
Instruction files (.instructions.md) are automatically applied by the CLI server based on applyTo glob patternsβexactly as in VS Code. You donβt need to load them manually.
How it works in SDK apps
- The CLI server scans
.github/instructions/for instruction files - The
applyTopattern in the YAML frontmatter determines which files trigger the instructions - When your SDK app references a file matching the pattern, the instructions are injected into the context
This means all the instruction file patterns from article 05 work without modification.
Example: enforcing coding standards
If your workspace has .github/instructions/csharp.instructions.md with:
---
applyTo: "**/*.cs"
---Then whenever the SDK session involves C# files, those instructions are automatically appliedβthe same behavior youβd see in VS Code.
π MCP server integration
MCP servers are a first-class feature of the SDK. They work identically to VS Codeβs MCP integration (see article 07 for building MCP servers).
Configuration
MCP servers are configured via mcp.json in your workspace, the same file VS Code uses:
{
"servers": {
"my-validation-server": {
"command": "dotnet",
"args": ["run", "--project", "src/McpServer/"]
}
}
}The SDK client automatically discovers and connects to MCP servers defined in mcp.json.
Tool call flow
SDK App β sends prompt β CLI Server β calls model β model requests tool
β
MCP Server executes tool
β
result flows back to model
β
response to SDK App
The model handles tool invocation planningβyou donβt need to manually orchestrate tool calls. The agentic loop in the CLI server manages the conversation turn, tool calls, and follow-up reasoning automatically.
ποΈ Multi-model routing
The SDK supports model selection per session, enabling the multi-model architecture patterns described in article 08.
Available models
SDK apps access models through the Copilot subscription, which currently includes:
| Model | Provider | Best for |
|---|---|---|
| GPT-4o | OpenAI | General tasks, fast responses |
| GPT-5 | OpenAI | Complex reasoning, broad domains |
| o3 / o4-mini | OpenAI | Mathematical and scientific reasoning |
| Claude Sonnet 4 | Anthropic | Balanced coding and analysis |
| Claude Opus 4.6 | Anthropic | Frontier agentic tasks, multi-step workflows |
| Gemini 2.0 Flash | Fast inference, multimodal |
Model-per-task pattern
// Use a fast model for simple classification
const triageSession = await client.createSession({ model: "gpt-4o" });
const category = await triageSession.send({
prompt: "Classify this issue: " + issueText,
});
// Use a frontier model for complex analysis
const analysisSession = await client.createSession({ model: "claude-opus-4.6" });
const analysis = await analysisSession.send({
prompt: "Perform deep security analysis on: " + codeText,
});πΎ Memory and persistence
The SDK provides persistent conversational memory across interactions within a session:
- Session persistence β Context is maintained across multiple
send()calls within the same session - Intelligent compaction β The SDK automatically compacts context when approaching token limits, preserving the most relevant information
- Infinite sessions β Long-running workflows donβt fail from context overflow; the SDK manages compaction transparently
// Multi-turn conversation with persistent context
const session = await client.createSession({ model: "gpt-5" });
await session.send({ prompt: "Read the file src/auth/handler.ts" });
await session.send({ prompt: "What security issues do you see?" });
await session.send({ prompt: "Fix the SQL injection vulnerability you found" });
// Each turn has full context from previous turnsπ§ Practical example: documentation review agent
Hereβs an end-to-end example that combines prompt files, agent definitions, and MCP servers to build a documentation review agent:
1. Agent definition
Create .github/agents/doc-reviewer.agent.md:
---
name: doc-reviewer
description: Reviews documentation articles for quality and consistency
tools:
- read_file
- grep_search
- mcp: iqpilot
---
You're a documentation reviewer that checks articles against the team's writing
standards. For each article, check:
1. Structure follows the DiβΓtaxis framework
2. References are properly classified
3. YAML frontmatter is complete
4. Writing tone matches Microsoft Voice Principles2. Instruction file
The existing .github/instructions/documentation.instructions.md automatically applies to all .md filesβno changes needed.
3. SDK application
import { CopilotClient } from "@github/copilot-sdk";
import { readdirSync } from "fs";
async function reviewArticles() {
const client = new CopilotClient();
await client.start();
// Create a session using the doc-reviewer agent
const session = await client.createSession({
model: "claude-opus-4.6",
agent: "doc-reviewer",
});
// Find all articles to review
const articles = readdirSync("03.00-tech/05.02-prompt-engineering/")
.filter((f) => f.endsWith(".md"));
for (const article of articles) {
const result = await session.send({
prompt: `Review the article: 03.00-tech/05.02-prompt-engineering/${article}`,
});
console.log(`Review for ${article}:`, result);
}
await client.stop();
}
reviewArticles();This example leverages:
- Agent definition β The
doc-reviewer.agent.mdprovides the review persona and tool restrictions - Instruction files β Documentation standards are automatically injected via
applyTopatterns - MCP server β The IQPilot MCP server provides validation tools
- Model choice β Claude Opus 4.6 handles the nuanced writing analysis
β οΈ Limitations and considerations
Technical preview status
The GitHub Copilot SDK is in technical preview as of February 2026. This means:
- β οΈ APIs may change in future releases
- β οΈ Not recommended for production workloads without fallback strategies
- β οΈ Feature parity across languages may vary during preview
Billing
SDK usage follows the same billing as Copilot CLI:
- Each prompt counts toward your premium request quota
- Enterprise and individual plans have different quotas
- For details, see Requests in GitHub Copilot
Network dependency
The SDK requires connectivity to the Copilot serviceβit canβt run fully offline. The CLI server communicates with GitHubβs API for authentication and model access.
Differences from VS Code
| Feature | VS Code | SDK Apps |
|---|---|---|
Interactive file picker (#file) |
β | β |
| Visual diff review | β | β |
| Chat history UI | β | β (you manage) |
| Terminal integration | β | β (you manage) |
| Prompt discovery UI | β | β (programmatic) |
| MCP servers | β | β |
| Agent definitions | β | β |
| Instruction files | β | β |
π― Conclusion
The GitHub Copilot SDK extends the prompt engineering practices youβve learned throughout this series to any application surface. The key takeaways:
- Same files, new surface β
.prompt.md,.agent.md,.instructions.md, andSKILL.mdfiles work in SDK apps without modification - Programmatic control β You get fine-grained control over session creation, model selection, and tool availability
- MCP integration β Your custom MCP servers work identically in SDK apps
- Multi-model routing β Apply the model-per-task patterns from article 08 with full flexibility
- Preview status β The SDK is in technical preview; expect API evolution
Next in the series: Articles 15 and 16 will cover testing/iterating on prompts and versioning prompt librariesβtopics that become even more critical when prompts are consumed by SDK applications.
π References
GitHub Copilot SDK Repository π [Official]
The official SDK repository with installation guides, API references, and starter examples for all four supported languages.
GitHub Copilot SDK β Building Agents for Any Application π [Verified Community]
Detailed analysis of the SDK announcement with architecture diagrams, comparison tables, and practical implications.
Requests in GitHub Copilot π [Official]
Official GitHub documentation on billing and premium request quotas for Copilot CLI and SDK usage.
Model Context Protocol Specification π [Official]
The MCP standard specification. SDK apps use MCP servers identically to VS Code.
How GitHub Copilot Uses Markdown and Prompt Folders π [Verified Community]
The series overview article covering all Copilot customization surfaces, now updated with SDK Apps support.