Get the FREE Ultimate OpenClaw Setup Guide →

file-search

npx machina-cli add skill next-open-ai/openclawx/file-search --openclaw
Files (1)
SKILL.md
899 B

File Search Skill

Use this skill to recursively search for files or file contents within a specified directory.

Workflow

  1. Identify the user's search criteria:
    • By name/extension pattern (e.g., "*.md")
    • By content (e.g., "contains the word 'auth'")
    • By metadata (e.g., "modified in the last 7 days", "larger than 10MB")
  2. Formulate the appropriate bash command:
    • Use find <dir> -name "*.ext" -type f to search by name.
    • Use grep -rn "pattern" <dir> or rg "pattern" <dir> (if ripgrep is available) to search by content.
    • Use find <dir> -mtime -7 -size +10M to search by metadata.
  3. Execute the command using the bash tool.
  4. Process the output and present the results clearly to the user.

Source

git clone https://github.com/next-open-ai/openclawx/blob/main/presets/workspaces/file-assistant/skills/file-search/SKILL.mdView on GitHub

Overview

The file-search skill helps locate files by name, content, or metadata within a directory tree. It leverages bash tools like find for name and metadata searches, and grep or rg for content searches. This makes it easier to locate assets, logs, or code across large projects.

How This Skill Works

First, identify the search criteria (name pattern, content, or metadata). Then formulate a bash command using find for names and metadata, and grep or rg for content when available. Finally run the command through the bash tool and present the results in a clear, readable list of paths.

When to Use It

  • Locating all markdown files by name or extension in a project
  • Finding files that contain a specific keyword or phrase
  • Identifying recently modified or large files using metadata filters
  • Scanning a directory tree for assets like images or config files
  • Troubleshooting by locating relevant log or config files across directories

Quick Start

  1. Step 1: Define your search criteria as name pattern, content keyword, or metadata range
  2. Step 2: Build the bash command using find for names and metadata, and grep or rg for content
  3. Step 3: Run the command through the bash tool and review the output, adjusting scope as needed

Best Practices

  • Clarify the exact name pattern or keyword before running the search
  • Prefer ripgrep (rg) for content searches when available, otherwise fall back to grep
  • Scope searches with an explicit top level directory to reduce results
  • Use -maxdepth or directory pruning to limit deep scans during tuning
  • Review results for false positives and verify paths before taking action

Example Use Cases

  • Find all README files in a project: find . -name README.* -type f
  • Search for files containing the word auth under /app: grep -rn auth /app
  • List files modified in the last 7 days and larger than 10M: find /path -mtime -7 -size +10M
  • Locate all PNG assets in the assets folder: find assets -name *.png -type f
  • Use rg to search for init across the src directory: rg init src

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers