Every rule, skill and setting you have built for Claude Code sits in one folder on one computer. If that laptop dies, all of it goes with it.
That folder is called .claude, in your home folder. On Windows it is C:\Users\YOUR-NAME\.claude. Anthropic's docs say it holds the files you write, such as CLAUDE.md, settings.json, skills and rules. They also say it holds what Claude Code writes while you work: your login credentials in
.credentials.json and full conversation transcripts under projects/. The docs state that transcripts and prompt history are plaintext, with only file permissions protecting them. So you never copy the whole folder. You copy only the parts you built. On a Mac, your login is kept in the macOS Keychain, not in the .claude folder, so it is not in the folder you copy either way.
01 / 07
What goes in and what stays out
In (the parts you built):
CLAUDE.mdandsettings.json- the
skills,rules,agentsandcommandsfolders - the
hooksfolder, if you have one
Out (never copy these):
.credentials.json, your loginprojects/, your chat transcripts andClaude's auto-memory notes
history.jsonl,stats-cache.json,backups/,shell-snapshots/and caches- any
.envfile and any file with a key, token or password in it ~/.claude.json, which sits outside the folder
Claude's own memory notes live inside
projects/, so they stay out. To keep some, type /memory, read them, and copy the ones you want into the repo by hand.
02 / 07
The backup prompt
You need Git, a free GitHub account, and the GitHub command-line tool gh signed in. You sign in yourself with gh auth login. This prompt never asks for your password. Open Claude Code and paste it.
Download the ZIP for the prompt and the new-computer steps in one folder.
03 / 07
After it runs
Open the repo page on GitHub and check the badge says Private.
Scroll through the files. If you see a key or a password, see the section on a committed key below.
From now on, after you change a rule or a skill, type "save my setup". That is your new version.
04 / 07
On a new laptop
Install
Claude Code, run it once so it creates its
.claudefolder, and sign in again. Your login is never in the backup.Sign in to GitHub yourself with
gh auth login.Download the repo into a scratch folder, not into
.claude:gh repo clone claude-config-backup.Ask
Claude Code: "Compare the folder claude-config-backup with my .claude folder. Show me which files are new and which would overwrite an existing file. Copy over only what I approve. Never touch .credentials.json, projects/ or history.jsonl."
Restart
Claude Code, type
/memoryto confirm your CLAUDE.md is listed, and type a skill name to confirm it shows up.Put your keys back by hand from your password manager. Passwords and API keys never go in the repo. Reconnect any tools that need a login and check them with
/mcp.
Paths in settings.json and hooks often mention your old username. Fix any that do.
05 / 07
If a key was committed by mistake
Deleting the file in a new commit is not enough. The key stays in the history.
Treat the key as leaked: make a new one at the service that issued it and turn off the old one.
Ask
Claude to help remove it from the repo history, or delete the repo and make a fresh one from clean files.
06 / 07
Test it safely
Run the prompt and stop at step 4. Read the file list. It should hold only files you recognise, and no
.credentials.json,projects/or.env.Say yes. Check on GitHub that the repo is Private.
Change one rule, type "save my setup", and confirm
Claude shows you the difference before it pushes.
Where was this tested? The author ran steps 1 to 4 on a made-up home folder with a fake token planted in settings.json and decoy login, history and cache files. The secret scan stopped the run and showed only the first 4 characters, only the built parts were copied, and Claude waited for a yes before the commit. Not tested: creating the real GitHub repo, pushing, the README, the "save my setup" skill, and the new-laptop steps on a second computer. You still read the file list before you say yes.
Common mistakes
Copying the whole folder. That includes your login and chat history in plain text.
Making the repo public. Check the Private badge on the repo page.
Committing a key. Read the scan results, and rotate any key that got in.
Never saving a new version. A backup from last month will not have your newest skill.
Why a private repo and not a public one?
Your rules and skills may describe your business or contain details you would not publish. Private means only you can see it.
Where do my keys go?
They never go in the repo. Carry them to a new computer by hand from your password manager.
Does this back up Claude's memory notes?
No. They live inside the projects folder with your chat transcripts, which stays out. Copy the ones you want by hand.
Do I need to code?
No. You paste one prompt and read the list of files before you say yes.
Finish line
What to do next
Run the prompt and read the file list before you say yes.
Check the repo says Private on GitHub.
Next time you change a skill, type "save my setup".
Back to all the free guides. Two that pair well with this one: undo a Claude Code mistake and Claude Code hooks that block pushes, deletes and secrets.
You reached the end of the guide