feat(config): support CLAUDE_CONFIG_DIR environment variable#451
Open
iwvelando wants to merge 9 commits intortk-ai:developfrom
Open
feat(config): support CLAUDE_CONFIG_DIR environment variable#451iwvelando wants to merge 9 commits intortk-ai:developfrom
iwvelando wants to merge 9 commits intortk-ai:developfrom
Conversation
add security check cicd on dev branch PR Signed-off-by: aesoft <43991222+aeppling@users.noreply.github.com>
fix(cicd): Add security check on dev branch PR
- Add install_method detection (homebrew/cargo/script/nix/other) - Add tokens_saved_24h and tokens_saved_total to payload - Add Tracker::total_tokens_saved() and Tracker::tokens_saved_24h() methods - Point telemetry to new dedicated rtk-telemetry service Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
- Add install_method detection (homebrew/cargo/script/nix/other) - Add tokens_saved_24h and tokens_saved_total to payload - Add Tracker::total_tokens_saved() and Tracker::tokens_saved_24h() methods - Point telemetry to new dedicated rtk-telemetry service Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
Add backslash variants for .cargo\bin and .local\bin detection Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
fix: detect install method on Windows paths
RTK now respects the CLAUDE_CONFIG_DIR environment variable, enabling users who run multiple Claude Code instances with custom config directories (e.g., CLAUDE_CONFIG_DIR=~/.claude-a claude) to install and use RTK seamlessly. - Update resolve_claude_dir() to check CLAUDE_CONFIG_DIR env var first with ~ expansion, falling back to ~/.claude if unset - Make resolve_claude_dir() pub(crate) and reuse from integrity.rs and hook_check.rs instead of duplicating hardcoded ~/.claude paths - Update user-facing messages to display actual resolved path - Add 4 unit tests covering default, absolute, tilde, and bare tilde - Update README.md and CLAUDE.md documentation Signed-off-by: Isaac Velando <isaac@greplinux.com>
dc20fc4 to
cc93afc
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
feat(config): support CLAUDE_CONFIG_DIR environment variable
Summary
RTK now respects the
CLAUDE_CONFIG_DIRenvironment variable, enabling users who run multiple Claude Code instances with custom config directories (e.g.,CLAUDE_CONFIG_DIR=~/.claude-a claude) to install and use RTK seamlessly.Problem
All three places that resolved the Claude config directory (
init.rs,integrity.rs,hook_check.rs) had the path~/.claudehardcoded. Users launching Claude withCLAUDE_CONFIG_DIR=~/.claude-a claudecould not usertk init --globalbecause hooks,RTK.md,settings.json, andCLAUDE.mdwere always written to~/.clauderegardless of their actual config directory.Solution
resolve_claude_dir()ininit.rsto check theCLAUDE_CONFIG_DIRenvironment variable first, with~expansion support, falling back to~/.claudeif unset.resolve_claude_dir()pub(crate)so it can be reused fromintegrity.rsandhook_check.rsinstead of duplicating logic.integrity.rs::resolve_hook_path()to delegate to the shared resolver instead of hardcoding~/.claude.hook_check.rs::hook_installed_path()to delegate to the shared resolver instead of hardcoding~/.claude.show_config()andprint_manual_instructions()to display the actual resolved path instead of hardcoded~/.claude.resolve_claude_dir_impl()as an inner function acceptingOption<String>for testability, avoiding env var races in parallel test execution.Testing
4 new unit tests covering:
None→~/.claude)/tmp/my-custom-claude-dir)~/.claude-custom→$HOME/.claude-custom)~→$HOME)Manual Testing: CLAUDE_CONFIG_DIR Support
Environment
~/.claude-afeat/config-support-claude-config-dir-env-var./target/release/rtk(release build)Pre-existing state
Running
rtk init --globalwith CLAUDE_CONFIG_DIRPost-install verification
Result
PASS — Hook, RTK.md, CLAUDE.md reference, and settings.json patch all installed correctly under
~/.claude-a/instead of~/.claude/.Usage