--- topic: examples source_keys: - context7-github-en-copilot - github-plugins-creating - github-custom-agents-configuration - github-sdk-custom-agents - github-cli-plugin-reference - github-plugins-marketplace --- # Examples ## Plugin Directory Structure ``` my-plugin/ ├── plugin.json ├── agents/ │ └── helper.agent.md ├── skills/ │ └── deploy/ │ └── SKILL.md ├── hooks.json └── .mcp.json ``` ## Minimal `plugin.json` ```json { "name": "my-plugin" } ``` ## Full `plugin.json` ```json { "name": "my-dev-tools", "description": "React development utilities", "version": "1.2.0", "author": { "name": "Jane Doe", "email": "jane@example.com" }, "license": "MIT", "keywords": ["react", "frontend"], "agents": "agents/", "skills": ["skills/", "extra-skills/"], "hooks": "hooks.json", "mcpServers": ".mcp.json" } ``` ## CLI Agent Examples ### Read-Only Research Agent ```markdown --- name: researcher description: Explores codebases and answers questions; never modifies files tools: ["search", "read"] --- You are a research assistant. Analyze code and answer questions clearly. Do not modify any files under any circumstances. ``` ### Write-Capable Implementation Agent ```markdown --- name: implementer description: Makes targeted code changes based on provided specifications tools: ["read", "edit", "bash"] --- You are a code editor. Make minimal, surgical changes to files as instructed. Always read the relevant file before editing. ``` ## Cloud / IDE Agent Examples ### Testing Specialist (tool-unrestricted, behavioral constraint) ```markdown --- name: test-specialist description: Focuses on test coverage and quality without modifying production code --- You are a testing specialist. Write tests, identify coverage gaps, and improve test quality. Never modify source files outside of test directories. ``` ### Implementation Planner (tool-restricted) ```markdown --- name: implementation-planner description: Creates detailed implementation plans and technical specifications in markdown tools: ["read", "search", "edit"] --- You are a technical planning specialist. Produce comprehensive implementation plans as structured markdown. Do not execute code or run shell commands. ``` ### Agent with Custom MCP Server ```markdown --- name: db-analyst description: Analyzes database schema and queries using a Postgres MCP server tools: ["read", "search", "custom-db/query"] mcp-servers: custom-db: type: 'local' command: 'pg-mcp-server' args: ['--port', '5432'] tools: ["*"] env: DB_PASSWORD: ${{ secrets.COPILOT_DB_PASSWORD }} --- You are a database analyst. Use the Postgres MCP server to run read-only queries and explain schema structure. ``` ## SDK Examples ### TypeScript — Researcher + Editor Pattern ```typescript import { CopilotClient } from "@github/copilot-sdk"; const client = new CopilotClient(); await client.start(); const session = await client.createSession({ model: "gpt-4.1", customAgents: [ { name: "researcher", displayName: "Research Agent", description: "Explores codebases and answers questions using read-only tools", tools: ["grep", "glob", "view"], prompt: "You are a research assistant. Analyze code and answer questions. Do not modify any files.", }, { name: "editor", displayName: "Editor Agent", description: "Makes targeted code changes", tools: ["view", "edit", "bash"], prompt: "You are a code editor. Make minimal, surgical changes to files as requested.", }, ], onPermissionRequest: async () => ({ kind: "approve-once" }), }); ``` ### Python — Equivalent ```python from copilot import CopilotClient, PermissionDecisionApproveOnce client = CopilotClient() await client.start() session = await client.create_session( model="gpt-4.1", custom_agents=[ { "name": "researcher", "display_name": "Research Agent", "description": "Explores codebases and answers questions using read-only tools", "tools": ["grep", "glob", "view"], "prompt": "You are a research assistant. Analyze code. Do not modify files.", }, { "name": "editor", "display_name": "Editor Agent", "description": "Makes targeted code changes", "tools": ["view", "edit", "bash"], "prompt": "You are a code editor. Make minimal changes.", }, ], on_permission_request=lambda req, inv: PermissionDecisionApproveOnce(), ) ``` ### Pre-Selecting an Agent at Session Start ```typescript const session = await client.createSession({ model: "gpt-4.1", customAgents: [{ name: "researcher", ... }], agent: "researcher", // pre-activates without inference roundtrip onPermissionRequest: async () => ({ kind: "approve-once" }), }); ``` ### Listening to Sub-Agent Lifecycle Events ```typescript session.on((event) => { if (event.type === "subagent.started") { console.log(`Sub-agent started: ${event.agentName} (${event.toolCallId})`); } if (event.type === "subagent.failed") { console.error(`Sub-agent failed: ${event.agentName}`, event.error); } }); ``` ## Hooks Example ```json { "version": 1, "hooks": { "sessionStart": [ { "type": "command", "bash": "echo 'Copilot session started'", "powershell": "Write-Output 'Copilot session started'", "cwd": ".", "timeoutSec": 10 } ] } } ``` ## Marketplace Manifest Example ```json { "name": "my-team-marketplace", "owner": { "name": "My Team", "email": "team@example.com" }, "metadata": { "description": "Internal tools", "version": "1.0.0" }, "plugins": [ { "name": "backend-tools", "source": "./plugins/backend", "version": "1.0.0" }, { "name": "frontend-tools", "source": "./plugins/frontend", "version": "2.1.0" } ] } ``` Register it: `copilot plugin marketplace add myorg/my-team-plugins` ## Cross-Platform LSP Configuration ```json { "lspServers": { "my-lsp": { "bash": "${PLUGIN_ROOT}/scripts/start-lsp.sh", "powershell": "${PLUGIN_ROOT}/scripts/start-lsp.ps1", "fileExtensions": { ".myext": "mylang" } } } } ```