DEV Community

Cover image for I Built a Chrome Extension to Fix My Biggest Claude.ai Frustration
Sreyas
Sreyas

Posted on

I Built a Chrome Extension to Fix My Biggest Claude.ai Frustration

I use Claude for everything — work research, personal projects, side experiments. The problem: I have multiple accounts and switching between them meant logging out, logging back in, waiting for the page to load, every single time.

So I built ClaudeShift — a Chrome extension that saves your Claude.ai sessions and switches between them with one click.

Here's how it works, what I learned, and why I almost gave up halfway through.


The Problem

If you only use one Claude account, this won't resonate. But if you have a work account and a personal account — or you're a developer managing multiple workspaces — you know the pain.

Every switch looks like this:

  1. Open settings
  2. Log out
  3. Wait for redirect
  4. Type email
  5. Type password
  6. Wait for login
  7. Finally back where you wanted to be

Multiply that by 10 times a day and you've wasted a meaningful chunk of your week on something that should take one click.


The Idea

The fix was obvious once I thought about it: Claude.ai uses session cookies to keep you logged in. If I could save those cookies for each account and restore them on demand, switching would be instant.

That's exactly what ClaudeShift does.


How It Works

ClaudeShift is a Chrome extension built with Manifest V3 and plain JavaScript — no frameworks, no build step.

Saving a session

When you hit "Save Session", the extension reads your active Claude.ai session cookies using the Chrome Cookies API and stores them locally using chrome.storage.local. Nothing leaves your browser.

// Read cookies for claude.ai
const cookies = await chrome.cookies.getAll({ domain: 'claude.ai' });

// Store them with a profile name
await chrome.storage.local.set({
  [profileName]: { cookies, savedAt: Date.now() }
});
Enter fullscreen mode Exit fullscreen mode

Switching accounts

When you select a saved profile, the extension:

  1. Clears the current claude.ai cookies
  2. Restores the saved cookies for the selected profile
  3. Refreshes the active Claude tab
// Clear existing session
await chrome.cookies.getAll({ domain: 'claude.ai' })
  .then(cookies => Promise.all(
    cookies.map(c => chrome.cookies.remove({ url: "https://claude.ai", name: c.name }))
  ));

// Restore saved cookies
for (const cookie of savedCookies) {
  await chrome.cookies.set({
    url: "https://claude.ai",
    name: cookie.name,
    value: cookie.value,
    // ...other properties
  });
}

// Refresh the tab
chrome.tabs.reload(tabId);
Enter fullscreen mode Exit fullscreen mode

The whole switch happens in under a second.


The Hard Parts

Manifest V3 service workers

Chrome's Manifest V3 replaced persistent background pages with service workers. Service workers are great for performance but they go to sleep when idle — which means any state stored in memory gets wiped.

I had to move all session state to chrome.storage.local and re-fetch it every time the service worker woke up. It took me longer than I'd like to admit to figure out why my saved sessions kept disappearing.

Cookie scope

Claude.ai sets cookies with specific domain and path attributes. When restoring cookies, you have to match those attributes exactly or the session won't be recognized. One wrong attribute and you get silently logged out.

I spent an afternoon debugging what looked like a working restore that consistently failed — turned out the sameSite attribute was being dropped during serialization.

The incognito window approach

Adding a second account while already logged into the first was tricky. The solution: open a temporary incognito window, let the user log in, detect the successful login, capture those cookies, then close the window. It feels seamless from the user's side but there's a fair bit of tab monitoring happening in the background.


What I'd Do Differently

Start with the edge cases. I built the happy path first and spent twice as long fixing the edge cases after. Cookie expiry, tabs that aren't claude.ai, users with no saved sessions — every one of these needed handling.

Test with real accounts from day one. I used placeholder data early on and it masked several bugs that only appeared with actual session cookies.

Design the UI last. I wasted time polishing the popup before the core logic was stable. Ship the logic first.


The Stack

  • Manifest V3 Chrome Extension API
  • Vanilla JavaScript — no frameworks, no dependencies
  • chrome.cookies — reading and writing session cookies
  • chrome.storage.local — persisting session data
  • chrome.tabs — detecting and refreshing Claude tabs
  • chrome.windows — incognito window management for adding accounts

Total bundle size: essentially zero. No npm, no webpack, no config files.


Try It

ClaudeShift is free and open source.

GitHub: github.com/codebysreyas/ClaudeShift

Landing page: codebysreyas.github.io/ClaudeShift

Installation takes about 30 seconds via Chrome developer mode — full instructions in the README.

If you use Claude with multiple accounts, give it a try. And if you find a bug or want to contribute, PRs are open.


What I Learned

Building a browser extension is a different kind of challenge from building a web app. You're working within a heavily sandboxed environment, the APIs are quirky, and the documentation assumes you already know things it never explains.

But it's also one of the most satisfying things I've built — because every time I switch accounts in one click, I feel it. The problem was real, the solution is real, and the extension is running in my browser right now while I write this.

That's what good side projects should feel like.


Built by Sreyas VM · GitHub · sreyasmurali150@gmail.com

Top comments (0)