Get the FREE Ultimate OpenClaw Setup Guide →

Code Search

Scanned
npx machina-cli add skill YPares/rigup.nix/code-search --openclaw
Files (1)
SKILL.md
2.3 KB

Code Search & File Tree Browsing

Fast, efficient utilities for searching code and browsing file hierarchies.

Tools Overview

ripgrep (rg)

Ultra-fast grep alternative that respects .gitignore by default.

Common usage:

rg <pattern> [<path>]              # Search for pattern in files
rg -t <type> <pattern>             # Search files of specific type
rg --no-ignore <pattern>           # Search ignoring .gitignore
rg -w <pattern>                    # Match whole word
rg -C <num> <pattern>              # Show context lines

fd

Faster, simpler alternative to find with better defaults and colorized output.

Common usage:

fd <pattern> [<path>]              # Find files matching pattern
fd -e <ext> <pattern>              # Find by extension
fd -t f <pattern>                  # Find files only
fd -t d <pattern>                  # Find directories only
fd --follow <pattern>              # Follow symlinks

bat

Syntax-highlighting cat with git integration and line numbers.

Common usage:

bat <file>                         # View file with syntax highlighting
bat --line-range <start:end> <file>  # Show specific line range
rg <pattern> | bat --file-name <path>  # Syntax highlight search results

fzf

Fuzzy filtering and pattern matching for command pipelines.

Common usage:

<command> | fzf --filter <pattern>  # Filter output by pattern (non-interactive)
echo -e "file1\nfile2\nfile3" | fzf --filter "file"  # Match lines containing "file"
rg <pattern> | fzf --filter <secondary-pattern>  # Further filter search results

tree

Display directory structure in tree format.

Common usage:

tree [<path>]                      # Show tree structure
tree -L <depth> [<path>]           # Limit depth
tree -I '<pattern>'                # Exclude pattern
tree -a                            # Include hidden files

Common Workflows

Filter search results by secondary pattern

rg <primary-pattern> | fzf --filter <secondary-pattern>

Search code and show context

rg -C 3 <pattern>

Search specific file types

rg -t ts <pattern>      # TypeScript files
rg -t py <pattern>      # Python files
rg -t go <pattern>      # Go files

List directory tree

tree -L 3

Source

git clone https://github.com/YPares/rigup.nix/blob/main/riglets/code-search/SKILL.mdView on GitHub

Overview

Code Search bundles fast utilities for locating code patterns and exploring project hierarchies. It centers on ripgrep for fast pattern matching, fd for quick file discovery, bat for syntax-highlighted viewing, fzf for interactive filtering, and tree for visualizing directory structure, enabling rapid code exploration and debugging.

How This Skill Works

You compose shell pipelines using the provided tools: ripgrep searches files with options like -t for language, --no-ignore to include or respect gitignore, -w for whole-word matches, and -C to show context; fd finds files by name; bat renders matches with syntax highlighting; fzf offers interactive filtering; and tree displays a readable directory structure for quick navigation.

When to Use It

  • When you need to locate a symbol or pattern across a large codebase.
  • When you want to quickly find files by extension or language type.
  • When you need contextual code snippets around matches with syntax highlighting.
  • When you want to progressively narrow results with interactive filtering.
  • When you want a quick visual of the project layout.

Quick Start

  1. Step 1: rg <pattern> [<path>]
  2. Step 2: rg -t <type> <pattern> # search by file type
  3. Step 3: rg <pattern> | bat --file-name <path> # syntax-highlight search results

Best Practices

  • Rely on ripgrep's default behavior that respects .gitignore; use --no-ignore only when you truly need to include ignored files.
  • Target specific languages or file types with -t to reduce noise (e.g., -t ts, -t py).
  • Use -w to enforce whole-word matches to avoid partial hits.
  • Show context around matches with -C <num> to understand usage quickly.
  • Combine rg with fzf for interactive filtering and bat for syntax-highlighted inspection of chosen results.

Example Use Cases

  • rg 'getUser' <repo-root>
  • rg -t ts 'updateUser' <src/>
  • rg --no-ignore 'password' .
  • rg -w 'connect' -t go <path>
  • rg -C 3 'initialize' <path> | bat --file-name <path>

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers