惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

L
LINUX DO - 最新话题
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
PCI Perspectives
PCI Perspectives
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
H
Heimdal Security Blog
S
Security @ Cisco Blogs
N
News | PayPal Newsroom
J
Java Code Geeks
罗磊的独立博客
Security Archives - TechRepublic
Security Archives - TechRepublic
N
News and Events Feed by Topic
V
V2EX
WordPress大学
WordPress大学
Google Online Security Blog
Google Online Security Blog
N
News and Events Feed by Topic
www.infosecurity-magazine.com
www.infosecurity-magazine.com
月光博客
月光博客
AI
AI
小众软件
小众软件
The GitHub Blog
The GitHub Blog
MongoDB | Blog
MongoDB | Blog
A
Arctic Wolf
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
美团技术团队
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Hacker News - Newest:
Hacker News - Newest: "LLM"
T
Tailwind CSS Blog
S
Schneier on Security
博客园 - 三生石上(FineUI控件)
F
Full Disclosure
B
Blog RSS Feed
Forbes - Security
Forbes - Security
S
SegmentFault 最新的问题
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
人人都是产品经理
人人都是产品经理
云风的 BLOG
云风的 BLOG
Jina AI
Jina AI
Cisco Talos Blog
Cisco Talos Blog
U
Unit 42
Project Zero
Project Zero
H
Hacker News: Front Page
Y
Y Combinator Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
The Cloudflare Blog
大猫的无限游戏
大猫的无限游戏
S
Secure Thoughts
The Hacker News
The Hacker News
Microsoft Azure Blog
Microsoft Azure Blog

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
Where the Hell Do I Put This Token? Syncing Claude Code Secrets to 3 Macs with the 1Password CLI
Kohei Aoki · 2026-06-24 · via DEV Community

Intro

At some point I looked up and I had three Macs.

There's a clear reason they multiplied: trying to do everything on one machine fell apart. Run a few AI jobs in the background — Claude Code and friends — and they eat memory by the fistful, and the actual work I'm supposed to be doing starts to stutter. Editor lags, browser lags, and I end up in this backwards place where "running AI stops my own work." So I split it up: the heavy AI stuff runs on a separate Mac that I ssh into, while my main machine stays free for the actual work. Offload the AI to the Mac next to me. That's how the number of Macs crept up.

So now there's the main one on my desk, a MacBook I carry around, and the box that runs the AI — and the moment you want Claude Code to behave the same on all of them, the annoying part — the part that quietly eats your time — is dealing with tokens. Running the MCP servers for Notion, Linear, and GitHub needs API tokens. Write those straight into .mcp.json and you've got plaintext sitting in a config file. Copy-paste them across three machines by hand and, well, that's its own kind of misery.

"Where the hell do I actually put this token?" I went back and forth on that for a while, and eventually landed on 1Password, which I already use every day. The short version: keep every secret in one place — 1Password — and sync it to each Mac with the 1Password CLI (op). That killed both "plaintext scattered everywhere" and "paste it N times for N machines" in one shot.

Below is what was painful, why I went with the 1Password CLI, and exactly what the two scripts I actually run look like — in the order I did things.

What was painful

Once you start using Claude Code for real, your MCP server config (.mcp.json) needs tokens. At first I just wrote the values in directly.

{
  "mcpServers": {
    "github": {
      "headers": { "Authorization": "Bearer ghp_xxxxxxxxxxxx" }  // ← plaintext
    }
  }
}

This had a pile of problems:

  • Plaintext tokens end up mixed into config files. Private repo or not, having them sit in the git history just feels gross.
  • You have to share the same value across multiple machines. The more machines, the more pasting, and the more chances to paste the wrong thing.
  • Every rotation means editing every machine. Update a token and you're rewriting it on all three. Just thinking about it made me tired.

And the thing I agonized over most: where do I store the token in the first place? Hand a .env to each machine? Encrypt it into my dotfiles? Use a cloud secrets service? Every option felt like "add a whole new mechanism," and I kept not pulling the trigger.

Why the 1Password CLI

Then it hit me one day: the answer was already sitting right there. I've kept my passwords and credit cards in 1Password for years. A token is just another "secret" — there's no reason to stand up a separate home for it.

On top of that, 1Password has a CLI (op), and you can read items out with op item get. There's even an MCP server for it now, so the ecosystem has legs. When I lined the options up side by side, 1Password fit my use case the most naturally.

