shopify-account-switcher
v1.0.0
Published
Quickly switch between multiple Shopify CLI accounts without logout/login
Maintainers
Readme
Shopify CLI Account Switcher
Quickly switch between multiple Shopify CLI accounts without logout/login.
🎯 Problem Solved
Shopify CLI requires you to log out and log back in every time you want to switch between different accounts. This is time-consuming and inefficient.
Solution: This tool allows you to switch between multiple Shopify CLI accounts instantly by manipulating the currentSessionId in Shopify CLI's configuration file.
🏗️ How It Works
Technical Architecture
┌─────────────────────────────────────────────┐
│ Shopify CLI Config File │
│ (via Conf package) │
│ │
│ projectName: 'shopify-cli-kit' │
│ Config Path: │
│ Windows: %APPDATA%\Roaming\shopify-cli-kit-nodejs\Config\config.json
│ macOS: ~/Library/Application Support/shopify-cli-kit-nodejs/Config/
│ Linux: ~/.config/shopify-cli-kit-nodejs/Config/ │
│ │
│ Key Fields: │
│ - sessionStore (JSON string) │
│ - currentSessionId (string) │
└─────────────────────────────────────────────┘Session Storage Format
{
"sessionStore": "{\"accounts.shopify.com\":{\"66e7601e-09b8-4245-ae12-f7968ce6b28a\":{...}}}",
"currentSessionId": "66e7601e-09b8-4245-ae12-f7968ce6b28a"
}Switching Mechanism
Before:
currentSessionId: "[email protected]"
After (switch to user2):
currentSessionId: "[email protected]"
No other config changes - Shopify CLI now thinks [email protected] is the active userSecurity Model
✅ What This Tool DOES:
- Reads Shopify CLI's config file
- Modifies
currentSessionIdfield - Displays account information (alias, stores, expiration)
✅ What This Tool DOES NOT:
- Access or read authentication tokens
- Modify any session data
- Store credentials
- Create new sessions
- Interfere with Shopify CLI's authentication flow
🔒 Security Guarantee:
- Token access: NO
- Token storage: NO
- Token transmission: NO
- Session modification: NO (only ID pointer change)
📦 Installation
Prerequisites
- Node.js: 18.0.0 or higher
- Shopify CLI: Must be installed first
npm install -g @shopify/cli
Install This Tool
npm install -g shopify-account-switcherOr locally for development:
git clone https://github.com/username/shopify-cli-account-switcher.git
cd shopify-cli-account-switcher
npm install
npm run build
npm link💻 Usage
List All Accounts
shopify-acc listExample output:
Accounts:
[1] [email protected]
[2] [email protected]
[3] [email protected]
(*) Current account: [email protected]Display Format:
- Numbered list:
[1],[2],[3], etc. - Current account indicator:
(*)appears at end with account alias - Each line shows account alias
Switch Account
By Number
shopify-acc switch 1Output:
✓ Switched to [email protected] (Account #1)
Stores: mystore.myshopify.comBy Alias (Email)
shopify-acc switch [email protected]Output:
✓ Switched to [email protected]
Stores: store1.myshopify.com, store2.myshopify.com
No Arguments - Shows Numbered List
shopify-acc switchOutput:
Accounts:
[1] [email protected]
[2] [email protected]
[3] [email protected]
(*) Current account: [email protected]Note: When no arguments provided, shopify-acc switch displays the same numbered list as shopify-acc list so you can see all available accounts and their numbers.
Show Current Account
shopify-acc currentExample output:
Current Account:
Alias: [email protected]
User ID: 66e7601e-09b8-4245-ae12-f7968ce6b28a
FQDN: accounts.shopify.com
Stores: store1.myshopify.com, store2.myshopify.com
Expires: 2/15/2026, 3:45:00 PM
Status: ValidAdd New Account
shopify-acc addOutput:
Starting authentication...
This will run "shopify auth login" to authenticate a new account.
[Shopify CLI will open browser for authentication...]
✓ Authentication successful!
Your account has been added to Shopify CLI.
Use "shopify-acc list" to see all your accounts.Note: This command simply runs shopify auth login which handles the entire browser-based OAuth flow securely.
Remove Account
shopify-acc remove [email protected]Output:
✓ Removed [email protected]🔄 Numbered List & Switching Feature
Display Format
shopify-acc listAccounts:
[1] [email protected]
[2] [email protected]
[3] [email protected]
(*) Current account: [email protected]Key Points:
- Each account has a number:
[1],[2],[3] - Current account shown at end:
(*) Current account: [email protected] - You can switch by either number or alias
Switching Priority
The switch command tries alias first, then checks for numbers:
// Priority: alias → number
if (identifier isNumeric) {
// Treat as index (convert 1-based)
const account = accounts[number - 1]
} else {
// Treat as alias
const account = accounts.find(a => a.alias === identifier)
}Examples
# Switch by number
shopify-acc switch 1
# Switch by alias (email)
shopify-acc switch [email protected]
# Show numbered list (same as list)
shopify-acc switchSingle Account Scenario
When only one account exists:
shopify-acc switchAuto-switches to the only account (no list displayed, no selection needed).
🛠️ Troubleshooting
"No accounts found"
Problem: No Shopify CLI accounts configured on your system.
Solution:
# Login to Shopify CLI first
shopify auth login
# Then list accounts
shopify-acc list"Account not found"
Problem: The provided number or alias doesn't exist.
Solution:
# List all available accounts with numbers
shopify-acc list
# Use the exact number or alias shown in the list
shopify-acc switch 2
# or
shopify-acc switch [email protected]"Account number X is out of range"
Problem: Number provided is outside valid range.
Solution:
# List accounts to see valid range
shopify-acc list
# If you see [1], [2], [3], only numbers 1-3 are valid
shopify-acc switch 4 # ❌ Invalid
shopify-acc switch 3 # ✅ ValidSession Expired
Problem: Session has expired and is no longer valid.
Solution:
# Re-authenticate the specific account
shopify acc switch <alias>
# Or manually with Shopify CLI
shopify auth loginConfig File Not Found
Problem: Error: Config file not found
Possible Causes:
- Shopify CLI has never been run
- Different Shopify CLI version installed
- Custom config location
Solution:
# Ensure Shopify CLI is installed and has been used
npm list -g @shopify/cli
shopify --version
# Run Shopify CLI once to create config
shopify auth --help
shopify auth login
# Then try this tool again
shopify-acc listPermission Denied
Problem: Cannot access or modify config file.
Solution:
# Windows: Run terminal as Administrator
# macOS/Linux: Fix file permissions
chmod u+rw ~/.config/shopify-cli-kit-nodejs/📂 File Structure
shopify-cli-account-switcher/
├── package.json
├── tsconfig.json
├── README.md
├── LICENSE
├── .gitignore
├── src/
│ ├── lib/
│ │ ├── config.ts # Config storage (Conf package)
│ │ ├── session.ts # Session operations + getAccountByIndex, switchAccountByIndex
│ │ └── types.ts # TypeScript interfaces
│ ├── commands/
│ │ ├── list.ts # Numbered list display [1] [email protected]
│ │ ├── switch.ts # Number/alias switching
│ │ ├── add.ts # Runs shopify auth login
│ │ ├── current.ts # Shows current account details
│ │ └── remove.ts # Removes account
│ └── index.ts # CLI entry point
└── bin/
└── shopify-acc # Executable script🔐 Security Considerations
What's Secure
✅ No Token Access: Tool never reads or stores authentication tokens
✅ No Credential Storage: All credentials remain in Shopify CLI's secure storage
✅ Minimal Modifications: Only changes currentSessionId pointer
✅ No Network Access: Tool operates locally on filesystem only
✅ Shopify CLI Handles Auth: shopify-acc add delegates to shopify auth login
What's Not Stored
❌ Tokens: No access or storage of any authentication tokens ❌ Passwords: No password storage ❌ Cookies: No cookie handling ❌ API Keys: No API key storage
Attack Vector Protection
🛡️ Token Hijacking: Impossible - tool never accesses tokens 🛡️ Credential Theft: Impossible - tool never reads credentials 🛡️ Session Elevation: Impossible - no session modification capability 🛡️ Replay Attacks: Impossible - only pointer change, no token access
📊 Platform-Specific Details
Windows
Config Path: %APPDATA%\shopify-cli-kit-nodejs\Config\config.json
Example: C:\Users\username\AppData\Roaming\shopify-cli-kit-nodejs\Config\config.jsonmacOS
Config Path: ~/Library/Application Support/shopify-cli-kit-nodejs/Config/
Example: /Users/username/Library/Application Support/shopify-cli-kit-nodejs/Config/config.jsonLinux
Config Path: ~/.config/shopify-cli-cli-kit-nodejs/
Example: /home/username/.config/shopify-cli-kit-nodejs/config.json🚀 Development
Build
npm run buildLocal Installation
npm link
shopify-acc listProject Structure
- TypeScript
- ES Modules (.mjs) + CommonJS (.js) dual format
- Minimal dependencies (conf, chalk, commander)
📝 License
MIT License - see LICENSE file
🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Development Setup
git clone https://github.com/username/shopify-cli-account-switcher.git
cd shopify-cli-account-switcher
npm install
npm run build
npm linkCode Style
- TypeScript strict mode enabled
- ESLint recommended
- Follow Shopify CLI conventions
🎓 Use Cases
Multiple Agency Accounts
# Developer works with 3 different clients
shopify-acc list
shopify-acc switch 1 # client-a
shopify-acc switch 2 # client-b
shopify app dev # Works on client-a projectTeam Collaboration
# Multiple developers share same machine
shopify-acc switch developer-a
shopify-acc list
# ...work on personal project...
shopify acc switch developer-b
# ...switch to team project...Store Management
# Manage multiple stores across different accounts
shopify-acc switch [email protected]
shopify app push
shopify-acc switch [email protected]
shopify app serveNote: This tool is not affiliated with or endorsed by Shopify. It's a utility for developers working with multiple Shopify CLI accounts.
