From 7c3e7c13ebe957c1a6807b7105b80ddeda42287b Mon Sep 17 00:00:00 2001 From: Josh Johanning Date: Thu, 19 Mar 2026 22:10:51 -0500 Subject: [PATCH 1/2] feat: add scripts to retrieve repositories with and without Copilot custom instructions --- gh-cli/README.md | 20 ++++++++ ...-repositories-with-copilot-instructions.sh | 50 +++++++++++++++++++ ...positories-without-copilot-instructions.sh | 46 +++++++++++++++++ 3 files changed, 116 insertions(+) create mode 100755 gh-cli/get-repositories-with-copilot-instructions.sh create mode 100755 gh-cli/get-repositories-without-copilot-instructions.sh diff --git a/gh-cli/README.md b/gh-cli/README.md index f3c6617..466f17b 100644 --- a/gh-cli/README.md +++ b/gh-cli/README.md @@ -1290,6 +1290,26 @@ Get repositories that have a CircleCI configuration file `.circleci/config.yml` (not perfect, doesn't search for `codeql*.yml`) +### get-repositories-with-copilot-instructions.sh + +Get repositories that have Copilot custom instruction files, checking for both repository-wide (`.github/copilot-instructions.md`) and path-specific (`.github/instructions/`) instructions + +Usage: + +```shell +./get-repositories-with-copilot-instructions.sh my-org +``` + +### get-repositories-without-copilot-instructions.sh + +Get repositories that do not have any Copilot custom instruction files (neither `.github/copilot-instructions.md` nor `.github/instructions/`) + +Usage: + +```shell +./get-repositories-without-copilot-instructions.sh my-org +``` + ### get-repositories-using-codeql.sh Get repositories that have a CodeQL configuration file `.github/workflows/codeql.yml` diff --git a/gh-cli/get-repositories-with-copilot-instructions.sh b/gh-cli/get-repositories-with-copilot-instructions.sh new file mode 100755 index 0000000..72adde1 --- /dev/null +++ b/gh-cli/get-repositories-with-copilot-instructions.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# Get repositories that have Copilot custom instruction files +# Checks for: +# - .github/copilot-instructions.md (repository-wide custom instructions) +# - .github/instructions/ directory (path-specific custom instructions) +# +# Usage: +# ./get-repositories-with-copilot-instructions.sh +# # If you want to in a nicely formatted table, you can pipe the output to `column`: +# ./get-repositories-with-copilot-instructions.sh | column -ts $'\t' + +if [ -z "$1" ]; then + echo "Usage: $0 " + exit 1 +fi + +org=$1 + +echo -e "Repository\tRepo-Wide\tPath-Specific Files" + +gh api graphql --paginate -F owner="$org" -H "X-Github-Next-Global-ID: 1" -f query=' + query ($owner: String!, $endCursor: String = null) { + organization(login: $owner) { + repositories( + first: 100 + orderBy: { field: NAME, direction: ASC } + after: $endCursor + ) { + totalCount + pageInfo {hasNextPage endCursor} + nodes { + nameWithOwner + repoWide: object(expression: "HEAD:.github/copilot-instructions.md") { + ... on Blob { + byteSize + } + } + pathSpecific: object(expression: "HEAD:.github/instructions/") { + ... on Tree { + entries { + path + } + } + } + } + } + } + } +' --jq '.data.organization.repositories.nodes[] | select(.repoWide != null or .pathSpecific != null) | [.nameWithOwner, (if .repoWide != null then "yes" else "no" end), (if .pathSpecific != null then (.pathSpecific.entries | length | tostring) else "0" end)] | @tsv' diff --git a/gh-cli/get-repositories-without-copilot-instructions.sh b/gh-cli/get-repositories-without-copilot-instructions.sh new file mode 100755 index 0000000..ab69039 --- /dev/null +++ b/gh-cli/get-repositories-without-copilot-instructions.sh @@ -0,0 +1,46 @@ +#!/bin/bash + +# Get repositories that do not have any Copilot custom instruction files +# Checks for the absence of both: +# - .github/copilot-instructions.md (repository-wide custom instructions) +# - .github/instructions/ directory (path-specific custom instructions) +# +# Usage: +# ./get-repositories-without-copilot-instructions.sh + +if [ -z "$1" ]; then + echo "Usage: $0 " + exit 1 +fi + +org=$1 + +gh api graphql --paginate -F owner="$org" -H "X-Github-Next-Global-ID: 1" -f query=' + query ($owner: String!, $endCursor: String = null) { + organization(login: $owner) { + repositories( + first: 100 + orderBy: { field: NAME, direction: ASC } + after: $endCursor + ) { + totalCount + pageInfo {hasNextPage endCursor} + nodes { + nameWithOwner + repoWide: object(expression: "HEAD:.github/copilot-instructions.md") { + ... on Blob { + byteSize + } + } + pathSpecific: object(expression: "HEAD:.github/instructions/") { + ... on Tree { + entries { + path + } + } + } + } + } + } + } +' --jq '.data.organization.repositories.nodes[] | select(.repoWide == null and .pathSpecific == null) | .nameWithOwner' From fae16cc7792d2d3ea7a2cf3de671bed3d3a821c7 Mon Sep 17 00:00:00 2001 From: Josh Johanning Date: Thu, 19 Mar 2026 22:20:46 -0500 Subject: [PATCH 2/2] docs: update README and scripts to include authentication details for Copilot instructions --- gh-cli/README.md | 40 +++++++++---------- ...-repositories-with-copilot-instructions.sh | 7 +++- ...positories-without-copilot-instructions.sh | 4 ++ 3 files changed, 30 insertions(+), 21 deletions(-) diff --git a/gh-cli/README.md b/gh-cli/README.md index 466f17b..a5c4b53 100644 --- a/gh-cli/README.md +++ b/gh-cli/README.md @@ -1290,26 +1290,6 @@ Get repositories that have a CircleCI configuration file `.circleci/config.yml` (not perfect, doesn't search for `codeql*.yml`) -### get-repositories-with-copilot-instructions.sh - -Get repositories that have Copilot custom instruction files, checking for both repository-wide (`.github/copilot-instructions.md`) and path-specific (`.github/instructions/`) instructions - -Usage: - -```shell -./get-repositories-with-copilot-instructions.sh my-org -``` - -### get-repositories-without-copilot-instructions.sh - -Get repositories that do not have any Copilot custom instruction files (neither `.github/copilot-instructions.md` nor `.github/instructions/`) - -Usage: - -```shell -./get-repositories-without-copilot-instructions.sh my-org -``` - ### get-repositories-using-codeql.sh Get repositories that have a CodeQL configuration file `.github/workflows/codeql.yml` @@ -1339,6 +1319,26 @@ Generates a CSV with 4 columns: This script is useful when doing migrations, to determine the kind of actions that might be needed based on the webhooks inventory. +### get-repositories-with-copilot-instructions.sh + +Get repositories that have Copilot custom instruction files, checking for both repository-wide (`.github/copilot-instructions.md`) and path-specific (`.github/instructions/`) instructions + +Usage: + +```shell +./get-repositories-with-copilot-instructions.sh my-org +``` + +### get-repositories-without-copilot-instructions.sh + +Get repositories that do not have any Copilot custom instruction files (neither `.github/copilot-instructions.md` nor `.github/instructions/`) + +Usage: + +```shell +./get-repositories-without-copilot-instructions.sh my-org +``` + ### get-repository-languages-for-organization.sh Get the repository language information (ie: JavaScript, Python, etc) for all repositories in an organization. Can specify how many language results to return (top X). diff --git a/gh-cli/get-repositories-with-copilot-instructions.sh b/gh-cli/get-repositories-with-copilot-instructions.sh index 72adde1..960aadd 100755 --- a/gh-cli/get-repositories-with-copilot-instructions.sh +++ b/gh-cli/get-repositories-with-copilot-instructions.sh @@ -5,9 +5,14 @@ # - .github/copilot-instructions.md (repository-wide custom instructions) # - .github/instructions/ directory (path-specific custom instructions) # +# +# Authentication: +# Requires a GitHub CLI token with at least read:org and repo scopes +# Example: gh auth refresh -h github.com -s read:org,repo +# # Usage: # ./get-repositories-with-copilot-instructions.sh -# # If you want to in a nicely formatted table, you can pipe the output to `column`: +# If you want to see the results in a nicely formatted table, you can pipe the output to `column`: # ./get-repositories-with-copilot-instructions.sh | column -ts $'\t' if [ -z "$1" ]; then diff --git a/gh-cli/get-repositories-without-copilot-instructions.sh b/gh-cli/get-repositories-without-copilot-instructions.sh index ab69039..6dc0647 100755 --- a/gh-cli/get-repositories-without-copilot-instructions.sh +++ b/gh-cli/get-repositories-without-copilot-instructions.sh @@ -5,6 +5,10 @@ # - .github/copilot-instructions.md (repository-wide custom instructions) # - .github/instructions/ directory (path-specific custom instructions) # +# Authentication: +# Requires a GitHub CLI token with at least read:org and repo scopes +# Example: gh auth refresh -h github.com -s read:org,repo +# # Usage: # ./get-repositories-without-copilot-instructions.sh