Storage method Sharing Security Verdict
Hand a .env to each machine manual file sits in plaintext ❌ work per machine + paste mistakes
Encrypt into dotfiles via git need to manage a decryption key separately ❌ another moving part
Cloud secrets service via API good △ new tool to adopt, more login juggling
1Password CLI sync with op Touch ID + Vault picked it: just an extension of what I already use

Three things sold me. I already use it daily, so there's barely anything new to learn. I can approve with Touch ID. I can keep all my secrets in one spot. Basically, "get it done with the tools you already have" was the least-effort path.

The design: 1Password is the only source of secrets

The core of the whole thing is making the flow of secrets one-directional. The real values live only in 1Password, and from there they flow downstream only — into each Mac's env vars, then into config-file references.

1Password (the only source)
   │  op item get (sync script)
   ▼
~/.config/claude/secrets.env  ← auto-generated, not tracked by git, chmod 600
   │  source (loaded at shell startup)
   ▼
env vars  $GITHUB_MCP_PAT etc.
   │  ${VAR} reference
   ▼
.mcp.json / settings.json  ← tracked by git. holds no real values, references only

The key point: never write a real token into a file that git tracks. .mcp.json only gets an env-var reference like ${GITHUB_MCP_PAT}, and the real thing is poured in from 1Password. That way you can commit the config files and no secret leaks.

Holding the whole thing up are just two scripts — one for saving, one for reading.

Prerequisite: 1Password CLI setup

Before running the scripts, get this much out of the way:

  • Install the 1Password CLI (op) (on macOS, brew install 1password-cli)
  • Connect the desktop app and the CLI: 1Password app → Settings → Developer → turn on "Integrate with 1Password CLI." Now you can approve op runs with Touch ID.
  • Make an item to store things in: create an item named Claude Code MCP (category: Password) in the Personal vault, and add a field per token.

On the script side, I map env var names to 1Password field names like this (shared by both scripts):

# ENV_VAR=1Password field name
declare -a MAP=(
  "NOTION_API_KEY=notion_api_key"
  "LINEAR_API_KEY=linear_api_key"
  "GITHUB_MCP_PAT=github_pat"
  "SLACK_MCP_XOXB_TOKEN=slack_xoxb"
  "GOOGLE_TOKEN_JSON=google_token_json"
  "STRIPE_SECRET_KEY=stripe_secret_key"
)

The vault and item can be overridden with env vars (OP_VAULT / OP_ITEM). The defaults are Personal / Claude Code MCP.

The save side: push the env tokens into 1Password

