{"id":23,"date":"2026-10-23T09:00:00","date_gmt":"2026-10-23T03:00:00","guid":{"rendered":"https:\/\/nazmulrobin.com\/blog\/?p=23"},"modified":"2026-10-11T10:29:58","modified_gmt":"2026-10-11T04:29:58","slug":"two-claude-code-accounts-on-one-machine","status":"publish","type":"post","link":"https:\/\/nazmulrobin.com\/blog\/two-claude-code-accounts-on-one-machine\/","title":{"rendered":"Claude Code tip: two accounts on one machine, with the active one in the status line"},"content":{"rendered":"\n<p>I use Claude Code with two accounts on one laptop: one from my office and a personal one. I do not want personal projects on the office account, or the other way round, and I do not want to log out and back in every time I switch.<\/p>\n<p>This is the first in a series of short Claude Code tips. It covers how I keep the two accounts apart and how I always know which one I am in.<\/p>\n<h2>One alias, two profiles<\/h2>\n<p>Claude Code keeps its login, settings, history and memory in a config folder, <code>~\/.claude<\/code> by default. The <code>CLAUDE_CONFIG_DIR<\/code> environment variable points it at a different folder. That is all a second profile is.<\/p>\n<p>I added one line to <code>~\/.zshrc<\/code>:<\/p>\n<pre><code class=\"language-sh hljs\"><span class=\"hljs-comment\"># Claude Code: personal account profile (office = plain `claude`)<\/span>\n<span class=\"hljs-built_in\">alias<\/span> claude-personal=<span class=\"hljs-string\">'CLAUDE_CONFIG_DIR=\"$HOME\/.claude-personal\" claude'<\/span><\/code><\/pre>\n<p>Now there are two commands:<\/p>\n<ul>\n<li><code>claude<\/code> runs with the office account.<\/li>\n<li><code>claude-personal<\/code> runs with the personal account.<\/li>\n<\/ul>\n<p>The first time I ran <code>claude-personal<\/code> it asked me to log in, because the new folder was empty. I logged in with the personal account once, and both logins have stayed in place since. I can have both open in two terminal tabs at the same time.<\/p>\n<h2>Showing the active account<\/h2>\n<p>Two profiles that look identical are an accident waiting to happen. So the status line at the bottom of Claude Code tells me where I am:<\/p>\n<pre><code>\ud83c\udfe0 Personal \u00b7 me@example.com<\/code><\/pre>\n<p>and in the other profile:<\/p>\n<pre><code>\ud83c\udfe2 Office \u00b7 me@company.com<\/code><\/pre>\n<p>Claude Code can run a command to produce its status line. The setting goes in <code>settings.json<\/code>, in each profile&#8217;s folder:<\/p>\n<pre><code class=\"language-json hljs\">{\n  <span class=\"hljs-attr\">\"statusLine\"<\/span>: {\n    <span class=\"hljs-attr\">\"type\"<\/span>: <span class=\"hljs-string\">\"command\"<\/span>,\n    <span class=\"hljs-attr\">\"command\"<\/span>: <span class=\"hljs-string\">\"\/Users\/me\/.claude\/statusline-account.sh\"<\/span>\n  }\n}<\/code><\/pre>\n<p>Both profiles point at the same script. The script works out which profile it is running in from <code>CLAUDE_CONFIG_DIR<\/code>, and reads the logged-in email from that profile&#8217;s <code>.claude.json<\/code>:<\/p>\n<pre><code class=\"language-bash hljs\"><span class=\"hljs-meta\">#!\/bin\/bash<\/span>\n<span class=\"hljs-comment\"># Shows which Claude account profile is active.<\/span>\ncat &gt;\/dev\/null\ndir=<span class=\"hljs-string\">\"<span class=\"hljs-variable\">${CLAUDE_CONFIG_DIR:-$HOME\/.claude}<\/span>\"<\/span>\n<span class=\"hljs-keyword\">if<\/span> [ <span class=\"hljs-string\">\"<span class=\"hljs-variable\">$dir<\/span>\"<\/span> = <span class=\"hljs-string\">\"<span class=\"hljs-variable\">$HOME<\/span>\/.claude-personal\"<\/span> ]; <span class=\"hljs-keyword\">then<\/span>\n  label=<span class=\"hljs-string\">\"\ud83c\udfe0 Personal\"<\/span>\n<span class=\"hljs-keyword\">else<\/span>\n  label=<span class=\"hljs-string\">\"\ud83c\udfe2 Office\"<\/span>\n<span class=\"hljs-keyword\">fi<\/span>\nread_email=<span class=\"hljs-string\">'import json,sys; print(json.load(open(sys.argv[1])).get(\"oauthAccount\",{}).get(\"emailAddress\",\"\"))'<\/span>\nemail=$(\/usr\/bin\/python3 -c <span class=\"hljs-string\">\"<span class=\"hljs-variable\">$read_email<\/span>\"<\/span> <span class=\"hljs-string\">\"<span class=\"hljs-variable\">$dir<\/span>\/.claude.json\"<\/span> 2&gt;\/dev\/null)\n[ -z <span class=\"hljs-string\">\"<span class=\"hljs-variable\">$email<\/span>\"<\/span> ] &amp;&amp; [ <span class=\"hljs-string\">\"<span class=\"hljs-variable\">$dir<\/span>\"<\/span> = <span class=\"hljs-string\">\"<span class=\"hljs-variable\">$HOME<\/span>\/.claude\"<\/span> ] &amp;&amp; email=$(\/usr\/bin\/python3 -c <span class=\"hljs-string\">\"<span class=\"hljs-variable\">$read_email<\/span>\"<\/span> <span class=\"hljs-string\">\"<span class=\"hljs-variable\">$HOME<\/span>\/.claude.json\"<\/span> 2&gt;\/dev\/null)\n<span class=\"hljs-built_in\">echo<\/span> <span class=\"hljs-string\">\"<span class=\"hljs-variable\">$label<\/span><span class=\"hljs-variable\">${email:+ \u00b7 $email}<\/span>\"<\/span><\/code><\/pre>\n<p>A few notes on it:<\/p>\n<ul>\n<li><strong><code>cat &gt;\/dev\/null<\/code><\/strong> is there because Claude Code sends session details to the script as JSON on standard input. This script does not need them, so it reads and discards them.<\/li>\n<li><strong>The second lookup<\/strong> covers the default profile, which keeps its <code>.claude.json<\/code> in the home folder and not inside <code>~\/.claude<\/code>.<\/li>\n<li><strong>The email comes from an internal file.<\/strong> The <code>oauthAccount<\/code> field is not a documented setting, so it may change in a future version. If it does, the script still prints the label and leaves the email out.<\/li>\n<\/ul>\n<p>Remember to make the script executable with <code>chmod +x<\/code>.<\/p>\n<h2>Sharing instructions between the two<\/h2>\n<p>Each profile has its own global <code>CLAUDE.md<\/code>, the file with instructions that apply to every project. I want the same working rules in both accounts, so the personal one is a symlink to the office one:<\/p>\n<pre><code class=\"language-sh hljs\">ln -s ~\/.claude\/CLAUDE.md ~\/.claude-personal\/CLAUDE.md<\/code><\/pre>\n<p>I edit one file and both profiles follow it.<\/p>\n<h2>What stays separate<\/h2>\n<p>Everything else lives in the profile&#8217;s folder, so it is separate by default:<\/p>\n<ul>\n<li><strong>Login and usage.<\/strong> Each profile uses its own account and its own plan limits.<\/li>\n<li><strong>Settings and permissions.<\/strong> A permission I allow in one profile is not allowed in the other.<\/li>\n<li><strong>Skills and plugins.<\/strong> Office skills stay in the office profile. I copy over only the ones I want in both.<\/li>\n<li><strong>History and memory.<\/strong> Conversations and saved memory for a project are per profile, even for the same folder on disk.<\/li>\n<\/ul>\n<p>That separation is the point. Office work stays on the office account, and my own projects stay on mine. The status line makes sure I notice before I start typing in the wrong one.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I use Claude Code with an office account and a personal account on the same laptop. One alias keeps them apart, and a small status line script shows which account I am in.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17],"tags":[18,19],"class_list":["post-23","post","type-post","status-publish","format-standard","hentry","category-claude-code","tag-claude-code-tips","tag-terminal"],"_links":{"self":[{"href":"https:\/\/nazmulrobin.com\/blog\/wp-json\/wp\/v2\/posts\/23","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nazmulrobin.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nazmulrobin.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nazmulrobin.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nazmulrobin.com\/blog\/wp-json\/wp\/v2\/comments?post=23"}],"version-history":[{"count":1,"href":"https:\/\/nazmulrobin.com\/blog\/wp-json\/wp\/v2\/posts\/23\/revisions"}],"predecessor-version":[{"id":36,"href":"https:\/\/nazmulrobin.com\/blog\/wp-json\/wp\/v2\/posts\/23\/revisions\/36"}],"wp:attachment":[{"href":"https:\/\/nazmulrobin.com\/blog\/wp-json\/wp\/v2\/media?parent=23"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nazmulrobin.com\/blog\/wp-json\/wp\/v2\/categories?post=23"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nazmulrobin.com\/blog\/wp-json\/wp\/v2\/tags?post=23"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}