Skip to content

Fix Claude Code CLI detection for npm-local installs#1978

Open
one-kash wants to merge 4 commits intogithub:mainfrom
one-kash:fix/claude-npm-local-detection
Open

Fix Claude Code CLI detection for npm-local installs#1978
one-kash wants to merge 4 commits intogithub:mainfrom
one-kash:fix/claude-npm-local-detection

Conversation

@one-kash
Copy link

Summary

  • Fixes specify check reporting "Claude Code CLI (not found)" for users with npm-local installs (the default Claude Code install method, common with nvm)
  • Adds CLAUDE_NPM_LOCAL_PATH (~/.claude/local/node_modules/.bin/claude) as a second well-known detection path alongside the existing migrate-installer path
  • Adds 8 unit tests covering all Claude CLI install methods (migrate-installer, npm-local, PATH) and non-Claude tools

Root Cause

check_tool("claude") only checks:

  1. ~/.claude/local/claude (migrate-installer path)
  2. shutil.which("claude") (system PATH)

For npm-local installs, the binary is at ~/.claude/local/node_modules/.bin/claude — neither of the above paths match, so detection fails even though Claude is installed and working.

Test plan

  • New test: detected via migrate-installer path (~/.claude/local/claude)
  • New test: detected via npm-local path (~/.claude/local/node_modules/.bin/claude)
  • New test: detected via system PATH
  • New test: correctly reports not found when genuinely missing
  • New test: StepTracker updated correctly for npm-local detection
  • New test: non-Claude tools unaffected (git, kiro-cli fallback)
  • Full test suite passes (847/847)

Fixes #550

`specify check` reports "Claude Code CLI (not found)" for users who
installed Claude Code via npm-local (the default installer path, common
with nvm). The binary lives at ~/.claude/local/node_modules/.bin/claude
which was not checked. Add CLAUDE_NPM_LOCAL_PATH as a second well-known
location alongside the existing migrate-installer path.

Fixes github#550
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes specify check incorrectly reporting Claude Code as missing when installed via npm-local by adding an additional well-known local binary path and covering the behavior with targeted tests.

Changes:

  • Add CLAUDE_NPM_LOCAL_PATH (~/.claude/local/node_modules/.bin/claude) and treat it as a valid Claude local install location in check_tool("claude").
  • Update Claude-specific detection logic comments to reflect multiple local install methods.
  • Add unit tests covering Claude detection via migrate-installer path, npm-local path, PATH, and tracker updates; plus regression checks for other tools.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/specify_cli/__init__.py Adds npm-local Claude binary path constant and checks it in check_tool before falling back to PATH.
tests/test_check_tool.py New tests validating Claude detection across install methods and ensuring non-Claude tools are unaffected.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Collaborator

@mnriem mnriem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please address Copilot feedback. If not applicable, please explain why

@one-kash
Copy link
Author

You brought the big guns, I like it!

I might have to call my buddy Claude too ;)

- Remove unused pytest import from test_check_tool.py
- Use tmp_path instead of hardcoded /nonexistent/claude for hermetic tests
- Simplify redundant exists() + is_file() to just is_file()

AI-assisted: Changes applied with Claude Code.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

one-kash and others added 2 commits March 27, 2026 08:30
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Claude Code CLI (not found)

3 participants