agentleFS
vltingvlting/claude-skills/skills/sim-source/SKILL.md

sim-source

Skill2 starsChanged 9 months agoMITView on GitHub

Switch the iOS Simulator's Metro bundler between the main repo root and a git worktree. Use when the user wants the running playground-native app to load sources from a worktree (to preview in-progress work) or switch back to the main checkout.

The file

We split this skill into the rules it gives an agent

5 rules. About 0 are common, 2 are distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    No rebuild of the native binary is needed as long as native deps haven't changed.

    line 14
  2. Very specific:

    Wait for port to free (poll lsof -iTCP:8081 until empty, max 5s).

    line 35
  3. Very specific:

    Run in background (run_in_background: true).

    line 41
  4. Very specific:

    Native deps must match: If the target worktree has a different react-native / Expo version or added native modules, the installed sim …

    line 50
  5. Distinctive:

    Worktree cleanup: if user asks to switch away from a worktree and then remove it, switch first (to avoid Metro holding file handles).

    line 52

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

sim-source

Repoints the running playground-native Metro bundler at a different source directory. The installed iOS Simulator binary connects to Metro on localhost:8081 and will pick up whichever source tree Metro is serving.

How it works

  • Each checkout has its own apps/playground-native/metro.config.js which resolves monorepoRoot as ../.. and writes .source-root.json.
  • Switching source = kill the current Metro process, cd into the target checkout's apps/playground-native, run yarn dev (alias for expo start --clear).
  • No rebuild of the native binary is needed as long as native deps haven't changed.

Procedure

  1. Read current source
    cat <REPO_ROOT>/apps/playground-native/.source-root.json
    Shows { "root": "...", "worktree": "<name>" | null }.
  2. List available targets
    • Main: /Users/lucas/Sites/vlt-ui
    • Worktrees: git -C /Users/lucas/Sites/vlt-ui worktree list
    • Filter to those containing apps/playground-native/ (all do, in this monorepo).
  3. Ask user (via AskUserQuestion) which target to switch to. Show current in the question. Options are the main repo + each worktree branch.
  4. Kill running Metro
    lsof -tiTCP:8081 -sTCP:LISTEN | xargs -r kill
    Wait for port to free (poll lsof -iTCP:8081 until empty, max 5s).
  5. Start from target
    cd <TARGET>/apps/playground-native && yarn dev
    Run in background (run_in_background: true).
  6. Verify
    • Poll <TARGET>/apps/playground-native/.source-root.json until root matches target (written on Metro config load).
    • Confirm port 8081 is listening again.
    • On the Simulator, the user presses r in Metro (or shakes device → Reload) to reload the bundle. Mention this.

Notes

  • Native deps must match. If the target worktree has a different react-native / Expo version or added native modules, the installed sim binary won't work — requires yarn ios rebuild. Check git diff <main> <target> -- apps/playground-native/package.json before switching.
  • Do not edit metro.config.js to hard-code paths. The ../.. resolution is correct by design.
  • Worktree cleanup: if user asks to switch away from a worktree and then remove it, switch first (to avoid Metro holding file handles).
  • Simulator state persists across source switches (AsyncStorage, nav state). That's usually desirable; mention if it could confuse the user.

When to offer this skill

  • User mentions wanting to preview a worktree's changes on the sim.
  • User is reviewing a PR / /do output and the changes are UI-visible.
  • User says "switch the sim to X" or "point the sim at the worktree".

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.