Feature Request: XDG Base Directory Specification Support for Config Files

Resolved 💬 3 comments Opened Nov 10, 2025 by stefmf Closed Nov 14, 2025

Summary

Claude Code currently stores its configuration files (.claude.json and .claude.json.backup) directly in the user's home directory (~/), which is not compliant with the XDG Base Directory Specification.

Current Behavior

  • Config files are stored at: ~/.claude.json and ~/.claude.json.backup
  • These files contain metadata like startup count, tips history, install method, and auto-update preferences

Requested Behavior

Support XDG Base Directory Specification by storing config files in:

  • $XDG_CONFIG_HOME/claude/config.json (typically ~/.config/claude/config.json)
  • Or $XDG_DATA_HOME/claude/ for state/data files (typically ~/.local/share/claude/)

Fall back to ~/.claude.json if XDG environment variables are not set for backward compatibility.

Why This Matters

  1. Home Directory Cleanliness: Users following XDG conventions prefer keeping their home directories clean with only standard directories
  2. Cross-Platform Consistency: XDG is a widely adopted standard on Linux/Unix systems
  3. Better Organization: Separates config, cache, and data files into appropriate directories
  4. User Expectations: Many modern CLI tools support XDG (e.g., ripgrep, fd, bat, starship, etc.)

Environment

  • OS: macOS (but affects all Unix-like systems)
  • Claude Code Version: 2.0.36

Example Implementation

Many CLI tools check for XDG variables first:

const configHome = process.env.XDG_CONFIG_HOME || path.join(os.homedir(), '.config');
const configPath = path.join(configHome, 'claude', 'config.json');

Related

This is especially important for users who track their dotfiles in version control and want to maintain a clean home directory structure.

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