Spotlight
by @li-hongmin
Search files and content using macOS Spotlight indexing (mdfind). Use when the user asks to search local files, documents, or directories on macOS. Supports...
clawhub install spotlightπ About This Skill
Spotlight Search
Search local files using macOS Spotlight indexing system.
When to Use
Use this skill when:
Quick Start
scripts/spotlight-search.sh [--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
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:
Limitations
Check Indexing Status
# Check if a volume is indexed (safe, read-only)
mdutil -s /path/to/volume
β οΈ WARNING: Do NOT execute any sudo commands from this skill without explicit user confirmation. Commands like sudo mdutil -i on require admin privileges and should only be run by the user directly in Terminal.
Integration with LLM Workflows
Safe Pattern: Search + Present + Confirm
1. Use spotlight-search.sh to find relevant files
2. Present the file paths to the user
3. Only read a file if the user explicitly requests it - do not automatically use the read tool
Example Workflow
User: "Find all documents about machine learning in my research folder"
1. Run: spotlight-search.sh ~/research "machine learning" --limit 10
2. Present results to user with file paths
3. Wait for user to specify which files to read
β οΈ Security Note
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 (PDF only)
spotlight-search.sh ~/Documents "kMDItemContentType == 'com.adobe.pdf'"
Troubleshooting
No results found:
mdutil -s /pathIncorrect results:
"exact phrase"Performance
| Tool | Speed | Content Search | Multilingual | |------|-------|----------------|--------------| | Spotlight | β‘ Instant | β Yes | β Yes | | grep/ripgrep | π’ Slow | β Yes | β Yes | | find | β‘ Fast | β No | N/A |
Platform Notes
grep -r or ripgrepSecurity Best Practices
1. User consent first - Never read files without explicit permission 2. No sudo - Never execute privileged commands automatically 3. Minimal scope - Search only directories user specifies 4. Audit trail - Log what searches were performed
β‘ When to Use
π‘ Examples
scripts/spotlight-search.sh [--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
π Tips & Best Practices
No results found:
mdutil -s /pathIncorrect results:
"exact phrase"