Skip to content

feat: respect CLAUDE_CONFIG_DIR and CODEX_HOME env vars#83

Open
shellRaining wants to merge 1 commit into
MioMioOS:mainfrom
shellRaining:feat/respect-custom-config-dir
Open

feat: respect CLAUDE_CONFIG_DIR and CODEX_HOME env vars#83
shellRaining wants to merge 1 commit into
MioMioOS:mainfrom
shellRaining:feat/respect-custom-config-dir

Conversation

@shellRaining

Copy link
Copy Markdown

Summary

  • Introduce ConfigPaths as a single source of truth for discovering Claude Code and Codex configuration directories
  • Respect CLAUDE_CONFIG_DIR environment variable (falls back to ~/.claude)
  • Respect CODEX_HOME environment variable (falls back to ~/.codex)
  • Replace all hardcoded ~/.claude/... and ~/.codex/... paths across 14 files with centralized ConfigPaths lookups

Problem

Users who customise their configuration location via environment variables (e.g. CLAUDE_CONFIG_DIR=~/.config/claude or CODEX_HOME=~/.config/codex) find that MioIsland writes hooks, settings, and session files to the default ~/.claude / ~/.codex directories instead of the configured locations, making the app unusable for these setups.

These are officially supported environment variables:

  • Claude Code: CLAUDE_CONFIG_DIR — "Override the configuration directory (default: ~/.claude)"
  • Codex: CODEX_HOME — custom config directory

Changes

New file

  • ClaudeIsland/Core/ConfigPaths.swift — centralises path discovery with convenience accessors for hooks, settings, projects, sessions, log file, etc.

Modified files (14)

  • HookInstaller.swift — use ConfigPaths.claudeSettings, ConfigPaths.hookScript, etc.
  • CodexHookInstaller.swift — use ConfigPaths.codexDir, ConfigPaths.hookScript, etc.
  • HookHealthCheck.swift — use ConfigPaths.claudeDir / ConfigPaths.codexDir as defaults
  • DebugLogger.swift / LogStreamer.swift — use ConfigPaths.claudeLogFile
  • BuddyReader.swift — use ConfigPaths.claudeBuddyFile, ConfigPaths.claudeSaltCache, ConfigPaths.claudeBonesCache
  • AgentFileWatcher.swift / JSONLInterruptWatcher.swift / ConversationParser.swift — use ConfigPaths.claudeProjectsDir
  • SessionState.swift — use ConfigPaths.claudeProjectsDir
  • TerminalWriter.swift — use ConfigPaths.claudeSessionsDir
  • CapabilityScanner.swift — use ConfigPaths.claudeDir, ConfigPaths.claudeBuddyFile
  • CodexUsage.swift — use ConfigPaths.codexDir
  • HookDiagnosticsView.swift — use ConfigPaths.claudeHooksDir, ConfigPaths.claudeSettings

Hook command change

The hook command written to settings.json now uses the absolute path (via ConfigPaths.hookScript.path) instead of the shell-tilde shortcut ~/.claude/hooks/codeisland-state.py. This correctly resolves to the custom directory when CLAUDE_CONFIG_DIR is set.

Test plan

  • Verify hooks install/uninstall correctly with default ~/.claude config
  • Set CLAUDE_CONFIG_DIR=~/.config/claude and verify hooks are installed to the custom location
  • Set CODEX_HOME=~/.config/codex and verify Codex hooks are installed to the custom location
  • Verify the app detects existing sessions from both default and custom config directories
  • Verify log file is written to the correct location
  • Verify buddy/salt/bones caches are read from the correct location

Previously all configuration paths were hardcoded to ~/.claude and
~/.codex. Users who set CLAUDE_CONFIG_DIR (e.g. to ~/.config/claude)
or CODEX_HOME (e.g. to ~/.config/codex) would find hooks, settings,
and session files written to the wrong location.

Introduce ConfigPaths as a single source of truth that checks the
environment variables first and falls back to the default paths.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant