smart-explore by thedotmack/claude-mem
npx skills add https://github.com/thedotmack/claude-mem --skill smart-explore通过 AST 解析进行结构化代码探索。此技能会覆盖你默认的探索行为。 当此技能激活时,请使用 smart_search/smart_outline/smart_unfold 作为主要工具,而非 Read、Grep 和 Glob。
核心原则: 先索引,按需获取。在加载实现细节之前,先给自己一份代码地图。每次读取文件前的问题应该是:“我需要查看全部内容,还是可以先获取一个结构概览?”答案几乎总是:先获取地图。
此技能仅加载指令。你必须自己调用 MCP 工具。你的下一个操作应该是以下之一:
smart_search(query="<topic>", path="./src") -- 在目录中发现文件 + 符号
smart_outline(file_path="<file>") -- 单个文件的结构骨架
smart_unfold(file_path="<file>", symbol_name="<name>") -- 单个符号的完整源代码
不要首先运行 Grep、Glob、Read 或 find 来发现文件。smart_search 会遍历目录,解析所有代码文件,并在一次调用中返回排序后的符号。它取代了 Glob → Grep → Read 的发现循环。
smart_search(query="shutdown", path="./src", max_results=15)
返回: 排序后的符号(包含签名、行号、匹配原因)以及折叠的文件视图(约 2-6k tokens)
-- 匹配的符号 --
function performGracefulShutdown (services/infrastructure/GracefulShutdown.ts:56)
function httpShutdown (services/infrastructure/HealthMonitor.ts:92)
method WorkerService.shutdown (services/worker-service.ts:846)
-- 折叠的文件视图 --
services/infrastructure/GracefulShutdown.ts (7 个符号)
services/worker-service.ts (12 个符号)
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
这是你的发现工具。它能找到相关文件并显示其结构。无需预先进行 Glob/find 扫描。
参数:
query (字符串,必需) -- 要搜索的内容(函数名、概念、类名)path (字符串) -- 要搜索的根目录(默认为当前工作目录)max_results (数字) -- 最大匹配符号数,默认 20,最大 50file_pattern (字符串,可选) -- 筛选特定的文件/路径smart_outline(file_path="services/worker-service.ts")
返回: 完整的结构骨架 -- 所有函数、类、方法、属性、导入(每个文件约 1-2k tokens)
当步骤 1 的折叠文件视图已经提供了足够的结构信息时,跳过此步骤。对于搜索结果未覆盖的文件最有用。
参数:
file_path (字符串,必需) -- 文件路径查看步骤 1-2 中的符号。挑选你需要的那些。仅展开它们:
smart_unfold(file_path="services/worker-service.ts", symbol_name="shutdown")
返回: 指定符号的完整源代码,包括 JSDoc、装饰器和完整实现(约 400-2,100 tokens,取决于符号大小)。AST 节点边界保证了完整性,无论符号大小如何——这与可能截断长方法的 Read + 智能体摘要不同。
参数:
file_path (字符串,必需) -- 文件路径(由搜索/概览返回)symbol_name (字符串,必需) -- 要展开的函数/类/方法的名称仅当 smart_* 工具不适用时使用这些:
ensureWorkerStarted 定义在哪里?”)对于超过约 100 行的代码文件,优先使用 smart_outline + smart_unfold 而非 Read。
发现某个功能如何工作(跨领域):
1. smart_search(query="shutdown", path="./src")
-> 一次调用中,7 个文件中的 14 个符号,完整视图
2. smart_unfold(file_path="services/infrastructure/GracefulShutdown.ts", symbol_name="performGracefulShutdown")
-> 查看核心实现
导航大型文件:
1. smart_outline(file_path="services/worker-service.ts")
-> 1,466 tokens: 12 个函数,包含 24 个成员的 WorkerService 类
2. smart_unfold(file_path="services/worker-service.ts", symbol_name="startSessionProcessor")
-> 1,610 tokens: 你需要的特定方法
总计: ~3,076 tokens 对比 读取整个文件的 ~12,000 tokens
编写关于代码的文档(混合工作流):
1. smart_search(query="feature name", path="./src") -- 发现所有相关文件和符号
2. smart_outline on key files -- 理解结构
3. smart_unfold on important functions -- 获取实现细节
4. Read on small config/markdown/plan files -- 获取非代码上下文
使用 smart_* 工具进行代码探索,使用 Read 处理非代码文件。可以自由混合使用。
先探索后精确:
1. smart_search(query="session", path="./src", max_results=10)
-> 10 个排序后的符号: SessionMetadata, SessionQueueProcessor, SessionSummary...
2. 选择相关的符号,展开它
| 方法 | Tokens | 使用场景 |
|---|---|---|
| smart_outline | ~1,000-2,000 | “这个文件里有什么?” |
| smart_unfold | ~400-2,100 | “给我看看这个函数” |
| smart_search | ~2,000-6,000 | “在代码库中查找所有 X” |
| search + unfold | ~3,000-8,000 | 端到端:查找并读取(主要工作流) |
| Read (完整文件) | ~12,000+ | 当你确实需要所有内容时 |
| Explore agent | ~39,000-59,000 | 带有叙述的跨文件综合 |
在文件理解上节省 4-8 倍 的 tokens(outline + unfold 对比 Read)。在代码库探索上节省 11-18 倍 的 tokens(对比 Explore agent)。查询越具体,差距越大——通过 unfold 读取一个 27 行的函数比通过 Explore agent 读取便宜 55 倍,因为智能体仍然会读取整个文件。
每周安装量
297
仓库
GitHub 星标
40.0K
首次出现
2026年2月26日
安全审计
安装于
codex291
gemini-cli289
github-copilot289
amp289
kimi-cli289
cursor289
Structural code exploration using AST parsing. This skill overrides your default exploration behavior. While this skill is active, use smart_search/smart_outline/smart_unfold as your primary tools instead of Read, Grep, and Glob.
Core principle: Index first, fetch on demand. Give yourself a map of the code before loading implementation details. The question before every file read should be: "do I need to see all of this, or can I get a structural overview first?" The answer is almost always: get the map.
This skill only loads instructions. You must call the MCP tools yourself. Your next action should be one of:
smart_search(query="<topic>", path="./src") -- discover files + symbols across a directory
smart_outline(file_path="<file>") -- structural skeleton of one file
smart_unfold(file_path="<file>", symbol_name="<name>") -- full source of one symbol
Do NOT run Grep, Glob, Read, or find to discover files first. smart_search walks directories, parses all code files, and returns ranked symbols in one call. It replaces the Glob → Grep → Read discovery cycle.
smart_search(query="shutdown", path="./src", max_results=15)
Returns: Ranked symbols with signatures, line numbers, match reasons, plus folded file views (~2-6k tokens)
-- Matching Symbols --
function performGracefulShutdown (services/infrastructure/GracefulShutdown.ts:56)
function httpShutdown (services/infrastructure/HealthMonitor.ts:92)
method WorkerService.shutdown (services/worker-service.ts:846)
-- Folded File Views --
services/infrastructure/GracefulShutdown.ts (7 symbols)
services/worker-service.ts (12 symbols)
This is your discovery tool. It finds relevant files AND shows their structure. No Glob/find pre-scan needed.
Parameters:
query (string, required) -- What to search for (function name, concept, class name)path (string) -- Root directory to search (defaults to cwd)max_results (number) -- Max matching symbols, default 20, max 50file_pattern (string, optional) -- Filter to specific files/pathssmart_outline(file_path="services/worker-service.ts")
Returns: Complete structural skeleton -- all functions, classes, methods, properties, imports (~1-2k tokens per file)
Skip this step when Step 1's folded file views already provide enough structure. Most useful for files not covered by the search results.
Parameters:
file_path (string, required) -- Path to the fileReview symbols from Steps 1-2. Pick the ones you need. Unfold only those:
smart_unfold(file_path="services/worker-service.ts", symbol_name="shutdown")
Returns: Full source code of the specified symbol including JSDoc, decorators, and complete implementation (~400-2,100 tokens depending on symbol size). AST node boundaries guarantee completeness regardless of symbol size — unlike Read + agent summarization, which may truncate long methods.
Parameters:
file_path (string, required) -- Path to the file (as returned by search/outline)symbol_name (string, required) -- Name of the function/class/method to expandUse these only when smart_* tools are the wrong fit:
ensureWorkerStarted defined?")For code files over ~100 lines, prefer smart_outline + smart_unfold over Read.
Discover how a feature works (cross-cutting):
1. smart_search(query="shutdown", path="./src")
-> 14 symbols across 7 files, full picture in one call
2. smart_unfold(file_path="services/infrastructure/GracefulShutdown.ts", symbol_name="performGracefulShutdown")
-> See the core implementation
Navigate a large file:
1. smart_outline(file_path="services/worker-service.ts")
-> 1,466 tokens: 12 functions, WorkerService class with 24 members
2. smart_unfold(file_path="services/worker-service.ts", symbol_name="startSessionProcessor")
-> 1,610 tokens: the specific method you need
Total: ~3,076 tokens vs ~12,000 to Read the full file
Write documentation about code (hybrid workflow):
1. smart_search(query="feature name", path="./src") -- discover all relevant files and symbols
2. smart_outline on key files -- understand structure
3. smart_unfold on important functions -- get implementation details
4. Read on small config/markdown/plan files -- get non-code context
Use smart_* tools for code exploration, Read for non-code files. Mix freely.
Exploration then precision:
1. smart_search(query="session", path="./src", max_results=10)
-> 10 ranked symbols: SessionMetadata, SessionQueueProcessor, SessionSummary...
2. Pick the relevant one, unfold it
| Approach | Tokens | Use Case |
|---|---|---|
| smart_outline | ~1,000-2,000 | "What's in this file?" |
| smart_unfold | ~400-2,100 | "Show me this function" |
| smart_search | ~2,000-6,000 | "Find all X across the codebase" |
| search + unfold | ~3,000-8,000 | End-to-end: find and read (the primary workflow) |
| Read (full file) | ~12,000+ | When you truly need everything |
| Explore agent | ~39,000-59,000 | Cross-file synthesis with narrative |
4-8x savings on file understanding (outline + unfold vs Read). 11-18x savings on codebase exploration vs Explore agent. The narrower the query, the wider the gap — a 27-line function costs 55x less to read via unfold than via an Explore agent, because the agent still reads the entire file.
Weekly Installs
297
Repository
GitHub Stars
40.0K
First Seen
Feb 26, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
codex291
gemini-cli289
github-copilot289
amp289
kimi-cli289
cursor289
agent-browser 浏览器自动化工具 - Vercel Labs 命令行网页操作与测试
140,500 周安装