npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@johnlindquist/ghx

v1.11.0

Published

GitHub search and examples CLI tool

Readme

ghx - GitHub Code Search CLI

A CLI tool for searching GitHub code and viewing results in your editor.

Prerequisites

GitHub CLI Required

This tool requires the GitHub CLI (gh) to be:

  1. Installed and available in your PATH
  2. Authenticated with your GitHub account

Without these requirements, the tool will fail to work due to GitHub API rate limiting.

Installation & Authentication Steps

  1. Install GitHub CLI:

  2. Authenticate with GitHub:

    gh auth login

    Follow the prompts to complete authentication.

  3. Install ghx:

    pnpm add -g @johnlindquist/ghx

Usage

ghx "your search query" [options]

Options

  • --pipe - Output results directly to stdout
  • --debug - Output code fence contents for testing
  • --limit, -L <n> - Maximum number of results to fetch (default: 50)
  • --context, -c <n> - Number of context lines around matches (default: 20)
  • --max-filename, -f <n> - Maximum length of generated filenames (default: 50)

Search Qualifiers

You can use either CLI flags or GitHub's search qualifiers:

CLI Flags:

  • --filename <name> - Search in files with a specific name
  • --extension <ext> - Search files with specific extension
  • --language <lang> - Search in a specific programming language
  • --repo <owner/repo> - Search in a specific repository
  • --path <path> - Search in a specific file path
  • --size <n> - Files that are n bytes in size
  • --fork - Include or exclude forked repositories

Examples:

# Search for TypeScript config files
ghx --filename tsconfig.json "strict"

# Find React components
ghx --language typescript --extension tsx "useState"

# Search in specific repo
ghx --repo facebook/react "useState"

# Search and pipe results to stdout
ghx --pipe --filename tsconfig.json "strict"

# Pipe results to a file
ghx --pipe --language typescript "useState" > results.md

# Get more results
ghx --limit 100 --filename package.json "dependencies"

# Show more context around matches
ghx --context 50 --language typescript "useState"

# Allow longer filenames
ghx --max-filename 100 --filename package.json "devDependencies"

# Combine options
ghx -L 100 -c 30 -f 75 --repo facebook/react "hooks"

Search Results

Results are saved as markdown files in your system's config directory:

  • macOS: ~/Library/Preferences/johnlindquist/ghx-nodejs/searches/
  • Linux: ~/.config/johnlindquist/ghx-nodejs/searches/
  • Windows: %APPDATA%/johnlindquist/ghx-nodejs/searches/

Editor Integration

On first run, ghx will prompt you to:

  1. Choose whether to automatically open results in an editor
  2. Specify your preferred editor command (e.g., 'code', 'cursor', 'vim')

You can change these settings by editing the config file in:

  • macOS: ~/Library/Preferences/johnlindquist/ghx-nodejs/config.json
  • Linux: ~/.config/johnlindquist/ghx-nodejs/config.json
  • Windows: %APPDATA%/johnlindquist/ghx-nodejs/config.json

Features

  • Searches GitHub code using the GitHub API
  • Shows matching code snippets with context
  • Saves results as markdown for easy viewing
  • Handles rate limiting and authentication through GitHub CLI
  • Opens results in Cursor (if available)

Troubleshooting

If you get authentication errors:

  1. Make sure GitHub CLI is installed: gh --version
  2. Make sure you're logged in: gh auth status
  3. Try logging in again: gh auth login

Development

# Clone the repo
git clone https://github.com/johnlindquist/ghx.git

# Install dependencies
pnpm install

# Run in development
pnpm dev

# Build
pnpm build

License

ISC