AgentSkillsCN

managing-n8n

在紫外光下管理n8n工作流自动化。当您需要创建工作流、管理备份、配置凭证,或进行服务运维时,此工具将助您事半功倍。

SKILL.md
--- frontmatter
name: managing-n8n
description: Manages n8n workflow automation on ultraviolet. Use when creating workflows, managing backups, configuring credentials, or service operations.

n8n Workflow Automation

Workflow Authoring

Claude creates workflows as JSON files in n8n/workflows/. They sync to n8n on rebuild.

code
User describes intent → Claude creates JSON → `update` syncs to n8n → User tests in UI

If user modifies in UI and wants to reconcile:

bash
n8n-export <workflow-id>              # Export specific workflow
n8n-export all                        # Export all workflows
# Then copy from /tmp/n8n-export to nix-config/n8n/workflows/

Workflow JSON Structure

json
{
  "id": "unique-workflow-id",
  "name": "Workflow Name",
  "active": false,
  "nodes": [
    {
      "id": "node-uuid",
      "name": "Node Name",
      "type": "n8n-nodes-base.webhook",
      "position": [250, 300],
      "parameters": {}
    }
  ],
  "connections": {
    "Node Name": {
      "main": [[{"node": "Next Node", "type": "main", "index": 0}]]
    }
  }
}

Common Node Types

NodeType StringUse
Webhookn8n-nodes-base.webhookHTTP trigger
Schedulen8n-nodes-base.scheduleTriggerCron trigger
HTTP Requestn8n-nodes-base.httpRequestAPI calls
Coden8n-nodes-base.codeJavaScript
AI Agent@n8n/n8n-nodes-langchain.agentLLM agent
Anthropic Chat@n8n/n8n-nodes-langchain.lmChatAnthropicClaude model

Deployment

  • URL: https://n8n.husbuddies.gay
  • Host: ultraviolet (NixOS)
  • Workflows: n8n/workflows/*.json (git-tracked)
  • Config: hosts/ultraviolet/services/n8n.nix

Service Commands

bash
systemctl status n8n.service           # Check status
journalctl -u n8n.service -f           # View logs
sudo systemctl restart n8n.service     # Restart (reimports workflows)

Backup & Restore

bash
n8n-restore list                       # List backups
n8n-restore latest                     # Restore from latest

Anthropic/AI Setup

Credentials MUST be configured via n8n UI - env vars don't work.

  1. Open https://n8n.husbuddies.gay
  2. Settings → Credentials → Add Credential → Anthropic
  3. Enter API key and save

Common Mistakes

WrongRight
Setting ANTHROPIC_API_KEY env varConfigure in n8n UI → Credentials
Editing workflows only in UICreate JSON in n8n/workflows/, run update
Expecting UI changes to persistExport with n8n-export and commit to git
docker exec n8n ...Direct systemctl (not containerized)

Directory Structure

code
nix-config/
└── n8n/workflows/          # Git-tracked workflow JSON files
    └── *.json              # Claude creates these

/var/lib/n8n/               # n8n database (synced from git on rebuild)
/mnt/backups/n8n/           # Daily backups to NAS