[BUG] Claude infers GitHub repo owner from OS username instead of checking git remote
Preflight Checklist
- [x] I have searched existing issues 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?
When running gh CLI commands (e.g., gh issue list), Claude infers the GitHub repository owner from the local OS username in the working directory path (e.g., /Users/<local-username>/...) instead of checking git remote -v or gh repo view. This produces incorrect commands when the GitHub username differs from the OS username.
For example, with a repo cloned from https://github.com/<github-user>/my-repo.git but a local path of /Users/<local-username>/projects/my-repo, Claude ran:
gh issue list --repo <local-username>/my-repo
instead of:
gh issue list --repo <github-user>/my-repo
This returned no results because the repo <local-username>/my-repo doesn't exist. If someone with that OS username were to fork the repo, it would silently return the wrong data.
This happens without any compaction event — it occurred in the first interaction of a fresh session. The gitStatus context provided in the system prompt at conversation start includes the branch and recent commits but does not include the remote URL, so the model is left to guess the owner.
Workaround
I had to add the following to my CLAUDE.md memory files to prevent this:
## GitHub
- **Repo is `<github-user>/my-repo`** — do NOT infer owner from local username (`<local-username>`). Always use `git remote -v` or `gh repo view` to get the correct owner/org.
What Should Happen?
Claude should either:
- Check
git remote -vorgh repo viewbefore constructingghcommands that require an owner/repo, or - The
gitStatussystem context should include the remote URL so the model doesn't need to guess
Error Messages/Logs
# Claude ran:
gh issue list --repo <local-username>/my-repo
# Returned 0 results (repo doesn't exist under that user)
# Correct command:
gh issue list --repo <github-user>/my-repo
Steps to Reproduce
- Have a GitHub username that differs from your local OS username
- Clone a repo:
git clone https://github.com/<github-user>/my-repo.git - Start a Claude Code session in the repo directory
- Ask Claude to list issues or interact with the repo via
gh - Observe that Claude uses the OS username as the repo owner
Claude Model
Opus (claude-opus-4-6)
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
Latest (February 2026)
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
VS Code integrated terminal
Additional Information
Related but distinct from #10960 and #15169, which are about losing repo context after compaction. This bug occurs in fresh sessions with no compaction.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