跳到正文
DEV Community· Shoeb Reza | Arwahyn AI·· 53 分鐘前AI 評分58

Claude Code 如何按英文描述構建 n8n 工作流程:設置方法及避免出錯的 4 條規則

I describe an n8n workflow in plain English and Claude Code builds it: the setup and the 4 rules that stop it breaking things

AI 導讀

作者用英文描述 n8n 工作流程,由 Claude Code 在其 n8n 實例中建立,再由作者檢查。文章介紹以 n8n-MCP 提供節點文件、結構描述及建立和更新工作流程的工具,並建議先查閲節點文件、驗證後才儲存,以及複製工作流程,以樣本數據測試而不直接修改正式流程。憑證須由用戶在 n8n 中連接;涉及金錢、價格或客戶承諾時,作者建議逐行檢查 AI 節點使用的提示詞,並明確要求加入錯誤處理。

正文

Shoeb Reza | Arwahyn AI

We build n8n automations for clients every week, and the slowest part used to be clicking nodes together and hunting for the right field names. Now I describe the workflow to Claude Code, it builds it in our n8n instance, and I review it, a bit like dictating a letter to someone who types faster than you and then reading it before it goes out.

What you need

  • Claude Code installed
  • An n8n instance you can reach (self-hosted or cloud) and an API key from n8n → Settings → n8n API
  • The open-source n8n-MCP server, which gives Claude the docs and schemas for every n8n node, plus tools to create and update workflows

Setup

  1. Add the n8n-MCP server to Claude Code with your n8n URL and API key as environment variables. The exact command is in the n8n-MCP README; it's one claude mcp add … line.
  2. Restart Claude Code and ask it to list your workflows. If that works, it's connected.
  3. Keep the API key in an environment variable, never in a prompt or in a file you commit.

The 4 rules we give it

  1. Search the node docs before using a node. Without this it guesses parameter names from memory and gets them half right.
  2. Validate before saving. n8n-MCP has a validate tool, and the workflow doesn't get created until validation is clean.
  3. Never touch a live workflow directly. It builds a copy, we test it with pinned sample data, and then we swap.
  4. No real customer messages while testing. Test data only. This one matters most for anything that sends WhatsApp messages or email.

A prompt that works well

Build an n8n workflow: when a new row is added to the "Leads" Google Sheet, wait 5 minutes, send a WhatsApp message to the number in column C using the template in column D, and log the result in column E. Search the node docs first, validate before saving, and don't activate it.

Where it still needs a human

  • Credentials: you connect them in n8n yourself.
  • Anything with money, prices or customer promises: read the prompt the AI node uses, line by line.
  • Error handling: ask for it explicitly, or you'll get a happy-path workflow that fails silently.

If people want, I can share the system prompt we keep in our CLAUDE.md for n8n work.


I run Arwahyn AI, an AI automation agency in Dhaka. There's a step-by-step Bangla version of this setup on our blog, and we run free live AI automation classes in Bangla every Friday and Saturday at 9:30 PM Dhaka time at Arwahyn Academy.

來源:DEV Community · dev.to