一键导入
mdfind
Search your entire Mac instantly using Spotlight's CLI. No RAG, no indexing setup, works out of the box.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Search your entire Mac instantly using Spotlight's CLI. No RAG, no indexing setup, works out of the box.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | mdfind |
| description | Search your entire Mac instantly using Spotlight's CLI. No RAG, no indexing setup, works out of the box. |
| homepage | https://x.com/_chenglou/status/2018915948456214940 |
| metadata | {"openclaw":{"emoji":"🔍","requires":{"bins":["mdfind"]},"platforms":["darwin"]}} |
macOS Spotlight as a terminal tool. Fuzzy & exact search across your entire computer in real time.
No RAG. No external tools. No prescriptive structure. Built-in and optimized.
Source: @_chenglou
# Simple text search (fuzzy, searches content + names)
mdfind "statistical learning"
# Search in specific folder only
mdfind -onlyin ~/clawd "pipeline"
# Live search (updates as files change)
mdfind -live "TODO"
# PDFs only
mdfind "kMDItemContentType == 'com.adobe.pdf'"
# Markdown files
mdfind "kMDItemContentType == 'net.daringfireball.markdown'"
# Images
mdfind "kMDItemContentType == 'public.image'"
# Python files
mdfind "kMDItemFSName == '*.py'"
# Word documents
mdfind "kMDItemContentType == 'org.openxmlformats.wordprocessingml.document'"
# PDF containing "methods"
mdfind "kMDItemContentType == 'com.adobe.pdf' && kMDItemTextContent == '*methods*'"
# Markdown files modified today
mdfind "kMDItemContentType == 'net.daringfireball.markdown' && kMDItemFSContentChangeDate >= \$time.today"
# Files by author
mdfind "kMDItemAuthors == 'Smith'"
# Large files (>100MB)
mdfind "kMDItemFSSize > 100000000"
# Modified in last 7 days
mdfind "kMDItemFSContentChangeDate >= \$time.today(-7)"
# Created this week
mdfind "kMDItemFSCreationDate >= \$time.this_week"
# Modified today
mdfind "kMDItemFSContentChangeDate >= \$time.today"
# Exact filename
mdfind "kMDItemFSName == 'README.md'"
# Filename pattern (case-insensitive)
mdfind "kMDItemFSName == '*.qmd'c"
# Name contains
mdfind "kMDItemDisplayName == '*grant*'c"
| Attribute | Description |
|---|---|
kMDItemFSName | File name |
kMDItemDisplayName | Display name |
kMDItemTextContent | File contents |
kMDItemContentType | UTI type |
kMDItemFSSize | File size (bytes) |
kMDItemFSCreationDate | Created date |
kMDItemFSContentChangeDate | Modified date |
kMDItemAuthors | Authors |
kMDItemTitle | Document title |
kMDItemKeywords | Keywords/tags |
mdls /path/to/file.pdf
# All files in a project mentioning "EEG"
mdfind -onlyin ~/clawd/Projects "EEG"
# Markdown modified in last 3 days
mdfind "kMDItemContentType == 'net.daringfireball.markdown' && kMDItemFSContentChangeDate >= \$time.today(-3)"
# Python files containing "import torch"
mdfind "kMDItemFSName == '*.py' && kMDItemTextContent == '*import torch*'"
mdfind -count "kMDItemContentType == 'com.adobe.pdf'"
# Just count
mdfind -count "query"
# Null-separated (for xargs)
mdfind -0 "query" | xargs -0 ls -la
# Pipe to other tools
mdfind -onlyin . "TODO" | head -20
-onlyin to scope searches and speed up results* and must be quoted: '*pattern*'c suffix: '*readme*'cmdfind "query" | xargs grep -l "specific"mdutil -s /From the original thread:
@udaysy: "been using ripgrep for everything but mdfind would catch stuff outside the project dir too right? like config files scattered across ~/"
Yes! Unlike rg or grep which search from cwd, mdfind searches your entire indexed filesystem by default. Great for finding those scattered config files.
@sentigen_ai: "Also works great paired with fd for when you know the rough name but not the path. mdfind for fuzzy semantic queries, fd for fast exact matches."
Recommended combo:
mdfind — fuzzy semantic search (content + metadata)fd — fast exact filename matchingrg — fast exact content grep@sughanthans1: "can it look inside files or just file names"
Both! Spotlight indexes file contents for supported types (PDF, Word, text, code, etc.). Use kMDItemTextContent to explicitly search inside files.
/tmp, external drives unless enabled)mdutil -s /path to verify indexing statusTL;DR: mdfind "your query" — instant full-text search across your Mac. Add -onlyin ~/folder to scope it. 🔍