Open source · MIT · Get the skill github.com/CODEWIRENET/claude-history

Initialise ~/.claude/ as a git repository, scrub secrets out, commit on a schedule, and review what your assistant looks like over time.

Open on GitHub →

// TL;DR

Your ~/.claude/ folder isn't just a config dump — it's the runtime contract for every session. CLAUDE.md, settings, hooks, skills, memory, MCP servers. Without git over it, every change is silent and irreversible. With git, you can roll back, diff, blame, and share. Use the claude-history skill to set it up.

Why .claude/ deserves version control

When you fix a rule in CLAUDE.md, when you tweak a hook, when you add a skill, when memory accumulates — these are changes to your AI assistant's behaviour. They're not transient. They affect every future session. And by default, none of it is tracked.

That's a problem for the same reasons untracked code is a problem:

The folder is where the agent is. Versioning it is just sane software engineering applied to the assistant.

What's in .claude/

Roughly, on a Codewire-style setup:

CLAUDE.md
Global rules — the one this wiki is about. Highest-leverage file in the folder.
settings.json
Harness configuration: hooks, permissions, theme, env vars, statusline.
settings.local.json
Machine-specific overrides — typically not committed.
skills/
Custom skills you've installed or written.
hooks/
Scripts that fire on session events (start, stop, etc.).
memory/ or memories/
Long-running cross-session knowledge.
logs/ and cache/
Transient — should be gitignored.
keys/ or tokens/
Sensitive — must never be committed.

What you must NOT commit

// Pre-flight: secret hygiene

Before git init: identify and exclude anything that's secret. API keys, OAuth tokens, session cookies, signed credentials, machine-local DB connection strings. The claude-history skill ships with a secret-scanner that runs before every commit, but the responsibility is still yours.

Sensible default .gitignore for the folder:

# Transient
logs/
cache/
sessions/
*.log
*.tmp

# Local-only overrides
settings.local.json
*.local.json

# Secrets
keys/
tokens/
*.pem
*.key
.env
.env.*

# OS
.DS_Store
Thumbs.db

Set up history with the skill

The claude-history skill automates the steps that are easy to get wrong: secret-scrubbing, sensible .gitignore, an initial commit message that doesn't leak personal info, and a periodic snapshot so you don't forget to commit.

# Install the skill (one-time)
claude skill install CODEWIRENET/claude-history

# Initialise version control on ~/.claude/
claude /claude-history init

# Commit current state with a meaningful message
claude /claude-history commit "Add security-audit rule, tweak handoff format"

# See what changed since last commit
claude /claude-history diff

# Roll back if a recent change broke something
claude /claude-history revert HEAD~1

Behind the scenes, the skill runs a secret scanner against the staged diff, blocks the commit if it finds anything that looks like a key or token, and writes commits with a structured prefix so they're easy to find later.

Local-only vs. shared remote

Two reasonable patterns:

Local-only (most common)

Run git in ~/.claude/ with no remote. You get history, diffs, and rollback locally. Nothing leaves the machine. This is the default — and for most people, it's all you need.

Private remote

Push to a private repo (GitHub, Gitea, self-hosted). You get backup, multi-machine sync, and the ability to share rules with future-you across laptops. Only do this if you're confident in the secret-hygiene step.

// Sharing your setup

Want to share your CLAUDE.md with a teammate? Don't share the entire .claude/ folder. Share only CLAUDE.md (which by design contains no secrets) and any custom skills that are clearly yours. Memory, tokens, and machine-local settings stay private.

What a healthy commit history looks like

Commits should be small and explain why:

# Good
feat(rules): Add security-audit gate before installs
fix(claude.md): Clarify "fortsæt uden at spørge" exception list
chore(skills): Bump security-audit to 0.4.0
refactor(hooks): Move shutdown alert into separate file

# Avoid (too vague)
update
tweak
stuff

The same commit-message hygiene that applies to your code applies here. Future-you reading the log a year from now needs to be able to figure out what the change was for.

What you get out of it

Once you've been versioning .claude/ for a few weeks, you start using the history actively:

Pair with the broader discipline

Versioning your .claude/ is part of the same family of rules as the rest of this wiki: make the implicit explicit, keep history, leave a forensic trail, prefer auditability over speed.

And it lowers the cost of every other rule. If CLAUDE.md is in git, you can iterate on it more boldly — bad changes can be reverted instead of lived with.


Related rules