swiftfindrefs

iOS & macOS Development
v1.0.5
Benign

Use swiftfindrefs (IndexStoreDB) to list every Swift source.

11.6K downloads1.6K installsby @michaelversus

Setup & Installation

Install command

clawhub install michaelversus/swiftfindrefs

If the CLI is not installed:

Install command

npx clawhub@latest install michaelversus/swiftfindrefs

Or install with OpenClaw CLI:

Install command

openclaw skills install michaelversus/swiftfindrefs

or paste the repo link into your assistant's chat

Install command

https://github.com/openclaw/skills/tree/main/skills/michaelversus/swiftfindrefs

What This Skill Does

swiftfindrefs queries Xcode's IndexStore (DerivedData) to return every Swift source file that references a given symbol. It covers classes, structs, enums, protocols, functions, and variables across modules. Output is one absolute file path per line, deduplicated and safe to pipe.

grep and IDE search operate on text and miss references that the compiler resolved through type inference or module re-exports, while IndexStoreDB reflects what was actually compiled.

When to Use It

  • Finding all callers of a function before renaming it
  • Auditing files affected by moving a type to a new module
  • Adding missing imports only to files that reference a relocated symbol
  • Confirming a symbol is unused before deleting it
  • Scoping a cross-module refactor to exactly the files that matter
View original SKILL.md file
# SwiftFindRefs

## Purpose
Use `swiftfindrefs` 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
- Always run `swiftfindrefs` before editing any files.
- Only edit files returned by `swiftfindrefs`.
- Do not substitute `grep`, `rg`, IDE search, or filesystem heuristics for reference discovery.
- Do not expand the file set manually.
- If IndexStore/DerivedData resolution fails, stop and report the error. Do not guess.

## Preconditions
- macOS with Xcode installed
- Project has been built at least once (DerivedData exists)
- `swiftfindrefs` available in PATH

## Installation
```bash
brew tap michaelversus/SwiftFindRefs https://github.com/michaelversus/SwiftFindRefs.git
brew install swiftfindrefs
```

## Canonical command
Prefer providing `--projectName` and `--symbolType` when possible.

```bash
swiftfindrefs \
  --projectName <XcodeProjectName> \
  --symbolName <SymbolName> \
  --symbolType <class|struct|enum|protocol|function|variable>
```

Optional flags:
- `--dataStorePath <path>`: explicit DataStore (or IndexStoreDB) path; skips discovery
- `-v, --verbose`: enables verbose output for diagnostic purposes (flag, no value required)

## Output contract
- One absolute file path per line
- Deduplicated
- Script-friendly (safe to pipe line-by-line)
- Ordering is not semantically meaningful

## Standard workflows

### Workflow A: Find all references
1. Run `swiftfindrefs` 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
Use `swiftfindrefs` to restrict scope, then add imports only where needed.

```bash
swiftfindrefs -p <Project> -n <Symbol> -t <Type> | while read file; do
  if ! grep -q "^import <ModuleName>$" "$file"; then
    echo "$file"
  fi
done
```

Then for each printed file:
- Insert `import <ModuleName>` in the imports block at the top.
- Preserve existing import ordering/grouping.
- Never add duplicate imports.
- Do not reformat unrelated code.

### Workflow C: Audit usage before deleting or renaming a symbol
1. Run `swiftfindrefs` 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
- CLI details: references/cli.md
- Playbooks: references/workflows.md
- Troubleshooting: references/troubleshooting.md

Example Workflow

Here's how your AI assistant might use this skill in practice.

INPUT

User asks: Finding all callers of a function before renaming it

AGENT
  1. 1Finding all callers of a function before renaming it
  2. 2Auditing files affected by moving a type to a new module
  3. 3Adding missing imports only to files that reference a relocated symbol
  4. 4Confirming a symbol is unused before deleting it
  5. 5Scoping a cross-module refactor to exactly the files that matter
OUTPUT
Use swiftfindrefs (IndexStoreDB) to list every Swift source.

Share this skill

Security Audits

VirusTotalBenign
OpenClawBenign
View full report

These signals reflect official OpenClaw status values. A Suspicious status means the skill should be used with extra caution.

Details

LanguageMarkdown
Last updatedFeb 26, 2026