Token导航 LogoToken导航TokenDH.com
研究检索操作浏览器github未标认证来源可访问许可证需确认审计提醒

gh-search-codegh 搜索码

Agent Skill

gh-search-code 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

269

周安装

11

GitHub Stars

4

下载量

86
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:gh-search-code(gh 搜索码)
来源仓库:https://github.com/aaddrick/gh-cli-search
仓库路径:skills/gh-search-code
安装命令:
npx skills add https://github.com/aaddrick/gh-cli-search --skill gh-search-code
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/aaddrick/gh-cli-search --skill gh-search-code

简介

gh-search-code 用于查找、检索和筛选相关信息。

  • 适合在 Codex、Claude、Cursor、Gemini CLI 中根据关键词、任务场景或来源线索快速定位候选结果。
  • 通过 npx skills add 命令从指定 GitHub 仓库安装并使用。
  • 安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。
  • 可结合来源仓库和原始 README 继续核验具体用法。

SKILL.md

GitHub CLI: Search Code

Overview

Search for code across GitHub repositories using gh search code. Important: CLI API uses legacy search engine. For regex and advanced features, use -w flag to open in web browser.

When to Use This Skill

Use this skill when searching code across GitHub:

  • Searching for code patterns across multiple repositories
  • Finding specific file types or filenames in repos/orgs
  • Locating code by language or file size across GitHub
  • Searching in specific repositories or organizations
  • Need to exclude certain results (requires -- flag)
  • Need regex search (use -w to open in browser)

Syntax

gh search code <query> [flags]

Key Flags Reference

FlagPurposeExample
--extension <string>Filter by file extension--extension js
--filename <string>Target specific filenames--filename package.json
--language <string>Filter by programming language--language python
--owner <strings>Limit to specific owners--owner microsoft
-R, --repo <strings>Search within repository--repo cli/cli
--size <string>Filter by file size (KB)--size ">100"
--match <strings>Search in file or path--match file or --match path
-L, --limit <int>Max results (default: 30)--limit 100
-w, --webOpen in browser-w
--json <fields>JSON output--json path,repository

JSON Output Fields

Available fields: path, repository, sha, textMatches, url

Exclusion Syntax (Critical!)

When using inline query exclusions (negations with -), you MUST use the -- separator:

✅ Correct: gh search code -- "search-terms -qualifier:value" ❌ Wrong: gh search code "search-terms" --flag=-value ❌ Wrong: gh search code "search-terms" --flag=!value ❌ Wrong: gh search code "search-terms" --filename="!test"

Examples:

  • gh search code -- "function -filename:test" (exclude files named "test")
  • gh search code -- "import -language:javascript" (exclude language)
  • gh search code -- "config -path:vendor" (exclude vendor directories)
  • gh search code -- "TODO -extension:md" (exclude extension)

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.

Understanding -filename: vs -path: Qualifiers

Critical Distinction: These qualifiers have different matching behaviors:

QualifierMatchesUse When
-filename:Filename only (e.g., test.js, utils_test.py)Excluding files by their name pattern
-path:Full file path (e.g., src/test/file.js, lib/testing/util.js)Excluding directory paths or path segments

When to Use Each

Use -filename: when:

  • User says "exclude test files" → means files named with "test"
  • Targeting files by their name pattern
  • Examples: test.js, config_test.py, utils.test.ts

Use -path: when:

  • User says "exclude test directories" → means directories containing "test"
  • Targeting files in specific directory paths
  • Examples: tests/, __test__/, src/test/, lib/testing/

Matching Examples

