🦀 ClawHub
swiftfindrefs
by @michaelversus
Use swiftfindrefs (IndexStoreDB) to list every Swift source file referencing a symbol. Mandatory for “find references”, “fix missing imports”, and cross-module refactors. Do not replace with grep/rg or IDE search.
TERMINAL
clawhub install swiftfindrefs📖 About This Skill
name: swiftfindrefs description: Use swiftfindrefs (IndexStoreDB) to list every Swift source file referencing a symbol. Mandatory for “find references”, “fix missing imports”, and cross-module refactors. Do not replace with grep/rg or IDE search.
SwiftFindRefs
Purpose
Useswiftfindrefs to locate every Swift source file that references a given symbol by querying Xcode’s IndexStore (DerivedData). This skill exists to prevent incomplete refactors caused by text search or heuristics.Rules
swiftfindrefs before editing any files.swiftfindrefs.grep, rg, IDE search, or filesystem heuristics for reference discovery.Preconditions
swiftfindrefs available in PATHInstallation
brew tap michaelversus/SwiftFindRefs https://github.com/michaelversus/SwiftFindRefs.git
brew install swiftfindrefs
Canonical command
Prefer providing--projectName and --symbolType when possible.swiftfindrefs \
--projectName \
--symbolName \
--symbolType
Optional flags:
--dataStorePath : explicit DataStore (or IndexStoreDB) path; skips discovery-v, --verbose: enables verbose output for diagnostic purposes (flag, no value required)Output contract
Standard workflows
Workflow A: Find all references
1. Runswiftfindrefs for the symbol.
2. Treat the output as the complete reference set.
3. If more detail is needed, open only the returned files.Workflow B: Fix missing imports after moving a symbol
Useswiftfindrefs to restrict scope, then add imports only where needed.swiftfindrefs -p -n -t | while read file; do
if ! grep -q "^import $" "$file"; then
echo "$file"
fi
done
Then for each printed file:
import in the imports block at the top.Workflow C: Audit usage before deleting or renaming a symbol
1. Runswiftfindrefs for the symbol.
2. If output is empty, treat the symbol as unused (still validate via build/tests if needed).
3. If non-empty, review the listed files before changing public API.References
🔒 Constraints
swiftfindrefs before editing any files.swiftfindrefs.grep, rg, IDE search, or filesystem heuristics for reference discovery.