Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions docs/examples/claude-code-usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,15 @@ task-master set-status --id=task-001 --status=in-progress

## Requirements

1. Claude Code CLI must be installed and authenticated on your system
2. Install the optional `@anthropic-ai/claude-code` package if you enable this provider:
1. Claude Code CLI must be installed and authenticated on your system. Install from the [official docs](https://docs.anthropic.com/en/docs/claude-code/overview) or run:
```bash
npm install @anthropic-ai/claude-code
curl -fsSL https://claude.ai/install.sh | bash
```
3. Run Claude Code for the first time and authenticate with your Anthropic account:
2. Run Claude Code for the first time and authenticate with your Anthropic account:
```bash
claude
```
4. No API key is required in your environment variables or MCP configuration
3. No API key is required in your environment variables or MCP configuration

## Advanced Settings

Expand Down
2 changes: 1 addition & 1 deletion packages/tm-core/src/modules/loop/services/loop.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ Loop iteration ${iteration} of ${config.iterations}${tagInfo}`;
if (error.code === 'ENOENT') {
return sandbox
? 'Docker is not installed. Install Docker Desktop to use --sandbox mode.'
: 'Claude CLI is not installed. Install with: npm install -g @anthropic-ai/claude-code';
: 'Claude Code CLI is not installed. Install it from: https://docs.anthropic.com/en/docs/claude-code/getting-started';
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.

if (error.code === 'EACCES') {
Expand Down
45 changes: 38 additions & 7 deletions src/ai-providers/claude-code.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
*
*/

import { execSync } from 'child_process';
import { execSync, execFileSync } from 'child_process';
import { existsSync } from 'fs';
import { join, dirname } from 'path';
import { homedir } from 'os';
import { createClaudeCode } from 'ai-sdk-provider-claude-code';
import {
getClaudeCodeSettingsForCommand,
Expand Down Expand Up @@ -82,11 +85,39 @@ export class ClaudeCodeProvider extends BaseAIProvider {
execSync('claude --version', { stdio: 'pipe', timeout: 1000 });
_claudeCliAvailable = true;
} catch (error) {
_claudeCliAvailable = false;
log(
'warn',
'Claude Code CLI not detected. Install it with: npm install -g @anthropic-ai/claude-code'
);
// PATH-based lookup failed - check common install locations
// The native binary may be installed outside the current PATH
// (e.g. when running as an MCP server with a minimal environment)
const home = homedir();
const commonPaths = [
join(home, '.local', 'bin', 'claude'),
join(home, '.bun', 'bin', 'claude'),
'/usr/local/bin/claude'
];
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Missing Homebrew Apple Silicon path in fallback detection

Medium Severity

The commonPaths array for fallback CLI detection is missing /opt/homebrew/bin/claude, which is the standard Homebrew install location on Apple Silicon Macs. This is a very common platform among developers. The codebase itself already accounts for this path elsewhere (e.g., mcpClient.ts checks /opt/homebrew/bin/npx for "Homebrew on Apple Silicon"). In minimal PATH environments like MCP servers — the exact scenario this fallback targets — the CLI won't be detected for these users.

Fix in Cursor Fix in Web

const found = commonPaths.find((p) => existsSync(p));
if (found) {
try {
execFileSync(found, ['--version'], {
stdio: 'pipe',
timeout: 1000
});
// Add the binary's directory to PATH so the SDK can find it
const binDir = dirname(found);
process.env.PATH = `${binDir}${process.platform === 'win32' ? ';' : ':'}${process.env.PATH || ''}`;
_claudeCliAvailable = true;
} catch {
_claudeCliAvailable = false;
}
} else {
_claudeCliAvailable = false;
}

if (!_claudeCliAvailable) {
log(
'warn',
'Claude Code CLI not detected. Install it from: https://docs.anthropic.com/en/docs/claude-code/getting-started'
);
}
Comment thread
cursor[bot] marked this conversation as resolved.
} finally {
_claudeCliChecked = true;
}
Expand Down Expand Up @@ -147,7 +178,7 @@ export class ClaudeCodeProvider extends BaseAIProvider {
const code = error?.code;
if (code === 'ENOENT' || /claude/i.test(msg)) {
const enhancedError = new Error(
`Claude Code CLI not available. Please install Claude Code CLI first. Original error: ${error.message}`
`Claude Code CLI not available. Install it from: https://docs.anthropic.com/en/docs/claude-code/getting-started - Original error: ${error.message}`
);
enhancedError.cause = error;
this.handleError('Claude Code CLI initialization', enhancedError);
Expand Down