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