### Install ast-index using Homebrew one-line tap
Source: https://github.com/defendend/claude-ast-index-search/blob/main/USER_GUIDE.md
A concise way to install ast-index using Homebrew by combining the tap and install commands.
```bash
brew install defendend/ast-index/ast-index
```
--------------------------------
### Install and Initialize ast-index CLI
Source: https://github.com/defendend/claude-ast-index-search/blob/main/plugin/skills/ast-index/SKILL.md
Install the CLI using Homebrew and initialize a new index in your project's root directory.
```bash
brew tap defendend/ast-index
brew install ast-index
```
```bash
cd /path/to/project
ast-index rebuild
```
--------------------------------
### Example Proto Workflow
Source: https://github.com/defendend/claude-ast-index-search/blob/main/plugin/skills/ast-index/references/proto-commands.md
A step-by-step example demonstrating how to index proto files, check statistics, search for definitions, and find usages.
```bash
# 1. Index proto files
cd /path/to/proto/project
ast-index rebuild
```
```bash
# 2. Check index statistics
ast-index stats
```
```bash
# 3. Find all messages
ast-index search "message"
```
```bash
# 4. Find service definitions
ast-index search "Service"
```
```bash
# 5. Show proto file structure
ast-index outline "api/v1/user.proto"
```
```bash
# 6. Find usages of message
ast-index usages "UserRequest"
```
--------------------------------
### Verify ast-index Setup
Source: https://github.com/defendend/claude-ast-index-search/blob/main/plugin/commands/initialize-android.md
Perform a quick search using ast-index commands to confirm that the setup and indexing were successful.
```bash
ast-index stats
```
```bash
ast-index search "Activity"
```
--------------------------------
### Check ast-index Installation
Source: https://github.com/defendend/claude-ast-index-search/blob/main/plugin/commands/initialize-csharp.md
Verify if ast-index is installed on your system. If not, instructions are provided to install it using Homebrew.
```bash
ast-index version
```
```bash
brew tap defendend/ast-index
brew install ast-index
```
--------------------------------
### Install ast-index CLI
Source: https://github.com/defendend/claude-ast-index-search/blob/main/docs/mcp-setup.md
Installs the ast-index command-line interface using Homebrew or npm. Ensure ast-index is on your PATH.
```bash
# macOS / Linux
brew tap defendend/ast-index
brew install ast-index
# npm (all platforms)
npm install -g @defendend/ast-index
```
--------------------------------
### Example Workflow for WSDL/XSD Indexing
Source: https://github.com/defendend/claude-ast-index-search/blob/main/plugin/skills/ast-index/references/wsdl-commands.md
A step-by-step example demonstrating how to index WSDL/XSD files, check statistics, and search for services, operations, types, and usages.
```bash
# 1. Index WSDL/XSD files
cd /path/to/wsdl/project
ast-index rebuild
# 2. Check index statistics
ast-index stats
# 3. Find all services
ast-index search "Service"
# 4. Find all operations
ast-index symbol "operation"
# 5. Show WSDL structure
ast-index outline "api/UserService.wsdl"
# 6. Find type usages
ast-index usages "UserType"
```
--------------------------------
### Install ast-index via Winget (Windows)
Source: https://github.com/defendend/claude-ast-index-search/blob/main/USER_GUIDE.md
Install the ast-index CLI on Windows using the Winget package manager.
```powershell
winget install --id defendend.ast-index
```
--------------------------------
### Install @ast-index/cli Globally
Source: https://github.com/defendend/claude-ast-index-search/blob/main/npm/README.md
Install the CLI tool globally using npm for system-wide access.
```bash
npm install -g @ast-index/cli
```
--------------------------------
### Verify ast-index Setup
Source: https://github.com/defendend/claude-ast-index-search/blob/main/plugin/commands/initialize-ruby.md
Run basic ast-index commands to confirm the setup is successful and the index is operational. This includes checking index statistics and performing a sample search.
```bash
ast-index stats
ast-index search "class"
```
--------------------------------
### Install Claude Code Plugin
Source: https://github.com/defendend/claude-ast-index-search/blob/main/README.md
Install the ast-index plugin for Claude Code via the marketplace or directly if ast-index is already installed. Restart Claude Code to activate the plugin.
```bash
claude plugin marketplace add defendend/Claude-ast-index-search
claude plugin install ast-index
```
```bash
ast-index install-claude-plugin
```
--------------------------------
### Install ast-index via Yandex tool
Source: https://github.com/defendend/claude-ast-index-search/blob/main/docs/setup-guide.md
Install and verify the ast-index CLI using the Yandex development toolchain.
```bash
ya tool ast-index version
```
--------------------------------
### Verify ast-index installation
Source: https://github.com/defendend/claude-ast-index-search/blob/main/USER_GUIDE.md
Check if the ast-index CLI is installed correctly and accessible by running the 'version' and 'help' commands.
```bash
ast-index version
```
```bash
ast-index help
```
--------------------------------
### Install ast-index via Homebrew
Source: https://github.com/defendend/claude-ast-index-search/blob/main/docs/setup-guide.md
Use this command to install the ast-index CLI on macOS and Linux systems using Homebrew.
```bash
brew tap defendend/ast-index
brew install ast-index
```
--------------------------------
### Install Gemini CLI Skill
Source: https://github.com/defendend/claude-ast-index-search/blob/main/README.md
Install the ast-index skill for the Gemini CLI using the provided GitHub repository URL and path.
```bash
gemini skills install https://github.com/defendend/Claude-ast-index-search.git --path plugin/skills/ast-index
```
--------------------------------
### Example Go Indexing Workflow
Source: https://github.com/defendend/claude-ast-index-search/blob/main/plugin/skills/ast-index/references/go-commands.md
A step-by-step workflow demonstrating how to index a Go service, check statistics, search for elements, and find usages.
```bash
# 1. Index Go service
cd /path/to/go/service
ast-index rebuild
# 2. Check index statistics
ast-index stats
# 3. Find all structs
ast-index search "struct"
# 4. Find constructor functions
ast-index symbol "New"
# 5. Show file structure
ast-index outline "internal/handler.go"
# 6. Find usages
ast-index usages "Service"
```
--------------------------------
### Verify ast-index Setup
Source: https://github.com/defendend/claude-ast-index-search/blob/main/plugin/commands/initialize-rust.md
Run these commands to confirm that the ast-index setup is successful and the index is operational. `ast-index stats` provides index information, and `ast-index search` tests basic search functionality.
```bash
ast-index stats
ast-index search "fn"
```
--------------------------------
### Build and Verify ast-index
Source: https://github.com/defendend/claude-ast-index-search/blob/main/plugin/commands/initialize-csharp.md
Initiate the ast-index build process and then run a quick search to confirm the setup is successful.
```bash
ast-index rebuild
```
```bash
ast-index stats
ast-index search "class"
```
--------------------------------
### Verify AST Index Setup
Source: https://github.com/defendend/claude-ast-index-search/blob/main/plugin/commands/initialize.md
Checks the status of the AST index and performs sample searches to confirm correct setup for various language stacks.
```bash
ast-index stats
```
```bash
ast-index search "Activity"
```
```bash
ast-index search "ViewModel"
```
```bash
ast-index search "ViewController"
```
```bash
ast-index search "Component"
```
```bash
ast-index search "fn"
```
```bash
ast-index search "class"
```
```bash
ast-index search "def"
```
```bash
ast-index search "func"
```
```bash
ast-index search "Widget"
```
```bash
ast-index search "trait"
```
--------------------------------
### Proto Import Handling Examples
Source: https://github.com/defendend/claude-ast-index-search/blob/main/plugin/skills/ast-index/references/proto-commands.md
Examples of import statements in Protocol Buffers, including standard, aliased, and public imports. Also shows commands to analyze imports.
```protobuf
import "google/protobuf/timestamp.proto";
import "common/types.proto";
import public "shared.proto";
```
```bash
ast-index imports "service.proto" # Shows all imports
```
```bash
ast-index usages "common/types.proto" # Find where proto is imported
```
--------------------------------
### Example Workflow for Rust Project Analysis
Source: https://github.com/defendend/claude-ast-index-search/blob/main/plugin/skills/ast-index/references/rust-commands.md
A step-by-step workflow demonstrating common ast-index operations on a Rust project, from indexing to specific searches.
```bash
# 1. Index Rust project
cd /path/to/rust/project
ast-index rebuild
# 2. Check index statistics
ast-index stats
# 3. Find all structs
ast-index search "struct" --kind class
# 4. Find all traits
ast-index search "trait" --kind interface
# 5. Find implementations of a trait
ast-index implementations "Repository"
# 6. Show file structure
ast-index outline "src/lib.rs"
# 7. Find usages
ast-index usages "UserService"
# 8. Find callers
ast-index callers "process_request"
```
--------------------------------
### Install MCP Server for Codex (OpenAI CLI)
Source: https://github.com/defendend/claude-ast-index-search/blob/main/docs/mcp-setup.md
Installs the MCP server for Codex, setting `AST_INDEX_ROOT` and `AST_INDEX_BIN`. Preview the changes with `--dry-run`.
```bash
cd /absolute/path/to/your/project
ast-index rebuild
ast-index install-codex-mcp
```
--------------------------------
### AST Index Workflow Examples
Source: https://github.com/defendend/claude-ast-index-search/blob/main/plugin/skills/ast-index/references/csharp-commands.md
Demonstrates a typical workflow using `ast-index`, including rebuilding the index, checking statistics, searching for classes, interfaces, implementations, file outlines, and usages.
```bash
# 1. Index .NET project
cd /path/to/dotnet/project
ast-index rebuild
```
```bash
# 2. Check index statistics
ast-index stats
```
```bash
# 3. Find all controllers
ast-index class "Controller"
```
```bash
# 4. Find all interfaces
ast-index class "I"
```
```bash
# 5. Find implementations
ast-index implementations "IUserRepository"
```
```bash
# 6. Show file structure
ast-index outline "Services/UserService.cs"
```
```bash
# 7. Find usages
ast-index usages "UserService"
```
--------------------------------
### Example Workflow for AST Index
Source: https://github.com/defendend/claude-ast-index-search/blob/main/plugin/skills/ast-index/references/typescript-commands.md
Demonstrates a typical workflow for using ast-index commands, from indexing a project to searching for specific code elements.
```bash
# 1. Index web project
cd /path/to/react/project
ast-index rebuild
# 2. Check index statistics
ast-index stats
# 3. Find all components
ast-index search "Component" --kind class
# 4. Find all hooks
ast-index search "use" --kind function
# 5. Find usages of a hook
ast-index usages "useAuth"
# 6. Show component structure
ast-index outline "UserProfile.tsx"
# 7. Find implementations of interface
ast-index implementations "UserRepository"
# 8. Find who calls a function
ast-index callers "fetchUser"
```
--------------------------------
### Build and search project index
Source: https://github.com/defendend/claude-ast-index-search/blob/main/USER_GUIDE.md
Quick start commands to rebuild the ast-index for a project, view statistics, and perform a search. Assumes you are in the project root directory.
```bash
cd /path/to/your/project
ast-index rebuild
ast-index stats
ast-index search "UserRepository"
```
--------------------------------
### Build and Verify ast-index
Source: https://github.com/defendend/claude-ast-index-search/blob/main/plugin/commands/initialize-ios.md
Build the ast-index by running a full reindex and then verify the setup with a quick search command.
```bash
ast-index rebuild
```
```bash
ast-index stats
ast-index search "ViewController"
```
--------------------------------
### Go Import Handling Example
Source: https://github.com/defendend/claude-ast-index-search/blob/main/plugin/skills/ast-index/references/go-commands.md
Shows a Go import block with standard library and custom package imports. `ast-index` tracks imports with their full paths and aliases.
```go
import (
"context"
"fmt"
"github.com/example/backend-go/services/files-uploads/internal/entities"
)
```
--------------------------------
### gRPC Service Definition Example
Source: https://github.com/defendend/claude-ast-index-search/blob/main/plugin/skills/ast-index/references/proto-commands.md
An example of a gRPC service definition, outlining RPC methods with their request and response types.
```protobuf
service UserService {
rpc GetUser(UserRequest) returns (UserResponse);
rpc CreateUser(CreateUserRequest) returns (UserResponse);
rpc ListUsers(ListUsersRequest) returns (stream UserResponse);
}
```
--------------------------------
### Vue 3 Composition API Script Setup
Source: https://github.com/defendend/claude-ast-index-search/blob/main/plugin/skills/ast-index/references/typescript-commands.md
Shows a Vue 3 script setup block using Composition API. ast-index extracts and indexes interfaces, constants, and computed properties defined within.
```vue
```
--------------------------------
### Rust Implementation Examples
Source: https://github.com/defendend/claude-ast-index-search/blob/main/plugin/skills/ast-index/references/rust-commands.md
Examples of implementing traits and defining methods for structs. Both trait implementations and standalone struct methods are indexed.
```rust
impl Repository for SqlUserRepository {
fn find(&self, id: u64) -> Option {
// ...
}
}
impl User {
pub fn new(name: String) -> Self {
Self { id: 0, name }
}
}
Indexed as:
- impl Repository for SqlUserRepository [class] with parent Repository
- impl User [class]
- find [function]
- new [function]
```
--------------------------------
### MCP Server Configuration Example
Source: https://github.com/defendend/claude-ast-index-search/blob/main/docs/mcp-setup.md
Configure the ast-index MCP server command path if the binary is not in your system's PATH. This is useful when troubleshooting 'tool not found' errors.
```json
"command": "/usr/local/bin/ast-index-mcp"
```
--------------------------------
### Rust Module and Import Examples
Source: https://github.com/defendend/claude-ast-index-search/blob/main/plugin/skills/ast-index/references/rust-commands.md
Examples of Rust module declarations and import statements. Modules are indexed as packages, and use statements as imports.
```rust
mod tests;
pub mod utils;
use std::collections::HashMap;
use crate::db::{Database, Connection};
Indexed as:
- tests [package]
- utils [package]
- std::collections::HashMap [import]
- crate::db [import]
```
--------------------------------
### Migrate from kotlin-index to ast-index
Source: https://github.com/defendend/claude-ast-index-search/blob/main/README.md
Uninstalls the old kotlin-index and installs the new ast-index using Homebrew.
```bash
brew uninstall kotlin-index
brew untap defendend/kotlin-index
brew tap defendend/ast-index
brew install ast-index
```
--------------------------------
### Example Python Project Workflow
Source: https://github.com/defendend/claude-ast-index-search/blob/main/plugin/skills/ast-index/references/python-commands.md
A step-by-step workflow for indexing a Python project, checking statistics, searching for code elements, and analyzing file structures.
```bash
# 1. Index Python project
cd /path/to/python/project
ast-index rebuild
# 2. Check index statistics
ast-index stats
# 3. Find all classes
ast-index search "class"
# 4. Find async functions
ast-index symbol "async"
# 5. Show file structure
ast-index outline "main.py"
# 6. Find usages
ast-index usages "UserService"
```
--------------------------------
### Example C++ Project Workflow
Source: https://github.com/defendend/claude-ast-index-search/blob/main/plugin/skills/ast-index/references/cpp-commands.md
A typical workflow for indexing a C++ project, checking statistics, and performing searches.
```bash
# 1. Index C++ project
cd /path/to/cpp/project
ast-index rebuild
```
```bash
# 2. Check index statistics
ast-index stats
```
```bash
# 3. Find all classes
ast-index search "class"
```
```bash
# 4. Find header usages
ast-index usages "RequestHandler"
```
```bash
# 5. Show file structure
ast-index outline "src/handler.cpp"
```
--------------------------------
### Import Handling in WSDL and XSD
Source: https://github.com/defendend/claude-ast-index-search/blob/main/plugin/skills/ast-index/references/wsdl-commands.md
Examples of WSDL and XSD import/include statements, demonstrating how external schemas and namespaces are referenced.
```xml
```
--------------------------------
### List project modules
Source: https://github.com/defendend/claude-ast-index-search/blob/main/docs/setup-guide.md
Get a list of all modules defined within the project.
```bash
ast-index module ""
```
--------------------------------
### Framework Detection Examples
Source: https://github.com/defendend/claude-ast-index-search/blob/main/plugin/commands/initialize-web.md
Use `ast-index search` with specific keywords and kinds to detect and find elements related to different web frameworks like React, Vue, Svelte, and NestJS.
```bash
# Check for React
ast-index search "useState" --kind function
```
```bash
# Check for Vue
ast-index search "defineComponent"
```
```bash
# Check for Svelte
ast-index search "export let"
```
```bash
# Check for NestJS
ast-index search "@Controller"
```
```bash
# Check for Angular
ast-index search "@Component"
```
--------------------------------
### Add Codex Plugin Marketplace
Source: https://github.com/defendend/claude-ast-index-search/blob/main/README.md
Add the defendend/Claude-ast-index-search repository to the Codex plugin marketplace for installation.
```bash
codex plugin marketplace add defendend/Claude-ast-index-search
```
--------------------------------
### Go Action Pattern Example
Source: https://github.com/defendend/claude-ast-index-search/blob/main/plugin/skills/ast-index/references/go-commands.md
Illustrates the Go 'Action' pattern with a `DeleteAction` struct, its constructor `NewDeleteAction`, and a `Do` method. This code is indexed by ast-index.
```go
type DeleteAction struct {
avaSrv AvatarsMDS
tmpStorageSrv TmpStorage
filesRepo FilesRepo
}
func NewDeleteAction(
avaSrv *avatarsmds.Service,
tmpStorageSrv *tmpstorage.FileUploader,
storage *repositories.Storage,
) *DeleteAction {
return &DeleteAction{...}
}
func (a *DeleteAction) Do(ctx context.Context, task *entities.TaskToProcess) error {
// ...
}
```
--------------------------------
### Unity MonoBehaviour Example
Source: https://github.com/defendend/claude-ast-index-search/blob/main/plugin/skills/ast-index/references/csharp-commands.md
A Unity C# script `PlayerController` that inherits from `MonoBehaviour`. It shows the use of `[SerializeField]`, `[Header]`, and the `Start` and `Update` methods.
```csharp
public class PlayerController : MonoBehaviour
{
[SerializeField] private float _speed;
[Header("Settings")]
public int health = 100;
void Start()
{
Initialize();
}
void Update()
{
HandleInput();
}
}
```
--------------------------------
### Search AST Index with JSON Output
Source: https://github.com/defendend/claude-ast-index-search/blob/main/plugin/skills/ast-index/SKILL.md
Use the `--format json` flag to get structured output from the `ast-index search` command. This is useful for parsing results programmatically, for example, to extract file paths using `jq`.
```bash
ast-index search "Query" --format json | jq '.results[].path'
```
--------------------------------
### Run @ast-index/cli Commands with npx
Source: https://github.com/defendend/claude-ast-index-search/blob/main/npm/README.md
Execute CLI commands directly without global installation using npx.
```bash
npx @ast-index/cli rebuild
```
```bash
npx @ast-index/cli search MyClass
```
--------------------------------
### Detect .NET Project Types with ast-index
Source: https://github.com/defendend/claude-ast-index-search/blob/main/plugin/commands/initialize-csharp.md
Examples of using ast-index search commands to identify specific .NET project types and common constructs within them.
```bash
# ASP.NET Core Web API
ast-index search "[ApiController]"
ast-index search "ControllerBase"
# ASP.NET MVC
ast-index search "Controller"
ast-index search "ActionResult"
# Unity
ast-index search "MonoBehaviour"
ast-index search "ScriptableObject"
# WPF/MAUI
ast-index search "Window"
ast-index search "UserControl"
# Console/Library
ast-index search "Main"
```
--------------------------------
### ASP.NET Controller Example
Source: https://github.com/defendend/claude-ast-index-search/blob/main/plugin/skills/ast-index/references/csharp-commands.md
A C# ASP.NET Core controller `UsersController` demonstrating the use of `[ApiController]`, `[Route]`, `[HttpGet]`, `[HttpPost]`, and `[Authorize]` attributes.
```csharp
[ApiController]
[Route("api/[controller]")]
public class UsersController : ControllerBase
{
[HttpGet("{id}")]
public async Task> GetById(int id)
{
return await _service.GetByIdAsync(id);
}
[HttpPost]
[Authorize]
public async Task> Create(UserDto dto)
{
return await _service.CreateAsync(dto);
}
}
```
--------------------------------
### Rust Enum Definition Example
Source: https://github.com/defendend/claude-ast-index-search/blob/main/plugin/skills/ast-index/references/rust-commands.md
Example of a Rust enum definition. The enum itself is indexed as a distinct symbol.
```rust
pub enum Status {
Active,
Inactive,
Pending,
}
Indexed as:
- Status [enum]
```
--------------------------------
### C++ JNI Function Example
Source: https://github.com/defendend/claude-ast-index-search/blob/main/plugin/skills/ast-index/references/cpp-commands.md
Example of a C++ JNI (Java Native Interface) function definition.
```cpp
extern "C" JNIEXPORT jstring JNICALL
Java_com_example_MyClass_nativeMethod(JNIEnv* env, jobject obj) {
return env->NewStringUTF("Hello from JNI");
}
```
--------------------------------
### Build and Run Project
Source: https://github.com/defendend/claude-ast-index-search/blob/main/CONTRIBUTING.md
Clone the repository, navigate to the project directory, and build the project using cargo.
```bash
git clone https://github.com/defendend/Claude-ast-index-search.git
cd Claude-ast-index-search
cargo build
```
--------------------------------
### Rust Trait Definition Example
Source: https://github.com/defendend/claude-ast-index-search/blob/main/plugin/skills/ast-index/references/rust-commands.md
Example of a Rust trait definition, including its methods. Both the trait and its methods are indexed.
```rust
pub trait Repository {
fn find(&self, id: u64) -> Option;
fn save(&mut self, user: User);
}
Indexed as:
- Repository [interface]
- find [function]
- save [function]
```
--------------------------------
### Set up Local Claude Code Index Automation
Source: https://github.com/defendend/claude-ast-index-search/blob/main/USER_GUIDE.md
Add this uncommitted project setting to ensure an index exists at session start. It creates a .claude directory and adds it to gitignore.
```bash
mkdir -p .claude
printf ".claude/\n" >> .git/info/exclude
```
--------------------------------
### Enum Definition Example
Source: https://github.com/defendend/claude-ast-index-search/blob/main/plugin/skills/ast-index/references/proto-commands.md
An example of an enum definition in Protocol Buffers, showing named constants for a set of values.
```protobuf
enum Status {
STATUS_UNSPECIFIED = 0;
STATUS_ACTIVE = 1;
STATUS_INACTIVE = 2;
}
```
--------------------------------
### C++ Class Definition Example
Source: https://github.com/defendend/claude-ast-index-search/blob/main/plugin/skills/ast-index/references/cpp-commands.md
An example of a C++ class definition within a namespace, showing its structure and members.
```cpp
namespace myapp {
class RequestHandler {
public:
RequestHandler(Database* db);
~RequestHandler();
bool Handle(const Request& req, Response* resp);
private:
Database* db_;
};
} // namespace myapp
```
--------------------------------
### Build ast-index from source
Source: https://github.com/defendend/claude-ast-index-search/blob/main/README.md
Clones the repository, builds the ast-index tool in release mode, and notes the binary size.
```bash
git clone https://github.com/defendend/Claude-ast-index-search.git
cd Claude-ast-index-search
cargo build --release
# Binary: target/release/ast-index (~44 MB)
```
--------------------------------
### Build Project Index
Source: https://github.com/defendend/claude-ast-index-search/blob/main/docs/mcp-setup.md
Rebuilds the index for a specific project. This is a one-time setup step before the MCP server can query the project. Run `ast-index update` after pulling changes.
```bash
cd /path/to/your/project
ast-index rebuild
```
--------------------------------
### Python Class Definition Example
Source: https://github.com/defendend/claude-ast-index-search/blob/main/plugin/skills/ast-index/references/python-commands.md
Example of a Python class definition with an initializer and an async method. This structure is indexed by ast-index.
```python
class UserService:
def __init__(self, db: Database):
self.db = db
async def get_user(self, user_id: int) -> User:
return await self.db.fetch_user(user_id)
```
--------------------------------
### Manage Multi-Root Projects with AST Index
Source: https://github.com/defendend/claude-ast-index-search/blob/main/plugin/skills/ast-index/SKILL.md
Commands to add, remove, and list additional source roots for monorepos or multi-project setups. Use `--force` to add roots within the project directory.
```bash
ast-index add-root /path/to/other/source # Add source root (warns on overlap)
```
```bash
ast-index add-root ./subdir --force # Force add even if inside project root
```
```bash
ast-index remove-root /path/to/other/source # Remove source root
```
```bash
ast-index list-roots # List configured roots
```
--------------------------------
### RSpec Test Example
Source: https://github.com/defendend/claude-ast-index-search/blob/main/plugin/skills/ast-index/references/ruby-commands.md
Example of an RSpec test suite for a Ruby class, including describe blocks, let bindings, and it expectations.
```ruby
RSpec.describe User do
describe "#valid?" do
let(:user) { build(:user) }
it "returns true for valid user" do
expect(user).to be_valid
end
end
end
```
--------------------------------
### Example Ingest Proxy Write Endpoint
Source: https://github.com/defendend/claude-ast-index-search/blob/main/docs/telemetry-pipeline-guide.md
This is an example of the write endpoint URL that the ingest proxy team will provide after a topic is registered.
```http
POST https:///write//production/report
```
--------------------------------
### Rust Macro Definition Example
Source: https://github.com/defendend/claude-ast-index-search/blob/main/plugin/skills/ast-index/references/rust-commands.md
Example of a Rust macro definition using `macro_rules!`. The macro export attribute and the macro itself are indexed.
```rust
#[macro_export]
macro_rules! vec_of_strings {
($($x:expr),*) => (vec![$($x.to_string()),*]);
}
Indexed as:
- #[macro_export] [annotation]
- vec_of_strings! [function]
```
--------------------------------
### Rust Struct Definition Example
Source: https://github.com/defendend/claude-ast-index-search/blob/main/plugin/skills/ast-index/references/rust-commands.md
Example of a Rust struct definition with derive attributes. Indexed elements include annotations and the struct itself.
```rust
#[derive(Debug, Clone, Serialize)]
pub struct User {
pub id: u64,
pub name: String,
}
Indexed as:
- #[derive(Debug)] [annotation]
- #[derive(Clone)] [annotation]
- #[derive(Serialize)] [annotation]
- User [class]
```
--------------------------------
### Build Project Index with ast-index
Source: https://github.com/defendend/claude-ast-index-search/blob/main/README.md
Build an initial index for your project using the `rebuild` command. This command should be run once per project in the project's root directory.
```bash
cd /path/to/project
ast-index rebuild
```
--------------------------------
### Index Flutter Project and Search
Source: https://github.com/defendend/claude-ast-index-search/blob/main/plugin/skills/ast-index/references/dart-commands.md
Demonstrates a typical workflow for indexing a Flutter project and performing various searches using the ast-index CLI. This includes rebuilding the index, checking statistics, and finding classes, implementations, usages, and outlines.
```bash
# 1. Index Flutter project
cd /path/to/flutter/app
ast-index rebuild
# 2. Check index statistics
ast-index stats
# 3. Find all widgets
ast-index class "Widget"
# 4. Find all BLoC implementations
ast-index implementations "Bloc"
# 5. Find usages of a class
ast-index usages "UserRepository"
# 6. Show widget structure
ast-index outline "lib/src/widgets/custom_button.dart"
# 7. Find all screens
ast-index class "Screen"
```
--------------------------------
### Proto3 Message Definition Example
Source: https://github.com/defendend/claude-ast-index-search/blob/main/plugin/skills/ast-index/references/proto-commands.md
An example of a Protocol Buffer message definition using proto3 syntax, including fields, repeated fields, and oneof.
```protobuf
syntax = "proto3";
package api.v1;
message UserRequest {
string user_id = 1;
repeated string fields = 2;
oneof filter {
string name = 3;
int32 age = 4;
}
}
message UserResponse {
User user = 1;
Status status = 2;
}
```
--------------------------------
### Generate Project Map Summary
Source: https://github.com/defendend/claude-ast-index-search/blob/main/plugin/skills/ast-index/SKILL.md
Use `ast-index map` to display a compact project overview, showing top directories by size and symbol kind counts. Customize the number of directories shown with `--limit`.
```bash
ast-index map # Summary: top 50 dirs with kind counts (~54 lines)
```
```bash
ast-index map --limit 20 # Show only top 20 directories
```
--------------------------------
### Rust Function Definitions Example
Source: https://github.com/defendend/claude-ast-index-search/blob/main/plugin/skills/ast-index/references/rust-commands.md
Examples of various Rust function definitions, including regular functions, async functions, and const functions. All are indexed as functions.
```rust
pub fn process_data(data: &[u8]) -> Result<(), Error> {
Ok(())
}
pub async fn fetch_user(id: u64) -> User {
todo!()
}
const fn compute() -> i32 {
42
}
All indexed as [function].
```
--------------------------------
### Run Benchmarks in Quick Mode
Source: https://github.com/defendend/claude-ast-index-search/blob/main/docs/benchmarks.md
Execute benchmarks in a quick mode that provides rough numbers in seconds. This is suitable for local development and rapid feedback.
```bash
cargo bench --bench parser -- --quick
```
--------------------------------
### Dart Enhanced Enum Example
Source: https://github.com/defendend/claude-ast-index-search/blob/main/plugin/skills/ast-index/references/dart-commands.md
An example of an enhanced enum in Dart that implements the `Comparable` interface. This showcases custom behavior within enums, including a `compareTo` method.
```dart
enum Status implements Comparable {
active,
inactive;
@override
int compareTo(Status other) => index - other.index;
}
```
--------------------------------
### Test on Real Projects
Source: https://github.com/defendend/claude-ast-index-search/blob/main/CONTRIBUTING.md
Build the release version of the project and test its commands on a real codebase. This includes rebuilding the index, checking statistics, and performing searches.
```bash
cargo build --release
./target/release/ast-index rebuild # in a project directory
./target/release/ast-index stats
./target/release/ast-index search "ClassName"
```
--------------------------------
### Dart Extension Type Example
Source: https://github.com/defendend/claude-ast-index-search/blob/main/plugin/skills/ast-index/references/dart-commands.md
An example of an extension type introduced in Dart 3.3, providing a way to wrap existing types with new behavior. This includes a constructor for creating instances from strings.
```dart
extension type UserId(int id) {
UserId.fromString(String s) : id = int.parse(s);
}
```
--------------------------------
### Run All Benchmarks
Source: https://github.com/defendend/claude-ast-index-search/blob/main/docs/benchmarks.md
Compile and run all benchmarks. This is useful for collecting a baseline before making optimizations. It can take several minutes to complete.
```bash
cargo bench
```
--------------------------------
### Get JSON Output for Symbol Search
Source: https://github.com/defendend/claude-ast-index-search/blob/main/docs/setup-guide.md
Use `--format json` with the symbol command to get structured JSON output for a specific symbol, optionally filtering by kind (e.g., function).
```bash
ast-index --format json symbol "fetchUser" --kind function
```
--------------------------------
### Show All Imports
Source: https://github.com/defendend/claude-ast-index-search/blob/main/plugin/skills/ast-index/references/wsdl-commands.md
Use the 'imports' command to list all import and include statements within a specified WSDL file.
```bash
ast-index imports "service.wsdl" # Shows all imports
```
--------------------------------
### Build and Test Commands
Source: https://github.com/defendend/claude-ast-index-search/blob/main/CLAUDE.md
Commands for building the project and running tests. Use `--workspace` to include all crates.
```bash
cargo build --release # root binary only (default members)
cargo build --release --workspace # root + MCP
cargo test --release --workspace # full suite, ~600 tests
./target/release/ast-index search Foo
```
--------------------------------
### Telemetry Control Flow: Command Start
Source: https://github.com/defendend/claude-ast-index-search/blob/main/docs/telemetry-pipeline-guide.md
Illustrates the control flow executed at the start of each instrumented command. It appends an event to the telemetry buffer and triggers a background flush if the last flush was more than 30 minutes ago.
```pseudocode
on command start:
append one line to telemetry.jsonl
if now - mtime(last-telemetry-flush) > 30 min:
touch(last-telemetry-flush) # BEFORE network I/O
spawn background flush
```
--------------------------------
### Ruby Module Definition
Source: https://github.com/defendend/claude-ast-index-search/blob/main/plugin/skills/ast-index/references/ruby-commands.md
Example of a Ruby module definition with a method.
```ruby
module Authenticatable
def authenticate
true
end
end
```
--------------------------------
### Basic Ast-Index Configuration
Source: https://github.com/defendend/claude-ast-index-search/blob/main/README.md
Default configuration for ast-index, specifying directories to index and exclude, and whether to respect .gitignore.
```yaml
# Additional directories to index
roots:
- "../shared-lib"
- "../common-modules"
# Directories to exclude from indexing
exclude:
- "vendor"
- "build"
- "node_modules"
# Include files ignored by .gitignore
no_ignore: false
```
--------------------------------
### Get Module Dependencies
Source: https://github.com/defendend/claude-ast-index-search/blob/main/plugin/skills/ast-index/references/module-commands.md
Retrieve the direct dependencies of a specified module.
```bash
ast-index deps "features.payments.impl"
```
--------------------------------
### Find JNI Functions
Source: https://github.com/defendend/claude-ast-index-search/blob/main/plugin/skills/ast-index/references/cpp-commands.md
Commands to find JNI functions, which typically start with 'Java_'.
```bash
ast-index symbol "Java_" # Find all JNI functions
```
```bash
ast-index search "JNICALL" # Find JNI exports
```
--------------------------------
### Create Rules Directory
Source: https://github.com/defendend/claude-ast-index-search/blob/main/plugin/commands/initialize.md
Creates the necessary directory for AST index rules. This command should be run from the repository root.
```bash
mkdir -p .claude/rules
```
--------------------------------
### Create/Update .claude/settings.json
Source: https://github.com/defendend/claude-ast-index-search/blob/main/plugin/commands/initialize-csharp.md
Configure the .claude/settings.json file to enable ast-index integration and set necessary permissions. Ensure to merge keys if the file already exists.
```bash
mkdir -p .claude
```
```json
{
"extraKnownMarketplaces": {
"ast-index": {
"source": {
"source": "github",
"repo": "defendend/Claude-ast-index-search"
}
}
},
"enabledPlugins": {
"ast-index@ast-index": true
},
"permissions": {
"allow": [
"Bash(ya tool ast-index *)",
"Bash(ast-index *)"
]
}
}
```
--------------------------------
### Generic MCP Server Configuration
Source: https://github.com/defendend/claude-ast-index-search/blob/main/docs/mcp-setup.md
A generic configuration pattern for agents supporting MCP over stdio. Includes command and optional environment variables like `AST_INDEX_ROOT` and `AST_INDEX_BIN`.
```text
command: ast-index-mcp
env:
AST_INDEX_ROOT: /absolute/path/to/your/project (optional)
AST_INDEX_BIN: ast-index (optional, default 'ast-index')
```
--------------------------------
### Rails Model Definition
Source: https://github.com/defendend/claude-ast-index-search/blob/main/plugin/skills/ast-index/references/ruby-commands.md
Example of a Rails model including associations, validations, scopes, and callbacks.
```ruby
class Post < ApplicationRecord
belongs_to :author
has_many :comments
validates :title
validates :content
scope :published, -> { where(published: true) }
before_save :normalize_title
end
```
--------------------------------
### Build ast-index MCP Server
Source: https://github.com/defendend/claude-ast-index-search/blob/main/docs/mcp-setup.md
Builds the MCP server binary from source. The binary will be located in `target/release/ast-index-mcp`.
```bash
git clone https://github.com/defendend/Claude-ast-index-search.git
cd Claude-ast-index-search
cargo build --release -p ast-index-mcp
```
--------------------------------
### Ruby Class Definition
Source: https://github.com/defendend/claude-ast-index-search/blob/main/plugin/skills/ast-index/references/ruby-commands.md
Example of a standard Ruby class definition including attributes and an initializer method.
```ruby
class User < ApplicationRecord
attr_accessor :name
def initialize(name)
@name = name
end
end
```
--------------------------------
### XSD Simple Type with Restriction Pattern
Source: https://github.com/defendend/claude-ast-index-search/blob/main/plugin/skills/ast-index/references/wsdl-commands.md
Example of an XSD simple type with restrictions, indexed as a class.
```xml
```
--------------------------------
### Generate project map
Source: https://github.com/defendend/claude-ast-index-search/blob/main/docs/setup-guide.md
Create a compact map of the project, showing key types organized by directory.
```bash
ast-index map
```
--------------------------------
### WSDL Message Pattern
Source: https://github.com/defendend/claude-ast-index-search/blob/main/plugin/skills/ast-index/references/wsdl-commands.md
Example of WSDL messages, which are indexed as classes with parts representing message components.
```xml
```
--------------------------------
### WSDL Service Definition Pattern
Source: https://github.com/defendend/claude-ast-index-search/blob/main/plugin/skills/ast-index/references/wsdl-commands.md
Example of a WSDL service definition, which is indexed as an interface and its associated ports.
```xml
```
--------------------------------
### Configure .claude/settings.json for ast-index
Source: https://github.com/defendend/claude-ast-index-search/blob/main/plugin/commands/initialize-rust.md
Create or update the .claude/settings.json file to enable and configure the ast-index plugin. Ensure to merge keys if the file already exists.
```json
{
"extraKnownMarketplaces": {
"ast-index": {
"source": {
"source": "github",
"repo": "defendend/Claude-ast-index-search"
}
}
},
"enabledPlugins": {
"ast-index@ast-index": true
},
"permissions": {
"allow": [
"Bash(ya tool ast-index *)",
"Bash(ast-index *)"
]
}
}
```
--------------------------------
### Track Ruby Mixins with include, extend, and prepend
Source: https://github.com/defendend/claude-ast-index-search/blob/main/plugin/skills/ast-index/references/ruby-commands.md
Shows how to use `include`, `extend`, and `prepend` to incorporate modules into Ruby classes. These relationships are indexed to track dependencies.
```ruby
class User
include Authenticatable
extend ClassMethods
prepend Trackable
end
```
--------------------------------
### Monorepo workflow with ast-index
Source: https://github.com/defendend/claude-ast-index-search/blob/main/README.md
Demonstrates how to use the --walk-up flag or AST_INDEX_WALK_UP environment variable to reuse a parent-level index in a monorepo.
```bash
# once, in the root
cd /monorepo && ast-index rebuild
# later, from any subproject — reuse the root index
AST_INDEX_WALK_UP=1 ast-index search ViewModel
# or per-call:
ast-index --walk-up search ViewModel
```
--------------------------------
### TypeScript Enums
Source: https://github.com/defendend/claude-ast-index-search/blob/main/plugin/skills/ast-index/references/typescript-commands.md
Provides an example of an enum definition in TypeScript. Use `ast-index symbol` to find enum types.
```typescript
enum UserStatus {
Active = 'ACTIVE',
Inactive = 'INACTIVE',
Pending = 'PENDING'
}
```
--------------------------------
### TypeScript Type Aliases
Source: https://github.com/defendend/claude-ast-index-search/blob/main/plugin/skills/ast-index/references/typescript-commands.md
Shows examples of type aliases in TypeScript. These can be searched using the `ast-index symbol` command.
```typescript
type UserID = string;
type UserMap = Map;
type AsyncResult = Promise>;
```
--------------------------------
### Inspect Live Database with ast-index CLI
Source: https://github.com/defendend/claude-ast-index-search/blob/main/docs/db-schema.md
Commands to interact with the live database. Use `ast-index db-path` to get the database file path, `ast-index schema` for a schema dump, and `ast-index query` for executing SELECT statements. Raw `sqlite3` can be used for mutations.
```bash
ast-index db-path # path to the .db file
```
```bash
ast-index schema # JSON dump of all tables + row counts
```
```bash
ast-index query "SELECT * FROM symbols WHERE name = ?1 LIMIT 20" foo
```
```bash
# Raw SQLite
sqlite3 $(ast-index db-path) ".tables"
```
```bash
sqlite3 $(ast-index db-path) "SELECT kind, COUNT(*) FROM symbols GROUP BY kind ORDER BY 2 DESC"
```
--------------------------------
### XSD Complex Type Pattern
Source: https://github.com/defendend/claude-ast-index-search/blob/main/plugin/skills/ast-index/references/wsdl-commands.md
Example of an XSD complex type, which is indexed as a class with properties for its elements and attributes.
```xml
```
--------------------------------
### Python Decorator Example
Source: https://github.com/defendend/claude-ast-index-search/blob/main/plugin/skills/ast-index/references/python-commands.md
Demonstrates Python decorators applied to a class and a function. These decorators are recognized and indexed by ast-index.
```python
@dataclass
class Config:
host: str
port: int
@router.get("/users")
async def get_users():
pass
```
--------------------------------
### Create Cursor Project Rule for AST Index
Source: https://github.com/defendend/claude-ast-index-search/blob/main/plugin/commands-cursor/initialize-ast-index.md
Create the `.cursor/rules` directory and define the `ast-index.mdc` rule file to prioritize structural code search.
```bash
mkdir -p .cursor/rules
```
```markdown
---
description: Use ast-index for fast structural code search before broad text search.
alwaysApply: true
---
Use `ast-index` first for codebase navigation tasks: files, symbols, classes,
usages, implementations, callers, outlines, dependencies, and project maps.
Run `ast-index stats` before the first query. If no usable index exists, run
`ast-index rebuild` from the project root. In large repositories, prefer the
smallest relevant root or a scoped rebuild with `--include`.
Do not run grep or broad text search after `ast-index` returns sufficient
structural results. Fall back to text search only for regex searches, string
literals, comments, or when `ast-index` returns no useful result.
```
--------------------------------
### Show dependencies of a module
Source: https://github.com/defendend/claude-ast-index-search/blob/main/docs/setup-guide.md
List the direct dependencies of a specified module.
```bash
ast-index deps "app"
```
--------------------------------
### Find Imports and Usages
Source: https://github.com/defendend/claude-ast-index-search/blob/main/plugin/skills/ast-index/references/go-commands.md
Commands to list all imports in a file, including aliases, and to find all usages of a specific package like 'context'.
```bash
ast-index imports "handler.go" # Shows all imports with aliases
ast-index usages "context" # Find context usage
```
--------------------------------
### Index Project with ast-index
Source: https://github.com/defendend/claude-ast-index-search/blob/main/npm/README.md
Use the 'rebuild' command to index your project for code searching.
```bash
ast-index rebuild
```
--------------------------------
### Run a Specific Benchmark File
Source: https://github.com/defendend/claude-ast-index-search/blob/main/docs/benchmarks.md
Execute benchmarks from a specific file, such as 'parser', 'db_query', or 'index_build'.
```bash
cargo bench --bench parser
```
```bash
cargo bench --bench db_query
```
```bash
cargo bench --bench index_build
```
--------------------------------
### Analyze Ruby Files
Source: https://github.com/defendend/claude-ast-index-search/blob/main/plugin/skills/ast-index/references/ruby-commands.md
Commands to get an overview of a Ruby file's structure or to list its import statements.
```bash
ast-index outline "user.rb" # Show file structure
ast-index imports "controller.rb" # Show require statements
```
--------------------------------
### Suggested Agent Rules for Code Navigation
Source: https://github.com/defendend/claude-ast-index-search/blob/main/docs/mcp-setup.md
Integrate these rules into your agent's configuration to prioritize ast-index tools for code searching and navigation. They guide the agent on when to use specific ast-index commands like `outline`, `usages`, `callers`, and `implementations` before resorting to broader search methods.
```markdown
When you need to find code in this repository:
1. Use the ast-index MCP tools BEFORE grep or bulk Read.
2. Before reading any file longer than 500 lines, call `outline` on it
first, then Read only the line range you actually need.
3. For "who uses X" questions use `usages`; for "who calls X" use
`callers`; for "what implements X" use `implementations`.
4. If ast-index returns empty, fall back to grep — don't bulk-read files.
```
--------------------------------
### Reset Homebrew tap for ast-index
Source: https://github.com/defendend/claude-ast-index-search/blob/main/README.md
Resets the local Homebrew tap for ast-index to resolve merge conflict errors during installation.
```bash
cd /opt/homebrew/Library/Taps/defendend/homebrew-ast-index
git fetch origin
git reset --hard origin/main
brew install ast-index
```
--------------------------------
### Go Interface Definition Example
Source: https://github.com/defendend/claude-ast-index-search/blob/main/plugin/skills/ast-index/references/go-commands.md
Defines a Go interface `AvatarsMDS` with methods for deletion and upload. This interface is indexed by ast-index.
```go
type AvatarsMDS interface {
Delete(ctx context.Context, groupID int, name string) error
Upload(ctx context.Context, data []byte) (int, error)
}
```