<?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: Pau</title>
    <description>The latest articles on DEV Community by Pau (@paureis).</description>
    <link>https://dev.to/paureis</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%2F4189489%2F535cb266-1444-42d1-bfe9-c0c90479fa67.png</url>
      <title>DEV Community: Pau</title>
      <link>https://dev.to/paureis</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/paureis"/>
    <language>en</language>
    <item>
      <title>5 ways your cloud CLI picks the wrong account without telling you</title>
      <dc:creator>Pau</dc:creator>
      <pubDate>Fri, 16 Oct 2026 21:01:43 +0000</pubDate>
      <link>https://dev.to/paureis/5-ways-your-cloud-cli-picks-the-wrong-account-without-telling-you-19e2</link>
      <guid>https://dev.to/paureis/5-ways-your-cloud-cli-picks-the-wrong-account-without-telling-you-19e2</guid>
      <description>&lt;p&gt;You type &lt;code&gt;vercel deploy&lt;/code&gt;, &lt;code&gt;gh pr merge&lt;/code&gt; or &lt;code&gt;kubectl apply&lt;/code&gt;. Which account does it run on?&lt;/p&gt;

&lt;p&gt;Most people would say "the one I'm logged into". That's wrong more often than you'd think, and nothing on screen&lt;br&gt;
tells you. Each CLI works out the account from flags, environment variables, files in the current folder and files in&lt;br&gt;
your home directory, and each one checks them in a different order. These are five cases I ran into while building&lt;br&gt;
cloudpin, all on current versions.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. An environment variable silently beats your login
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;gh auth status&lt;/code&gt; says you're logged in as you. But if &lt;code&gt;GH_TOKEN&lt;/code&gt; or &lt;code&gt;GITHUB_TOKEN&lt;/code&gt; is set, &lt;code&gt;gh&lt;/code&gt; uses that token&lt;br&gt;
instead, for every command (&lt;code&gt;gh help environment&lt;/code&gt;). The same goes for &lt;code&gt;VERCEL_TOKEN&lt;/code&gt;, &lt;code&gt;SUPABASE_ACCESS_TOKEN&lt;/code&gt; and&lt;br&gt;
&lt;code&gt;CLOUDFLARE_API_TOKEN&lt;/code&gt; over their CLIs' stored logins.&lt;/p&gt;

&lt;p&gt;These variables usually get set once (a &lt;code&gt;.env&lt;/code&gt; file, a CI secret copied to a laptop, an old shell profile) and then&lt;br&gt;
forgotten. From then on, the login you see and the account your commands run on are different, and nothing on screen&lt;br&gt;
says so.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. The project folder picks the account
&lt;/h2&gt;

&lt;p&gt;Several CLIs read the target from the project folder, not from who you're logged in as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Vercel:&lt;/strong&gt; a linked project (&lt;code&gt;.vercel/project.json&lt;/code&gt;) sends project-level requests to the team it was linked under.
Observed on Vercel CLI 50.35: &lt;code&gt;--team&lt;/code&gt; changes account-level requests but not those; &lt;code&gt;VERCEL_ORG_ID&lt;/code&gt; does. And the
&lt;code&gt;current&lt;/code&gt; flag in &lt;code&gt;vercel teams ls&lt;/code&gt; shows only your global team, whatever the folder says.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Supabase:&lt;/strong&gt; commands go to the project in &lt;code&gt;supabase/.temp/project-ref&lt;/code&gt;, which &lt;code&gt;supabase link&lt;/code&gt; wrote, unless
&lt;code&gt;--project-ref&lt;/code&gt; or &lt;code&gt;SUPABASE_PROJECT_ID&lt;/code&gt; says otherwise. Copy a folder, and you copy the link.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cloudflare Wrangler:&lt;/strong&gt; &lt;code&gt;account_id&lt;/code&gt; in &lt;code&gt;wrangler.toml&lt;/code&gt; wins over &lt;code&gt;CLOUDFLARE_ACCOUNT_ID&lt;/code&gt;. The source even has a
TODO to swap them in v5. Setting the variable to "be sure" does nothing if the config file names another account.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So &lt;code&gt;cd ../other-project &amp;amp;&amp;amp; deploy&lt;/code&gt; can land on another account from the same terminal, with the same login.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Config files merge, and the first one wins
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;KUBECONFIG&lt;/code&gt; can list several files. kubectl merges them, and for each value the &lt;strong&gt;first&lt;/strong&gt; file to set it wins&lt;br&gt;
(kubernetes.io, "Organizing cluster access"). Add a file at the front of the list and your &lt;code&gt;prod&lt;/code&gt; context may now point&lt;br&gt;
somewhere else, with the same name.&lt;/p&gt;

