You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add a /cd slash command that allows changing the working directory at runtime without restarting OpenCode. This is a common workflow need when navigating between projects or worktrees mid-conversation.
Proposed behavior
/cd <path> — switch to the given directory (supports relative paths, absolute paths, ~ expansion)
/cd without arguments — return to the initial startup directory
Appears in slash command autocomplete list
When switching outside the current project root, show a confirmation dialog
Record the directory change in the session as a shell command (cd <path> display + pwd output)
Why this is useful
Users frequently need to navigate between related projects, monorepo packages, or git worktrees during a single session. Currently the only option is to quit and restart OpenCode in the new directory. A lightweight /cd command avoids losing conversation context.
Implementation approach
TUI-side only: resolve path, validate directory exists, update SDK's target directory, record in session
Minimal changes (~150 lines added across 7 files), no server-side changes needed
Feature hasn't been suggested before.
Describe the enhancement you want to request
Related: #2177, #15220
Add a
/cdslash command that allows changing the working directory at runtime without restarting OpenCode. This is a common workflow need when navigating between projects or worktrees mid-conversation.Proposed behavior
/cd <path>— switch to the given directory (supports relative paths, absolute paths,~expansion)/cdwithout arguments — return to the initial startup directorycd <path>display +pwdoutput)Why this is useful
Users frequently need to navigate between related projects, monorepo packages, or git worktrees during a single session. Currently the only option is to quit and restart OpenCode in the new directory. A lightweight
/cdcommand avoids losing conversation context.Implementation approach
Environment