Feature Request: Implement Proper XDG Base Directory Specification Compliance
Resolved 💬 1 comment Opened Jun 24, 2025 by matthieuHanne Closed Jun 24, 2025
Summary
Claude Code currently stores all its files (configuration, data, and cache) in a single directory, which doesn't follow the XDG Base Directory specification. This feature request proposes reorganizing file storage to properly comply with XDG standards.
Current State
All Claude Code files are currently stored in either:
~/.claude/(for user settings and CLAUDE.md)~/.config/claude/(for internal state, which is actually being used as a data directory)
Current ~/.config/claude/ contents:
~/.config/claude/
├── settings.json # ✓ Config (correct location)
├── claude_code_mcp_settings.json # ✓ Config (correct location)
├── projects/ # ✗ Data (should be in XDG_DATA_HOME)
├── todos/ # ✗ Data (should be in XDG_DATA_HOME)
└── statsig/ # ✗ Cache (should be in XDG_CACHE_HOME)
Proposed Structure
Following XDG Base Directory specification:
Configuration ($XDG_CONFIG_HOME/claude/ or ~/.config/claude/)
settings.json- User settingssettings.local.json- Local user settingsclaude_code_mcp_settings.json- MCP configurationCLAUDE.md- Global user preferences (alternative to ~/.claude/CLAUDE.md)
Data ($XDG_DATA_HOME/claude/ or ~/.local/share/claude/)
projects/- Conversation historytodos/- Todo lists and session state- Any other persistent user data
Cache ($XDG_CACHE_HOME/claude/ or ~/.cache/claude/)
statsig/- Analytics and feature flag cache- Any other non-essential cached data
Benefits
- Standards Compliance: Follows established Unix/Linux conventions
- Better Organization: Clear separation between config, data, and cache
- Easier Backup: Users can backup config and data while excluding cache
- System Integration: Works better with backup tools, dotfile managers, and system cleaners
- User Expectations: Power users expect tools to follow XDG spec
- Flexibility: Respects user's XDG environment variables if set
Implementation Proposal
I'm willing to help implement these changes. The implementation could:
- Check for XDG environment variables and use them if set
- Fall back to default XDG locations if not set
- Include a migration path for existing installations
- Maintain backward compatibility during a transition period
Migration Strategy
- On first run after update, check if old locations exist
- If found, offer to migrate files to new XDG-compliant locations
- Optionally maintain symlinks for a few versions for compatibility
Additional Considerations
- Could also move
~/.claude/CLAUDE.mdto$XDG_CONFIG_HOME/claude/CLAUDE.mdfor consistency - The
~/.claude/directory could be deprecated in favor of full XDG compliance
Would the team be interested in this improvement? I'd be happy to contribute to the implementation.
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