Skip to content

feat: support custom Claude CLI path and config directory#224

Open
JingkaiTang wants to merge 1 commit intoop7418:mainfrom
JingkaiTang:feat/custom-cli-path
Open

feat: support custom Claude CLI path and config directory#224
JingkaiTang wants to merge 1 commit intoop7418:mainfrom
JingkaiTang:feat/custom-cli-path

Conversation

@JingkaiTang
Copy link

Summary

  • Add centralized cli-config.ts module to support custom Claude CLI binary path and config directory (e.g. claude-internal / ~/.claude-internal)
  • Add two new settings in Settings → General: Claude CLI Path and Claude Config Directory
  • Replace all hardcoded ~/.claude references with configurable helpers
  • Add backend path validation on save with frontend error/success feedback
  • Support ~ tilde expansion in all path settings
  • Full i18n support (en/zh) for all new UI strings

Motivation

For teams using internal forks of Claude Code (e.g. claude-internal with ~/.claude-internal config dir), there was no way to configure CodePilot to use a different CLI binary or config directory. All paths were hardcoded to claude and ~/.claude.

Changes

New files

  • src/lib/cli-config.ts — Centralized config module with expandTilde(), getClaudeConfigDir(), getClaudeBinaryName(), getCustomCliPath(), and convenience helpers for commands/skills/projects/settings/plugins/bin directories
  • src/__tests__/unit/cli-config.test.ts — 33 unit tests covering all functions

Settings UI

Setting Description Default
Claude CLI Path Custom CLI executable path Auto-detect claude
Claude Config Directory Custom config directory ~/.claude

Modified files (14 total)

  • src/lib/claude-client.tsfindClaudePath() prioritizes custom CLI path + clearClaudePathCache() export
  • src/lib/claude-session-parser.ts — projects dir via cliConfig.getClaudeProjectsDir()
  • src/app/api/chat/route.ts — MCP config paths via cli-config helpers
  • src/app/api/settings/app/route.ts — new allowed keys + path validation + cache invalidation
  • src/app/api/settings/route.ts — settings path via getClaudeSettingsPath()
  • src/app/api/plugins/route.ts, [id]/route.ts, mcp/route.ts, mcp/[name]/route.ts — config dir via cli-config
  • src/app/api/skills/route.ts, [name]/route.ts — commands/plugins/skills dirs via cli-config
  • src/components/settings/GeneralSection.tsx — new CLI path/config dir inputs with debounced save
  • src/i18n/en.ts, src/i18n/zh.ts — 7 new translation keys each

Review feedback addressed (from #138)

  • ✅ Dedicated feature branch (feat/custom-cli-path) instead of mainmain
  • ✅ No formatting/quote-style changes — only functional modifications
  • ✅ Top-level import statements (no require())
  • ✅ Unified expandTilde() in single location (cli-config.ts)

Test plan

  • 199 tests pass (including 33 new cli-config tests)
  • TypeScript compiles with zero errors
  • Verify settings UI renders correctly (CLI path + config dir inputs)
  • Test with custom CLI path pointing to claude-internal
  • Test with custom config dir pointing to ~/.claude-internal
  • Test empty values fall back to defaults

🤖 Generated with Claude Code

@vercel
Copy link

vercel bot commented Mar 12, 2026

@JingkaiTang is attempting to deploy a commit to the op7418's projects Team on Vercel.

A member of the Team first needs to authorize it.

@JingkaiTang JingkaiTang force-pushed the feat/custom-cli-path branch 3 times, most recently from a3764c8 to 7310a6d Compare March 16, 2026 12:25
Add centralized CLI configuration module (cli-config.ts) that replaces
15+ hardcoded ~/.claude references across the codebase.

New features:
- Custom CLI binary path (claude_cli_path app setting)
- Custom config directory (claude_config_dir app setting)
- expandTilde() for ~ path expansion
- Path validation on save (file exists / directory exists)
- Cache invalidation when settings change

Backend changes:
- cli-config.ts: getClaudeConfigDir(), getCustomCliPath(), etc.
- claude-client.ts: findClaudePath() prioritizes custom CLI path
- settings/app/route.ts: validates and saves new path settings
- All route files (plugins, skills, settings, chat) now use
  cli-config helpers instead of hardcoded os.homedir()/.claude paths

Frontend changes:
- GeneralSection.tsx: CLI path and config dir input fields with
  debounced auto-save and validation feedback
- i18n: 7 new translation keys (en + zh)

Tests:
- 33 new unit tests for cli-config module (all passing)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@JingkaiTang JingkaiTang force-pushed the feat/custom-cli-path branch from 7310a6d to 5aebcf1 Compare March 17, 2026 08:31
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