Learning resourcesReviewed · GitHub

Creating extensions for GitHub Copilot CLI

This GitHub tutorial teaches JavaScript developers to extend Copilot CLI, but extensions are experimental and run with the user's local privileges. It demonstrates an assistant-callable tool for tracking tool durations and a user-invoked slash command for counting tokens, using the SDK bundled with the CLI.

Researched 23 Nov 2026

In short.

This GitHub tutorial helps JavaScript developers add tools and slash commands to Copilot CLI, with the catch that extensions are experimental and execute with the user's local privileges. Its two examples explain session events, persistent in-memory state, extension locations, permissions and reloading. The bundled SDK requires no separate installation for these examples. Totals reset when extensions reload; prices and minimum supported versions are unspecified. Runtime behavior was not assessed.

Researched and written by an AI model and checked by a second AI model. How it works

Covers the complete supplied page at [https://docs.github.com/api/article/body?pathname=/en/copilot/tutorials/create-an-extension], including both JavaScript examples, prerequisites, extension locations, setup, reloading, troubleshooting and notices about experimental status, local privileges, permissions and state resets. Linked pages are excluded. No code was executed; installation success, runtime behavior, version compatibility, tool invocation, numerical accuracy and correspondence with billing remain unverified.

The overview

Resource identity

Creating extensions for GitHub Copilot CLI is a GitHub documentation tutorial at [https://docs.github.com/api/article/body?pathname=/en/copilot/tutorials/create-an-extension]. It teaches how to write small JavaScript modules that extend an interactive Copilot CLI session.

The page contains two complete examples: tool-time, which registers the session_tool_time tool, and token-counter, which registers the /tokencount slash command.

Practical assessment

The tutorial is useful for understanding when to give Copilot a tool it can choose to call and when to provide a command that a person invokes directly. Both examples show why a long-running extension can maintain information that a one-off command cannot continuously collect.

Its practical strength is the connection between complete code, setup instructions and explanations of individual SDK fields. It does not establish production reliability, numerical accuracy or compatibility across CLI releases. No code was executed.

Who it suits

The primary audience is developers who already use Copilot CLI and know JavaScript. Developers new to extensions receive concrete explanations of tools, commands and session events; experienced developers can inspect registration options, event correlation and state management.

Personal customizations can use the user extension directory. Teams can place project-specific functionality inside a repository. Someone seeking an immediately usable token dashboard would still need to create and load the example extension.

What it teaches

The timing example collects durations and a count of completed tool calls, then exposes those totals through session_tool_time. The token example adds reported input and output tokens and lets the user establish a baseline with /tokencount start.

The page also covers user, project and plugin extension locations, checking extension status, reloading edited code and finding extension logs. It mentions SDK support for interactive views with buttons and forms, but neither example demonstrates those interfaces.

Using it

Requirements

Copilot CLI must already be installed and configured, experimental features must be enabled, and the reader needs JavaScript familiarity. The project-level token example also requires a local Git repository.

The CLI runs an extension entry file named extension.mjs, extension.cjs or extension.js with Node.js. The examples import @github/copilot-sdk/extension, which the CLI resolves automatically without a separate package installation. Minimum CLI and Node.js versions, supported operating systems and hardware requirements are not specified.

How extensions work

An extension runs in a separate, long-lived Node.js process alongside the interactive session. Calling joinSession connects that process and registers its tools or commands. Variables at module scope retain state between calls until the extension reloads or the session restarts.

A tool supplies a name, description, argument schema and asynchronous handler; the handler's returned string becomes information Copilot can read. A slash command receives user arguments through ctx.args and can write to the transcript through session.log.

The timing example correlates tool.execution_start and tool.execution_complete events by toolCallId. The token example subscribes to assistant.usage and sums inputTokens and outputTokens. Setting defer to "never" keeps a tool visible to the model, but does not force the model to call it.

Setup and operation

For the timing example, create ~/.copilot/extensions/tool-time/extension.mjs and use the supplied JavaScript. For the token example, create .github/extensions/token-counter/extension.mjs in the repository. User extensions are available across directories; project extensions apply to sessions in that repository.

Start with copilot --experimental, or enable experimental features in an existing session using /experimental on. Inspect /extensions manage for status; /env also summarizes loaded extensions. The timing example requests approval to skip individual tool permission prompts because its registration sets skipPermission to true.

After editing, ask Copilot to reload extensions, use /clear or restart the CLI. The page identifies ~/.copilot/logs/extensions/ as the location for extension logs. Using /clear starts a fresh session and resets the examples' in-memory totals.

Example use

For tool-time, the tutorial proposes asking Copilot to explore files and then asking how long tool calls have taken during the session. Copilot is expected to call session_tool_time and use its returned duration and call count. This is documented expected behavior, not an observed result.

For token-counter, enter /tokencount start, interact with Copilot and then enter /tokencount. The handler reports the difference between the accumulated token total and the saved baseline. Entering /tokencount start again replaces that baseline; requesting a count before starting produces an instruction to start it.

Assessment & evidence

Limits and caveats

Extensions are experimental and may change. They run with the user's computer privileges, so the page advises loading only trusted code. The timing example's approval to omit per-call prompts does not provide process isolation.

Timing totals include waits for permission approval, exclude the timing tool itself and reset on reload. Reading the code shows that only matched completion events contribute, and the handler does not check the completion's success flag. Failed calls can therefore contribute; unfinished calls are absent. If calls overlap, their durations would be added separately rather than measuring the session's elapsed duration.

Token totals come from input and output counts reported after assistant turns. They reset on reload and are measured against the latest start baseline. Agreement with billing totals is unknown. These observations follow from the supplied code and explanations, not execution.

Why the design matters

Both examples demonstrate a concrete reason to use a session extension: collecting events over time and retaining state between interactions. The timing tool gives the model access to measurements that the page says are otherwise unavailable to it. The slash command gives the person direct control over when a counting interval begins.

This makes the tutorial a useful starting point for session instrumentation. Durable reporting, centralized monitoring and authoritative cost accounting would require additional design that the examples do not supply.

Choices within the tutorial

Use a tool when Copilot should request information during its work; use a slash command when a person should explicitly trigger an operation. The page explains that model visibility cannot guarantee tool invocation.

Choose the user directory for personal functionality across projects or the project directory for repository-specific functionality shared with collaborators. Installed plugins are listed as another extension source, but plugin packaging is not taught here. The page provides no comparison with competing extension frameworks or external monitoring products.

Evidence and confidence

The source is the complete GitHub documentation page at [https://docs.github.com/api/article/body?pathname=/en/copilot/tutorials/create-an-extension]. It provides implementation code, expected interactions and explanations of SDK behavior. It does not provide independent runtime measurements, benchmarks or compatibility results.

The supplied page has source revision sha256:6836b5a1b215a4a0a576a41fd458670186fc5055bfbb66178f5f5c7f7f43313d. Code-based deductions are identified separately from documented behavior. Successful installation, actual model tool selection and numerical accuracy remain unverified.

Access & freshness

Costs

The examples use the SDK bundled with Copilot CLI, so they require no separate SDK installation. This does not establish that Copilot access or usage is free.

Subscription prices, eligible plans, quotas, usage rates and operating costs are unknown from this page. The token counter provides no documented conversion from its totals to a bill.

Licensing and sharing

The tutorial describes sharing a user extension by moving its directory into a repository's .github/extensions/ directory. It does not state an explicit license for the article or its sample code.

Permission to redistribute the captured documentation or example code, including commercial-use terms, is not established by the supplied page. Copilot service terms and SDK licensing are also not provided.

Freshness and compatibility

The supplied copy was captured on 23 November 2026 at 20:37:13.856 UTC. That timestamp identifies the capture, not the article's publication or update date.

The page explicitly labels extensions experimental and subject to change. It supplies no dated release history, minimum supported CLI version or compatibility matrix. Behavior in other versions and changes after capture are unknown.

How to proceed

Choose the example that matches the intended interaction and inspect its JavaScript before loading it. Confirm that the installed CLI supports extensions, enable experimental features and use /extensions manage to check loading status. Consult the extension log if startup fails.

Before relying on the figures, check their behavior in a session you control, including resets after reloading. Interpret timing as accumulated completed-call durations and token counts as the reported input-plus-output total since the chosen baseline. Establish pricing and usage-accounting rules separately before using the counter for budget decisions.

Evidence for this report

selected-page.txtselected · checked 2026-11-23