Skip to content

fix: add pre_start_script support to claude-code module for dependency ordering #609

@jasonwbarnett

Description

@jasonwbarnett

Problem

When using multiple startup modules in a Coder workspace template (e.g., git-clone and claude-code), there's a race condition where both modules' startup scripts execute in parallel. This causes issues when one module depends on another.

Specific Case: git-clone → claude-code

The claude-code module initializes with a workdir that should be populated by the git-clone module. However:

  1. All workspace agent startup scripts execute in parallel via Go's errgroup.Group
  2. The git-clone module's post_clone_script (which creates the workdir) runs sequentially AFTER the clone completes
  3. The claude-code module's startup scripts run concurrently and may fail if they try to access the workdir before git-clone completes

Root Cause

The Coder agent executes all startup scripts with concurrently. There's no built-in mechanism to enforce sequential execution between different coder_script resources or modules.

Solution

Add a variable to the claude-code module that allows users to run custom shell commands before the Claude Code startup script executes. This enables dependency management:

  1. claude-code's pre_start_script can wait for markers/conditions from other modules
  2. Once preconditions are met, the main start script proceeds
  3. This provides a clean way to handle module dependencies without architectural changes

Use Case

This pattern is already used in other parts of the Coder registry (pre_install_script, post_install_script) and would provide consistency.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions