Loading...
Loading...
KGF-aware token pattern and semantic code search. Use when the user wants to search code by structure (not just text), find specific patterns like nested loops or undocumented functions, or search by natural language similarity.
npx skill4agent add trkbt10/indexion-skills indexion-greppubKW_pub# Find all pub fn declarations
indexion grep "pub fn *" src/
# Find pub struct definitions
indexion grep "pub struct *" src/
# Nested for loops (O(n²) candidates)
indexion grep "for ... for" src/
# Functions named "sort"
indexion grep "fn Ident:sort" src/
# Any token except pub, followed by fn
indexion grep "!pub fn" src/
# Using raw KGF token kinds also works
indexion grep "KW_pub KW_fn Ident" src/| Pattern | Meaning |
|---|---|
| Match keyword (auto-alias → |
| Match token kind exactly |
| Match kind and text |
| Match any single token |
| Match zero or more tokens (non-greedy) |
| Negation — any token except this kind |
| Punctuation aliases |
# Find proxy functions (wrappers that just delegate)
indexion grep --semantic=proxy src/
# Find long functions (30+ lines)
indexion grep --semantic=long:30 src/
# Find short functions (3 lines or less)
indexion grep --semantic=short:3 src/
# Find functions with 4+ parameters
indexion grep --semantic=params-gte:4 src/
# Find functions by name substring
indexion grep --semantic=name:sort src/
# Find undocumented pub declarations (also available as --undocumented)
indexion grep --undocumented src/
indexion grep --semantic=undocumented src/digest# Find functions related to "parse JSON configuration"
indexion grep --semantic="similar:parse JSON configuration" src/
# Find tokenization-related code
indexion grep --semantic="similar:tokenize source code into tokens" src/
# Find error handling patterns
indexion grep --semantic="similar:handle error and return" src/# File paths only
indexion grep --files "pub fn *" src/
# Match count per file
indexion grep --count "pub fn *" src/
# Context lines around matches
indexion grep --context=3 "for ... for" src/
# Include/exclude patterns
indexion grep --include='*.mbt' --exclude='*_test.mbt' "pub fn *" src/| Option | Default | Description |
|---|---|---|
| — | Semantic query (see above) |
| false | Find pub declarations without doc comments |
| false | Show matching file paths only |
| false | Show match count per file only |
| 0 | Lines of context around matches |
| — | Include file pattern (repeatable) |
| — | Exclude file pattern (repeatable) |
| kgfs | KGF specs directory |
| Command | Purpose | When to use |
|---|---|---|
| Find specific patterns/functions | "Find all nested for loops" |
| File-level similarity matrix | "What files are similar?" |
| Actionable refactoring plan | "What duplicates should I fix?" |
| Proxy function detection + auto-fix | "Remove unnecessary wrappers" |
| Purpose-based function index | "Find function that handles X" (requires build step) |
grep --semantic=proxyplan unwrapplan unwrapgrepplan unwrapgrep --semantic=similar:...digest querydigest# After writing new code, check for patterns that need attention:
# 1. Find potential O(n²) sorts (nested loops)
indexion grep "for ... for" src/
# 2. Check for undocumented public API
indexion grep --undocumented src/
# 3. Find proxy functions to consider unwrapping
indexion grep --semantic=proxy src/
# 4. Find overly long functions
indexion grep --semantic=long:50 src/
# 5. Search for specific refactoring targets by similarity
indexion grep --semantic="similar:extract substring" src/
# 6. Trace all references to a type before moving it
indexion grep "TypeIdent:TfidfEmbeddingProvider" src/
# 7. Find all sort-related functions across the codebase
indexion grep --semantic=name:sort src/
# 8. Verify a refactoring didn't leave orphan references
indexion grep "Ident:old_function_name" src/ cmd/indexion/grep "TypeIdent:X"pubKW_pub...for ... for--semantic="similar:..."grep --semantic=name:Xplan refactor