-
Notifications
You must be signed in to change notification settings - Fork 28
Fix XDG_CONFIG_HOME support for Claude config directory #244
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
On Linux, Claude Code uses $XDG_CONFIG_HOME/claude (defaulting to ~/.config/claude) instead of ~/.claude. This change audits and fixes all hardcoded ~/.claude paths to respect XDG_CONFIG_HOME on Linux. Changes: - Add ClaudeConfigDir to RuntimeConfig that respects XDG_CONFIG_HOME - Add GetClaudeProjectsDir() helper method - Update all services to use config.Runtime.ClaudeConfigDir - Remove unused/deprecated claude_detector.go - Add tests for XDG_CONFIG_HOME path resolution Fixes #242 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
PR Review: Fix XDG_CONFIG_HOME support for Claude config directorySummaryThis PR successfully addresses issue #242 by properly implementing XDG Base Directory specification support for Claude's configuration directory on Linux. The changes are well-structured, thoroughly tested, and maintain backward compatibility. ✅ Strengths1. Clean Architecture
2. Excellent Test Coverage
3. Comprehensive Migration
4. Code Quality
🔍 Issues & Concerns1. Critical: Potential Race Condition in Runtime Initialization In func NewHistoryReader(homeDir string) *HistoryReader {
claudeConfigDir := config.Runtime.ClaudeConfigDir // Assumes Runtime is already initialized
return &HistoryReader{
claudeConfigPath: filepath.Join(homeDir, ".claude.json"),
historyJSONLPath: filepath.Join(claudeConfigDir, "history.jsonl"),
}
}Issue: If Recommendation: Either:
This pattern appears in multiple files:
2. Inconsistency: Mixed Path Construction Approaches In transformedPath := strings.ReplaceAll(session.WorkDir, "/", "-")
transformedPath = strings.TrimPrefix(transformedPath, "-")
transformedPath = "-" + transformedPath
claudeProjectsDir := filepath.Join(config.Runtime.GetClaudeProjectsDir(), transformedPath)Issue: This duplicates the path encoding logic instead of using the existing Recommendation: Refactor to use the centralized encoding function to avoid logic drift. 3. Test Gap: XDG Environment Variable Persistence The unit tests set Recommendation: Add a test that verifies the behavior when 4. Documentation: Missing Migration Guide Users running Catnip on Linux who already have configurations in
Recommendation: Add a migration note in the PR description or a comment in the code explaining the transition path. 🔒 Security Review✅ No security concerns identified
⚡ Performance Considerations✅ No performance issues
📋 RecommendationsMust Address:
Should Address: Nice to Have: ✅ Final AssessmentThis is a well-executed PR that properly implements XDG Base Directory specification support. The code quality is high, test coverage is good, and the cleanup of deprecated code is appreciated. The main concerns are around initialization order (potential for subtle bugs) and some minor code duplication. With those addressed, this will be a solid improvement to the codebase. Recommendation: Request changes to address the runtime initialization pattern, then approve. Great work on the thorough implementation and cleanup! 🎉 |
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
Summary
catnip reflectfails on Linux when Claude uses$XDG_CONFIG_HOME/claudeinstead of~/.claudeClaudeConfigDirtoRuntimeConfigthat respectsXDG_CONFIG_HOMEon Linux (defaults to~/.config/claude)~/.claudepaths throughout the codebase to use the new configclaude_detector.gofileTest plan
getClaudeConfigDir()functionXDG_CONFIG_HOMEset🤖 Generated with Claude Code