ast-index
ast-index is a native Rust command-line tool that indexes and searches code structures across 14+ programming languages and platforms, including Java/Kotlin, Swift, TypeScript, Python, Go, Rust, C#, PHP, and more. Use it to rapidly locate classes, functions, interfaces, structs, symbols, implementations, usages, callers, and module dependencies in large codebases by querying a local SQLite FTS5 database, which executes searches 17 to 69 times faster than grep.
git clone --depth 1 https://github.com/defendend/Claude-ast-index-search /tmp/ast-index && cp -r /tmp/ast-index/plugin/skills/ast-index ~/.claude/skills/ast-indexSKILL.md
# ast-index - Code Search for Multi-Platform Projects Fast native Rust CLI for structural code search in Android/Kotlin/Java, iOS/Swift/ObjC, Dart/Flutter, TypeScript/JavaScript, Rust, Ruby, C#, Scala, PHP, Perl, Python, Go, C++, and Proto projects using SQLite + FTS5 index. ## Critical Rules **ALWAYS use ast-index FIRST for any code search task.** These rules are mandatory: 1. **ast-index is the PRIMARY search tool** — use it before grep, ripgrep, or Search tool 2. **DO NOT duplicate results** — if ast-index found usages/implementations, that IS the complete answer 3. **DO NOT run grep "for completeness"** after ast-index returns results 4. **Use grep/Search ONLY when:** - ast-index returns empty results - Searching for regex patterns (ast-index uses literal match) - Searching for string literals inside code (`"some text"`) - Searching in comments content **Why:** ast-index is 17-69x faster than grep (1-10ms vs 200ms-3s) and returns structured, accurate results. ## Prerequisites Install the CLI before use: ```bash brew tap defendend/ast-index brew install ast-index ``` Initialize index in project root: ```bash cd /path/to/project ast-index rebuild ``` The index is stored at `~/Library/Caches/ast-index/<project-hash>/index.db` (macOS) or `~/.cache/ast-index/<project-hash>/index.db` (Linux). Rebuild deletes the DB file entirely and creates a fresh index. ## Supported Projects | Platform | Languages | Module System | |----------|-----------|---------------| | Android/Java | Kotlin, Java | Gradle (build.gradle.kts), Maven (pom.xml) | | iOS | Swift, Objective-C | SPM (Package.swift) | | Web | TypeScript, JavaScript, React, Vue, Svelte | package.json | | Rust | Rust | Cargo.toml | | Ruby | Ruby, Rails, RSpec | Gemfile | | .NET | C#, ASP.NET, Unity | *.csproj | | Dart/Flutter | Dart | pubspec.yaml | | Scala | Scala | Bazel (WORKSPACE, BUILD) | | PHP | PHP | composer.json | | Perl | Perl | Makefile.PL, Build.PL | | Python | Python | None (*.py files) | | Go | Go | None (*.go files) | | Proto | Protocol Buffers (proto2/proto3) | None (*.proto files) | | WSDL | WSDL, XSD | None (*.wsdl, *.xsd files) | | C/C++ | C, C++ (JNI, uservices) | None (*.cpp, *.h, *.hpp files) | | Godot | GDScript | project.godot | | Mixed | All above | All | Project type is auto-detected by marker files (build.gradle.kts, Package.swift, Makefile.PL, etc.). Python, Go, Proto, WSDL, and C++ files are indexed alongside main project type. ## Core Commands ### Universal Search **`search`** - Perform universal search across files, symbols, and modules simultaneously. ```bash ast-index search "Payment" # Finds files, classes, functions matching "Payment" ast-index search "ViewModel" # Returns files, symbols, modules in ranked order ast-index search "Store" --fuzzy # Fuzzy: exact → prefix → contains matching ast-index search "Handler" --module "core/" # Search within a module ast-index search "UserService" # Find Java/Spring services ast-index search "@RestController" # Find Spring REST controllers (annotation search) ast-index search "@GetMapping" # Find GET endpoint mappings ``` ### File Search **`file`** - Find files by name pattern. ```bash ast-index file "Fragment.kt" # Find files ending with Fragment.kt ast-index file "ViewController" # Find iOS view controllers ``` ### Symbol Search **`symbol`** - Find symbols (classes, interfaces, functions, properties) by name. ```bash ast-index symbol "PaymentInteractor" # Find exact symbol ast-index symbol "Presenter" # Find all presenters ast-index symbol "Store" --fuzzy # Fuzzy: exact → prefix → contains matching ast-index symbol "Mapper" --in-file "payments/" --limit 10 # Scoped search ast-index symbol "@Service" # Find all @Service annotations ``` ### Class Search **`class`** - Find class, interface, or protocol definitions. ```bash ast-index class "BaseFragment" # Find Android base fragment ast-index class "UIViewController" # Find iOS view controller subclass ast-index class "Store" --fuzzy # Find all classes containing "Store" ast-index class "Repository" --module "features/payments" # Filter by module ast-index class "UserController" # Find Java/Spring controller class ``` ### Usage Search **`usages`** - Find all places where a symbol is used. Critical for refactoring. ```bash ast-index usages "PaymentRepository" # Find all usages of repository ast-index usages "onClick" # Find all click handler usages ast-index usages "fetchData" --in-file "src/api/" # Scoped to file path ast-index usages "Repository" --module "features/auth" --limit 100 ``` Performance: ~8ms for indexed symbols. ### Cross-References **`refs`** - Show cross-references for a symbol: definitions, imports, and usages in one view. ```bash ast-index refs "PaymentRepository" # Definitions + imports + usages ast-index refs "BaseFragment" --limit 10 # Limit results per section ``` ### Implementation Search **`implementations`** - Find all classes that extend or implement a given class/interface/protocol. Supports partial name matching with relevance ranking (exact → suffix → contains). ```bash ast-index implementations "BasePresenter" # Find all presenter implementations ast-index implementations "Repository" # Find repository implementations (exact match) ast-index implementations "Service" # Partial: finds UserService, PaymentService impls too ast-index implementations "ViewModel" --module "features/" # Scoped to module ``` ### Class Hierarchy **`hierarchy`** - Display complete class hierarchy tree. ```bash ast-index hierarchy "BaseFragment" # Show fragment inheritance tree ``` ### Caller Search **`callers`** - Find all places that call a specific function. ```bash ast-index callers "onClick" # Find all onClick calls ast-index callers "fetchUser" # Find API call sites ``` ### Call Tree **`call-tree`** - Show complete call hier
Use this agent when a user reports a concrete bug ("X doesn't work", "crashes on Y", "wrong output for Z", a GitHub issue with steps-to-reproduce). The agent reproduces the bug, locates the root cause, applies a minimal fix, proves the fix works with a regression test, and confirms nothing else broke. Do NOT use for feature requests, refactors, or open-ended "look at this code" asks — those are different profiles.
Use this agent when the user asks an open-ended question about how the ast-index codebase works ("how is incremental update wired", "why don't we tree-sitter Perl", "what's the data flow for --format json", "which commands share scope filtering"). The agent reads the code, traces connections, and returns a structured answer with file:line citations. It does NOT edit code, does NOT run destructive commands, and does NOT speculate — every claim is grounded in a file you can open.
Use this agent to review a set of changes before they ship — staged/unstaged diff, a specific commit range, a PR description, or "the latest commit". The agent reads the diff against project rules in CLAUDE.md and .claude/rules/*, runs the build and test suite, and reports what's good, what's wrong, and what's missing. It does NOT fix anything itself — the point is feedback, not rework.