### Initialize and use Copilot client (Go) Source: https://github.com/github/docs/blob/main/content/copilot/how-tos/copilot-sdk/setup/bundled-cli.md Create a new Copilot client, start it, and defer stopping it. Then, create a session with a specified model and send a message to get a response. The Go SDK requires separate CLI installation. ```go package main import ( "context" "fmt" "log" copilot "github.com/github/copilot-sdk/go" ) func main() { ctx := context.Background() client := copilot.NewClient(nil) if err := client.Start(ctx); err != nil { log.Fatal(err) } defer client.Stop() session, _ := client.CreateSession(ctx, &copilot.SessionConfig{Model: "gpt-4.1"}) response, _ := session.SendAndWait(ctx, copilot.MessageOptions{Prompt: "Hello!"}) if d, ok := response.Data.(*copilot.AssistantMessageData); ok { fmt.Println(d.Content) } } ``` ```go client := copilot.NewClient(nil) if err := client.Start(ctx); err != nil { log.Fatal(err) } defer client.Stop() session, _ := client.CreateSession(ctx, &copilot.SessionConfig{Model: "gpt-4.1"}) response, _ := session.SendAndWait(ctx, copilot.MessageOptions{Prompt: "Hello!"}) if d, ok := response.Data.(*copilot.AssistantMessageData); ok { fmt.Println(d.Content) } ``` -------------------------------- ### Preinstalling Dependencies with Copilot Setup Steps Source: https://github.com/github/docs/blob/main/content/copilot/how-tos/copilot-on-github/customize-copilot/customize-cloud-agent/customize-the-agent-environment.md Use a `copilot-setup-steps` job in your workflow to deterministically install tools and dependencies before Copilot starts. This ensures that necessary packages are available, especially for private dependencies. ```yaml jobs: copilot-setup-steps: runs-on: ubuntu-latest steps: - name: Install dependencies run: | npm install pip install -r requirements.txt ``` -------------------------------- ### Session Start Hook Example Source: https://github.com/github/docs/blob/main/data/reusables/copilot/cloud-agent/create-hooks-instructions.md This example demonstrates how to use the `sessionStart` hook to log the session start date to a file. It includes configurations for both bash (Linux/macOS) and PowerShell (Windows). ```json "sessionStart": [ { "type": "command", "bash": "echo \"Session started: $(date)\" >> logs/session.log", "powershell": "Add-Content -Path logs/session.log -Value \"Session started: $(Get-Date)\"", "cwd": ".", "timeoutSec": 10 } ], ``` -------------------------------- ### Start Copilot Client (Python) Source: https://github.com/github/docs/blob/main/src/fixtures/fixtures/content/get-started/liquid/code-tabs-test.md Starts the Copilot client. This is a common setup step before creating sessions. ```python client = CopilotClient() await client.start() ``` -------------------------------- ### Start {% data variables.product.prodname_ghe_server %} VM (PowerShell) Source: https://github.com/github/docs/blob/main/content/admin/installing-your-enterprise-server/setting-up-a-github-enterprise-server-instance/installing-github-enterprise-server-on-hyper-v.md This PowerShell command starts the virtual machine that will host the {% data variables.product.prodname_ghe_server %} instance. After starting the VM, you can proceed to get its IP address for further configuration. ```powershell PS C:\> Start-VM -Name VM_NAME ``` -------------------------------- ### Install Go Dependencies Source: https://github.com/github/docs/blob/main/content/actions/tutorials/build-and-test-code/go.md Shows how to install project dependencies using the go get command within a workflow step. This assumes a prior checkout and Go setup step. ```yaml steps: - uses: {% data reusables.actions.action-checkout %} - name: Setup Go uses: {% data reusables.actions.action-setup-go %} with: go-version: '1.21.x' - name: Install dependencies run: | go get . go get example.com/octo-examplemodule go get example.com/octo-examplemodule@v1.3.4 ``` -------------------------------- ### Initialize Go Project and Install SDK Source: https://github.com/github/docs/blob/main/content/copilot/how-tos/copilot-sdk/getting-started.md Set up a new Go project and install the GitHub Copilot SDK for Go. ```bash mkdir copilot-demo && cd copilot-demo go mod init copilot-demo go get github.com/github/copilot-sdk/go ``` -------------------------------- ### Quick Start: Filesystem MCP Server Example Source: https://github.com/github/docs/blob/main/content/copilot/how-tos/copilot-sdk/features/mcp.md A complete example demonstrating how to create a session with a local filesystem MCP server using the Copilot SDK. This includes setting up the server command, arguments, and tool access, then sending a prompt to interact with the filesystem. ```typescript import { CopilotClient } from "@github/copilot-sdk"; async function main() { const client = new CopilotClient(); // Create session with filesystem MCP server const session = await client.createSession({ mcpServers: { filesystem: { type: "local", command: "npx", args: ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"], tools: ["*"], }, }, }); console.log("Session created:", session.sessionId); // The model can now use filesystem tools const result = await session.sendAndWait({ prompt: "List the files in the allowed directory", }); console.log("Response:", result?.data?.content); await session.disconnect(); await client.stop(); } main(); ``` -------------------------------- ### Get Copilot Code Suggestions in VS Code (JavaScript Example) Source: https://github.com/github/docs/blob/main/content/copilot/how-tos/get-code-suggestions/get-ide-code-suggestions.md This guide demonstrates how to obtain coding suggestions from GitHub Copilot within Visual Studio Code. The examples use JavaScript, but the process is similar for other supported languages. It also points to further documentation for VS Code specific instructions. ```javascript // Example JavaScript code function greet(name) { console.log(`Hello, ${name}!`); } ``` -------------------------------- ### Install Go SDK Source: https://github.com/github/docs/blob/main/content/copilot/how-tos/copilot-sdk/setup/choosing-a-setup-path.md Install the Go SDK. Note that this requires a separate CLI installation. ```bash go get github.com/github/copilot-sdk/go ``` -------------------------------- ### Verify Helm Deployment Source: https://github.com/github/docs/blob/main/content/actions/tutorials/use-actions-runner-controller/get-started.md Lists all installed Helm releases across all namespaces to confirm the runner scale set is correctly deployed. ```bash helm list -A ``` -------------------------------- ### Install Actions Runner Controller via Helm Source: https://github.com/github/docs/blob/main/content/actions/tutorials/use-actions-runner-controller/get-started.md Installs the ARC operator and custom resource definitions into a specified Kubernetes namespace using the Helm package manager. This command pulls the chart from the GitHub Container Registry. ```bash NAMESPACE="arc-systems" helm install arc \ --namespace "${NAMESPACE}" \ --create-namespace \ oci://ghcr.io/actions/actions-runner-controller-charts/gha-runner-scale-set-controller ``` -------------------------------- ### Configure Copilot SDK for Multi-tenancy (Go) Source: https://github.com/github/docs/blob/main/content/copilot/how-tos/copilot-sdk/setup/multi-tenancy.md This Go example shows how to set up the Copilot SDK for multi-user server deployments. It configures the client with `ModeEmpty`, a `BaseDirectory`, `SessionIdleTimeoutSeconds`, and connects to a runtime via `URIConnection`. A session is then created with a unique ID, model, custom tools, and a GitHub token. ```go package main import ( "context" "fmt" copilot "github.com/github/copilot-sdk/go" ) type appUser struct { ID string GitHubToken string } func main() { ctx := context.Background() runtimeInstanceID := "instance-1" runtimeURL := "http://127.0.0.1:8080" requestID := "req-1" user := appUser{ID: "alice", GitHubToken: "YOUR_GITHUB_TOKEN"} client := copilot.NewClient(&copilot.ClientOptions{ Mode: copilot.ModeEmpty, BaseDirectory: fmt.Sprintf("/var/lib/my-app/copilot/%s", runtimeInstanceID), SessionIdleTimeoutSeconds: 900, Connection: copilot.URIConnection{URL: runtimeURL}, }) session, err := client.CreateSession(ctx, &copilot.SessionConfig{ SessionID: fmt.Sprintf("user-%s-%s", user.ID, requestID), Model: "gpt-4.1", AvailableTools: []string{"custom:lookupOrder", "custom:createTicket"}, GitHubToken: user.GitHubToken, }) _ = session _ = err } ``` -------------------------------- ### Git LFS Initialization Example Source: https://github.com/github/docs/blob/main/content/contributing/style-guide-and-content-model/style-guide.md This example shows the correct way to display command output by commenting it out, allowing users to easily copy and execute the command. ```shell git lfs install # Git LFS initialized. ``` -------------------------------- ### Install Runner Scale Set with Helm Source: https://github.com/github/docs/blob/main/content/actions/tutorials/use-actions-runner-controller/get-started.md Deploys the runner scale set chart to a specified Kubernetes namespace. Requires configuration of the installation name, namespace, GitHub configuration URL, and a personal access token with appropriate permissions. ```bash INSTALLATION_NAME="arc-runner-set" NAMESPACE="arc-runners" GITHUB_CONFIG_URL="https://github.com/" GITHUB_PAT="" helm install "${INSTALLATION_NAME}" \ --namespace "${NAMESPACE}" \ --create-namespace \ --set githubConfigUrl="${GITHUB_CONFIG_URL}" \ --set githubConfigSecret.github_token="${GITHUB_PAT}" \ oci://ghcr.io/actions/actions-runner-controller-charts/gha-runner-scale-set ``` -------------------------------- ### Authenticate API Request with Installation Token (Shell) Source: https://github.com/github/docs/blob/main/content/apps/creating-github-apps/authenticating-with-a-github-app/authenticating-as-a-github-app-installation.md This example shows how to authenticate a GET request to the '/meta' REST API endpoint using an installation access token. The token is provided in the 'Authorization: Bearer' header. This method is applicable for both REST and GraphQL API requests, provided the app has the necessary permissions. ```shell curl --request GET \ --url "{% data variables.product.rest_url %}/meta" \ --header "Accept: application/vnd.github+json" \ --header "Authorization: Bearer INSTALLATION_ACCESS_TOKEN" \ --header "X-GitHub-Api-Version: {{ allVersions[currentVersion].latestApiVersion }}" ``` -------------------------------- ### Set up and Subscribe to Events (Go) Source: https://github.com/github/docs/blob/main/content/copilot/how-tos/copilot-sdk/features/streaming-events.md Creates a Copilot client and session, then subscribes to session events. It specifically checks for `AssistantMessageDeltaData` and prints the `DeltaContent`. ```go package main import ( "context" "fmt" copilot "github.com/github/copilot-sdk/go" "github.com/github/copilot-sdk/go/rpc" ) func main() { ctx := context.Background() client := copilot.NewClient(nil) session, _ := client.CreateSession(ctx, &copilot.SessionConfig{ Model: "gpt-4.1", Streaming: copilot.Bool(true), OnPermissionRequest: func(req copilot.PermissionRequest, inv copilot.PermissionInvocation) (rpc.PermissionDecision, error) { return &rpc.PermissionDecisionApproveOnce{}, nil }, }) session.On(func(event copilot.SessionEvent) { if d, ok := event.Data.(*copilot.AssistantMessageDeltaData); ok { fmt.Print(d.DeltaContent) } }) _ = session } ``` -------------------------------- ### Creating an Initial Full Backup Source: https://github.com/github/docs/blob/main/content/admin/backing-up-and-restoring-your-instance/configuring-backups-on-your-instance.md Execute this command to initiate the first full backup of your {% data variables.product.prodname_ghe_server %} instance. Ensure your `backup.config` file is properly configured before running this command. ```shell ./bin/ghe-backup ``` -------------------------------- ### Create Rust Project and Install SDK Source: https://github.com/github/docs/blob/main/content/copilot/how-tos/copilot-sdk/getting-started.md Initialize a new Rust binary crate and add the GitHub Copilot SDK and its direct dependencies. ```bash cargo new copilot-demo && cd copilot-demo cargo add github-copilot-sdk --features derive cargo add tokio --features rt-multi-thread,macros cargo add serde --features derive cargo add schemars ``` -------------------------------- ### Create .NET Project and Add SDK Source: https://github.com/github/docs/blob/main/content/copilot/how-tos/copilot-sdk/getting-started.md Initialize a new .NET console project and add the GitHub Copilot SDK package. ```bash dotnet new console -n CopilotDemo && cd CopilotDemo dotnet add package GitHub.Copilot.SDK ``` -------------------------------- ### Example copilot-setup-steps.yml Structure Source: https://github.com/github/docs/blob/main/content/copilot/tutorials/cloud-agent/improve-a-project.md This YAML snippet shows the basic structure of a `copilot-setup-steps.yml` workflow file, including triggers and job naming conventions. Ensure the job is named `copilot-setup-steps`. ```yaml on: workflow_dispatch: push: paths: - .github/workflows/copilot-setup-steps.yml pull_request: paths: - .github/workflows/copilot-setup-steps.yml jobs: copilot-setup-steps: runs-on: ubuntu-latest ``` -------------------------------- ### Example GET request to the GitHub API Source: https://github.com/github/docs/blob/main/content/rest/using-the-rest-api/getting-started-with-the-rest-api.md This example demonstrates how to use curl to make a GET request to the /octocat endpoint. It includes essential headers like Accept and X-GitHub-Api-Version. ```shell curl --request GET \ --url "https://api.github.com/octocat" \ --header "Accept: application/vnd.github+json" \ --header "X-GitHub-Api-Version: {{ defaultRestApiVersion }}" ``` -------------------------------- ### Install a plugin from a marketplace Source: https://github.com/github/docs/blob/main/content/copilot/how-tos/copilot-cli/customize-copilot/plugins-finding-installing.md Install a plugin by specifying its name and the marketplace it belongs to. Use the format `PLUGIN-NAME@MARKETPLACE-NAME`. ```shell copilot plugin install database-data-management@awesome-copilot ``` ```copilot /plugin install PLUGIN-NAME@MARKETPLACE-NAME ``` -------------------------------- ### Configure Workflow for Runner Scale Sets Source: https://github.com/github/docs/blob/main/content/actions/tutorials/use-actions-runner-controller/get-started.md A GitHub Actions workflow configuration that targets a specific runner scale set. The 'runs-on' field must match the Helm installation name of the autoscaling runner set. ```yaml name: Actions Runner Controller Demo on: workflow_dispatch: jobs: Explore-GitHub-Actions: # You need to use the INSTALLATION_NAME from the previous step runs-on: arc-runner-set steps: - run: echo "🎉 This job uses runner scale set runners!" ``` -------------------------------- ### Start Copilot Client (TypeScript) Source: https://github.com/github/docs/blob/main/src/fixtures/fixtures/content/get-started/liquid/code-tabs-test.md Starts the Copilot client. This is a common setup step before creating sessions. ```typescript const client = new CopilotClient(); await client.start(); ``` -------------------------------- ### Example Repository List for --include-from Source: https://github.com/github/docs/blob/main/content/actions/tutorials/migrate-to-github-actions/automated-migrations/circleci-migration.md This is an example of a file format expected by the `--include-from` argument. It should be a line-delimited list of repository names. ```text repository_one repository_two repository_three ``` -------------------------------- ### Example SKILL.md File Source: https://github.com/github/docs/blob/main/data/reusables/copilot/creating-adding-skills.md This example demonstrates the structure of a `SKILL.md` file, including YAML frontmatter for skill metadata and a Markdown body with instructions for {% data variables.product.prodname_copilot_short %}. ```markdown --- name: github-actions-failure-debugging description: Guide for debugging failing {% data variables.product.prodname_actions %} workflows. Use this when asked to debug failing {% data variables.product.prodname_actions %} workflows. --- To debug failing {% data variables.product.prodname_actions %} workflows in a pull request, follow this process, using tools provided from the {% data variables.product.github %} MCP Server: 1. Use the `list_workflow_runs` tool to look up recent workflow runs for the pull request and their status 2. Use the `summarize_job_log_failures` tool to get an AI summary of the logs for failed jobs, to understand what went wrong without filling your context windows with thousands of lines of logs 3. If you still need more information, use the `get_job_logs` or `get_workflow_run_logs` tool to get the full, detailed failure logs 4. Try to reproduce the failure yourself in your own environment. 5. Fix the failing build. If you were able to reproduce the failure yourself, make sure it is fixed before committing your changes. ``` -------------------------------- ### SQL Code Suggestion Example in Azure Data Studio Source: https://github.com/github/docs/blob/main/content/copilot/how-tos/get-code-suggestions/get-ide-code-suggestions.md Demonstrates how GitHub Copilot suggests SQL join conditions based on existing code and common patterns. Ensure you have the Copilot extension installed and a compatible Azure Data Studio version. ```sql SELECT [UserId], [Red], [Orange], [Yellow], [Green], [Blue], [Purple], [Rainbow] FROM [Tag].[Scoreboard] INNER JOIN ``` -------------------------------- ### Example: Build and push new Docker image Source: https://github.com/github/docs/blob/main/content/packages/working-with-a-github-packages-registry/working-with-the-docker-registry.md Example of building a new Docker image and pushing it to {% data variables.product.prodname_registry %}. Assumes subdomain isolation is enabled and Dockerfile is in the current directory. ```shell # Build the image with docker.HOSTNAME/OWNER/REPOSITORY/IMAGE_NAME:VERSION # Assumes Dockerfile resides in the current working directory (.) $ docker build -t docker.HOSTNAME/octocat/octo-app/monalisa:1.0 . # Push the image to {% data variables.product.prodname_registry %} $ docker push docker.HOSTNAME/octocat/octo-app/monalisa:1.0 ``` -------------------------------- ### Install Express Dependency for Node.js Source: https://github.com/github/docs/blob/main/content/webhooks/using-webhooks/handling-webhook-deliveries.md This command installs the Express library, a necessary dependency for the Node.js webhook example. Ensure you have Node.js and npm installed and updated to their latest versions. ```shell npm install express ``` -------------------------------- ### Sinatra Server Output Example Source: https://github.com/github/docs/blob/main/content/apps/creating-github-apps/writing-code-for-a-github-app/building-ci-checks-with-a-github-app.md Example output when the Sinatra server starts successfully. It indicates the port and environment the server is running on. ```text == Sinatra (v2.2.3) has taken the stage on 3000 for development with backup from Puma Puma starting in single mode... * Puma version: 6.3.0 (ruby 3.1.2-p20) ("Mugi No Toki Itaru") * Min threads: 0 * Max threads: 5 * Environment: development * PID: 14915 * Listening on http://0.0.0.0:3000 Use Ctrl-C to stop ``` -------------------------------- ### Example Next Steps Section with Learning Path Source: https://github.com/github/docs/blob/main/content/contributing/style-guide-and-content-model/contents-of-a-github-docs-article.md This example demonstrates linking to a learning path or a subsequent logical step after a user completes the current task, such as creating an enterprise account. ```markdown ## Next steps After your enterprise account is created, we recommend learning more about how enterprise accounts work and configuring settings and policies. Follow the "Get started with your enterprise account" learning path. ``` -------------------------------- ### GET /app/installations Source: https://github.com/github/docs/blob/main/content/rest/apps/installations.md List all installations for the authenticated GitHub App. ```APIDOC ## GET /app/installations ### Description Lists all installations of the authenticated GitHub App that the user has access to. ### Method GET ### Endpoint /app/installations ### Parameters #### Query Parameters - **per_page** (integer) - Optional - Results per page (max 100). - **page** (integer) - Optional - Page number of the results to fetch. ### Request Example GET /app/installations?per_page=30 ### Response #### Success Response (200) - **installations** (array) - A list of installation objects. #### Response Example [ { "id": 12345, "account": { "login": "octocat", "id": 1 }, "target_type": "User" } ] ``` -------------------------------- ### GET Request Example - Fetching Repository Data Source: https://github.com/github/docs/blob/main/src/article-api/templates/rest-page.template.md Demonstrates how to fetch repository data using a GET request. This example uses cURL and highlights the request URL and potential headers. It's useful for retrieving information about a specific repository. ```curl curl -L \ -X GET \ https://api.github.com/repos/octocat/Spoon-Knife ```