← 返回 Skills 市场
mozi1924

Spotlight Search

作者 Mozi Arasaka · GitHub ↗ · v0.1.2 · MIT-0
darwin ✓ 安全检测通过
138
总下载
0
收藏
1
当前安装
3
版本数
在 OpenClaw 中安装
/install spotlight-search
功能描述
Search files, apps, and metadata on macOS using Spotlight CLI tools (`mdfind`, `mdls`, `mdutil`) with a fallback script for cases where indexing is incomplet...
使用说明 (SKILL.md)

Spotlight Search

Overview

Use mdfind first for indexed search, mdls for metadata inspection, and mdutil only when diagnosing indexing issues. If Spotlight misses a known file, use the bundled fallback script instead of hand-rolling a find command every time.

Quick Start

Preferred flow:

  1. Use mdfind for normal search.
  2. Use mdls when the task is about metadata, not discovery.
  3. Use ./scripts/spotlight_search.sh when Spotlight indexing is incomplete or results are unexpectedly empty.
  4. Treat the fallback script as a filename/path matcher, not a general shell helper.
  5. Use mdutil only to inspect indexing, and only suggest re-indexing when the user explicitly wants that system-level change.
# Find files containing "invoice" in name or content
mdfind "invoice"

# Find PDFs modified today
mdfind 'kind:pdf AND kMDItemContentModificationDate >= $time.today'

# Find applications whose name contains "chrome"
mdfind 'kMDItemContentType == com.apple.application-bundle && kMDItemFSName == "*chrome*"cd'

# Search only within ~/Documents
mdfind -onlyin ~/Documents "kind:pdf"

# View metadata for a file
mdls /path/to/file

For a hybrid search that tries Spotlight first and falls back to find, use the bundled script:

./scripts/spotlight_search.sh "query"
./scripts/spotlight_search.sh -t pdf "report"
./scripts/spotlight_search.sh -d ~/Documents "meeting"

Core Capabilities

1. File Search

Spotlight indexes file contents and metadata, making it ideal for locating documents when you remember words inside them.

Common patterns:

  • Simple keyword: mdfind "quarterly report"
  • By file type: mdfind "kind:pdf invoice"
  • By extension: mdfind 'kMDItemFSName == "*.md"cd'
  • By date: mdfind 'kMDItemContentModificationDate >= $time.yesterday'
  • By size: mdfind 'kMDItemFSSize > 1000000' (files >1 MB)

When to use: You recall words from the file's content, need to filter by type/date, or want to search across all indexed volumes quickly.

2. Application Search

Spotlight knows about installed applications (.app bundles) and can find them by name or bundle identifier.

Examples:

# All applications
mdfind 'kMDItemContentType == com.apple.application-bundle'

# Applications containing "visual" in name
mdfind 'kMDItemContentType == com.apple.application-bundle && kMDItemFSName == "*visual*"cd'

When to use: You need to locate an installed app, verify its presence, or get its bundle path.

3. Metadata Inspection

Use mdls to view the rich metadata Spotlight stores for any file.

# All metadata
mdls /path/to/file

# Specific attribute
mdls -name kMDItemKind /path/to/file

Common attributes: kMDItemKind, kMDItemContentType, kMDItemAuthors, kMDItemContentCreationDate, kMDItemPixelHeight, kMDItemDurationSeconds.

When to use: You need to check file properties (creation date, dimensions, author) without opening the file.

4. Hybrid Search (Fallback)

Spotlight indexing may be incomplete (excluded directories, recent files not yet indexed). The bundled script scripts/spotlight_search.sh provides a hybrid approach:

  1. Attempts Spotlight search via mdfind
  2. If no results, falls back to find with name‑based matching
  3. Uses shell argument arrays instead of eval, so the query is passed as data rather than executable shell text
  4. Supports filtering by kind (pdf, image, application, etc.)

Usage:

./scripts/spotlight_search.sh "query"
./scripts/spotlight_search.sh -t pdf "report"
./scripts/spotlight_search.sh -d ~/Documents -l 10 "draft"

When to use: You want maximum recall, or Spotlight is returning empty results for known files.

Reference Materials

For detailed query syntax, operator reference, and advanced examples, see:

  • mdfind Query Reference – Comprehensive guide to mdfind syntax, attribute filters, date comparisons, and practical examples.

Load this reference when you need to construct complex queries or understand Spotlight's capabilities.

Workflow Guidance

Choosing the Right Tool

