skills/gh-search-commits/SKILL.md
Use when searching commit history across GitHub repositories - provides syntax for filtering by author, committer, dates, hashes, and merge commits with proper exclusion handling
npx skillsauth add aaddrick/gh-cli-search gh-search-commitsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Search for commits across GitHub repositories using gh search commits. Filter by author, committer, dates, commit hashes, and more.
Use this skill when searching commits across GitHub:
-- flag)gh search commits [<query>] [flags]
| Flag | Purpose | Example |
|------|---------|---------|
| --author <string> | Filter by author username | --author octocat |
| --author-name <string> | Filter by author name | --author-name "John Doe" |
| --author-email <string> | Filter by author email | --author-email [email protected] |
| --author-date <date> | Filter by authored date | --author-date ">2024-01-01" |
| --committer <string> | Filter by committer username | --committer octocat |
| --committer-name <string> | Filter by committer name | --committer-name "Jane Doe" |
| --committer-email <string> | Filter by committer email | --committer-email [email protected] |
| --committer-date <date> | Filter by committed date | --committer-date "<2024-06-01" |
| Flag | Purpose | Example |
|------|---------|---------|
| --hash <string> | Filter by commit hash | --hash 8dd03144 |
| --parent <string> | Filter by parent hash | --parent abc123 |
| --tree <string> | Filter by tree hash | --tree def456 |
| --merge | Filter merge commits only | --merge |
| Flag | Purpose | Example |
|------|---------|---------|
| --owner <strings> | Filter by repo owner | --owner github |
| -R, --repo <strings> | Search in specific repo | --repo cli/cli |
| --visibility <strings> | Filter by visibility | --visibility public |
| Flag | Purpose | Example |
|------|---------|---------|
| -L, --limit <int> | Max results (default: 30) | --limit 100 |
| --sort <string> | Sort by author-date or committer-date | --sort author-date |
| --order <string> | Sort direction: asc or desc | --order asc |
| --json <fields> | JSON output | --json sha,author,commit |
| -w, --web | Open in browser | -w |
Available fields: author, commit, committer, id, parents, repository, sha, url
When using inline query exclusions (negations with -), you MUST use the -- separator:
✅ Correct: gh search commits -- "search-terms -qualifier:value"
❌ Wrong: gh search commits "search-terms" --flag=-value
❌ Wrong: gh search commits "search-terms" --flag=!value
❌ Wrong: gh search commits --author-not=username
Examples:
gh search commits -- "fix -author:dependabot" (exclude author)gh search commits -- "merge -committer:bot" (exclude committer)gh search commits -- "deploy -merge:true" (exclude merge commits)gh search commits -- "refactor -author-date:<2024-01-01" (exclude date range)Why the -- separator is required:
The -- tells the shell to stop parsing flags and treat everything after it as arguments. Without it, -qualifier:value inside quotes may be misinterpreted.
Decision Tree:
Does your search include:
- Any exclusions (NOT, minus, without, except)? → Use Query Syntax with `--`
- Complex boolean logic (OR, AND)? → Use Query Syntax with `--`
Otherwise:
- Simple positive filters only? → Use Flag Syntax
Flag Syntax (for positive filters):
gh search commits "bug fix" --author octocat --repo cli/cli
Query Syntax with -- (required for exclusions):
gh search commits -- "deploy -author:dependabot -author:renovate"
⚠️ NEVER mix both syntaxes in a single command!
CRITICAL: When excluding results, you MUST use query syntax with the -- separator.
-- separator before your query-qualifier:value format (dash prefix for negation)Single exclusion:
# Exclude specific author
gh search commits -- "deploy -author:dependabot"
# Exclude specific committer
gh search commits -- "merge -committer:bot"
# Exclude merge commits
gh search commits -- "fix -merge:true"
Multiple exclusions:
# Exclude multiple authors
gh search commits -- "deployment -author:dependabot -author:renovate"
# Exclude author and date range
gh search commits -- "refactor -author:bot -author-date:<2024-01-01"
# Exclude merge commits and specific authors
gh search commits -- "feature -merge:true -author:bot"
Combine with positive filters using flags:
# Wrong - mixing syntaxes:
gh search commits "fix" --author octocat -committer:bot # ❌
# Correct - use query syntax for everything when excluding:
gh search commits -- "fix author:octocat -committer:bot" # ✅
PowerShell exclusions:
# Use --% to prevent PowerShell parsing
gh --% search commits -- "fix -author:dependabot"
| User Request | Command |
|--------------|---------|
| "Find commits but not by bots" | gh search commits -- "deploy -author:dependabot -author:renovate" |
| "Commits excluding merge commits" | gh search commits -- "feature -merge:true" |
| "Commits not by specific author" | gh search commits -- "refactor -author:olduser" |
| "Commits excluding specific date range" | gh search commits -- "bug -author-date:<2024-01-01" |
| "Commits not by multiple committers" | gh search commits -- "fix -committer:bot -committer:ci" |
| "Commits excluding specific email" | gh search commits -- "update -author-email:[email protected]" |
| "Commits not in specific repo" | gh search commits -- "security -repo:old/deprecated" |
Use ISO8601 format (YYYY-MM-DD) with comparison operators:
gh search commits --author-date ">2024-01-01"
gh search commits --committer-date "2024-01-01..2024-12-31"
Multi-word search:
gh search commits "bug fix"
Date comparisons need quotes:
gh search commits "refactor" --author-date "<2024-06-01"
Find commits by author:
gh search commits --author octocat --repo cli/cli
Search commit messages:
gh search commits "security fix" --repo myorg/myrepo
Find commits in date range:
gh search commits "refactor" --author-date "2024-01-01..2024-12-31"
Find merge commits:
gh search commits --merge --repo owner/repo
Exclude bot commits:
gh search commits -- "deployment -author:dependabot"
Search by commit hash:
gh search commits --hash 8dd03144
Find commits by email:
gh search commits --author-email [email protected]
| Mistake | Problem | Fix |
|---------|---------|-----|
| --author="NOT bot" or --committer=-user | Flag syntax doesn't support negation | Use query: -- "-author:bot" or -- "-committer:user" |
| gh search commits fix -author:bot | -author interpreted as flag | Use --: -- "fix -author:bot" |
| "deploy NOT author:bot" | NOT keyword doesn't work | Use -: -- "deploy -author:bot" |
| Mixing syntaxes: --author octocat "fix -committer:bot" | Can't mix flags with query qualifiers | Use query for all: -- "fix author:octocat -committer:bot" |
| --author-date 2024-01-01 without comparison | May not work as expected | Use: --author-date ">2024-01-01" |
| Not quoting date comparisons | Shell interprets operators | Quote: "<2024-06-01" |
| --author @octocat | Invalid @ prefix | Drop @: --author octocat |
| PowerShell without --% | Breaks with exclusions | Add: gh --% |
If gh command not found:
# Check if gh is installed
which gh
# Install: https://cli.github.com/manual/installation
If not authenticated:
# Authenticate with GitHub
gh auth login
> - After date>= - On or after date< - Before date<= - On or before date.. - Date range: 2024-01-01..2024-12-31gh-search-code, gh-search-issues, gh-search-prs, gh-search-repostools
MANDATORY skill when users mention GitHub CLI searches - establishes non-negotiable requirement to use gh-cli-search skills for correct syntax, quoting, and platform handling
development
SLASH COMMAND ONLY - Do NOT invoke automatically. Only runs via /test-gh-skills command. Executes Python test orchestrator for 80 tests across 6 skill groups.
tools
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
tools
Use when searching for repositories across GitHub - provides syntax for filtering by stars, forks, language, topics, license, archived status, and all repository attributes