Learn-skills.dev gh-search
Use when searching GitHub via CLI for issues, PRs, repos, code, or commits - provides correct syntax for exclusions, qualifiers, quoting, and platform-specific handling to avoid command failures
install
source · Clone the upstream repo
git clone https://github.com/NeverSight/learn-skills.dev
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/NeverSight/learn-skills.dev "$T" && mkdir -p ~/.claude/skills && cp -r "$T/data/skills-md/aaddrick/gh-cli-search/gh-search" ~/.claude/skills/neversight-learn-skills-dev-gh-search && rm -rf "$T"
manifest:
data/skills-md/aaddrick/gh-cli-search/gh-search/SKILL.mdsource content
GitHub CLI Search
Overview
Search GitHub from the command line using
gh search subcommands. The key principle: Always use -- before queries with exclusions to prevent shell interpretation of - prefixes.
When to Use
Use this skill when:
- Searching GitHub via
CLI for issues, PRs, repos, code, or commitsgh - User requests searches with exclusions (NOT, minus prefix)
- Constructing complex queries with multiple qualifiers
- Queries contain spaces or special characters
Subcommands Quick Reference
| Subcommand | Use For | Common Flags |
|---|---|---|
| Issues (add for PRs too) | , , , |
| Pull requests only | , , , , |
| Repositories | , , , |
| Code within files | , , |
| Commit messages | , , |
Critical Syntax Rules
1. Exclusions Require --
Flag
--Unix/Linux/Mac:
gh search issues -- "bug -label:duplicate"
PowerShell:
gh --% search issues -- "bug -label:duplicate"
Why: The
- prefix gets interpreted as a command flag without --. PowerShell needs --% to stop parsing.
2. Quoting Rules
Multi-word queries need quotes:
gh search issues "memory leak"
Entire query with spaces should be quoted:
gh search issues "bug label:urgent created:>2024-01-01"
Qualifier values with spaces need inner quotes:
gh search prs -- 'security label:"bug fix"'
3. Qualifier Syntax
Inline qualifiers (use within search query):
gh search repos "react stars:>1000 language:typescript"
Flag-based (use as separate flags):
gh search repos "react" --language typescript --stars ">1000"
Can mix both:
gh search issues "crash" --label bug created:>2024-01-01
Common Qualifiers
Comparison Operators
,>
,>=
,<
- Numeric:<=
,stars:>100comments:>=5
- Ranges:..
,stars:10..50created:2024-01-01..2024-12-31
Special Values
- Current user:@me
,author:@me
,assignee:@meowner:@me- Dates use ISO8601:
orcreated:>2024-01-01created:2024-01-01..2024-12-31
Field-Specific Search
- Search in title onlyin:title
- Search in body onlyin:body
- Search in comments onlyin:comments
Exclusions
- Exclude:-qualifier:value
,-label:bug-language:javascript
keyword - For words only:NOT"hello NOT world"
Examples
Find your open issues without bug label:
gh search issues -- "is:open author:@me -label:bug"
Find popular Python ML repos updated recently:
gh search repos "machine learning" --language python --stars ">1000" --updated ">2024-01-01"
Find PRs with specific label and text:
gh search prs -- 'security label:"bug fix" created:>2024-01-01'
Search code in organization repos:
gh search code "TODO" --owner myorg --language javascript
Common Mistakes
| Mistake | Problem | Fix |
|---|---|---|
| interpreted as flag | Add : |
| Searches "machine" OR "learning" | Quote it: |
outside quotes | Shell interprets oddly | Include in query: |
Mixing with value | Invalid syntax | Use or username, not both: ✓, ✗ (drop @) |
PowerShell without | Parsing breaks with exclusions | Add before command |
Output Options
All subcommands support:
- Max results (default: 30, max: 1000)--limit <n>
- JSON output for scripting--json <fields>
- Open results in browser--web
- Sort by: comments, created, reactions, updated, stars, etc.--sort <field>
- Sort direction (default: desc)--order asc|desc
Real-World Impact
Correct syntax prevents:
- Command failures from misinterpreted flags
- Missing results from incorrect exclusions
- Errors from unquoted spaces
- Platform-specific parsing issues