anthropics / anthropics/claude-code

Feature request: separate portable configuration from machine-local state under ~/.claude (or ship a recommended .gitignore)

Open
#81,392 1 comment 0 reactions 0 assignees View on GitHub
area:core stale
Dominant language
Python
Stars
145k
Forks
23.1k
PR merge metrics
PR metrics pending

Description

## Problem

`~/.claude` mixes durable, portable configuration with ephemeral
machine-local state in a single flat directory:

- **Portable / worth versioning:** `settings.json`, `CLAUDE.md`, `rules/`,
`skills/`, `agents/`, `commands/`, auto memory.
- **Machine-local / ephemeral:** `cache/`, `sessions/`, `shell-snapshots/`,
`file-history/`, `history.jsonl`, `stats-cache.json`, `paste-cache/`,
`daemon.log`, `ide/`, `session-env/`, ...

Anyone who versions `~/.claude` as dotfiles (a common practice, and today
the only way to carry a Claude Code profile across machines) has to build a
`.gitignore` by trial and error, and it silently breaks whenever a release
adds a new state directory.

## Proposal

Either of these would solve it, in order of preference:

1. **XDG-style split**: configuration under a config root, ephemeral state
under a state/cache root (e.g. `XDG_CONFIG_HOME` / `XDG_STATE_HOME` /
`XDG_CACHE_HOME` on Linux, with sensible macOS equivalents). The config
root becomes trivially versionable as a whole.
2. **Minimal alternative**: an officially maintained, documented
`.gitignore` for `~/.claude`, updated as part of the release process
when new state directories appear.

## Secondary: secret hygiene warning

Related, learned the hard way: with `~/.claude` under git it is easy to
accidentally commit secrets (e.g. an MCP server token in a config file
before switching to the supported `${VAR}` expansion). A warning when
Claude Code detects that a git-tracked file under `~/.claude` contains a
string that looks like a credential would prevent a whole class of leaks.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by locating the code and tests that resolve ~/.claude and initialize configuration, state, and cache paths across Linux and macOS. Compare the existing path behavior with the proposed XDG-style split and the documented .gitignore alternative. Done means one chosen approach is specified, implemented, tested, documented, and includes the requested secret-hygiene behavior if it remains in scope.

Written by the indexing model from the issue text.

Assessment

Tech stack
git, linux, macos, python
Domain
cli, developer-experience, security
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.