Skip to content

Commit 5de0d98

Browse files
Add copilot-usage-metrics skill
A Copilot CLI agent skill that retrieves and displays GitHub Copilot usage metrics for organizations and enterprises via the REST API. Features: - Organization-level aggregated and per-user metrics - Enterprise-level aggregated and per-user metrics - Query metrics for specific dates - Uses gh CLI for API authentication Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 76b1c55 commit 5de0d98

5 files changed

Lines changed: 140 additions & 0 deletions

File tree

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
name: copilot-usage-metrics
3+
description: Retrieve and display GitHub Copilot usage metrics for organizations and enterprises using the GitHub CLI and REST API.
4+
---
5+
6+
# Copilot Usage Metrics
7+
8+
You are a skill that retrieves and displays GitHub Copilot usage metrics using the GitHub CLI (`gh`).
9+
10+
## When to use this skill
11+
12+
Use this skill when the user asks about:
13+
- Copilot usage metrics, adoption, or statistics
14+
- How many people are using Copilot in their org or enterprise
15+
- Copilot acceptance rates, suggestions, or chat usage
16+
- Per-user Copilot usage breakdowns
17+
- Copilot usage on a specific date
18+
19+
## How to use this skill
20+
21+
1. Determine whether the user wants **organization** or **enterprise** level metrics.
22+
2. Ask for the org name or enterprise slug if not provided.
23+
3. Determine if they want **aggregated** metrics or **per-user** metrics.
24+
4. Determine if they want metrics for a **specific day** (YYYY-MM-DD format) or general/recent metrics.
25+
5. Run the appropriate script from this skill's directory.
26+
27+
## Available scripts
28+
29+
### Organization metrics
30+
31+
- `get-org-metrics.sh <org> [day]` — Get aggregated Copilot usage metrics for an organization. Optionally pass a specific day in YYYY-MM-DD format.
32+
- `get-org-user-metrics.sh <org> [day]` — Get per-user Copilot usage metrics for an organization. Optionally pass a specific day.
33+
34+
### Enterprise metrics
35+
36+
- `get-enterprise-metrics.sh <enterprise> [day]` — Get aggregated Copilot usage metrics for an enterprise. Optionally pass a specific day.
37+
- `get-enterprise-user-metrics.sh <enterprise> [day]` — Get per-user Copilot usage metrics for an enterprise. Optionally pass a specific day.
38+
39+
## Formatting the output
40+
41+
When presenting results to the user:
42+
- Summarize key metrics: total active users, acceptance rate, total suggestions, total chat interactions
43+
- Use tables for per-user breakdowns
44+
- Highlight trends if comparing multiple days
45+
- Note that metrics data is available starting from October 10, 2025, and historical data is accessible for up to 1 year
46+
47+
## Important notes
48+
49+
- These API endpoints require **GitHub Enterprise Cloud**.
50+
- The user must have appropriate permissions (enterprise owner, billing manager, or a token with `manage_billing:copilot` / `read:enterprise` scope).
51+
- The "Copilot usage metrics" policy must be enabled in enterprise settings.
52+
- If the API returns 403, advise the user to check their token permissions and enterprise policy settings.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env bash
2+
# Fetch aggregated Copilot usage metrics for an enterprise
3+
# Usage: get-enterprise-metrics.sh <enterprise> [day]
4+
# enterprise - GitHub enterprise slug
5+
# day - (optional) specific day in YYYY-MM-DD format
6+
7+
set -euo pipefail
8+
9+
ENTERPRISE="${1:?Usage: get-enterprise-metrics.sh <enterprise> [day]}"
10+
DAY="${2:-}"
11+
12+
if [ -n "$DAY" ]; then
13+
gh api \
14+
-H "Accept: application/vnd.github+json" \
15+
-H "X-GitHub-Api-Version: 2022-11-28" \
16+
"/enterprises/$ENTERPRISE/copilot/usage/day?day=$DAY"
17+
else
18+
gh api \
19+
-H "Accept: application/vnd.github+json" \
20+
-H "X-GitHub-Api-Version: 2022-11-28" \
21+
"/enterprises/$ENTERPRISE/copilot/usage"
22+
fi
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env bash
2+
# Fetch per-user Copilot usage metrics for an enterprise
3+
# Usage: get-enterprise-user-metrics.sh <enterprise> [day]
4+
# enterprise - GitHub enterprise slug
5+
# day - (optional) specific day in YYYY-MM-DD format
6+
7+
set -euo pipefail
8+
9+
ENTERPRISE="${1:?Usage: get-enterprise-user-metrics.sh <enterprise> [day]}"
10+
DAY="${2:-}"
11+
12+
if [ -n "$DAY" ]; then
13+
gh api \
14+
-H "Accept: application/vnd.github+json" \
15+
-H "X-GitHub-Api-Version: 2022-11-28" \
16+
"/enterprises/$ENTERPRISE/copilot/usage/users/day?day=$DAY"
17+
else
18+
gh api \
19+
-H "Accept: application/vnd.github+json" \
20+
-H "X-GitHub-Api-Version: 2022-11-28" \
21+
"/enterprises/$ENTERPRISE/copilot/usage/users"
22+
fi
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env bash
2+
# Fetch aggregated Copilot usage metrics for an organization
3+
# Usage: get-org-metrics.sh <org> [day]
4+
# org - GitHub organization name
5+
# day - (optional) specific day in YYYY-MM-DD format
6+
7+
set -euo pipefail
8+
9+
ORG="${1:?Usage: get-org-metrics.sh <org> [day]}"
10+
DAY="${2:-}"
11+
12+
if [ -n "$DAY" ]; then
13+
gh api \
14+
-H "Accept: application/vnd.github+json" \
15+
-H "X-GitHub-Api-Version: 2022-11-28" \
16+
"/orgs/$ORG/copilot/usage/day?day=$DAY"
17+
else
18+
gh api \
19+
-H "Accept: application/vnd.github+json" \
20+
-H "X-GitHub-Api-Version: 2022-11-28" \
21+
"/orgs/$ORG/copilot/usage"
22+
fi
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env bash
2+
# Fetch per-user Copilot usage metrics for an organization
3+
# Usage: get-org-user-metrics.sh <org> [day]
4+
# org - GitHub organization name
5+
# day - (optional) specific day in YYYY-MM-DD format
6+
7+
set -euo pipefail
8+
9+
ORG="${1:?Usage: get-org-user-metrics.sh <org> [day]}"
10+
DAY="${2:-}"
11+
12+
if [ -n "$DAY" ]; then
13+
gh api \
14+
-H "Accept: application/vnd.github+json" \
15+
-H "X-GitHub-Api-Version: 2022-11-28" \
16+
"/orgs/$ORG/copilot/usage/users/day?day=$DAY"
17+
else
18+
gh api \
19+
-H "Accept: application/vnd.github+json" \
20+
-H "X-GitHub-Api-Version: 2022-11-28" \
21+
"/orgs/$ORG/copilot/usage/users"
22+
fi

0 commit comments

Comments
 (0)