-filename:test matches:

  • test.js
  • utils_test.py
  • test_helper.rb
  • src/file.js ❌ (doesn't contain "test" in filename)
  • tests/utils.js ❌ (filename is "utils.js", not "test")

-path:test matches:

  • tests/utils.js ✅ (path contains "test")
  • src/test/file.js ✅ (path contains "test")
  • lib/testing/helper.py ✅ (path contains "test")
  • test.js ✅ (path includes filename)
  • src/utils.js ❌ (path doesn't contain "test")

Practical Examples

Exclude files by name:

# User: "Find functions but NOT in test files"
gh search code -- "function -filename:test"
# Excludes: test.js, utils_test.py, config.test.ts
# Includes: tests/utils.js (filename is "utils.js", not "test")

Exclude directories:

# User: "Find config but NOT in test directories"
gh search code -- "config -path:test"
# Excludes: tests/config.js, src/test/config.py, __test__/setup.js
# Includes: config_test.js (not in test directory)

Combine both qualifiers:

# User: "Exclude both test files AND test directories"
gh search code -- "function -filename:test -path:test"
# Excludes: test.js, tests/utils.js, src/test/file.js, utils_test.py

Critical Syntax Rules

When to Use Flag Syntax vs Query Syntax

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 code "import" --language python --extension py

Query Syntax with -- (required for exclusions):

gh search code -- "function -filename:test.js -language:javascript"

⚠️ NEVER mix both syntaxes in a single command!

1. Exclusions and Negations

CRITICAL: When excluding results, you MUST use query syntax with the -- separator.

Exclusion Syntax Rules:

  1. Use the -- separator before your query
  2. Use -qualifier:value format (dash prefix for negation)
  3. Quote the entire query string

Examples:

Single exclusion:

# Exclude files named "test.js"
gh search code -- "function -filename:test.js"

# Exclude specific language
gh search code -- "import -language:javascript"

# Exclude vendor directories
gh search code -- "config -path:vendor"

Multiple exclusions:

# Exclude multiple filenames
gh search code -- "function -filename:test.js -filename:spec.js"

# Exclude language and test directories
gh search code -- "TODO -language:go -path:test"

# Exclude multiple languages
gh search code -- "class -language:java -language:kotlin"

Combine with positive filters using flags:

# Wrong - mixing syntaxes:
gh search code "function" --language python -filename:test  # ❌

# Correct - use query syntax for everything when excluding:
gh search code -- "function language:python -filename:test"  # ✅

PowerShell exclusions:

# Use --% to prevent PowerShell parsing
gh --% search code -- "function -filename:test.js"

Common Exclusion Patterns:

User RequestCommandQualifier Used
"Find code but not in test files"gh search code -- "function -filename:test"-filename: (matches file names)
"Code excluding test directories"gh search code -- "function -path:test"-path: (matches directory paths)
"Code excluding specific language"gh search code -- "import -language:javascript"-language:
"Code not in vendor/node_modules dirs"gh search code -- "config -path:vendor -path:node_modules"-path: (matches directories)
"Functions excluding test and spec files"gh search code -- "function -filename:test -filename:spec"-filename: (matches file names)
"Code excluding large files"gh search code -- "class -size:>500"-size:
"Code not in specific extension"gh search code -- "TODO -extension:md -extension:txt"-extension:
"Code excluding example/doc directories"gh search code -- "api -path:examples -path:docs"-path: (matches directories)

2. Quoting Rules

Multi-word search:

gh search code "error handling"

Complex queries with qualifiers:

gh search code "TODO in:file" --language javascript

3. Size Comparisons

Use quotes for comparison operators:

gh search code "import" --size ">50" --language python

Common Use Cases

Search for function patterns:

gh search code "async function" --language typescript

Find configuration files:

gh search code "database" --filename config.json --owner myorg

Search in specific repo:

gh search code "TODO" --repo owner/repo --language go

Exclude files named with "test":

gh search code -- "function -filename:test"

Exclude test directories:

gh search code -- "function -path:test"

Search by file size:

gh search code "import" --size "100..500" --language python

Use regex (via web):

# Open in browser for regex support
gh search code "function.*test" --language javascript -w
# Web UI allows: /function.*test/ or /class\s+\w+/

Build complex query, refine in web:

# Start with CLI filters, finish with regex in browser
gh search code --owner microsoft --language typescript -w

Common Mistakes

MistakeProblemFix
--extension="NOT js" or --language=-pythonFlag syntax doesn't support negationUse query: -- "-extension:js" or -- "-language:python"
gh search code import -language:js-language interpreted as flagUse --: gh search code -- "import -language:js"
"function NOT language:js"NOT keyword doesn't workUse -: -- "function -language:js"
Mixing syntaxes: --language python "code -filename:test"Can't mix flags with query qualifiersUse query for all: -- "code language:python -filename:test"
Not quoting multi-word queriesSearches separatelyQuote: "error handling"
Forgetting quotes on comparisonsShell interprets >Quote: --size ">100"
Using -filename inline without --Parsed as flagUse --: -- "code -filename:test"
Trying regex via CLICLI API doesn't support regexUse -w flag: gh search code "pattern" -w
PowerShell without --%Breaks with exclusionsAdd: gh --%

Installation Check

If gh command not found:

# Check if gh is installed
which gh

# If not installed, see: https://cli.github.com/manual/installation

If not authenticated:

# Authenticate with GitHub
gh auth login

Web Browser Flag (-w/--web)

Important workaround for advanced features:

The -w/--web flag opens your search in GitHub's web interface, which supports features not available via CLI API:

Regex Search (Web Only)

# This opens in browser where you can use regex
gh search code "function.*test" --language javascript -w

# In the web UI, you can then modify to use regex syntax:
# /function.*test/ language:javascript

When to Use -w

Use the web flag when you need:

  • Regex patterns - /pattern/ syntax for complex matching
  • Advanced filters - Newer GitHub search features
  • Visual browsing - Easier to explore results visually
  • Better results - Web uses newer search engine

Combining CLI + Web

# Build query with CLI, open in web for regex
gh search code --language python --repo myorg/myrepo -w
# Then add regex pattern in web UI

Limitations (CLI API)

  • Powered by legacy GitHub search engine
  • Results may differ from github.com
  • Regex search not available via CLI (use -w flag instead)
  • Some advanced features may not work
  • Workaround: Use -w/--web to access full GitHub search features

Related

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

34.18%
按下载量换算29

Claude

30.33%
按下载量换算26

Cursor

19.82%
按下载量换算17

Gemini CLI

9.43%
按下载量换算8

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

可疑

权限和风险

操作浏览器

该 Skill 可能涉及浏览器控制能力,使用时可能读取或操作网页内容,需要在受控环境中确认权限边界。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在 warning/failed 结果,不能写成本站确认安全。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills