[BUG] /init creates CLAUDE.md at git root instead of launch directory when launched from subdirectory
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 Claude Code is launched from a subdirectory of a git repository and /init is run, the generated CLAUDE.md is created at the git root instead of the launch directory. This happens silently with no explanation to the user.
Additionally, before proceeding, /init does not clarify:
- Where the
CLAUDE.mdwill be written - What scope of the codebase it will read to generate the file
This leads to unexpected behavior — the user intends to generate documentation scoped to a subdirectory, but gets a repo-wide CLAUDE.md at the git root instead, without being told.
What Should Happen?
/init should generate CLAUDE.md in the directory Claude Code was launched from. If launched from a subdirectory, the file should be created there, scoped to that subdirectory's contents only.
If writing to the git root is intentional, /init must explicitly tell the user before proceeding — where the file will be written and what code it will read — so the user can make an informed decision.
Error Messages/Logs
Steps to Reproduce
- Have a git repository with subdirectories
cdinto a subdirectory (not the git root)- Run
claudeto start a session - Run
/init - Observe that
CLAUDE.mdis created at the git root, not the launch directory, with no prior notice
Claude Model
None
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.71
Platform
Anthropic API
Operating System
Ubuntu/Debian Linux
Terminal/Shell
VS Code integrated terminal
Additional Information
_No response_
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