Shaike1 Claude Code Simple icon

Shaike1 Claude Code Simple

Use Claude Code SDK to execute AI-powered coding tasks (simplified version)

Overview

This node integrates with the Claude Code SDK to perform AI-powered coding tasks based on a user-provided prompt. It sends instructions to Claude Code, which can generate code snippets, scripts, or other programming-related outputs. The node supports specifying a project directory context and restricting which tools Claude Code is allowed to use during execution.

Common scenarios include:

  • Automatically generating code functions or scripts from natural language descriptions.
  • Assisting in code editing or refactoring by providing instructions.
  • Running code generation within a specific project folder context.
  • Controlling the scope of AI actions by limiting available tools (e.g., allowing only reading and writing files).

Practical example:

  • A user inputs a prompt like "Create a Python function to parse CSV files" and receives a generated Python function as output.
  • Specifying a project path allows Claude Code to operate relative to that directory, useful for multi-file projects.
  • Selecting allowed tools such as "Read" and "Write" restricts Claude Code's capabilities to file operations only, enhancing security.

Properties

Name Meaning
Prompt The instruction or request sent to Claude Code describing the coding task to perform.
Project Path Optional directory path where Claude Code should run, setting the working directory context.
Allowed Tools Tools Claude Code is permitted to use during execution. Options: Bash, Edit, Read, Web Search, Write.

Output

The node outputs an array of items, each containing a json object with the following fields:

  • result: The main textual result returned by Claude Code, typically the generated code or response.
  • success: Boolean indicating whether the operation was successful.
  • messages: Number of messages exchanged during the interaction with Claude Code.
  • prompt: The original prompt string sent to Claude Code.

If the node encounters an error and is configured to continue on failure, it outputs an item with:

  • error: Error message string.
  • success: false.
  • prompt: The prompt that caused the error.

The node does not output binary data.

Dependencies

  • Requires access to the Claude Code SDK (@anthropic-ai/claude-code package).
  • Needs an API key or authentication token for Claude Code service configured in n8n credentials (not shown explicitly in code).
  • No additional environment variables are indicated beyond standard n8n credential setup.

Troubleshooting

  • Empty Prompt Error: If the prompt is empty or whitespace, the node throws an error stating "Prompt is required and cannot be empty". Ensure the prompt input is properly set.
  • API or Network Errors: Failures communicating with Claude Code will throw errors prefixed with "Claude Code execution failed". Check API credentials and network connectivity.
  • Permission Issues: Misconfiguration of allowed tools might limit functionality; verify that the selected tools match your intended use case.
  • Project Path Issues: Providing an invalid or inaccessible project path may cause unexpected behavior; ensure the path is correct and accessible by the runtime environment.

Links and References

Discussion