Available in
Marketplaces, most starred first
Tags
Add to README
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
Marketplaces, most starred first
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
Marketplaces, most starred first
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
By gruckionv1.0.0MITIn 1 marketplace
Fixes the working directory tracking bug in Claude Code by notifying Claude when the CWD changes after cd commands
You run one by typing its /name in Claude Code.
1 caution to review before installing
A hook runs when Claude uses the Bash tool
Static checks of hooks, mods, MCP servers and commands. Not a security audit.
1 marketplace, most starred first
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
A Claude Code plugin that fixes the working directory tracking bug. When Claude runs cd commands, it loses track of where it is—this hook tells it.
When Claude Code runs a Bash command containing cd (e.g., mkdir -p foo && cd foo && npm pack), the shell's working directory changes, but Claude is never informed. The system prompt's <env>Working directory: X</env> is static—set at session start and never updated.
This causes Claude to:
cd into directories it's already inThis bug has been reported 24+ times in GitHub issues #1669, #4100, #11067, #14122, and others.
You: "Download the package and extract it"
Claude runs: mkdir -p myproject && cd myproject && npm pack @some/package
✓ Works fine - Claude is now IN myproject/
Claude runs: cd myproject && tar -xzf package.tgz
✗ ERROR: "no such file or directory: myproject"
(Claude tried to cd into a directory it's already in)
Claude runs: ls /original/path/package.tgz
✗ ERROR: file not found
(File is actually at /original/path/myproject/package.tgz)
This plugin uses Claude Code's hook system to detect when the working directory changes and notify Claude via the tool output. Claude then knows exactly where it is and constructs correct paths.
┌─────────────────────────────────────────────────────────────────┐
│ Claude runs: mkdir -p foo && cd foo && touch file.txt │
└─────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ PostToolUse hook fires after Bash command completes │
│ Hook receives JSON with current cwd from Claude Code │
└─────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ Hook compares current cwd against stored previous cwd │
│ Previous: /home/user/project │
│ Current: /home/user/project/foo │
└─────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ CWD changed! Hook outputs to stderr + exits with code 2 │
│ "Note: Working directory changed from '...' to '...'" │
└─────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ Claude receives notification in tool result │
│ Claude now knows it's in /home/user/project/foo │
│ Subsequent commands use correct paths │
└─────────────────────────────────────────────────────────────────┘
Key insight: Claude Code's hook system feeds stderr + exit code 2 back to the LLM. Exit code 0 with stdout is only shown in the transcript (invisible to Claude).
The easiest way to install is via Claude Code's plugin system:
# Add the marketplace
/plugin marketplace add gruckion/claude-code-cwd-tracker
# Install the plugin
/plugin install cwd-tracker
That's it! The plugin is now active. On session start, you'll see:
✓ CWD Tracker loaded: Working directory changes will be tracked
If you prefer manual installation:
mkdir -p ~/.claude/hooks
curl -o ~/.claude/hooks/cwd-notify.sh \
https://raw.githubusercontent.com/gruckion/claude-code-cwd-tracker/main/scripts/cwd-notify.sh
Or clone the repository:
git clone https://github.com/gruckion/claude-code-cwd-tracker.git
cp claude-code-cwd-tracker/scripts/cwd-notify.sh ~/.claude/hooks/
chmod +x ~/.claude/hooks/cwd-notify.sh
Add the hook to your ~/.claude/settings.json:
Built from public signals: copy clicks on this site, GitHub stars and activity, the README and the manifest. Not a security audit or an endorsement.
npx claudepluginhub gruckion/claude-code-cwd-tracker --plugin cwd-trackerPlugins from other owners that cover similar ground