From ast-index
Initializes ast-index integration for Ruby/Rails projects by configuring .claude/settings.json, creating usage rules in .claude/rules/ast-index.md, and verifying installation.
npx claudepluginhub defendend/claude-ast-index-search --plugin ast-index# Initialize ast-index for Ruby Project This command sets up ast-index integration for Ruby projects (Rails, RSpec, plain Ruby). ## Steps to Execute ### 1. Check Prerequisites Verify ast-index is installed: If not installed, inform user to run: ### 2. Create/Update .claude/settings.json First, ensure the directory exists: Then create or merge into `.claude/settings.json`. If file doesn't exist, create it with this content: **Important**: If `.claude/settings.json` already exists, MERGE the keys (don't replace the whole file). ### 3. Create .claude/rules/ast-index.md (CRITIC...
This command sets up ast-index integration for Ruby projects (Rails, RSpec, plain Ruby).
Verify ast-index is installed:
ast-index version
If not installed, inform user to run:
brew tap defendend/ast-index
brew install ast-index
First, ensure the directory exists:
mkdir -p .claude
Then create or merge into .claude/settings.json. If file doesn't exist, create it with this content:
{
"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 *)"
]
}
}
Important: If .claude/settings.json already exists, MERGE the keys (don't replace the whole file).
Create the rules directory and ast-index rules file:
mkdir -p .claude/rules
Create file .claude/rules/ast-index.md with this content:
# ast-index Rules
## Mandatory Search Rules
1. **ALWAYS use ast-index FIRST** for any code search task
2. **NEVER 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
ast-index is 17-69x faster than grep (1-10ms vs 200ms-3s) and returns structured, accurate results.
## Command Reference
| Task | Command | Time |
|------|---------|------|
| Universal search | `ast-index search "query"` | ~10ms |
| Find class | `ast-index class "ClassName"` | ~1ms |
| Find module | `ast-index search "module ModuleName"` | ~1ms |
| Find usages | `ast-index usages "SymbolName"` | ~8ms |
| Call hierarchy | `ast-index call-tree "method" --depth 3` | ~1s |
| Find callers | `ast-index callers "methodName"` | ~1s |
| File outline | `ast-index outline "model.rb"` | ~1ms |
## Ruby/Rails-Specific Commands
| Task | Command |
|------|---------|
| Find models | `ast-index search "ApplicationRecord"` |
| Find controllers | `ast-index class "Controller"` |
| Find services | `ast-index class "Service"` |
| Find associations | `ast-index search "has_many"` |
| Find validations | `ast-index search "validates"` |
| Find scopes | `ast-index search "scope"` |
| Find callbacks | `ast-index search "before_action"` |
| Find tests | `ast-index search "describe"` |
## Index Management
- `ast-index rebuild` — Full reindex (run once after clone)
- `ast-index update` — After git pull/merge
- `ast-index stats` — Show index statistics
Run initial indexing:
ast-index rebuild
Show progress and report statistics when done.
Run a quick search to verify everything works:
ast-index stats
ast-index search "class"
After completion, inform user:
For Rails projects, you can detect the framework:
# Check for Rails
ast-index search "ApplicationRecord"
ast-index search "ApplicationController"
# Check for RSpec
ast-index search "RSpec.describe"
# Check for Minitest
ast-index search "Minitest::Test"