Skip to content

[FEATURE] Slim Claude Code OAuth-token forwarding (replace setup-claude.sh + sed-YAML editing) #546

Closed

Description

@gerchowl

Description

Replace the current Claude Code injection path (setup-claude.sh + inject_claude_auth in devc-remote.sh) with a slim, robust forwarding mechanism. Depends on #545 (Claude Code baked into image + IS_SANDBOX=1).

Problem Statement

PR #166 ships two pieces for in-container Claude Code:

  1. assets/workspace/.devcontainer/scripts/setup-claude.sh (~200 lines) — installs Node.js via apt with clock-skew workarounds, npm install -g @anthropic-ai/claude-code, creates a non-root claude user, ACLs the workspace, wraps claude so root invocations runuser into that user.
  2. scripts/devc-remote.sh:386-440 inject_claude_auth — reads CLAUDE_CODE_OAUTH_TOKEN from env or macOS Keychain, then sed-edits docker-compose.local.yaml with several heuristic branches (grep -q 'services: {}', grep -q 'environment:', etc.) to inject the env var.

Both have problems:

Proposed Solution

A ~50-line replacement that:

  1. Drops setup-claude.sh entirely. Image bake handles install; IS_SANDBOX=1 env handles uid check; no separate user needed.
  2. Drops sed-on-YAML in inject_claude_auth. Uses one of:
    • compose exec -e CLAUDE_CODE_OAUTH_TOKEN=$value ... — per-exec env injection, no compose file edits at all
    • bind-mount of ~/.claude/.credentials.json (file or via per-user dir) — auth state synced from host, container reads it directly
  3. Sources the token from a defined chain:
    • --account <slot> flag → ~/.claude-creds-mac/<slot>/cred (claude-switch slot)
    • ~/.claude-creds-mac/.active → that slot
    • macOS Keychain Claude Code-credentials/$USER → live (auto-refreshed) value
    • Linux ~/.claude/.credentials.json
  4. Warns when the credential's expiresAt is in the past so users know to refresh before deployment fails inside the container with HTTP 401.

Out of Scope

Changelog Category

Changed (replaces existing flow)

Activity

  1. added
    feature
    priority:medium
    area:workspace
    semver:minor
    on May 15, 2026
  2. c-vigo commented on Jun 23, 2026

    @c-vigo
    Contributor

    Cross-link: overlaps the editor/auth scripts touched by #629 in the Nix/Claude migration (#625). Mostly independent (remote-devcontainer OAuth forwarding), but coordinate the setup-claude.sh / non-root-user removal with #629.

  3. c-vigo commented on Jul 4, 2026

    @c-vigo
    Contributor

    The slim token path landed as part of B2 (#823, PR #844, draft PR #846): the devcontainer scaffold bind-mounts the canonical per-user secrets dir (~/.config/vigos/secrets, read-only) and a post-create hook exports each file as an env var in the container shell — no YAML editing, no setup-claude.sh. Claude picks up CLAUDE_CODE_OAUTH_TOKEN from the environment. Suggest closing this issue pointing at #823 once #846 merges.

  4. c-vigo commented on Jul 4, 2026

    @c-vigo
    Contributor

    Superseded/implemented by #823 (merged to dev in #846): the devcontainer scaffold bind-mounts the canonical per-user secrets dir read-only and a post-create hook exports the files as env vars — no setup-claude.sh, no YAML editing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:workspacefeaturepriority:mediumsemver:minor

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions