GitHub CLI (gh) Favorites

GitHub CLI patterns for security, PRs, and repo management.

Dependabot Alerts

Colored Table (Best for Quick Scan)

# Colored table view (best for quick scan)
gh api repos/EvanusModestus/domus-captures/dependabot/alerts | jq -r '
  "\u001b[1m#\tSEV\tPKG\tFIX\tSTATE\u001b[0m",
  (.[] |
    (if .security_advisory.severity == "critical" then "\u001b[91m"
     elif .security_advisory.severity == "high" then "\u001b[93m"
     elif .security_advisory.severity == "medium" then "\u001b[94m"
     else "\u001b[90m" end) as $sev_color |
    (if .state == "open" then "\u001b[91m" else "\u001b[92m" end) as $state_color |
    "\(.number)\t\($sev_color)\(.security_advisory.severity)\u001b[0m\t\(.security_vulnerability.package.name)\t\u001b[92m\(.security_vulnerability.first_patched_version.identifier // "\u001b[91m-")\u001b[0m\t\($state_color)\(.state)\u001b[0m"
  )' | column -t -s $'\t'
Output
#  SEV   PKG        FIX    STATE
3  high  minimatch  3.1.3  open
2  high  minimatch  5.1.7  open

Colors: Critical=red, High=yellow, Medium=blue, Open=red, Fixed=green

JSON Output (Auto-colored by jq)

# List alerts as JSON (auto-colored by jq)
gh api repos/EvanusModestus/domus-captures/dependabot/alerts | jq '.[] | {
  number,
  state,
  severity: .security_advisory.severity,
  package: .security_vulnerability.package.name,
  summary: .security_advisory.summary
}'

Colored Detail View

# Colored detail view (severity-based colors)
gh api repos/EvanusModestus/domus-captures/dependabot/alerts | jq -r '.[] |
  (if .security_advisory.severity == "critical" then "\u001b[91m"
   elif .security_advisory.severity == "high" then "\u001b[93m"
   elif .security_advisory.severity == "medium" then "\u001b[94m"
   else "\u001b[90m" end) as $color |
  "\($color)[\(.state)] \(.security_advisory.severity | ascii_upcase)\u001b[0m: \u001b[97m\(.security_vulnerability.package.name)\u001b[0m
  \(.security_advisory.summary)
  Fix: \u001b[92m\(.security_vulnerability.first_patched_version.identifier // "\u001b[91mno fix yet")\u001b[0m
"'

Count Alerts

# Count total alerts
gh api repos/EvanusModestus/domus-captures/dependabot/alerts | jq 'length'

Generic (Any Repo)

# Generic: replace OWNER/REPO
REPO="EvanusModestus/domus-captures"
gh api "repos/${REPO}/dependabot/alerts" | jq -r '
  "\u001b[1m#\tSEV\tPKG\tFIX\tSTATE\u001b[0m",
  (.[] |
    (if .security_advisory.severity == "critical" then "\u001b[91m"
     elif .security_advisory.severity == "high" then "\u001b[93m"
     elif .security_advisory.severity == "medium" then "\u001b[94m"
     else "\u001b[90m" end) as $sev_color |
    (if .state == "open" then "\u001b[91m" else "\u001b[92m" end) as $state_color |
    "\(.number)\t\($sev_color)\(.security_advisory.severity)\u001b[0m\t\(.security_vulnerability.package.name)\t\u001b[92m\(.security_vulnerability.first_patched_version.identifier // "\u001b[91m-")\u001b[0m\t\($state_color)\(.state)\u001b[0m"
  )' | column -t -s $'\t'

Color Reference

ANSI escape codes used:

Code Color Use

\u001b[91m

Red

Critical severity, open state, no fix

\u001b[93m

Yellow

High severity

\u001b[94m

Blue

Medium severity

\u001b[92m

Green

Fix available, fixed state

\u001b[97m

White

Package name

\u001b[90m

Gray

Low severity

\u001b[1m

Bold

Headers

\u001b[0m

Reset

End color