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

推荐订阅源

罗磊的独立博客
美团技术团队
Apple Machine Learning Research
Apple Machine Learning Research
Hugging Face - Blog
Hugging Face - Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
月光博客
月光博客
WordPress大学
WordPress大学
The Cloudflare Blog
阮一峰的网络日志
阮一峰的网络日志
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
博客园_首页
博客园 - Franky
博客园 - 司徒正美
酷 壳 – CoolShell
酷 壳 – CoolShell
爱范儿
爱范儿
Jina AI
Jina AI
Last Week in AI
Last Week in AI
雷峰网
雷峰网
IT之家
IT之家
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - 聂微东
小众软件
小众软件
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
V
V2EX

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
Putting Claude Code Under Version Control: Configs Since ...
Sascha Rahn · 2026-05-25 · via DEV Community

When you let an AI agent share your machine for a year, you eventually hit a question you can't answer: why does my setup look like this?

Not "what does it look like" — that's just cat. The why. Which config landed when, which edit was the agent's own work versus mine, which assumption got baked in three commits ago and is now invisible. If you've used Claude Code long enough to have an evolved settings file, a memory store, and a handful of skills installed, you already recognize the feeling.

I've been versioning Claude Code's configuration files since July 2025. Memory joined the repository in April 2026. The setup is mundane — a private git repo and a handful of symlinks — but the effects compound, and most of them I didn't anticipate when I started.

A small but important clarification

Claude Code doesn't edit its own configs autonomously. It only edits them when you ask it to, or when you've set up a workflow that includes "persist this to settings." That distinction matters for everything below: the audit trail is valuable not because the agent goes rogue, but because the agent does what you asked — and a week later, you no longer remember exactly what you asked for.

It also matters because Claude Code's settings live at different scopes. The global ~/.claude/settings.json is the one I've seen the agent touch most. User-scoped and project-scoped overrides have been more cautious in my experience. Memory is its own thing again, scoped per project working directory.

The mechanism

Claude Code writes its state to predictable paths:

  • Global settings: ~/.claude/settings.json
  • Project-scoped memory: ~/.claude/projects/<encoded-cwd>/memory/
  • Skills, hooks, MCP configs: various ~/.claude/... subfolders

<encoded-cwd> is deterministic — your working directory with slashes replaced by dashes. That predictability is the entire leverage point. If the path is constant, you can symlink it into a git repo and the agent doesn't know the difference.

The setup

# 1. Move the target dir into your private configs repo
mv ~/.claude/projects/<encoded-cwd>/memory \
   ~/configs/claude-code/projects/<encoded-cwd>/memory

# 2. Symlink back so Claude keeps reading at the original path
ln -s ~/configs/claude-code/projects/<encoded-cwd>/memory \
      ~/.claude/projects/<encoded-cwd>/memory

# 3. Commit
cd ~/configs && git add . && git commit -m "claude-code: memory under version control"

That's it. Claude continues reading and writing at the same path. Git tracks every change. Repeat for any other ~/.claude/... subtree you want to capture.

Configs repo README in GitKraken diff view — table of all versioned config files with their paths

After symlinking, the configs repo holds the canonical state. The diff is what you actually review.

What changed

I started narrow — I wanted a backup of settings.json in case something blew it away. The effects below emerged as the repo grew. None of them were the original motivation.

Audit trail

git log on the configs directory tells me what was rewritten when. git diff on a settings file shows me what changed yesterday. When the agent edits a settings file on my behalf — which happens whenever I run a setup or skill that persists state — the diff is the only honest record of what actually landed. Six months in, this is the effect I use most.

GitKraken commit graph showing audit trail of versioned Claude Code memory + settings

Every memory update, every correction, every policy tightening becomes one line in the log.

Rollback for bad generalizations

Sometimes a memory entry lands wrong. A correction the agent generalized too broadly, an entry that survived past its expiration. git checkout HEAD~N -- claude-code/projects/.../memory/<file>.md and the entry is gone, exactly as it was three days ago. Without version control, that path is one-way.

Backup resilience

~/.claude/ is an application home directory. A stray cleanup, a beta update that resets state, a disk failure — any of these can erase months of accumulated context. With the repo as the source of truth and symlinks pointing back, the recovery is git clone plus re-linking. That's it. If you're more paranoid, you can also push the repo to a private remote and have an offsite copy.

The fix-buddy effect

This is the one I didn't see coming. Once the repo contains the full agent setup — settings, skills, memory, MCP configurations — the agent itself can read its own history through git. When something breaks, I don't need to explain to Claude what its setup looked like a week ago. It can look. That changes what "debugging your AI workflow" feels like, because the agent is no longer guessing at its own past.

A note for multi-machine setups

If you do run Claude Code on more than one machine, a private remote plus git pull before each session gives you the same context everywhere. I run on one machine, so I haven't pressure-tested this; the moving parts (system-level paths, OS-specific binaries) make me cautious to promise it as a turnkey thing. But the file-level setup is there if you want to try.

The re-framing

The hack isn't the symlink. The hack is the relabeling.

Most people treat ~/.claude/ as application state. Browsers, IDEs, package managers all have similar directories, and the default reflex is to leave them alone — they're cache, they're ephemeral, they regenerate. That reflex is correct for browser cache. It's wrong for agent configuration.

Agent configuration is closer to code than to cache. It encodes intent: which model to use, which skills to load, which corrections to apply, which mistakes to avoid. That's documented behavior. Once you see it that way, every standard versioning argument applies — history, diff, rollback, sharing, review. The symlink trick is just the mechanical step that lets you act on the new framing.

A note on privacy

The repo is private. What exactly counts as sensitive is your call, not a checklist someone else writes.

What I'd tell someone starting today

Don't begin with memory. Begin with settings.json. Symlink it, commit it, watch it for a week. The diff will surprise you — settings drift more than you'd think, and seeing the drift is the first win.

Expand from there as you build trust in the pattern. Memory is a natural extension once the rest of the agent's state is already under git.

Ephemeral state is a design choice, not a fact of nature.