Skip to content

fix: add CLAUDE_WORKING_DIR support to main action#994

Open
TomokiIchi wants to merge 1 commit intoanthropics:mainfrom
TomokiIchi:fix/claude-working-dir-main-action
Open

fix: add CLAUDE_WORKING_DIR support to main action#994
TomokiIchi wants to merge 1 commit intoanthropics:mainfrom
TomokiIchi:fix/claude-working-dir-main-action

Conversation

@TomokiIchi
Copy link

Summary

  • Add CLAUDE_WORKING_DIR environment variable support to the main composite action (action.yml)
  • The base-action/action.yml already has this feature (L156-160), but the main action was missing it after the refactor in feat: integrate claude-code-base-action as local subaction #285
  • This is a 4-line addition that checks for CLAUDE_WORKING_DIR and cds to it before running the entrypoint

Motivation

Monorepo users need to run Claude Code in a subdirectory (e.g., systems/journey within a larger repo). The CLAUDE_WORKING_DIR environment variable was designed for this, but currently only works with claude-code-base-action, not the main claude-code-action.

This causes Claude Code to:

  • Start in the repository root instead of the intended subdirectory
  • Miss project-specific .claude/ configurations (CLAUDE.md, settings, skills)
  • Require workarounds like prompt-based cd instructions

Changes

Added the same CLAUDE_WORKING_DIR check from base-action/action.yml to the main action.yml:

if [ -n "$CLAUDE_WORKING_DIR" ]; then
  echo "Changing directory to CLAUDE_WORKING_DIR: $CLAUDE_WORKING_DIR"
  cd "$CLAUDE_WORKING_DIR"
fi

The guard (if [ -n ... ]) ensures no behavior change when the variable is not set.

Usage

- uses: anthropics/claude-code-action@v1
  env:
    CLAUDE_WORKING_DIR: ${{ github.workspace }}/my-subdirectory

Fixes #315

The base-action already supports CLAUDE_WORKING_DIR to change the
working directory before running Claude Code, but the main action
(action.yml) was missing this feature after the refactor in anthropics#285.

This adds the same cd logic to the main action's run step, enabling
monorepo users to set CLAUDE_WORKING_DIR to run Claude Code in a
subdirectory.

Fixes anthropics#315

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@TomokiIchi
Copy link
Author

Hello! Thank you for maintaining this project.
I've added support for CLAUDE_WORKING_DIR to the main action to fix #315.
Please let me know if there is anything I need to change, fix, or if I missed any contribution guidelines. I'd be happy to make any necessary updates.

Thank you for your time and for this awesome project!

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.

Broken CLAUDE_WORKING_DIR support

1 participant