← 返回 Skills 市场
michealxie001

OpenClaw Codebase Intelligence

作者 michealxie001 · GitHub ↗ · v1.1.0 · MIT-0
cross-platform ✓ 安全检测通过
121
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install oc-codebase-intelligence
功能描述
Intelligent codebase analysis and understanding with caching. Automatically explores project structure, identifies modules, analyzes dependencies, and answer...
使用说明 (SKILL.md)

Codebase Intelligence

智能代码库分析工具,自动理解项目结构、模块边界和依赖关系。

Version: 1.1
Features: 增量索引缓存、符号搜索、智能问答、架构图生成、C/C++ 支持 (NEW)


Quick Start

1. 首次索引(自动缓存)

cd /path/to/project
python3 /path/to/codebase-intelligence/scripts/main.py analyze .

第一次会创建 .codebase-intelligence/ 目录并缓存索引。后续查询秒开!

2. 智能问答

# 查找代码位置
python3 main.py ask "Where is authentication implemented?"

# 了解工作流程
python3 main.py ask "How does the user login flow work?"

# 查找如何修改
python3 main.py ask "What files need to change to add OAuth?"

3. 符号搜索

# 查找类定义
python3 main.py analyze --symbol "UserManager" --symbol-type class

# 查找函数
python3 main.py analyze --symbol "authenticate" --symbol-type func

4. 依赖分析

# 查看文件依赖什么
python3 main.py deps src/auth.py

# 查看什么依赖这个文件
python3 main.py deps src/utils.py --reverse

5. 生成架构图

# Mermaid 图
python3 main.py diagram --format mermaid

# 流程图
python3 main.py diagram --format mermaid-flow --entry-points main.py app.py

Commands

命令 功能 示例
analyze 分析代码库(带缓存) main.py analyze . --stats
analyze --search 搜索文件 main.py analyze --search "auth"
analyze --symbol 查找符号 main.py analyze --symbol "User"
ask 智能问答 main.py ask "How does X work?"
deps 依赖分析 main.py deps src/main.py --reverse
diagram 生成图表 main.py diagram --format mermaid
index 更新索引 main.py index --export index.json

Features

✅ 增量缓存

  • 首次分析后自动缓存
  • 后续只更新修改过的文件
  • 大型项目也能秒开
# 第一次:建立索引(可能需要几秒)
python3 main.py analyze .

# 第二次:秒开!
python3 main.py analyze .  # 瞬间完成

✅ 符号索引

自动索引:

  • 函数定义
  • 类/接口定义
  • 导入语句
  • 文件元数据(语言、行数)

✅ 智能问答

支持问题类型:

  • Location: "Where is X?" → 定位代码
  • How it works: "How does X work?" → 理解流程
  • Definition: "What is X?" → 查找定义
  • Dependencies: "What depends on X?" → 依赖分析
  • Modification: "How to add X?" → 修改建议

✅ 多语言支持

语言 符号解析 依赖提取
Python
JavaScript/TypeScript
Go
Java
Rust ⚠️
Ruby ⚠️ ⚠️
PHP ⚠️ ⚠️

Examples

场景 1:接手新项目

# 1. 获取整体概览
python3 main.py analyze /path/to/project --stats

# 2. 了解主要模块
python3 main.py analyze --search "module"

# 3. 查找核心类
python3 main.py analyze --symbol "App" --symbol-type class

# 4. 了解工作流程
python3 main.py ask "How does data flow through the system?"

# 5. 生成架构图
python3 main.py diagram --format mermaid-component

场景 2:重构前分析

# 1. 检查谁依赖要重构的模块
python3 main.py deps src/old-module.py --reverse --depth 3

# 2. 了解影响范围
python3 main.py ask "What would break if I refactor the auth module?"

# 3. 查看修改建议
python3 main.py ask "How to migrate from class X to class Y?"

场景 3:代码审查

# 查看变更影响
python3 main.py ask "What depends on src/utils/helpers.py?"

Configuration

忽略文件

.codebase-intelligence.json 中配置:

{
  "ignore": [
    "node_modules",
    ".git",
    "*.test.js",
    "vendor/"
  ],
  "entryPoints": [
    "src/main.py",
    "src/index.js"
  ]
}

缓存位置

默认缓存位置:\x3Cproject>/.codebase-intelligence/codebase_index.pkl

也可以指定:

python3 main.py analyze . --cache-dir /path/to/cache

Output Formats

Markdown Report

python3 main.py analyze --stats

包含:

  • 项目概览
  • 语言分布表
  • 模块结构树
  • 符号统计

JSON Export

