/init hangs / times out on an empty directory instead of failing fast
Summary
Running /init in a freshly-created empty directory causes the command to hang and eventually time out, with no useful diagnostic. The most natural state in which a user would invoke /init — a new project directory with nothing in it yet — is the state in which /init fails most opaquely.
Steps to reproduce
mkdir ~/PycharmProjects/protos
cd ~/PycharmProjects/protos
claude # start a new Claude Code session here
/init
The directory is genuinely empty:
$ du -sh .
0B .
$ find . -type f | wc -l
0
Expected behavior
/init should fail fast with a clear message — for example:
"This directory is empty; there is nothing to summarize. Would you like me to create a starterCLAUDE.mddescribing the project you intend to build, or would you like to add a few files first and re-run/init?"
…or simply error with nothing to analyze; add at least one file first. Either is preferable to hanging.
Actual behavior
The command runs without output, then times out without producing a CLAUDE.md, an error message, or any indication of what went wrong. The natural next user action is to assume Claude Code is broken or hung and force-quit the session.
Workaround
Adding any file before invoking /init resolves it:
touch README.md
# or
echo "# Project name" > README.md
/init then completes normally.
Why this matters
/init is positioned as the bootstrap command for a new project — its very purpose is to set up CLAUDE.md for a fresh codebase. The empty-directory case is therefore a first-encounter UX moment for many users. A silent hang here trains users to distrust slash commands.
Environment
- Claude Code:
2.1.142 - macOS: 26.3.1 (build 25D771280a)
- Shell: zsh
Suggested fix
Detect the zero-files-zero-bytes case at command entry and exit fast with either an error or, ideally, an interactive offer to create a starter CLAUDE.md from a one-line user-supplied project description.
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