Implement XDG_CONFIG_HOME for ~/.claude.json

Status Fixed / completed
Maintainer reply ✓ Yes — bcherny
Activity 6 comments · opened Mar 2, 2025 · closed Mar 2, 2025
💡 Likely answer: A maintainer (bcherny, collaborator) responded on this thread — see the highlighted reply below.

Currently it seems there's no way to change where the .claude.json lives. It would be great if it could be loaded from $XDG_CONFIG_HOME/claude/claude.json according to the XDG Base Directory Specification

View original on GitHub ↗

6 Comments

bcherny collaborator · 1 year ago

You can do this with the CLAUDE_CONFIG_DIR env var. Beware this API isn't finalized and may change.

Ramblurr · 1 year ago

@bcherny Its great that you provide CLAUDE_CONFIG_DIR to change the location, but by not using XDG_CONFIG_HOME by default you are not following the desktop standard. This causes problems on Linux workstations.

SamDc73 · 1 year ago

@bcherny even after having CLAUDE_CONFIG_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/claude" variable set up in my system, Claude still creates .claude/statsig/ folder in my $HOME

dezza · 1 year ago

@bcherny you can't be serious that you close an issue with a valid concern; It doesn't follow XDG Base Directory Specification as said above. This makes everyone that changes XDG_CONFIG_HOME pretty unhappy with what you're serving them, you don't even recognize it as an issue?

https://github.com/anthropics/claude-code/blob/555b6b5b8a5f06f1e8725a584e62fb6b7c8eece5/README.md?plain=1#L44

Welcome or not welcome?

AH-Merii · 1 year ago

@bcherny Thanks for pointing out the CLAUDE_CONFIG_DIR workaround, but I respectfully believe this issue warrants reopening. Relying on a custom environment variable alone doesn’t mesh with the wider Linux ecosystem’s expectations, and as others have noted, it doesn’t always work in practice.

According to the XDG Base Directory Specification, applications should default to loading config from

${XDG_CONFIG_HOME:-$HOME/.config}/claude/claude.json

when no override is provided.

This "just works" for users who have already set XDG_CONFIG_HOME, it follows established desktop standards, avoiding surprise files as mentioned by @SamDc73. This would eliminate friction for Linux users who expect applications to respect the XDG spec by default....

I urge you to consider reopening this ticket and updating the loader to fall back to $XDG_CONFIG_HOME/claude/claude.json before falling back to ~/.claude.json?

github-actions[bot] · 1 year ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.