From octocode
AI-powered code indexer with semantic search, knowledge graphs (GraphRAG), and persistent memory system. Use when you need to (1) perform semantic code searches across large codebases, (2) analyze file relationships and dependencies through GraphRAG, (3) store and retrieve code insights with memory system. This skill uses Bash to call octocode CLI directly with automatic index management.
How this skill is triggered — by the user, by Claude, or both
Slash command
/octocode:octocodeThis skill is limited to the following tools:
The summary Claude sees in its skill listing — used to decide when to auto-load this skill
> ⚠️ **实验性测试版本警告**
⚠️ 实验性测试版本警告
此 skill 目前处于早期实验阶段(v0.2.0),功能和接口可能随时变化。
仅供学习和测试使用,不建议在生产环境中使用。
使用风险自负。
Octocode 是一个基于 Rust 的 AI 代码索引工具,结合语义搜索、知识图谱(GraphRAG)和记忆系统能力。专为大型代码库设计,采用本地优先的方式。
核心特性:
实现方式:
octocode CLI说明:本 skill 整合了
~/.claude/CLAUDE.md中定义的多模型协作工作流(Phase 1: 上下文检索,Phase 6: 知识结晶)。完整工作流协议请参考该全局配置文件。
执行原则:优先使用语义检索获取全面上下文。
Octocode (首选): 语义搜索 + GraphRAG 知识图谱 (通过 Bash 调用 CLI)
octocode search "<query>": 语义级代码搜索octocode graphrag <operation>: 关系图谱查询(文件依赖、调用链、架构理解)octocode view <files>: 快速浏览文件签名结构Fallback: 当 Octocode 未安装或无法使用时 → glob + grep + 手动验证
scripts/check_index.sh 检查索引状态AskUserQuestion 询问用户是否创建octocode index 异步创建索引,实时显示进度glob/grep 做精确定位与兜底确认✅ Phase 1 必须先用 octocode search 或 octocode graphrag 检索
✅ 首次使用时必须检查索引状态 (运行 scripts/check_index.sh)
✅ 无索引时必须提示用户创建 (使用 AskUserQuestion)
✅ 一次性获取符号、依赖、调用链
✅ 上下文不足必须追溯
❌ 禁止 grep / keyword search 作为首选
❌ 禁止基于假设或内部知识回答
❌ 禁止未获取完整上下文就开始编码
❌ 禁止跳过索引检测直接搜索
bash scripts/check_index.shAskUserQuestion 询问用户octocode search 获取全局视图,再用 glob/grep 精确定位octocode graphrag 追踪依赖关系# 检查当前项目是否有索引
SKILL_DIR="${HOME}/.claude/skills/octocode"
if ! bash "${SKILL_DIR}/scripts/check_index.sh"; then
# 使用 AskUserQuestion 询问用户是否创建索引
# 如果用户同意,运行: octocode index
fi
执行者:Claude Code 执行条件:交付成功后
若任务涉及特定的用户偏好或项目隐式约定(非显式写在文档中的),使用 octocode memory save 命令记录。
⚠️ 安全警告:
使用示例(通过 Bash):
# 记录技术决策
octocode memory save "Fixed race condition in token refresh logic by adding mutex lock" \
--type bug_fix \
--tags security,jwt,race-condition \
--files src/auth/jwt.rs,src/middleware/auth.rs
code: 代码相关architecture: 架构决策bug_fix: Bug 修复optimization: 性能优化security: 安全相关testing: 测试相关documentation: 文档说明: 本 skill 通过 Bash 直接调用
octocodeCLI 命令,自动处理索引检测和创建。
用途:语义级代码搜索,支持自然语言查询
自动化特性:
scripts/check_index.sh)AskUserQuestion)CLI 命令:
# 基本语义搜索(自动处理索引)
octocode search "authentication logic"
# 搜索特定概念
octocode search "HTTP request handling with error recovery"
# 搜索代码模式
octocode search "database connection pooling implementation"
# 高级选项
octocode search "API endpoints" --mode code --expand
使用场景:
用途:基于关系的代码架构分析
自动化特性:
操作类型:
search - 语义搜索节点get-node - 获取节点详细信息get-relationships - 查看节点关系find-path - 查找节点间路径overview - 图谱统计概览CLI 命令:
# 语义搜索关系
octocode graphrag search --query "How does user authentication flow through the system?"
# 获取节点详情
octocode graphrag get-node --node-id src/auth/mod.rs
# 查看节点关系
octocode graphrag get-relationships --node-id src/auth/mod.rs
# 查找依赖路径
octocode graphrag find-path --source-id src/auth/mod.rs --target-id src/database/mod.rs
# 图谱概览
octocode graphrag overview
关系类型:
imports: 直接依赖关系sibling_module: 同目录文件parent_module / child_module: 层级结构使用场景:
用途:快速提取文件的函数签名、类定义等结构
CLI 命令:
# 查看特定文件
octocode view src/main.rs src/lib.rs
# 使用 glob 模式
octocode view "src/**/*.rs"
# 多语言分析
octocode view "**/*.{rs,py,js,ts}"
CLI 命令:
# 存储记忆
octocode memory save "Fixed race condition in JWT token refresh" \
--type bug_fix \
--tags security,jwt,race-condition \
--files src/auth/jwt.rs
# 简单记录
octocode memory save "Refactored authentication module for better testability"
CLI 命令:
# 搜索记忆
octocode memory search "authentication issues"
# 列出所有记忆
octocode memory list
CLI 命令:
# 删除特定记忆
octocode memory forget <memory-id>
# 1. Phase 1: 语义搜索理解架构(自动处理索引)
octocode search "main entry point and initialization"
octocode search "configuration and settings management"
octocode search "database access patterns"
# 2. 使用 GraphRAG 理解依赖
octocode graphrag overview
octocode graphrag search --query "How is the database connected?"
# 3. Phase 6: 保存发现(知识结晶)
octocode memory save "Main entry in src/main.rs, uses config from config/"
# Phase 1: 搜索相关代码(自动处理索引)
octocode search "authentication token validation"
# Phase 1: 分析依赖关系
octocode graphrag get-relationships --node-id src/auth/token.rs
# Phase 1: 查找类似的 Bug 修复(记忆检索)
octocode memory search "token validation bugs"
# Phase 2-5: 由 Claude Code 协调多模型完成
# Phase 6: 修复后记录(知识结晶)
octocode memory save "Fixed token expiry check in validate_token()" \
--type bug_fix \
--tags security,authentication
# Step 1: 检查索引状态
if ! bash ~/.claude/skills/octocode/scripts/check_index.sh; then
# Step 2: 使用 AskUserQuestion 询问用户
# 问题: "当前项目尚未创建 octocode 索引,是否现在创建?"
# 选项: ["是,创建索引 (推荐)", "否,跳过"]
# Step 3: 如果用户同意,创建索引
octocode index
fi
# Step 4: 执行搜索
octocode search "functions that call gemini-3-flash model"
scripts/check_index.shAskUserQuestion 询问octocode index)octocode watch)octocode search 或 octocode graphrag 检索scripts/check_index.shAskUserQuestion 询问octocode memory save 沉淀偏好octocode 命令已安装并在 PATH 中可用# Embedding 模型(至少需要一个)
export VOYAGE_API_KEY="..." # 推荐,每月 200M 免费 tokens
# export JINA_API_KEY="..." # 或 Jina AI
# export GOOGLE_API_KEY="..." # 或 Google
# 可选:LLM 功能(用于 CLI commit/review)
export OPENROUTER_API_KEY="..."
无需手动操作! 本 skill 实现了自动索引管理:
scripts/check_index.sh 检查索引状态AskUserQuestion 询问用户是否创建octocode index 创建索引并实时显示进度手动索引(可选):
# 如果想提前创建索引
cd /path/to/your/project
octocode index
# 监控模式(自动增量更新)
octocode watch
skill 包含一个辅助脚本用于检测索引状态:
# 位置
~/.claude/skills/octocode/scripts/check_index.sh
# 使用
if ! bash ~/.claude/skills/octocode/scripts/check_index.sh; then
echo "需要创建索引"
fi
⚠️ 再次提醒: 此项目仍在活跃开发中(v0.2.0),功能和 API 可能随时变化。生产环境请谨慎使用。
Creates, edits, and optimizes skills for Claude Code, including drafting, evaluating with test prompts, iterating on performance, and improving skill descriptions for better triggering accuracy.
npx claudepluginhub luw2007/skills --plugin octocode