&lt;p&gt;A harder one to spot: &lt;code&gt;kubectl config view --minify&lt;/code&gt; shows the context you'd expect but ignores &lt;code&gt;--cluster&lt;/code&gt;, and real&lt;br&gt;
requests use it (you can see it in the &lt;code&gt;kubectl -v=6&lt;/code&gt; request URLs). So the command you'd use to check can disagree&lt;br&gt;
with the command that runs.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Someone else changed the global state
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;az account set&lt;/code&gt;, &lt;code&gt;gh auth switch&lt;/code&gt; and &lt;code&gt;gcloud config configurations activate&lt;/code&gt; rewrite a file in your home folder.&lt;br&gt;
Every terminal and every tool on the machine shares it. Switch in one window to check something for a client, and the&lt;br&gt;
deploy you start in the other window an hour later goes to the client.&lt;/p&gt;

&lt;p&gt;Some mistakes don't even fail. On gcloud SDK 588, &lt;code&gt;--configuration&lt;/code&gt; with a name that doesn't exist is not an&lt;br&gt;
error: you get an empty configuration and exit code 0.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Names aren't IDs
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;In my own Azure account, several subscriptions are all called "Azure subscription 1". Only the subscription ID tells
them apart.&lt;/li&gt;
&lt;li&gt;Kubernetes context names are personal: the same cluster is &lt;code&gt;prod&lt;/code&gt; on one laptop and &lt;code&gt;acme-prod-admin&lt;/code&gt; on another.&lt;/li&gt;
&lt;li&gt;AWS CLI aliases (&lt;code&gt;~/.aws/cli/alias&lt;/code&gt;) can replace a built-in command, so &lt;code&gt;aws s3 ls&lt;/code&gt; may not be &lt;code&gt;s3 ls&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;gcloud puts the resource name after the verb: &lt;code&gt;gcloud compute instances delete describe&lt;/code&gt; deletes an instance named
"describe".&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What AI agents add
&lt;/h2&gt;

&lt;p&gt;Coding agents run these same commands for you, and they don't stop to ask which account is active unless you tell&lt;br&gt;
them to. When I started doing my side projects' Azure infrastructure with an agent, I approved each change myself,&lt;br&gt;
but the approval prompt shows the command, not the account it will run on. So I ended up adding the same line to&lt;br&gt;
almost every request: first check which account you're logged into. It worked, but only when I remembered to say&lt;br&gt;
it, and that's the part that kept bugging me.&lt;/p&gt;

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

&lt;p&gt;So I built &lt;a href="https://github.com/paureis/cloudpin" rel="noopener noreferrer"&gt;cloudpin&lt;/a&gt;. You pin the accounts a project uses in a&lt;br&gt;
&lt;code&gt;.cloudpin.yml&lt;/code&gt; by ID, since names repeat. Before any guarded command runs, cloudpin works out which account &lt;em&gt;that&lt;br&gt;
command&lt;/em&gt; would use, with its own flags, environment and folder, and stops it if it's not the pinned one. If it can't&lt;br&gt;
tell, it blocks the command and says why. It works in your terminal (a shell wrapper) and in agent hooks (Claude&lt;br&gt;
Code, Codex, Cursor, Copilot CLI, Antigravity and Gemini CLI).&lt;/p&gt;

&lt;p&gt;It covers az, aws, gcloud, vercel, gh, kubectl, helm, supabase and wrangler. &lt;code&gt;cloudpin explain -- &amp;lt;command&amp;gt;&lt;/code&gt; shows&lt;br&gt;
what it would decide for any command, and why, without running it.&lt;/p&gt;

&lt;h3&gt;
  
  
  Works alongside
&lt;/h3&gt;

&lt;p&gt;cloudpin doesn't manage credentials or switch accounts. It sits next to the tools that do:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;aws-vault and granted hand out short-lived AWS credentials; cloudpin checks they're for the right account.&lt;/li&gt;
&lt;li&gt;kubectx and kubens switch contexts quickly; cloudpin stops the command when the switch was the wrong one.&lt;/li&gt;
&lt;li&gt;direnv sets per-folder variables; cloudpin checks which account those variables point at.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It's still early days: cloudpin has only been around for about a week, so it's very much a work in progress and I'll&lt;br&gt;
keep adding to it. Next up are a Claude Code plugin, a GitHub Action, and Homebrew and Scoop installers.&lt;/p&gt;

&lt;p&gt;To try it: &lt;code&gt;npm install --global cloudpin&lt;/code&gt;, then &lt;code&gt;cloudpin init&lt;/code&gt; in a project. If it gets an account wrong for your&lt;br&gt;
setup, please open an issue. That's the feedback I'm most after.&lt;/p&gt;

</description>
      <category>devops</category>
      <category>cloud</category>
      <category>ai</category>
      <category>security</category>
    </item>
  </channel>
</rss>
