Coding

Codebase Index — 代码库索引系统

Try it

代码库索引与理解系统。扫描项目目录,提取所有符号定义(类、函数、变量、导入),构建可搜索的 JSON 索引,支持按名称/类型/文件查询。受 Claude Code 的 codebase indexing 启发,100% 原创实现,使用 Python ast + ripgrep。

What it does

代码库索引与理解系统。扫描项目目录,提取所有符号定义(类、函数、变量、导入),构建可搜索的 JSON 索引,支持按名称/类型/文件查询。受 Claude Code 的 codebase indexing 启发,100% 原创实现,使用 Python ast + ripgrep。

The skill document

Codebase Index 📚

Claude Code 最值钱的能力之一是它能理解整个代码库。 codebytelens 单文件分析 → codebase-index 全库索引。

工作流

项目目录
   │
   ▼ scan
┌─────────────────────┐
│ 符号提取器           │
│ • Python: ast        │
│ • 通用: ripgrep      │
└─────────┬───────────┘
          │
          ▼ index.json
┌─────────────────────┐
│ 符号索引             │
│ • 类、函数、变量     │
│ • 文件路径、行号     │
│ • 文档字符串         │
│ • 导入关系           │
└─────────┬───────────┘
          │
          ▼ query
┌─────────────────────┐
│ 查询接口             │
│ • 按名称搜索         │
│ • 按类型过滤         │
│ • 按文件搜索         │
│ • 模糊匹配           │
└─────────────────────┘

使用方式

# 扫描项目,构建索引
python3 indexer.py scan /path/to/project --output project-index.json

# 搜索符号
python3 indexer.py query "UserService" --index project-index.json

# 按类型过滤
python3 indexer.py query "def" --type function --index project-index.json

# 列出所有文件
python3 indexer.py files --index project-index.json

# 统计信息
python3 indexer.py stats --index project-index.json

示例输出

{
  "symbols": [
    {
      "name": "UserService",
      "type": "class",
      "file": "services/user_service.py",
      "line": 15,
      "docstring": "用户认证和授权服务",
      "methods": ["login", "logout", "register"]
    },
    {
      "name": "authenticate",
      "type": "function",
      "file": "auth/jwt.py",
      "line": 42,
      "docstring": "JWT token 验证"
    }
  ]
}

Related skills

代码智能分析工具箱。受 Claude Code LSPTool 设计模式启发,但使用 100% 开源工具:ripgrep (搜索)、pyright (Python 类型检查)、tree-sitter (AST 解析)。不需要 LSP 服务器,开箱即用。

2 installs

Study unfamiliar codebases and produce evidence-backed knowledge artifacts. Use for repository orientation, architecture mapping, subsystem tracing, onboarding, or codebase documentation.

Build a compact local SQLite index of every function, class, method, interface and type across your repos, so an agent finds a symbol's file:line and signatu...

Scan codebase for dependency graph, tech debt hotspots, and module health scores

4 installs

Advanced codebase analysis with HTML reports, git-aware diffs, trend tracking, SVG badges, CSV export, and CI/CD integration

1 installs

Produce a durable onboarding artifact for a codebase — writes `ONBOARDING.md` (or `docs/ONBOARDING.md` if `docs/` exists) covering a "read this first" minimum, system overview, dependency map (top-level deps + how each is actually used), startup flow (entry points → bootstrap → config), auth flow (or explicit "none detected"), and 5–15 important files — every claim backed by a `file:line` citation. Walks the repo via parallel Explore sub-agents so big projects don't blow context, calls out what makes THIS codebase non-obvious (not generic framework descriptions), refreshes an existing onboarding doc instead of rewriting from scratch, and renders a condensed summary inline. Built for revisiting a project after months away and for new teammates landing in an unfamiliar repo. Use this skill whenever the user says "explain this codebase", "explain the codebase", "onboard me", "give me a tour", "tour this repo", "what does this repo do", "where do I start", "I haven't looked at this in mont

1 installs