Shaike1 Claude Code
Overview
This node integrates with the Claude Code AI SDK to perform AI-powered coding tasks through conversational interactions. It allows users to send prompts or instructions to Claude Code, which can generate code snippets, analyze projects, or assist with programming-related queries. The node supports starting new conversations or continuing previous ones, enabling iterative development and refinement.
Common scenarios include:
- Generating code functions or scripts based on natural language prompts.
- Automating code review or refactoring suggestions.
- Running AI-assisted project analysis or debugging within a specified project directory.
- Using built-in tools like file editing, web search, or command execution to enhance AI capabilities.
Practical example:
- A user inputs a prompt like "Create a Python function to parse CSV files" and receives a structured response containing the generated code, usage metrics, and conversation messages.
- Another use case is allowing Claude Code to fetch web content or manage todo lists during the coding session by enabling specific built-in tools.
Properties
| Name | Meaning |
|---|---|
| Prompt | The instruction or query sent to Claude Code. Supports expressions to dynamically use data from previous nodes. Example: "Create a Python function to parse CSV files" |
| Model | Selects the Claude model variant: - Sonnet: Fast and efficient for most tasks - Opus: More capable for complex tasks |
| Max Turns | Maximum number of back-and-forth conversation turns allowed in the session. Controls how long the interaction can continue. |
| Timeout | Maximum time (in seconds) to wait for Claude Code to complete the task before aborting. Default is 300 seconds. |
| Project Path | Directory path where Claude Code should run, allowing it to access files and execute commands relative to this location. If empty, uses the current working directory. |
| Output Format | Determines the format of the output data: - Structured: Returns an object with messages, summary, result, and metrics. - Messages: Returns raw array of all exchanged messages. - Text: Returns only the final result text. |
| Allowed Tools | Built-in tools Claude Code is permitted to use during execution. Options include: Execute bash commands, Edit files, Exit planning mode, Find files by pattern, Search file contents, List directory contents, Multi-edit, Notebook editing/reading, Read/write files, Launch agents for complex searches, Manage todo lists, Fetch web content, Search the web. Default includes WebFetch, TodoWrite, WebSearch, exit_plan_mode, Task. |
| Additional Options | Collection of optional settings: - System Prompt: Extra context or instructions for Claude Code. - Require Permissions: Whether tool use requires explicit permission. - Debug Mode: Enables debug logging for detailed execution info. |
Output
The node outputs JSON data structured according to the selected Output Format:
Structured:
An object containing:messages: Array of all messages exchanged during the conversation (user, assistant, system).summary: Counts of user messages, assistant messages, tool uses, presence of result, and available tools.result: The final result text or error message if any.metrics: Performance data including duration in milliseconds, number of turns, total cost in USD, and usage details.success: Boolean indicating if the operation succeeded.
Messages:
Raw array of all messages exchanged, along with a count of messages.Text:
Only the final result text string, plus metadata such as success status, duration, and cost.
No binary data output is produced by this node.
Dependencies
- Requires the Claude Code SDK (
@anthropic-ai/claude-code) to interact with the Claude AI models. - Needs an API key credential configured in n8n to authenticate requests to the Claude Code service.
- Optionally depends on the availability of a project directory if
Project Pathis set, allowing file system access. - Uses Node.js AbortController for timeout handling.
Troubleshooting
Empty Prompt Error:
If the prompt is empty or whitespace, the node throws an error stating that the prompt is required. Ensure the prompt field is filled with meaningful input.Timeout Errors:
If the operation exceeds the specified timeout, an abort error occurs. Increase the timeout value in the node settings if longer processing is expected.Permission Denied for Tools:
IfRequire Permissionsis enabled, Claude Code may request permission before using certain tools. Denying permissions might cause incomplete results.API or Network Issues:
Failures connecting to the Claude Code service will throw execution errors. Verify API credentials and network connectivity.Debugging:
Enable Debug Mode in Additional Options to get detailed console logs about the execution flow, prompts, received messages, and tool usage, which helps diagnose issues.
Links and References
- Claude Code SDK Documentation (for understanding the underlying AI service)
- n8n Documentation (general guidance on creating and using custom nodes)
- AbortController MDN Docs (for understanding timeout handling)