Spotlight Search
Search local files using macOS Spotlight indexing system.
When to Use
Use this skill when:
- User asks to search files or directories on macOS
- Need to find documents containing specific text
- Searching large document collections (faster than grep)
- Need to search inside PDFs, Word docs, or other indexed formats
Quick Start
scripts/spotlight-search.sh <directory> <query> [--limit N]
Examples:
scripts/spotlight-search.sh ~/Documents "machine learning"
scripts/spotlight-search.sh ~/research "neural networks" --limit 10
scripts/spotlight-search.sh ~/Downloads "meeting notes" --limit 5
Search Features
- Fast: Uses system-level Spotlight index (no file scanning)
- Content-aware: Searches inside PDF, docx, txt, md, etc.
- Multilingual: Supports Chinese, Japanese, and all languages
- Metadata: Returns file path, type, and size
Output Format
🔍 Searching in /path/to/directory for: query
✅ Found N results (showing up to M):
📄 /full/path/to/file.pdf [pdf, 2.3M]
📄 /full/path/to/document.txt [txt, 45K]
📁 /full/path/to/folder/
Supported File Types
Spotlight automatically indexes:
- Text files (txt, md, csv, json, xml, etc.)
- Documents (pdf, docx, pages, rtf, etc.)
- Code files (py, js, java, c, etc.)
- Emails and contacts
- Images (with embedded metadata/OCR)
Limitations
- macOS only: Requires Spotlight indexing
- Indexed directories only: External drives may not be indexed
- Keyword search: Not semantic (use embedding-based search for semantic queries)
- Privacy: Respects Spotlight privacy settings (excluded directories won't appear)
Check Indexing Status
# Check if a volume is indexed
mdutil -s /path/to/volume
# Enable indexing (requires admin)
sudo mdutil -i on /path/to/volume
Integration with LLM Workflows
Pattern: Search + Extract + Summarize
- Use
spotlight-search.sh to find relevant files
- Use
read tool to extract content from top results
- Summarize or answer user's question based on extracted content
Example workflow:
User: "Find all documents about machine learning in my research folder"
1. Run: spotlight-search.sh ~/research "machine learning" --limit 10
2. Read top 3-5 results with read tool
3. Summarize findings for user
Advanced Query Syntax
Spotlight supports advanced query operators:
# Exact phrase
spotlight-search.sh ~/Documents "\"machine learning\""
# AND operator
spotlight-search.sh ~/Documents "neural AND networks"
# OR operator
spotlight-search.sh ~/Documents "AI OR artificial intelligence"
# Metadata queries
spotlight-search.sh ~/Documents "kMDItemContentType == 'com.adobe.pdf'"
Troubleshooting
No results found:
- Check if directory is indexed:
mdutil -s /path
- Wait for indexing to complete (new files may take minutes)
- Verify Spotlight is enabled in System Preferences
Incorrect results:
- Spotlight uses fuzzy matching and synonyms
- Use exact phrase search:
"exact phrase"
- Check privacy settings (some folders may be excluded)
Performance
- Instant: Pre-indexed, no file scanning needed
- Scales well: Handles millions of files
- Low CPU: No processing overhead (vs grep/ripgrep)
Comparison:
| Tool |
Speed |
Content Search |
Multilingual |
| Spotlight |
⚡ Instant |
✅ Yes |
✅ Yes |
| grep/ripgrep |
🐢 Slow |
✅ Yes |
✅ Yes |
| find |
⚡ Fast |
❌ No |
N/A |
Platform Notes
- macOS only: This skill requires macOS Spotlight
- Linux alternative: Use
grep -r or ripgrep
- Windows alternative: Use Windows Search or Everything search
1---
2name: spotlight
3description: Search files and content using macOS Spotlight indexing (mdfind). Use when the user asks to search local files, documents, or directories on macOS. Supports text content search inside PDFs, Word documents, text files, and more. Much faster than grep for large document collections. Only works on macOS systems with Spotlight enabled.
4metadata:
5 source: https://skillmd.com/skills/modbender/spotlight
6---
7
8# Spotlight Search
9
10Search local files using macOS Spotlight indexing system.
11
12## When to Use
13
14Use this skill when:
15- User asks to search files or directories on macOS
16- Need to find documents containing specific text
17- Searching large document collections (faster than grep)
18- Need to search inside PDFs, Word docs, or other indexed formats
19
20## Quick Start
21
22```bash
23scripts/spotlight-search.sh <directory> <query> [--limit N]
24```
25
26**Examples:**
27
28```bash
29scripts/spotlight-search.sh ~/Documents "machine learning"
30scripts/spotlight-search.sh ~/research "neural networks" --limit 10
31scripts/spotlight-search.sh ~/Downloads "meeting notes" --limit 5
32```
33
34## Search Features
35
36- **Fast**: Uses system-level Spotlight index (no file scanning)
37- **Content-aware**: Searches inside PDF, docx, txt, md, etc.
38- **Multilingual**: Supports Chinese, Japanese, and all languages
39- **Metadata**: Returns file path, type, and size
40
41## Output Format
42
43```
44🔍 Searching in /path/to/directory for: query
45
46✅ Found N results (showing up to M):
47
48📄 /full/path/to/file.pdf [pdf, 2.3M]
49📄 /full/path/to/document.txt [txt, 45K]
50📁 /full/path/to/folder/
51```
52
53## Supported File Types
54
55Spotlight automatically indexes:
56- Text files (txt, md, csv, json, xml, etc.)
57- Documents (pdf, docx, pages, rtf, etc.)
58- Code files (py, js, java, c, etc.)
59- Emails and contacts
60- Images (with embedded metadata/OCR)
61
62## Limitations
63
64- **macOS only**: Requires Spotlight indexing
65- **Indexed directories only**: External drives may not be indexed
66- **Keyword search**: Not semantic (use embedding-based search for semantic queries)
67- **Privacy**: Respects Spotlight privacy settings (excluded directories won't appear)
68
69## Check Indexing Status
70
71```bash
72# Check if a volume is indexed
73mdutil -s /path/to/volume
74
75# Enable indexing (requires admin)
76sudo mdutil -i on /path/to/volume
77```
78
79## Integration with LLM Workflows
80
81**Pattern: Search + Extract + Summarize**
82
831. Use `spotlight-search.sh` to find relevant files
842. Use `read` tool to extract content from top results
853. Summarize or answer user's question based on extracted content
86
87**Example workflow:**
88
89```
90User: "Find all documents about machine learning in my research folder"
91
921. Run: spotlight-search.sh ~/research "machine learning" --limit 10
932. Read top 3-5 results with read tool
943. Summarize findings for user
95```
96
97## Advanced Query Syntax
98
99Spotlight supports advanced query operators:
100
101```bash
102# Exact phrase
103spotlight-search.sh ~/Documents "\"machine learning\""
104
105# AND operator
106spotlight-search.sh ~/Documents "neural AND networks"
107
108# OR operator
109spotlight-search.sh ~/Documents "AI OR artificial intelligence"
110
111# Metadata queries
112spotlight-search.sh ~/Documents "kMDItemContentType == 'com.adobe.pdf'"
113```
114
115## Troubleshooting
116
117**No results found:**
118- Check if directory is indexed: `mdutil -s /path`
119- Wait for indexing to complete (new files may take minutes)
120- Verify Spotlight is enabled in System Preferences
121
122**Incorrect results:**
123- Spotlight uses fuzzy matching and synonyms
124- Use exact phrase search: `"exact phrase"`
125- Check privacy settings (some folders may be excluded)
126
127## Performance
128
129- **Instant**: Pre-indexed, no file scanning needed
130- **Scales well**: Handles millions of files
131- **Low CPU**: No processing overhead (vs grep/ripgrep)
132
133**Comparison:**
134
135| Tool | Speed | Content Search | Multilingual |
136|------|-------|----------------|--------------|
137| Spotlight | ⚡ Instant | ✅ Yes | ✅ Yes |
138| grep/ripgrep | 🐢 Slow | ✅ Yes | ✅ Yes |
139| find | ⚡ Fast | ❌ No | N/A |
140
141## Platform Notes
142
143- **macOS only**: This skill requires macOS Spotlight
144- **Linux alternative**: Use `grep -r` or `ripgrep`
145- **Windows alternative**: Use Windows Search or Everything search