python3 main.py index --export index.json

结构化数据,包含完整索引信息。

Mermaid Diagrams

python3 main.py diagram --format mermaid

可直接在 Markdown/GitHub/GitLab 中渲染。


Performance

项目规模 首次索引 增量更新
小 (\x3C100文件) \x3C1s \x3C0.1s
中 (100-1000文件) 2-5s \x3C0.5s
大 (1000-5000文件) 10-30s \x3C2s

Files

skills/codebase-intelligence/
├── SKILL.md                    # 本文件
└── scripts/
    ├── main.py                 # ⭐ 统一入口
    ├── indexer.py              # 索引引擎(带缓存)
    ├── ask_v2.py               # 智能问答
    ├── analyze.py              # 基础分析
    ├── deps.py                 # 依赖分析
    └── diagram.py              # 图表生成

Integration

Git Hooks

# .git/hooks/pre-commit
python3 scripts/main.py index

CI/CD

# .github/workflows/analysis.yml
- name: Analyze Codebase
  run: |
    python3 scripts/main.py analyze --stats
    python3 scripts/main.py diagram --format mermaid > architecture.md

Next Steps / Roadmap

  • 增量缓存
  • 符号索引
  • 智能问答
  • AST 解析(提高准确性)
  • 接入 LLM(语义理解)
  • 实时 watch 模式
  • Web UI

Production Ready? ✅

当前状态:可用,适合日常使用

  • 缓存机制 ✅
  • 增量更新 ✅
  • 符号索引 ✅
  • 智能问答 ✅
  • 性能优化 ✅

待完善:

  • AST 解析(当前使用正则,有 5-10% 误差)
  • LLM 集成(当前基于关键词匹配)
安全使用建议
This package appears to be a conventional local codebase indexing and query tool and does not request credentials or perform obvious network activity, but take these precautions before using it: - Don't run it on repositories containing secrets or sensitive data unless you trust the environment; the index/cache will contain readable copies or references to files. - Inspect the created cache (.codebase-intelligence/) and consider adding it to .gitignore so cached indexes aren't committed. - The SKILL.md includes optional Git hook and CI examples — do not add those automatically; review them first because they can cause automatic runs. - There are signs of incomplete/truncated code in provided files (possible runtime errors). Test on a small, non-sensitive repo first to confirm behavior. - If you plan to run it in an environment with network access and are security-conscious, run it in an isolated environment (container/VM) while you audit the full indexer/main.py code (remaining files were truncated here). If you want, I can scan the remaining files (indexer.py, main.py and any truncated portions) for network calls, subprocess usage, or code that would change this assessment.
能力评估
Purpose & Capability
Name/description (codebase analysis, indexing, QA, diagrams) match the included scripts (analyze, indexer, ask, deps, diagram, main). No unrelated binaries, environment variables, or cloud credentials are requested.
Instruction Scope
SKILL.md instructs the agent/user to run the scripts against a project root. The scripts traverse and read all files in the repository and create a local cache (.codebase-intelligence). This is expected for the stated purpose, but it will index any secrets or sensitive files present in the repo and store them in the cache — users should avoid running it on repos with sensitive data or inspect cache contents.
Install Mechanism
No install spec (instruction-only). Code is shipped as Python scripts that run directly; no external downloads or strange install steps were found in the provided manifest.
Credentials
The skill requires no environment variables, credentials, or config paths. The code references only local filesystem operations. A minor note: ask_v2 mentions LLM/kimi_search in comments, but no external API keys or network calls appear in the supplied files.
Persistence & Privilege
always:false and normal autonomous invocation are set. The tool writes a local cache directory by design and the SKILL.md suggests optional Git hook / CI integration examples; if applied, those could cause automatic indexing runs — review those hooks before enabling them.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install oc-codebase-intelligence
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /oc-codebase-intelligence 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.1.0
Added C/C++ support: symbol indexing, function/struct/macro extraction
元数据
Slug oc-codebase-intelligence
版本 1.1.0
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 1
常见问题

OpenClaw Codebase Intelligence 是什么?

Intelligent codebase analysis and understanding with caching. Automatically explores project structure, identifies modules, analyzes dependencies, and answer... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 121 次。

如何安装 OpenClaw Codebase Intelligence?

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

OpenClaw Codebase Intelligence 是免费的吗?

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

OpenClaw Codebase Intelligence 支持哪些平台?

OpenClaw Codebase Intelligence 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 OpenClaw Codebase Intelligence?

由 michealxie001(@michealxie001)开发并维护,当前版本 v1.1.0。

💬 留言讨论