skills/moonbit/ide.md
moon ideALWAYS use moon ide for code navigation in MoonBit projects instead of manual file searching, grep, or semantic search.
This tool provides two essential commands for precise code exploration:
moon ide goto-definition - Find where a symbol is definedmoon ide find-references - Find all usages of a symbolSymbol lookup uses a two-part query system for precise results:
-query)Fuzzy search for symbol names with package filtering support:
# Find any symbol named 'symbol'
moon ide goto-definition -query 'symbol'
# Find methods of a specific type
moon ide goto-definition -query 'Type::method'
# Find trait method implementations
moon ide goto-definition -query 'Trait for Type with method'
# Find symbol in specific package using @pkg prefix
moon ide goto-definition -query '@moonbitlang/x encode'
# Find symbol in multiple packages (searches in pkg1 OR pkg2)
moon ide goto-definition -query '@username/mymodule/pkg1 @username/mymodule/pkg2 helper'
# Find symbol in nested package
moon ide goto-definition -query '@username/mymodule/mypkg helper'
Supported symbols: functions, constants, let bindings, types, structs, enums, traits
Package filtering: Prefix your query with @package_name to scope the search. Multiple @pkg prefixes create an OR condition.
-tags)Pre-filter symbols by characteristics before name matching:
Visibility tags:
pub - Public symbolspub all - Public structs with all public fieldspub open - Public traits with all methods publicpriv - Private symbolsSymbol type tags:
type - Type definitions (struct, enum, typealias, abstract)error - Error type definitionsenum - Enum definitions and variantsstruct - Struct definitionsalias - Type/function/trait aliaseslet - Top-level let bindingsconst - Constant definitionsfn - Function definitionstrait - Trait definitionsimpl - Trait implementationstest - Named test functionsCombine tags with logical operators:
# Public functions only
moon ide goto-definition -tags 'pub fn' -query 'my_func'
# Functions or constants
moon ide goto-definition -tags 'fn | const' -query 'helper'
# Public functions or constants
moon ide goto-definition -tags 'pub (fn | const)' -query 'api'
# Public types or traits
moon ide goto-definition -tags 'pub (type | trait)' -query 'MyType'
# Find public function definition
moon ide goto-definition -tags 'pub fn' -query 'maximum'
# Find all references to a struct
moon ide find-references -tags 'struct' -query 'Rectangle'
# Find trait implementations
moon ide goto-definition -tags 'impl' -query 'Show for MyType'
# Find errors in specific package
moon ide goto-definition -tags 'error' -query '@mymodule/parser ParseError'
# Find symbol across multiple packages
moon ide goto-definition -query '@moonbitlang/x @moonbitlang/core encode'
# Combine package filtering with tags
moon ide goto-definition -tags 'pub fn' -query '@username/myapp helper'
The tool processes queries in this order:
-tags conditions@pkg prefixes in -queryBest Practice: Start with -tags to reduce noise, then use @pkg prefixes in -query to scope by package for precise navigation.