home / skills / codingheader / myskills / 0xdarkmatter-file-search

0xdarkmatter-file-search skill

/Skillstore/file-search/0xdarkmatter-file-search

This skill helps you search codebases efficiently by combining fd, rg, and fzf for quick file discovery and content queries.

This is most likely a fork of the file-search skill from 0xdarkmatter
npx playbooks add skill codingheader/myskills --skill 0xdarkmatter-file-search

Review the files below or copy the command above to add this skill to your agents.

Files (3)
SKILL.md
2.3 KB
---
name: file-search
description: "Modern file and content search using fd, ripgrep (rg), and fzf. Triggers on: fd, ripgrep, rg, find files, search code, fzf, fuzzy find, search codebase."
compatibility: "Requires fd, ripgrep (rg), and optionally fzf. Install: brew install fd ripgrep fzf (macOS)."
allowed-tools: "Bash"
---

# File Search

Modern file and content search.

## fd - Find Files

```bash
# Find by name
fd config                    # Files containing "config"
fd -e py                     # Python files

# By type
fd -t f config               # Files only
fd -t d src                  # Directories only

# Exclude
fd -E node_modules           # Exclude directory
fd -E "*.min.js"             # Exclude pattern

# Execute command
fd -e py -x wc -l            # Line count per file
```

## rg - Search Content

```bash
# Simple search
rg "TODO"                    # Find TODO
rg -i "error"                # Case-insensitive

# By file type
rg -t py "import"            # Python files only
rg -t js -t ts "async"       # JS and TS

# Context
rg -C 3 "function"           # 3 lines before/after

# Output modes
rg -l "TODO"                 # File names only
rg -c "TODO"                 # Count per file
```

## fzf - Interactive Selection

```bash
# Find and select
fd | fzf

# With preview
fd | fzf --preview 'bat --color=always {}'

# Multi-select
fd -e ts | fzf -m | xargs code
```

## Combined Patterns

```bash
# Find files, search content
fd -e py -x rg "async def" {}

# Search, select, open
rg -l "pattern" | fzf --preview 'rg -C 3 "pattern" {}' | xargs vim
```

## Quick Reference

| Task | Command |
|------|---------|
| Find TS files | `fd -e ts` |
| Find in src | `fd -e ts src/` |
| Search pattern | `rg "pattern"` |
| Search in type | `rg -t py "import"` |
| Files with match | `rg -l "pattern"` |
| Count matches | `rg -c "pattern"` |
| Interactive | `fd \| fzf` |
| With preview | `fd \| fzf --preview 'bat {}'` |

## Performance Tips

| Tip | Why |
|-----|-----|
| Both respect `.gitignore` | Auto-skip node_modules, dist |
| Use `-t` over `-g` | Type flags are faster |
| Narrow the path | `rg pattern src/` faster |
| Use `-F` for literals | Avoids regex overhead |

## Additional Resources

For detailed patterns, load:
- `./references/advanced-workflows.md` - Git integration, shell functions, power workflows

Overview

This skill provides modern file and content search workflows using fd, ripgrep (rg), and fzf. It combines fast filesystem discovery, blazing content search, and interactive fuzzy selection to help you locate files, inspect code, and open results quickly. The skill is optimized for codebases and respects .gitignore by default.

How this skill works

It runs fd to locate files by name, type, or pattern; uses rg to search file content with context, counts, or filename-only output; and integrates fzf for interactive selection and preview. Commands can be chained so you can find files, filter by content, preview matches (via bat or rg), and open or act on selections with your editor or tools.

When to use it

  • Locate files by name, extension, or type across a large repository
  • Search code for function names, TODOs, or error messages quickly
  • Interactively filter and preview matches before opening files
  • Count matches per file or list filenames containing a pattern
  • Build shell workflows that open, edit, or process search results

Best practices

  • Prefer fd -t and rg -t to limit by language/type for speed
  • Narrow search paths (e.g., src/) to reduce scan time
  • Use rg -F for literal string searches to avoid regex overhead
  • Leverage fzf --preview with bat or rg -C for quick context
  • Exclude heavy directories with fd -E or rely on .gitignore

Example use cases

  • Find all TypeScript files: fd -e ts
  • Search for TODO comments across the codebase: rg "TODO"
  • Interactively open a matched file with context preview: rg -l "pattern" | fzf --preview 'rg -C 3 "pattern" {}' | xargs vim
  • Count TODOs per file: rg -c "TODO"
  • Find Python files and run a line count: fd -e py -x wc -l

FAQ

Do these tools respect .gitignore?

Yes. fd and rg automatically respect .gitignore, so ignored directories like node_modules are skipped by default.

How do I preview matches in fzf?

Pipe filenames into fzf and use --preview with bat or rg, e.g., fd | fzf --preview 'bat --color=always {}' or fzf --preview 'rg -C 3 "pattern" {}'.