Skip to content

Write the Claude Code entry to the directory CLAUDE_CONFIG_DIR names - #173

Open
sohan-bhat wants to merge 2 commits into
prooflinedev:mainfrom
sohan-bhat:claude-config-dir
Open

sohan-bhat wants to merge 2 commits into
prooflinedev:mainfrom
sohan-bhat:claude-config-dir

Conversation

@sohan-bhat

Copy link
Copy Markdown

Problem

Claude Code keeps .claude.json in the home directory, or in the directory CLAUDE_CONFIG_DIR names. People set that variable to keep two Claude accounts on one computer. 327 public .zshrc files on GitHub set the variable.

With the variable set, proofline agent install claude-code writes nothing and stops.

$ CLAUDE_CONFIG_DIR=$S/work-profile proofline agent install claude-code --yes
proofline: CLAUDE_CONFIG_DIR selects custom configuration; use --print and configure Claude Code manually

The one-command setup, curl -fsSL https://proofline.sh/cli | sh -s -- --setup, skips Claude Code for the same reason, so the person has to copy the entry by hand.

Change

run in src/agent.rs passes the directory an absolute CLAUDE_CONFIG_DIR names to install in place of the home directory. Layout then targets .claude.json in that directory, and every check in src/agent/store.rs applies there unchanged, including the symlink, Git working tree, size, read-only and drift checks.

I checked each case against Claude Code 2.1.337 with claude mcp add --scope user, in a scratch HOME.

CLAUDE_CONFIG_DIR Claude Code reads This PR
unset or empty ~/.claude.json writes there. Before, an empty value was refused
absolute .claude.json in that directory writes there
relative resolved from the directory Claude Code starts in still refused, with a message that says why
absolute, not an existing directory creates the directory on its first run refused, names the path and says to start Claude Code once

--print is unchanged. CODEX_HOME is unchanged, because Codex lays the directory out differently and I have no Codex installation to verify against.

Testing

cargo fmt --check, cargo clippy --locked --all-targets -- -D warnings and cargo test --locked pass, 289 tests on macOS.

tests/agent_install.rs runs the shipped binary.

  • New claude_config_dir_selects_the_file_claude_code_reads. An absolute value receives the entry and keeps the existing settings, the home directory gets no file, an empty value writes to the home directory, and a missing directory is refused and not created.
  • unattended_confirmation_keeps_refusals_and_manual_preview now uses a relative value and checks the message.

On macOS two tests in that file fail on main as well (#112), so I ran the suite with TMPDIR on a path without a symlink.

End to end with the real Claude Code, in a scratch HOME ($S is a scratch directory).

$ CLAUDE_CONFIG_DIR=$S/work-profile proofline agent install claude-code --yes
Added Proofline to $S/work-profile/.claude.json. ...
$ ls -A $S/home
$ CLAUDE_CONFIG_DIR=$S/work-profile claude mcp get proofline
proofline:
  Scope: User config (available in all your projects)
  Type: stdio
  Command: $REPO/target/debug/proofline
  Args: --base-url https://proofline.sh mcp
$ CLAUDE_CONFIG_DIR=rel proofline agent install claude-code --yes
proofline: CLAUDE_CONFIG_DIR is a relative path, which Claude Code resolves from the directory it starts in; use --print and configure Claude Code manually

Proofline review

I ran Proofline on this change in my fork, sohan-bhat#1. The first run reported one finding.

Warning. Claude Code install fails for a new profile directory. Layout::new requires the directory to already exist. Resolve the path from its nearest existing ancestor, retain Git worktree checks, and create missing directories only on confirmed save.

The finding is right about the failure. A missing directory reached Layout::new and failed with "could not resolve the user home", which names the wrong thing.

I disagreed with the suggested fix. Creating the directory means a typo in CLAUDE_CONFIG_DIR produces a new profile that Claude Code never reads, and resolving from the nearest ancestor changes Layout for every client. Claude Code creates the directory on its first run, so I kept the refusal and made the message say that.

$ CLAUDE_CONFIG_DIR=$S/nope proofline agent install claude-code --yes
proofline: CLAUDE_CONFIG_DIR is not an existing directory: $S/nope; start Claude Code once to create it, or use --print and configure Claude Code manually

The second run, on the updated commit, reported no new findings. The first finding stays open in Proofline, because the install still stops for a missing directory, which is the behaviour I chose.

This branch has not been deployed

No deployments
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