n8n-code-tool
Write JavaScript or Python for the n8n Custom Code Tool (@n8n/n8n-nodes-langchain.toolCode) — the AI-agent-callable tool, NOT the workflow Code node.
Skill by czlonkowski
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/czlonkowski-n8n-code-tool
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: data, ml, writing, productivity, code-generation, debugging
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/n8n-code-tool
What's inside
- Skill name
n8n-code-tool- Description
- Write JavaScript or Python for the n8n Custom Code Tool (@n8n/n8n-nodes-langchain.toolCode) — the AI-agent-callable tool, NOT the workflow Code node. Use when building a Code Tool attached to an AI Agent, writing code that an LLM will invoke, parsing the `query` input, returning a string result, defining an input schema for structured arguments (specifyInputSchema, jsonSchemaExample, DynamicStructuredTool), or troubleshooting errors like "Wrong output type returned", "No execution data available", "The response property should be a string, but it is an object", "Cannot assign to read only property 'name'", or an AI agent that refuses to call the tool. Covers the critical differences between Code node and Code Tool: return format (string vs `[{json:{...}}]`), unavailability of `$fromAI`/`$input`/`$helpers` in the Code Tool sandbox, naming rules for AI invocation, and when to use `toolWorkflow`/HTTP Request Tool instead.
- License
- MIT
- Instructions
- 335 lines in SKILL.md · view on GitHub
Files (4)
- ERROR_PATTERNS.md
- INPUT_SCHEMA.md
- README.md
- SKILL.md
SKILL.md (first lines)
# n8n Custom Code Tool
Expert guidance for writing code inside `@n8n/n8n-nodes-langchain.toolCode` — the tool an AI Agent can invoke, **not** the regular workflow Code node.
---
## ⚠️ This is NOT the Code node
The Custom Code Tool looks like a Code node in the editor — same JavaScript editor, similar layout — but it is a **completely different node** from a different package with a **different runtime contract**.
| | Code node | Custom Code Tool |
|---|---|---|
| **Node type** | `n8n-nodes-base.code` | `@n8n/n8n-nodes-langchain.toolCode` |
| **Package** | `n8n-nodes-base` | `@n8n/n8n-nodes-langchain` |
| **Invoked by** | Previous node (workflow flow) | AI Agent (LangChain) |
| **Input** | `$input.all()` — item stream | `query` — string or object from LLM |
| **Return** | `[{json: {...}}]` (items array) | **A string** |
| **`$fromAI()`** | N/A | **Not available** (see Errors) |
| **HTTP helper** | `this.helpers.httpRequest` (auth helpers blocked) | Not exposed to the tool sandbox |
| **State** | Per-run execution data | No `getContext`, no `$getWorkflowStaticData` |
**If you treat it like a Code node, it fails.** The rest of this skill covers the Code Tool's actual contract.
---
## Quick Start
### Minimal JavaScript Code Tool
```javascript
// `query` is whatever the AI sent (a string by default)
return `You asked: ${query}`;
```
### Minimal Python Code Tool
```python
# `_query` is whatever the AI sent (a string by default)
return f"You asked: {_query}"
```
### Essential Rules
1. **Return a string.** Numbers are auto-converted. Anything else throws `"The response property should be a string, but it is an object"`.
2. **Input variable is fixed**: `query` (JS), `_query` (Python). You cannot rename it.
3. **Do NOT use `$fromAI()`** inside the Code Tool sandbox — it throws `"No execution data available"`.
4. **Do NOT use `[{json: {...}}]`** return format — that's for Code nodes. Throws `"Wrong output type returned"`.
5. **Use a descriptive tool name** (letters/numbers/underscores, v1.1+). The agent calls the tool by its name.
6. **Write a precise description** — the LLM decides whether to invoke the tool based on it.
---
## The Two Input Modes
The Code Tool has two input shapes, controlled by `specifyInputSchema`:
### Mode 1: Unstructured (default, `specifyInputSchema: false`)
The AI passes **a single string** as `query`. If you need multiple fields, the AI has to stuff them into that one string and you parse them out. In practice, LLMs will happily pass a JSON string if your description tells them to.
```javascript
// Parse a JSON string the AI sent
let params;
try {
params = typeof query === 'string' ? JSON.parse(query) : query;
} catch (e) {
throw new Error('Expected a JSON object. Parser said: ' + e.message);
}
const price = Number(params.price);
const months = Number(params.months);
// ...
return JSON.stringify({ monthly_payment: /* ... */ });
```
**Pros**: simplest to set up, one field to describe.
**Cons**: no schema validation — if the LLM forgets a field, the tool throws at runtime.
**Best for**: quick prototypes, tools with one natural input (a question, a URL, a text blob).
### Mode 2: Structured (`specifyInputSchema: true`)
The tool becomes a LangChain `DynamicStructuredTool`. The LLM sees a typed argument schema and passes a **validated object** as `query`. You access fields directly.
```javascript
// query is now an object matching your schema
const price = query.price;
const months = query.months;
const residual_percent = query.residual_percent;
const monthly = computeAnnuity(price, months, residual_percent);
return JSON.stringify({ monthly_payment: monthly });
```
Schema is defined via either:
- `schemaType: "fromJson"` + `jsonSchemaExample` (n8n v≥1.3) — paste an example JSON, n8n infers the schema
- `schemaType: "manual"` + `inputSchema` — write a full JSON Schema yourself
**Pros**: LLM gets type hints, invalid calls rejected before your code runs, cleaner code.
**Cons**: a little more setup; requires n8n version with schema support.
**Best for**: production tools with multiple typed parameters (calculators, API wrappers, anything with numeric fields the LLM tends to stringify).
**See**: [INPUT_SCHEMA.md](INPUT_SCHEMA.md) for complete schema setup.
---
## Return Format
**The return value must be a string.** The LLM reads it as the tool's observation.
```javascript
// ✅ String
return "42";
// ✅ Number (auto-converted to string by n8n)
return 42;
// ✅ JSON-encoded structured result (recommended for rich output)
return JSON.stringify({ result: 42, currency: "SEK" });From czlonkowski/n8n-skills, MIT.
More from czlonkowski/n8n-skills
- 0.848score
n8n-subworkflows
czlonkowski
Build reusable, composable n8n sub-workflows.
SkillAFreshness: A★ 6.5KClaude Code +9 - 0.848score
n8n-self-hosting
czlonkowski
Deploy a production self-hosted n8n end-to-end to a fresh Linux VM over SSH, using Docker Compose behind a Caddy reverse proxy with automatic HTTPS.
SkillAFreshness: A★ 6.5KClaude Code +9 - 0.848score
n8n-code-javascript
czlonkowski
Write, review, or debug JavaScript in an n8n Code node.
SkillAFreshness: A★ 6.5KClaude Code +9 - 0.848score
n8n-error-handling
czlonkowski
Wire n8n error handling so failures are loud, structured, and recoverable.
SkillAFreshness: A★ 6.5KClaude Code +9 - 0.848score
n8n-multi-instance
czlonkowski
Use when an n8n-mcp account targets more than one n8n instance — i.e.
SkillAFreshness: A★ 6.5KClaude Code +9 - 0.848score
n8n-mcp-tools-expert
czlonkowski
Expert guide for using n8n-mcp MCP tools effectively.
SkillAFreshness: A★ 6.5KClaude Code +9 - 0.848score
n8n-code-python
czlonkowski
Write Python in n8n Code nodes (native Python, `language` pythonNative, n8n 2.x).
SkillAFreshness: A★ 6.5KClaude Code +9 - 0.848score
n8n-binary-and-data
czlonkowski
Handle files and binary data in n8n correctly.
SkillAFreshness: A★ 6.5KClaude Code +9 - 0.848score
n8n-agents
czlonkowski
Design n8n AI agents the right way.
SkillAFreshness: A★ 6.5KClaude Code +9 - 0.848score
using-n8n-mcp-skills
czlonkowski
Use when building, editing, validating, testing, or debugging an n8n workflow through the n8n-mcp MCP server — designing a flow, configuring a node, writing…
SkillAFreshness: A★ 6.5KClaude Code +9 - 0.838score
n8n-node-configuration
czlonkowski
Operation-aware node configuration guidance.
SkillAFreshness: A★ 6.5KClaude Code +9 - 0.838score
n8n-workflow-patterns
czlonkowski
Proven workflow architectural patterns from real n8n workflows.
SkillAFreshness: A★ 6.5KClaude Code +9
Compare and alternatives
Featured in
Signals
- Stars
- 6,517
- Forks
- 1,075
- Open issues
- 10
- Last commit (this folder)
- Jul 6, 2026 (3 months ago)
- Last release
- Oct 24, 2026 (4 days ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/czlonkowski/n8n-skills
- Website
- www.n8n-skills.com
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from czlonkowski
- 0.848score
n8n-mcp-tools-expert
czlonkowski
Expert guide for using n8n-mcp MCP tools effectively.
SkillAFreshness: A★ 6.5KClaude Code +9 - 0.848score
n8n-multi-instance
czlonkowski
Use when an n8n-mcp account targets more than one n8n instance — i.e.
SkillAFreshness: A★ 6.5KClaude Code +9 - 0.848score
using-n8n-mcp-skills
czlonkowski
Use when building, editing, validating, testing, or debugging an n8n workflow through the n8n-mcp MCP server — designing a flow, configuring a node, writing…
SkillAFreshness: A★ 6.5KClaude Code +9 - 0.848score
n8n-subworkflows
czlonkowski
Build reusable, composable n8n sub-workflows.
SkillAFreshness: A★ 6.5KClaude Code +9 - 0.848score
n8n-self-hosting
czlonkowski
Deploy a production self-hosted n8n end-to-end to a fresh Linux VM over SSH, using Docker Compose behind a Caddy reverse proxy with automatic HTTPS.
SkillAFreshness: A★ 6.5KClaude Code +9 - 0.848score
n8n-code-python
czlonkowski
Write Python in n8n Code nodes (native Python, `language` pythonNative, n8n 2.x).
SkillAFreshness: A★ 6.5KClaude Code +9
Cite this page
n8n-code-tool skill. Agent Mart. https://agentmart.dev/skills/czlonkowski-n8n-code-tool (last updated 2026-10-24)