First, the script that saves the tokens currently in my shell into 1Password — save-to-1password.sh. The trick is that it grabs the values from the exports in ~/.zshrc and never spells them out on the command line directly (so they don't land in your history).

The heart of it is how you assemble the fields you hand to 1Password. You line them up in the form ${field name}[password]=value, and if the item already exists you use op item edit, otherwise op item create.

# Build a 6-field shell. If env has a value, put it in; if not, an empty field.
fields=()
for pair in "${MAP[@]}"; do
  var="${pair%%=*}"; field="${pair#*=}"
  val="${!var-}"
  if [ -z "$val" ]; then
    fields+=( "${field}[password]=" )         # just create an empty slot
  else
    fields+=( "${field}[password]=${val}" )    # put the value in
  fi
done

# Update if it exists, create if it doesn't
if op item get "$ITEM" --vault "$VAULT" >/dev/null 2>&1; then
  op item edit "$ITEM" --vault "$VAULT" "${fields[@]}" >/dev/null
else
  op item create --category=password --title="$ITEM" --vault "$VAULT" "${fields[@]}" >/dev/null
fi

The quietly useful bit is creating an empty slot for fields that have no value. You don't need all six tokens lined up from day one. Create the empty fields up front, and later you just paste the post-rotation value into the 1Password GUI to fill them. Instead of going for perfection in one go, I made it something I could migrate to bit by bit.

Run it from an interactive terminal (since Touch ID approval is needed). From inside Claude Code you can just hit it with a leading !.

! bash ~/claudecode/scripts/save-to-1password.sh

The read side: regenerate env from 1Password

Next, the real workhorse, the one I run on each Mac — sync-claude-secrets.sh. It reads the tokens out of 1Password and writes them to an env file that git doesn't track. Run this on each Mac and every machine ends up with the same values. This is exactly what I was after.

I got bitten here once. At first I was calling op read per field, but partway through 1Password would re-lock and ask me for Touch ID over and over, or some fields would just fail to fetch. So I switched to grabbing the whole item at once with --format json and pulling each field out with jq. One op call, total.

# Fetch the item exactly once (less exposed to a mid-run re-lock)
json="$(op item get "$ITEM" --vault "$VAULT" --format json)"

umask 177  # generated file will be 600
got=0; miss=()
for pair in "${MAP[@]}"; do
  var="${pair%%=*}"; field="${pair#*=}"
  # grab the value of the field whose label matches `field`
  val="$(printf '%s' "$json" | jq -r --arg f "$field" \
        '.fields[] | select(.label==$f) | .value // empty')"
  if [ -z "$val" ]; then
    miss+=("$field"); continue
  fi
  printf 'export %s=%q\n' "$var" "$val" >> "$tmp"
  got=$((got+1))
done

The output goes to ~/.config/claude/secrets.env. I use umask 177 and chmod 600 so only the owner can read it, and the values get shell-safe-escaped with printf '%q'.

I also made it fail if nothing came through, but succeed even if some pieces are missing — fail-soft.

if [ "$got" -eq 0 ]; then
  echo "✗ Got nothing. Check your field names." >&2
  exit 1
fi
# Even if some are missing, write out what we got and call it a success

So even in a state like "haven't added the Stripe token yet," the sync still goes through. Whatever's filled in lands in env, and a warning tells you what's missing. Once I dropped the "nothing works unless everything's there" rule, the day-to-day got a lot easier.

Once the env is built, open a new shell or source ~/.config/claude/secrets.env to apply it.

The config files only "reference"

Once the values are in env, all that's left is for .mcp.json to receive them via ${VAR}.

{
  "mcpServers": {
    "github": {
      "headers": { "Authorization": "Bearer ${GITHUB_MCP_PAT}" }
    }
  }
}

No real value is written anywhere, so this file commits just fine. Alongside that, I use .gitignore to broadly exclude the files where secrets tend to sneak in.

# secrets (private repo, just for me, so .mcp.json IS tracked)
CLAUDE.local.md
**/.env
**/.env.*
*.pem
*.key

Day-to-day: new Macs and rotation

Once the setup was in place, the daily operations got almost anticlimactically simple.

Setting up a new Mac is just: turn on the op integration and run sync once.

bash ~/claudecode/scripts/sync-claude-secrets.sh
# → generates ~/.config/claude/secrets.env. Open a new shell and you're done.

Rotating a token is: update the one item in 1Password, then re-run sync on each Mac. You don't touch the config files at all.

# 1. update the field's value in the 1Password GUI
# 2. just re-run sync on each Mac
bash ~/claudecode/scripts/sync-claude-secrets.sh

All that changed was "fix every machine by hand" becoming "fix 1Password once and sync on each machine." But honestly, even just that made a real difference to how much it weighs on me.

Gotchas

A few small traps before it ran cleanly:

  • 1Password CLI unescaping: putting a bare shell variable right before a full-width character can mess up the variable-name boundary and crash with unbound variable. Wrap it in braces like ${ITEM} to avoid it.
  • Handling partially-filled fields: at first it failed unless every field was present, and that tripped me up early in the migration. Fixed by the "succeed with whatever you got" change above.
  • No Touch ID prompt: call op from a non-interactive shell and the approval dialog never shows, so auth fails. Always run save and sync from an interactive terminal.

⚠️ Heads up on git history and rotation
If there was ever a period where you wrote plaintext tokens into config files, the old values are still sitting in your git history. Swapping in env references doesn't erase history, so after migrating it's safest to rotate the affected tokens just in case (update both the service side and 1Password).

Wrapping up

After consolidating all my secrets into 1Password, the things that had been bugging me forever — "plaintext scattered everywhere," "paste it per machine," "fix every machine on every rotation" — all went away together. What it actually does is plain bash: op item get, jq, and writing out exports. Zero flashiness. But that one principle — narrow the source of secrets down to a single place — really does pull its weight.

The more MCP servers you add, the more kinds of tokens you handle. Reusing a password manager you already trust as the "single source of keys" is, I think, a pretty practical move — you get there without adding a new mechanism.

So — where do you keep your Claude Code tokens? If you've got a better way, I'd genuinely like to hear it. And if you're still writing them straight into config files, start by getting just one of them out into 1Password.

References