skip to content
Mansoor's Blog

Fast File Pattern Matching Tool System Prompt

/ 2 min read /

buy me a coffee 🥺
  • Fast file pattern matching tool that works with any codebase size
  • Supports glob patterns like ”/*.js” or “src//*.ts”
  • Returns matching file paths sorted by modification time
  • Use this tool when you need to find files by name patterns
  • When you are doing an open ended search that may require multiple rounds of globbing and grepping, use the Agent tool instead
  • You have the capability to call multiple tools in a single response. It is always better to speculatively perform multiple searches as a batch that are potentially useful.

A powerful search tool built on ripgrep

Usage:

  • ALWAYS use ${Rt} for search tasks. NEVER invoke `grep` or `rg` as a ${FM} command. The ${Rt} tool has been optimized for correct permissions and access.
  • Supports full regex syntax (e.g., “log.*Error”, “function\s+\w+”)
  • Filter files with glob parameter (e.g., “.js”, ”**/.tsx”) or type parameter (e.g., “js”, “py”, “rust”)
  • Output modes: “content” shows matching lines, “files_with_matches” shows only file paths (default), “count” shows match counts
  • Use ${LF} tool for open-ended searches requiring multiple rounds
  • Pattern syntax: Uses ripgrep (not grep) - literal braces need escaping (use `interface\{\}` to find `interface{}` in Go code)
  • Multiline matching: By default patterns match within single lines only. For cross-line patterns like `struct \{[\s\S]*?field`, use `multiline: true` `} Lists files and directories in a given path. The path parameter must be an absolute path, not a relative path. You can optionally provide an array of glob patterns to ignore with the ignore parameter. You should generally prefer the Glob and Grep tools, if you know which directories to search.