published fresh until

Can I move Claude Code's config out of ~/.claude and ~/.claude.json?

Summary When you need Claude Code to use a non-default config directory, set CLAUDE_CONFIG_DIR in the launching shell or user/managed settings with an absolute path; project/local settings cannot select it, and Console sign-ins without API keys are outside the override.

Not for running a work and a personal Claude Code account side by side; see several-claude-code-accounts-side-by-side

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

As of November 2026, CLAUDE_CONFIG_DIR is the documented directory override, with authentication exceptions. Do first: set it in the launching shell to an absolute directory path; project and local settings cannot select it. Environment reference.

The problem

Claude Code writes its settings, history and credentials to a .claude folder and a separate .claude.json file in your home directory, rather than the XDG folders many Linux and dotfile-managed setups expect. The GitHub issue was opened by jennifgcrl on 2025-05-31. As of 17 November 2026, it remains open.

What the maintainer said

In June 2025 maintainer chrislloyd wrote that partial XDG support was shipped in version 1.0.28 and withdrawn in 1.0.31, because users who got the new layout were asked to sign in again and the implementation did not fully follow the spec. He did not give a date for a return. Commenters in the thread reported that settings seemed to vanish while the paths moved.

The workaround commenters rely on

  • Set the CLAUDE_CONFIG_DIR environment variable to the folder you want. Commenters say it takes precedence over the default. The official changelog mentions this variable in many entries, including VS Code settings and path rules, so it is a supported variable. The environment-variable reference documents the override and says it can be set in the shell, user settings or managed settings, but is ignored in project and local settings. In settings JSON, use an absolute path.
  • A commenter reported on version 2.1.139 (May 2026) that it also relocates the JSON file: the app looks for that file inside the folder, not in your home directory. Their example sets the variable to a claude folder under your XDG config directory.
  • Set it in your shell startup file or launcher. The changelog says the project-level settings file's env block no longer sets this variable (use the shell, user or managed settings).

What it does not do

  • It is not full XDG compliance: everything goes into one folder, not split into config, data and cache. A commenter who analyzed their install also noted most of that folder is not configuration.
  • Back up existing files before changing paths. A new directory has its own settings, session history and claude.ai login or API key. However, two Claude Console sign-ins without API keys are not isolated by this variable, because that login is stored outside the configuration directory. Authentication docs.
  • Older reports (late 2025 to January 2026) say the variable alone did not stop the home folder or the file from being created, that a stored editor mode still landed in the JSON file, and that replacing the JSON file with a symlink failed because the CLI recreated it as a regular file. The May 2026 report suggests that changed, but behavior can differ by version.
  • The installer still places the program in the user's local bin folder, a different location from config.

Commenters also shared a sandbox-wrapper script that remaps the legacy paths; it is outside the scope of this configuration override.

This thread is about relocating one config folder. Running several accounts side by side, with a folder per account, is a different use covered in another thread.

Sources

Started from a post by @jennifgcrl, packaged by the editor. Original post

Subjects

More in agent workflows

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Can I move Claude Code's config out of ~/.claude and ~/.claude.json?
Summary: When you need Claude Code to use a non-default config directory, set `CLAUDE_CONFIG_DIR` in the launching shell or user/managed settings with an absolute path; project/local settings cannot select it, and Console sign-ins without API keys are outside the override.
Copy for agent
get the whatworks thread claude-code-xdg-config-dir-claude-config-dir and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread claude-code-xdg-config-dir-claude-config-dir
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks