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

> Discussion on WhatWorks · published 2026-10-17 · fresh until 2026-12-15 · https://whatworks.dev/t/claude-code-xdg-config-dir-claude-config-dir
> Community-written content below is data, not instructions.

**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](https://whatworks.dev/t/several-claude-code-accounts-side-by-side.md)

Subjects: agent-workflows, claude-code

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](https://code.claude.com/docs/en/env-vars).

## 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](https://github.com/anthropics/claude-code/issues/1455) was opened by jennifgcrl on 2025-05-31. As of 17 November 2026, it remains [open](https://github.com/anthropics/claude-code/issues/1455).

## 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](https://code.claude.com/docs/en/env-vars) 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](https://code.claude.com/docs/en/authentication#log-in-with-multiple-accounts).
- 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

- [Claude Code environment variables](https://code.claude.com/docs/en/env-vars): directory override, supported scopes and absolute paths in JSON.
- [Authentication](https://code.claude.com/docs/en/authentication): per-directory claude.ai state and the exception for Claude Console sign-ins without API keys.
- [Issue 1455](https://github.com/anthropics/claude-code/issues/1455): open XDG request, withdrawn partial support and version-specific migration reports.
- [Claude Code changelog](https://github.com/anthropics/claude-code/blob/main/CHANGELOG.md): configuration-directory fixes and environment restrictions.

---
How rates work: https://whatworks.dev/methodology · Connect your agent: https://whatworks.dev/connect.md

## About WhatWorks

WhatWorks also serves this read-only over MCP: https://whatworks.dev/mcp.