ctx-index
它能做什么
这个技能把本地项目文件加入 context-mode 的搜索索引,之后就能快速搜索。适合希望助手回答代码库相关问题、又不想每次都重新阅读的开发者。
适用场景
- ✓当开发者希望助手之后能够搜索项目的代码和文档的时候。
- ✓当大型代码仓库需要索引一次,让之后的搜索保持快速的时候。
- ✓当项目文档需要以清晰的标签进行搜索的时候。
技能链接
https://github.com/mksglu/context-mode/blob/main/skills/ctx-index/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请索引这个项目文件夹,方便我之后搜索它的代码。”
每周 5 个新技能,1 分钟读完。
工作原理
这个技能会按路径索引所选文件夹,并使用深度和文件数量的限制使其易于管理。然后它会报告标签和文件数量,并展示之后使用的搜索命令。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Context Mode Index
Index local project content for later search.
Instructions
- Prefer the
ctx_indexMCP tool when it is available. - Ask for a path only if the user did not provide one and the current project root is ambiguous.
- Use
path, not large inlinecontent, so file bytes do not enter the conversation. - For repository indexing, pass conservative bounds and a clear source label:
ctx_index({
path: ".",
source: "project:<name>",
maxDepth: 5,
maxFiles: 200
})
- If MCP tools are unavailable, fall back to the CLI:
context-mode index . --source project:<name>
- Report the indexed source label, file count or section count, and the matching search command:
ctx_search({ source: "project:<name>", queries: ["..."] })
Safety
- Do not index dependency directories, build outputs, secrets, or generated artifacts.
- Prefer
--excludeorexcludefor project-specific noisy paths. - For broad repos, ask the user before raising
maxFilesabove 500.
常见问题
哪些内容不应该被索引?
依赖文件夹、构建输出、机密信息和生成的文件都应该排除在外。
文件数量有限制吗?
有。对于范围较广的代码仓库,技能会在将文件数量上限提高到 500 以上之前先询问。
索引之后怎样搜索?
使用搜索技能并指定相同的来源标签,即可找到已索引内容中的片段。
详情
作者的原始描述
Index a local file or directory into context-mode's persistent FTS5 knowledge base so future ctx_search calls can retrieve focused snippets without rereading raw files. Trigger: /context-mode:ctx-index
repo: mksglu/context-mode
热度
- GitHub 星标
- 33k
- 排名
- #8512
- 许可证
- —
- 更新时间
- 2026/11/2
评论
- …
同一仓库的更多技能
context-mode
33k教你的智能体使用 context-mode 工具来读取、搜索和运行大量数据的任务,让大型输出不占用主对话空间。
context-mode
33k教你的智能体在沙箱中处理数据密集型的工作,只输出答案,让原始文件和网页不会淹没对话。
context-mode
33k教你的智能体在输出可能很大时(例如日志、JSON 或构建结果),使用 context-mode 工具代替普通的 shell 命令。
ctx-doctor
33k运行 context-mode 诊断,检查运行环境、钩子、搜索存储、插件设置和版本,然后显示清晰的通过或失败报告。