Change Claude Code Configuration Directory on Linux

Change Claude Code Configuration Directory on Linux

By default, Claude Code stores its configuration data in the ~/.claude directory. All settings, credentials, session history, and plugins are kept under this location. In some cases, keeping these files in a custom path may be preferable, such as when organizing development tools in a dedicated workspace. This tutorial demonstrates how to change Claude Code configuration directory on Linux.

To specify a custom configuration directory, add the CLAUDE_CONFIG_DIR environment variable to the shell profile. For example, the following command sets the configuration directory to $HOME/.dev/claude:

echo 'export CLAUDE_CONFIG_DIR=$HOME/.dev/claude' >> ~/.profile

After modifying the profile, the updated environment variable must be loaded before Claude Code recognizes the new directory. For changes to take effect, either log out and log back in, or apply them immediately to the current session with the following command:

source ~/.profile

To verify that the variable is set correctly, display its value:

echo $CLAUDE_CONFIG_DIR

If the custom directory is no longer needed, remove the configuration entry from the profile file using the following command:

sed -i '/CLAUDE_CONFIG_DIR/d' ~/.profile

Leave a Comment

Cancel reply

Your email address will not be published.