Skip to content
This repository was archived by the owner on Nov 17, 2025. It is now read-only.

Commit ccaf748

Browse files
committed
Fix Claude process detection to recognize 'claude' command
- Add 'claude' to list of process names to check (not just 'node') - Improve isClaudeProcess detection to check if command ends with 'claude' - Add debug logging for process arguments to help diagnose detection issues - Handle processes run directly as 'claude' without node wrapper This fixes detection of Claude Code instances that are run directly as the 'claude' command rather than through node.
1 parent bfda85a commit ccaf748

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

Features/Monitoring/Domain/Services/ClaudeProcessDetector.swift

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ final class ClaudeProcessDetector: Loggable, @unchecked Sendable {
1515
"/.claude/local/node_modules/.bin/claude",
1616
"\\.claude\\local\\node_modules\\.bin\\claude"
1717
]
18-
static let nodeProcessNames = ["node"]
18+
static let nodeProcessNames = ["node", "claude"]
1919
static let claudeIndicators = ["anthropic", "claude"]
2020
}
2121

@@ -78,6 +78,7 @@ final class ClaudeProcessDetector: Loggable, @unchecked Sendable {
7878
// Check if this Node process is running Claude
7979
guard isClaudeProcess(arguments: processArgs) else {
8080
logger.debug("Node process PID \(pid) is not Claude")
81+
logger.debug("Process args for PID \(pid): \(String(processArgs.prefix(200)))")
8182
continue
8283
}
8384

@@ -187,6 +188,16 @@ final class ClaudeProcessDetector: Loggable, @unchecked Sendable {
187188
private func isClaudeProcess(arguments: String) -> Bool {
188189
let lowercasedArgs = arguments.lowercased()
189190

191+
// If the first argument (command) ends with "claude", it's definitely Claude
192+
let components = arguments.split(separator: "\0", maxSplits: 2, omittingEmptySubsequences: false)
193+
if let firstArg = components.first {
194+
let command = String(firstArg).trimmingCharacters(in: .whitespaces)
195+
if command.hasSuffix("claude") || command.hasSuffix("/claude") {
196+
logger.debug("Found Claude via command name: \(command)")
197+
return true
198+
}
199+
}
200+
190201
// Check for specific Claude installation path patterns
191202
for pattern in Configuration.claudePathPatterns {
192203
if arguments.contains(pattern) {

0 commit comments

Comments
 (0)