Get the FREE Ultimate OpenClaw Setup Guide →

file-search

Scanned
npx machina-cli add skill aiskillstore/marketplace/file-search --openclaw
Files (1)
SKILL.md
2.3 KB

File Search

Modern file and content search.

fd - Find Files

# 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

# 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

# Find and select
fd | fzf

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

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

Combined Patterns

# 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

TaskCommand
Find TS filesfd -e ts
Find in srcfd -e ts src/
Search patternrg "pattern"
Search in typerg -t py "import"
Files with matchrg -l "pattern"
Count matchesrg -c "pattern"
Interactivefd | fzf
With previewfd | fzf --preview 'bat {}'

Performance Tips

TipWhy
Both respect .gitignoreAuto-skip node_modules, dist
Use -t over -gType flags are faster
Narrow the pathrg pattern src/ faster
Use -F for literalsAvoids regex overhead

Additional Resources

For detailed patterns, load:

  • ./references/advanced-workflows.md - Git integration, shell functions, power workflows

Source

git clone https://github.com/aiskillstore/marketplace/blob/main/skills/0xdarkmatter/file-search/SKILL.mdView on GitHub

Overview

This skill enables fast file discovery and content search across a codebase using fd to locate files, rg to search within them, and fzf for interactive selection. It helps developers quickly find files and relevant code snippets.

How This Skill Works

The workflow uses fd to enumerate files by name or type, rg to scan contents with optional context, and fzf to interactively pick results. Preview with bat is available to inspect matches before opening the file.

When to Use It

  • Find a file by name or extension quickly (e.g., fd -e ts)
  • Search code for a pattern across the repo (e.g., rg 'pattern')
  • Interactively browse results and open a file with a keystroke (fd | fzf)
  • Narrow searches to specific folders or file types (fd -t f -E node_modules; rg -t py)
  • Combine file discovery and content search in one workflow (fd -e py -x rg 'async def' {})

Quick Start

  1. Step 1: Install dependencies: brew install fd ripgrep fzf
  2. Step 2: Do a basic file search: fd -e ts src/
  3. Step 3: Explore content or pick interactively: fd -e py -x rg 'async def' {} | fzf

Best Practices

  • Respect .gitignore to skip large ignored dirs like node_modules
  • Use -t flags (type filters) instead of -g for speed
  • Narrow the search path to reduce results (e.g., rg pattern src/)
  • Use -F when matching literals to avoid regex overhead
  • Leverage fzf preview to inspect matches before opening

Example Use Cases

  • Find TypeScript files: fd -e ts
  • Search a code pattern in JS/TS: rg -t js -t ts 'async'
  • Interactive file selection: fd | fzf
  • Find Python files and search inside: fd -e py -x rg 'def ' {}
  • Open a match with Vim after selection: rg -l 'pattern' | fzf --preview 'rg -C 3 pattern' | xargs vim

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers