1jehuang / 1jehuang/jcode

CLAUDE_CONFIG_DIR is ignored when locating Claude Code config (credentials, skills, MCP, sessions)

Open
#883 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

autonomous: no bug triage: needs-decision
Dominant language
Rust
Stars
19.9k
Forks
2.3k
Avg merge
2d 7h
Merged PRs (30d)
30

Description

Summary

jcode reads Claude Code's user-level config by hardcoding ~/.claude (and ~/.claude.json) almost everywhere. Claude Code lets users relocate that directory with the CLAUDE_CONFIG_DIR environment variable, and when it is set, ~/.claude is not where the data lives — everything (including .claude.json and .credentials.json) moves under $CLAUDE_CONFIG_DIR.

Exactly one place in the tree honors it (crates/jcode-setup-hints/src/cli_launch_hints.rs:150); every other Claude Code integration ignores it.

Impact

For a user with CLAUDE_CONFIG_DIR=~/.config/claude-code (my setup), jcode silently fails to find:

Feature Code Looks in
Claude OAuth credentials crates/jcode-base/src/auth/claude.rs:285 ~/.claude/.credentials.json
OAuth preflight identity crates/jcode-provider-anthropic-runtime/src/lib.rs:74 ~/.claude.json
Session/transcript import crates/jcode-base/src/import.rs:77 ~/.claude/projects
Live Claude session detection crates/jcode-base/src/claude_live.rs:79 ~/.claude/sessions
Skill import crates/jcode-base/src/skill.rs:109 ~/.claude/skills
Plugin import crates/jcode-base/src/skill.rs:330 ~/.claude/plugins
MCP server import crates/jcode-base/src/mcp/protocol.rs:623,640 ~/.claude.json, ~/.claude/mcp.json
Onboarding detection crates/jcode-tui/src/tui/app/onboarding_flow.rs:574-575 ~/.claude/...
Onboarding repair crates/jcode-tui/src/tui/app/onboarding_repair.rs:67 ~/.claude/.credentials.json
Continuation-prompt suggestions crates/jcode-tui/src/tui/app/state_ui_input_helpers.rs:1731 ~/.claude/projects
SDK login inheritance crates/jcode-sdk/src/launch.rs:30 ~/.claude/.credentials.json

Worse than "not found": a stale leftover ~/.claude (common — the dir often lingers after someone sets CLAUDE_CONFIG_DIR) makes jcode import old sessions/skills/credentials while reporting success. On my machine ~/.claude still exists and ~/.claude.json does not, so the auth path just comes up empty.

Reproduction

export CLAUDE_CONFIG_DIR="$HOME/.config/claude-code"   # with a real, logged-in Claude Code install there
# ~/.claude either absent or stale
jcode   # onboarding does not detect the Claude Code login; skills/MCP/sessions do not import

Suggested fix

Add a single resolver next to user_home_path in crates/jcode-storage/src/lib.rs — something like claude_config_path(rel) — that returns $CLAUDE_CONFIG_DIR/<rel> when set and ~/.claude/<rel> otherwise (keeping the existing JCODE_HOME sandboxing so tests stay hermetic), plus a sibling for .claude.json, and route every call site above through it. That also removes the one-off CLAUDE_CONFIG_DIR handling in cli_launch_hints.rs.

Project-local .claude/ directories (./.claude/skills, ./.claude/mcp.json) are correctly unaffected — CLAUDE_CONFIG_DIR only relocates the user-level directory.

Happy to send a PR for this.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with user_home_path in crates/jcode-storage/src/lib.rs and the existing CLAUDE_CONFIG_DIR handling in crates/jcode-setup-hints/src/cli_launch_hints.rs. Trace the listed credential, session, skill, plugin, MCP, onboarding, and SDK call sites and verify their user-level paths use the shared resolver. Done means relocated Claude Code data is found across these integrations, project-local .claude paths remain unchanged, and the relevant tests stay hermetic.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
65/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.