anthropics / anthropics/claude-code

[BUG] sshConfigs startDirectory is accepted by the schema but ignored when a session starts

Open
#91,171 0 comments 0 reactions 0 assignees View on GitHub
area:desktop bug has repro platform:macos
Dominant language
Python
Stars
145k
Forks
23.1k
PR merge metrics
PR metrics pending

Description

### Preflight Checklist

- [x] I have searched [existing issues](https://github.com/anthropics/claude-code/issues?q=is%3Aissue%20state%3Aopen%20label%3Abug) and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code

### What's Wrong?

An SSH connection defined in `~/.claude/settings.json` with `startDirectory` connects correctly, but the session opens in the **remote user's home directory** instead of the directory I specified.

Because session history is keyed on the working directory, the session also starts with an **empty history**. A machine I had been working on from the CLI opens in the desktop app showing none of my conversations. The transcripts are intact on the host, just stored under the key for the other path, but it reads as data loss.

The field is schema-validated (an invalid type is rejected), so it is accepted and then discarded rather than ignored as unknown.

### What Should Happen?

The session opens in the directory given by `startDirectory`, as documented:

> Default working directory on the remote host. Supports tilde expansion (e.g. ~/projects). If not specified, defaults to the remote user home directory.

I did specify it, so the default should not apply.

### Error Messages/Logs

```shell

```

### Steps to Reproduce

1. Add an SSH connection to `~/.claude/settings.json`:

```json
{
"sshConfigs": [
{
"id": "team.project-a",
"name": "Project A",
"sshHost": "project-a",
"startDirectory": "/opt/src/project-a"
}
]
}
```

2. Restart Claude Desktop and open the Code tab.
3. Pick "Project A" from the environment dropdown. It connects.
4. Ask Claude what the working directory is, or run `pwd`.
5. It reports the remote user's home directory, not `/opt/src/project-a`.
6. On the remote host, `ls ~/.claude/projects/` shows a store keyed on the home directory rather than on the configured one, which is why the history looks empty.

### Claude Model

_No response_

### Is this a regression?

I don't know

### Last Working Version

_No response_

### Claude Code Version

2.1.56 (Claude Code); Claude Desktop 1.40609.0

### Platform

Anthropic API

### Operating System

macOS

### Terminal/Shell

Terminal.app (macOS)

### Additional Information

**Why this matters beyond one setting**

For anyone managing a fleet of remote development machines, every connection needs a manual folder step before it is usable, per machine and per developer. The published `startDirectory` is the only mechanism for that, so there is currently no way to hand someone a ready-to-use connection.

**Possibly useful**

Connections supplied by at least one built-in integration do open at a working directory, so the session model appears to carry one already; it looks like the settings path simply does not pass the value through.

The documented workaround, `claude ssh [dir]`, does not currently run either. Filed separately.

**Searched first:** #83561 also involves `sshConfigs` but is a different problem (the SSH environment never appearing in third-party API mode). I found no existing report of `startDirectory` being ignored.

Desktop app version: 1.40609.0. Also reproduced on 1.37937.3.

Contributor guide

No contributing guide indexed for this repository

Research direction

The report identifies ~/.claude/settings.json and the sshConfigs.startDirectory setting, but no implementation file or test. Start by tracing how this value reaches SSH session startup; verify completion by reproducing the connection and confirming that the session opens in the configured remote directory and uses the corresponding history.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.