SHOPIFY CLI DEVELOPER TOOLING

Profile Switcher

Shopify developer tooling for managing and switching CLI development contexts.


Overview

Profile Switcher is a developer tooling extension for managing active Shopify CLI environments directly within VS Code. It allows Shopify developers working across multiple client stores to swap store credentials, target domains, and API environments without re-running OAuth authentication flows.

The problem

Shopify agency developers frequently switch between multiple development stores every day. Constantly logging out, opening browser OAuth popups, and selecting partner stores in the CLI breaks focus and wastes minutes on every context switch.

What I built

A VS Code extension that inspects the local Shopify CLI session cache, indexes active store profiles, and provides a quick Command Palette selector to swap the CLI's active session target pointer (`currentSessionId` / `SHOPIFY_FLAG_STORE`).

How it works

The extension updates active CLI target environments with zero token manipulation:

Developer Action (Command Palette / Status Bar)
↓
VS Code Extension Host
↓
Local Config Reader (~/.config/shopify/config)
↓
Session Pointer Swap (currentSessionId)
↓
Active CLI Context Swapped (shopify theme dev)

Key decisions

KEY DECISION — Session Pointer Delegation

Swapped pointer metadata directly inside the native Shopify CLI session state file rather than storing raw OAuth tokens in the extension, ensuring security and compatibility with Shopify's native authentication routines.

Implementation

Core environment pointer swap logic:

profile-switcher.js
JavaScript
function switchShopifyProfile(targetProfileKey) {
  const profileConfig = loadLocalProfileConfig(targetProfileKey);
  if (!profileConfig) throw new Error(`Profile "${targetProfileKey}" not found`);
  
  process.env.SHOPIFY_FLAG_STORE = profileConfig.storeDomain;
  console.log(`[Profile Switcher] Switched active environment to: ${profileConfig.storeDomain}`);
}

Result

Eliminated repetitive OAuth re-authentications during multi-store development sessions, reducing environment switching time from ~45 seconds to under 2 seconds.

What I learned

Building developer tooling directly around existing CLI configuration files yields a much cleaner, maintenance-free integration than wrapping CLI binary processes.