<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Aamer Patel</title>
    <description>The latest articles on DEV Community by Aamer Patel (@aamerp86).</description>
    <link>https://dev.to/aamerp86</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4283839%2F3da6252e-4889-414f-b64e-a0d4eb486378.png</url>
      <title>DEV Community: Aamer Patel</title>
      <link>https://dev.to/aamerp86</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/aamerp86"/>
    <language>en</language>
    <item>
      <title>How to run Claude Code with separate accounts per project</title>
      <dc:creator>Aamer Patel</dc:creator>
      <pubDate>Sat, 05 Dec 2026 02:34:14 +0000</pubDate>
      <link>https://dev.to/aamerp86/how-to-run-claude-code-with-separate-accounts-per-project-36ea</link>
      <guid>https://dev.to/aamerp86/how-to-run-claude-code-with-separate-accounts-per-project-36ea</guid>
      <description>&lt;p&gt;If you work on more than one project, you've probably done this: asked Claude Code to push or deploy, and it used the wrong account. Your computer is signed in as whoever you used last, and the AI doesn't know any better.&lt;/p&gt;

&lt;p&gt;Here's the free do-it-yourself setup that fixes most of it, where it falls short, and what I ended up building.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Git: the right name and email per folder
&lt;/h2&gt;

&lt;p&gt;Git can switch your identity by folder on its own. Put each project under a parent folder, then add this to &lt;code&gt;~/.gitconfig&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ini"&gt;&lt;code&gt;&lt;span class="k"&gt;[includeIf "gitdir:~/projects/acme/"]&lt;/span&gt;
    &lt;span class="na"&gt;path&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;~/&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;gitconfig&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;acme&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And in &lt;code&gt;~/.gitconfig-acme&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ini"&gt;&lt;code&gt;&lt;span class="k"&gt;[user]&lt;/span&gt;
    &lt;span class="na"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Your&lt;/span&gt; &lt;span class="nc"&gt;Name&lt;/span&gt;
    &lt;span class="na"&gt;email&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;you&lt;/span&gt;@&lt;span class="n"&gt;acme&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;com&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Every repo under &lt;code&gt;~/projects/acme/&lt;/code&gt; now commits as that email.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Command-line tools: a token per folder
&lt;/h2&gt;

&lt;p&gt;Most dev CLIs read a token from an environment variable, so the trick is setting that variable per folder. &lt;a href="https://direnv.net" rel="noopener noreferrer"&gt;direnv&lt;/a&gt; does this. Add a &lt;code&gt;.envrc&lt;/code&gt; file in the project folder:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;GH_TOKEN&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;...               &lt;span class="c"&gt;# GitHub CLI&lt;/span&gt;
&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;VERCEL_TOKEN&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;...           &lt;span class="c"&gt;# Vercel&lt;/span&gt;
&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;SUPABASE_ACCESS_TOKEN&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;...  &lt;span class="c"&gt;# Supabase&lt;/span&gt;
&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;CLOUDFLARE_API_TOKEN&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;...   &lt;span class="c"&gt;# Cloudflare&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run &lt;code&gt;direnv allow&lt;/code&gt;, and those accounts switch on when you &lt;code&gt;cd&lt;/code&gt; into the folder. &lt;strong&gt;Add &lt;code&gt;.envrc&lt;/code&gt; to &lt;code&gt;.gitignore&lt;/code&gt;&lt;/strong&gt; so you never commit your tokens.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Claude Code: a separate profile per project
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;CLAUDE_CONFIG_DIR&lt;/code&gt; points Claude Code at a different settings folder, which means a separate set of MCP servers and logins:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;CLAUDE_CONFIG_DIR&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;~/.claude-acme
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Put that in the same &lt;code&gt;.envrc&lt;/code&gt; and a terminal session in that folder gets the Acme profile.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where this falls short
&lt;/h2&gt;

&lt;p&gt;This setup works, but here's where it kept failing for me:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;It only works in a terminal.&lt;/strong&gt; direnv runs when your shell changes folders. Claude Code desktop and editor buttons don't start from your shell, so they never see &lt;code&gt;.envrc&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Browser sign-ins ignore all of it.&lt;/strong&gt; MCP servers that sign in through the browser (OAuth) use whichever account the browser is logged into.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tokens sit in plain text files&lt;/strong&gt; on your disk.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Nothing stops a mistake.&lt;/strong&gt; If the wrong token is loaded, the push or deploy still goes through.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What I built instead
&lt;/h2&gt;

&lt;p&gt;I'm not a developer. I build with Claude Code across several projects, and I got tired of keeping all of this in sync. So I built &lt;strong&gt;Hats&lt;/strong&gt;, with Claude Code doing the coding.&lt;/p&gt;

&lt;p&gt;Each project folder gets a "hat," meaning its set of accounts: GitHub, Vercel, Supabase, Cloudflare, Sentry and more. Open the folder, in the terminal or in Claude Code desktop, and that project's accounts are on. Keys stay in your computer's secure keychain, not in text files. If something tries to push or deploy as the wrong account, Hats stops it.&lt;/p&gt;

&lt;p&gt;It runs on Mac and Windows, and I use it every day. There's a waitlist at &lt;a href="https://gethats.dev?ref=devto" rel="noopener noreferrer"&gt;gethats.dev&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If you juggle several projects: which accounts do you switch between the most? I'm deciding what to support next.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Disclosure: Hats is my project. The DIY setup above works without it.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>claudecode</category>
      <category>git</category>
      <category>productivity</category>
      <category>vibecoding</category>
    </item>
  </channel>
</rss>