Scenario Recommended Tool Example
"Find files containing 'budget'" mdfind "budget" Content‑aware search
"Find all PDFs modified this week" mdfind 'kind:pdf AND kMDItemContentModificationDate >= $time.this_week' Metadata‑filtered search
"Find the Chrome app" mdfind 'kMDItemContentType == com.apple.application-bundle && kMDItemFSName == "*chrome*"cd' Application search
"Search only in Downloads folder" mdfind -onlyin ~/Downloads "kind:image" Scoped search
"Check when a file was created" mdls -name kMDItemContentCreationDate /path/to/file Metadata inspection
"Spotlight returns nothing but I know the file exists" ./scripts/spotlight_search.sh "filename" Hybrid fallback

Troubleshooting

No results for known files?

  1. Check indexing status: mdutil -s /
  2. Ensure the directory is indexed (Spotlight excludes some system and Library folders)
  3. Re-index only with explicit user approval because it is a privileged, system-wide action: sudo mdutil -E /

Query syntax errors?

  • Enclose queries containing spaces or special characters in single quotes.
  • Use cd after == for case‑ and diacritic‑insensitive matching: kMDItemFSName == "*.pdf"cd
  • Combine filters with AND/OR and parentheses.

Slow performance?

  • Limit results with -limit N
  • Restrict search scope with -onlyin

Notes

  • Spotlight indexing is not real‑time; newly created files may take minutes to appear.
  • Some directories (e.g., ~/Library, system folders) may be excluded from indexing.
  • mdfind searches all indexed volumes by default; use -onlyin to constrain.
  • The hybrid script requires find (always present) and optionally fd (faster).

See Also

安全使用建议
This skill appears to do exactly what it says: call macOS Spotlight tools and, if needed, run a local safe fallback find. Before installing or running, verify you are comfortable with the included script (scripts/spotlight_search.sh) and that you trust local execution. Be cautious about any recommendation to re-index Spotlight (commands like 'sudo mdutil -E /') — that is a system-wide action requiring your explicit approval and may be slow. No credentials or network endpoints are involved, but the fallback 'find' can traverse many files and reveal file paths; only proceed if you are okay with that behavior.
功能分析
Type: OpenClaw Skill Name: spotlight-search Version: 0.1.2 The spotlight-search skill bundle is a legitimate utility for searching files and metadata on macOS. It uses standard system tools (mdfind, mdls, mdutil) and includes a well-structured bash script (scripts/spotlight_search.sh) that implements a safe fallback to the 'find' command, avoiding shell injection by using argument arrays instead of eval.
能力评估
Purpose & Capability
The name/description (Spotlight search) align with the declared binaries (mdfind, mdls, mdutil, find) and included script. Requiring 'find' for a fallback is reasonable; nothing requests unrelated services or secrets.
Instruction Scope
SKILL.md and the bundled script limit actions to searching and metadata inspection. The doc explicitly warns only to suggest re-indexing when the user explicitly wants it; re-indexing (sudo mdutil -E /) is a system-level action and should not be suggested or run without explicit user consent. Otherwise the runtime instructions do not read unrelated env vars or external endpoints.
Install Mechanism
No install spec — instruction-only plus a small included shell script. Nothing is downloaded from external URLs and no archives are extracted; the code is local and straightforward.
Credentials
No environment variables, credentials, or config paths are requested. The few operations that require elevated privileges (rebuilding the Spotlight index) are documented and conditional on user consent.
Persistence & Privilege
The skill does not request permanent presence (always:false), does not modify other skills or system configuration by default, and contains no self-enabling behavior. Autonomous invocation is allowed by platform default but not combined with other red flags.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install spotlight-search
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /spotlight-search 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v0.1.2
Add explicit macOS platform and binary dependency metadata
v0.1.1
Harden fallback script by removing eval and tighten guidance around reindexing
v0.1.0
Initial public release with improved macOS Spotlight workflow guidance
元数据
Slug spotlight-search
版本 0.1.2
许可证 MIT-0
累计安装 1
当前安装数 1
历史版本数 3
常见问题

Spotlight Search 是什么?

Search files, apps, and metadata on macOS using Spotlight CLI tools (`mdfind`, `mdls`, `mdutil`) with a fallback script for cases where indexing is incomplet... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 138 次。

如何安装 Spotlight Search?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install spotlight-search」即可一键安装,无需额外配置。

Spotlight Search 是免费的吗?

是的,Spotlight Search 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

Spotlight Search 支持哪些平台?

Spotlight Search 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(darwin)。

谁开发了 Spotlight Search?

由 Mozi Arasaka(@mozi1924)开发并维护,当前版本 v0.1.2。

💬 留言讨论