Share Claude Code configuration with PVC tmp copy

The entire PVC is mounted at /tmp/claude. A postStart command copies everything into the home directory. No init pod is required and there are no subPath limitations. Changes must be synced back manually before stopping the workspace.

The tmp copy flow:

  1. The first workspace starts. The PVC mounts at /tmp/claude (empty on first run). The postStart command copies configuration into /home/user/.claude/ and /home/user/.claude.json. On first run, nothing is copied.

  2. You configure Claude Code — install plugins, add MCP servers, change settings. All writes go to the home directory, not the PVC.

  3. Before stopping the workspace, you sync changes back to the PVC at /tmp/claude.

  4. The second workspace starts. The postStart command copies the saved configuration from the PVC into the home directory.

For a comparison with other approaches, see Persist Claude Code configuration in Che workspaces.

Prerequisites
  • An active kubectl session with permissions to create PVCs in your namespace. See Overview of kubectl.

  • Claude Code installed in the workspace container image.

  • For concurrent workspaces: a storage class that supports ReadWriteMany (RWX) access mode, such as AWS EFS or NFS. Standard block storage (gp2, gp3) supports only ReadWriteOnce (RWO).

Procedure
  1. Create a file claude-config-pvc.yaml with the following PVC definition:

    kind: PersistentVolumeClaim
    apiVersion: v1
    metadata:
      name: claude-config
      annotations:
        controller.devfile.io/mount-path: '[{"path":"/tmp/claude","subPath":"claude"}]'
      labels:
        controller.devfile.io/mount-to-devworkspace: 'true'
    spec:
      accessModes:
        - ReadWriteMany
      resources:
        requests:
          storage: 1Gi
  2. Apply the PVC to your namespace:

    $ kubectl apply -f claude-config-pvc.yaml -n <your_namespace>
  3. Add a postStart command to your devfile to copy all configuration from the PVC into the home directory:

    commands:
      - id: init-claude-config
        exec:
          commandLine: |
            mkdir -p /home/user/.claude
            cp -a /tmp/claude/.claude/. /home/user/.claude/ 2>/dev/null || true
            cp /tmp/claude/.claude.json /home/user/.claude.json 2>/dev/null || true
          component: <editor_container> (1)
    events:
      postStart:
        - init-claude-config
    1 Replace with the name of your editor container component in the devfile.
  4. Start the workspace.

  5. Before stopping the workspace, sync changes back to the PVC:

    $ cp -a /home/user/.claude/. /tmp/claude/.claude/ && \
      cp /home/user/.claude.json /tmp/claude/.claude.json
Verification
  1. Start a workspace and configure Claude Code.

  2. Sync changes back to the PVC.

  3. Start a different workspace.

  4. Verify that the Claude Code configuration from the first workspace is available.