Skip to content

Agent profiles: support multiple Claude Code configs with env var stripping #627

Description

@alexeygrigorev

Source (maintainer, 2026-06-09)

I have two Claude installations. One is the usual with subscription. Another uses a different config. There is a .claude folder that sets up the second config. You can set up a config directory and then point to this directory and it starts a different session. I want to use that. For Claude, especially for the second one, we also need to be resetting some variables in the same way we do for OpenCode. For all Claude sessions we unset these variables and then we can have the default one and then we can have profiles. These profiles can be configured in the host configuration. As a follow-up, do similar for Codex.

Background

Claude Code supports CLAUDE_CONFIG_DIR to point to a different config directory. The maintainer has two profiles:

  1. Default (~/.claude/) — normal Anthropic subscription
  2. Z.AI (~/.zlaude/) — uses ANTHROPIC_AUTH_TOKEN, ANTHROPIC_BASE_URL="https://api.z.ai/api/anthropic", and model overrides (glm-5.1, glm-5-turbo)

The setup lives in ~/git/.claude/configure.sh which creates the ~/.zlaude profile.

We already strip 71 API key env vars for OpenCode sessions (SessionTypePickerSheet.OPENCODE_ENV_UNSET_VARS). The same pattern should apply to Claude Code sessions — unset all provider API keys so the profile's own credentials are used, not leaked env vars from the host.

Scope

1. Env var stripping for Claude Code sessions

  • When launching a Claude Code session, unset the same provider API key env vars we unset for OpenCode (all 71 vars from OPENCODE_ENV_UNSET_VARS)
  • This ensures Claude Code uses its own credentials from CLAUDE_CONFIG_DIR, not leaked host env vars
  • The env strip should be the default for ALL Claude Code sessions, not just the second profile

2. Agent profiles in host configuration

  • Add a "Claude Code profiles" section to the host configuration (per-host, not global)
  • Each profile has:
    • Name (e.g., "Default", "Z.AI")
    • Config directory path on the remote host (e.g., ~/.claude, ~/.zlaude)
    • When launching a Claude session with this profile, set CLAUDE_CONFIG_DIR=<path> before the claude command
  • Default profile: no CLAUDE_CONFIG_DIR override (uses Claude Code's default ~/.claude)
  • Session type picker shows available profiles for Claude when creating a new session

3. Session creation flow

  • In the session type picker, when "Claude Code" is selected, show a profile selector (dropdown or chip row) if multiple profiles are configured
  • The selected profile determines the CLAUDE_CONFIG_DIR env var set before launch
  • The env var strip (all provider keys) is always applied regardless of profile

Acceptance criteria

  • Claude Code sessions strip all provider API key env vars (same 71 as OpenCode)
  • Host configuration supports multiple Claude Code profiles (name + config dir path)
  • Session type picker shows profile selector when >1 profile exists
  • Launching a Claude session with a profile sets CLAUDE_CONFIG_DIR before the claude command
  • Default profile (no config dir override) always available
  • Existing sessions continue to work without profile configuration (backward compatible)

Non-goals

  • Codex profile support (separate follow-up issue)
  • Profile sync between Android device and remote host (profiles reference remote paths)
  • Creating/managing profiles on the remote host from the app (assume they exist)
  • OpenCode profile support (OpenCode already works differently with its SQLite config)

Files

  • app/src/main/java/com/pocketshell/app/projects/SessionTypePickerSheet.kt — add profile selector, env strip for Claude
  • shared/core-storage/src/main/java/com/pocketshell/core/storage/entity/HostEntity.kt — add profile fields
  • app/src/main/java/com/pocketshell/app/hosts/AddEditHostViewModel.kt — profile editing in host form
  • app/src/main/java/com/pocketshell/app/projects/FolderListGateway.kt — launch command composition with profile

Refs

  • ~/git/.claude/configure.sh — existing profile setup script (zlaude)
  • ~/.zlaude/settings.json — Z.AI profile config (ANTHROPIC_AUTH_TOKEN, ANTHROPIC_BASE_URL)
  • Claude Code env vars docsCLAUDE_CONFIG_DIR documentation
  • SessionTypePickerSheet.OPENCODE_ENV_UNSET_VARS — existing 71-var env strip pattern

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions