Fix: preserve user working directory when spawning Claude instances#12
Closed
jrevillard wants to merge 1 commit intoruvnet:mainfrom
jrevillard:fix/claude-working-directory
Closed
Fix: preserve user working directory when spawning Claude instances#12jrevillard wants to merge 1 commit intoruvnet:mainfrom jrevillard:fix/claude-working-directory
jrevillard wants to merge 1 commit intoruvnet:mainfrom
jrevillard:fix/claude-working-directory
Conversation
When running `claude-flow claude spawn` from a specific directory, Claude was incorrectly started with the claude-flow installation directory instead of the user's current working directory. This fix implements a comprehensive solution: - Capture original working directory in bin/claude-flow wrapper - Pass original directory via CLAUDE_FLOW_ORIGINAL_CWD environment variable - Set correct cwd when spawning Claude subprocess in simple-cli.js - Provide explicit working directory instructions to Claude - Display working directory in task configuration Now Claude will start in the user's project directory and perform all file operations relative to that directory, not the claude-flow installation. Resolves issue where Claude showed installation directory instead of project directory in its working context.
Owner
|
take a look at my update. i think i resolved this |
Closed
32 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When running
claude-flow claude spawnfrom a specific directory, Claude was incorrectly started with the claude-flow installation directory (/usr/local/share/npm-global/lib/node_modules/claude-flow) as its working directory instead of the user's current working directory.Root Cause
The issue occurred because:
bin/claude-flowsetscwd: path.join(__dirname, '..')when spawning the Deno processsrc/cli/simple-cli.jsdid not specify a working directory when spawning Claude, inheriting the claude-flow installation directorySolution
Implemented a comprehensive fix that preserves the user's original working directory:
Changes Made
bin/claude-flow - Added
CLAUDE_FLOW_ORIGINAL_CWDenvironment variable to capture user's original working directorysrc/cli/simple-cli.js - Multiple improvements:
cwdparameter to use original working directory when spawning Claude processCLAUDE_FLOW_CWDenvironment variable passed to ClaudeHow It Works
bin/claude-flowcapturesprocess.cwd()inCLAUDE_FLOW_ORIGINAL_CWDCLAUDE_FLOW_CWDenvironment variableTesting
Result
After this fix, when users run
claude-flow claude spawnfrom their project directory, Claude will:Fixes issue where Claude was working in claude-flow installation directory instead of user's project directory.