n8n-as-code

repository·main·Indexed 23 days ago

https://github.com/etiennelescot/n8n-as-code

An agentic toolkit for turning n8n repositories into full development workspaces. It enables GitOps-style workflow management, TypeScript-based workflow authoring, and provides specialized skills for AI agents. Features include a CLI (n8nac) for syncing, promoting, and verifying workflows, an MCP server for AI integration, and utilities for managing n8n workflow ecosystems.

Tokens
118.3K
Snippets
283
Records
674
Agent score
80%

What's inside n8n-as-code

  1. Overview of n8n-as-code usage surfaces

    main

    n8n-as-code provides a unified workflow model that can be applied across several different surfaces depending on your needs:

    • Workspace environments: Managing active sync contexts and environments.
    • Explicit sync: Moving workflows between environments.
    • Local AI context: Providing context to AI agents (VS Code, Claude, etc.).
    • Local managed instances: Running local n8n instances via Docker and tunnels.

    Command Groups Summary

    GroupCommandPurpose
    Primary Usagen8nac envWorkspace environments and active sync context
    Workspace Inspectionn8nac workspaceV4 workspace snapshot
    Managed Local Instancesn8n-managerLocal managed instances, Docker, tunnels
  2. Overview of n8n-as-code packages

    main

    The monorepo consists of several specialized packages:

    PackagePurpose
    n8nacCLI + embedded sync engine
    @n8n-as-code/skillsInternal AI tooling library
    @n8n-as-code/transformerTypeScript workflow decorators and conversion
    @n8n-as-code/telemetryPrivacy-first telemetry primitives
    @n8n-as-code/workflow-coreWorkflow intelligence contracts and public authoring API
    @n8n-as-code/manager-adapterAdapter from n8n-as-code surfaces to n8n-manager packages
    @n8n-as-code/mcpDedicated MCP server for n8n-as-code tools
    @n8n-as-code/n8nacOpenClaw plugin package
    n8n-as-codeVS Code Extension
    Claude adapterGenerated from packages/skills
  3. Explore the n8n-as-code monorepo package structure

    main

    The monorepo is organized into several specialized packages:

    • packages/cli: The n8nac facade and embedded sync engine.
    • packages/workflow-core: Independent workflow contracts and the public workflow authoring API.
    • packages/manager-adapter: A facade bridge to n8n-manager and credentials management.
    • packages/skills: Workflow intelligence, node knowledge, documentation, and validation tools.
    • packages/transformer: Handles conversion between workflow JSON and TypeScript.
    • packages/mcp: The Model Context Protocol (MCP) facade for AI agents.
    • packages/vscode-extension: The VS Code and Cursor extension facade.
    • plugins/openclaw: The OpenClaw facade integration.
  4. Engage with the n8n-as-code community

    main

    The n8n-as-code community is hosted on GitHub. You can interact with the project through the following channels:

    • Discussions: Use GitHub Discussions to ask questions, share workflows, and discuss new ideas with other users and contributors.
    • Bug Reports & Feature Requests: Use GitHub Issues to report bugs or request new features.
    • Contributing: If you want to contribute code, documentation, or tests, refer to the Contribution Guide for architecture details and development setup instructions.
  5. Use the Integrated Agent Workbench and Visual Workflow Workspace

    main

    The extension provides two primary interfaces for workflow development:

    Integrated Agent Workbench

    An AI agent that operates with live n8n context. The agent has access to:

    • The current workflow file and its metadata.
    • Selected node or canvas context.
    • The active n8n environment.
    • The project and workflowsPath.
    • The generated AGENTS.md file.
    • Bundled n8n schemas, documentation, examples, templates, and validation rules.

    Visual Workflow Workspace

    • Sidebar: Browse both local and remote workflows via the n8n sidebar.
    • Split View: Inspect the n8n canvas side-by-side with your source files.
    • Workflow Sync: Explicitly pull, push, fetch, and resolve conflicts.
    • Multi-environment: Work across multiple workspace environments without affecting your local instance state.
  6. Choose your n8n-as-code entry point

    main

    Depending on your preferred development environment, choose the appropriate tool:

    • VS Code / Cursor: Use the VS Code Extension for a visual workspace and integrated Agent Workbench.
    • Terminal / CI: Use the CLI for n8nac env management, syncing, validation, and automation.
    • Managed local instances: Use n8n-manager to manage Docker instances, tunnels, and local machine state.
    • Claude Code / Claude Desktop: Use the Claude Plugin for n8n skills and MCP-backed workflow work.
    • Generic coding agents: Use the Skills Reference for portable n8n skills.
    • OpenClaw: Use the OpenClaw Plugin for portable n8n skills inside OpenClaw.
  7. Understand the enriched node search scoring

    main

    The enhanced search algorithm uses relevance-based scoring rather than simple substring matching. When calling searchNodes(), results are ranked based on the following criteria:

    • Exact name matches: 1000 points
    • Display name matches: 800 points
    • Keyword matches: 300 points
    • Description matches: 100 points
    • Operations matches: 100 points per match
    • Use case matches: 80 points per match

    This allows for multi-word queries (e.g., "generate image") to find nodes that satisfy multiple criteria.

  8. Configure multi-agent setups with AGENTS.md

    main
    In multi-agent environments that utilize a repo-level CLAUDE.md, it is recommended to keep CLAUDE.md minimal. Instead of defining node schemas within CLAUDE.md, point the agent back to AGENTS.md in the project root. This ensures that planners and coding agents use the authoritative, generated n8n-as-code instructions rather than hallucinating node schemas.
  9. How workflow filtering is performed

    main
    While the n8n REST API supports includeArchived and onlyArchived query parameters, n8n-as-code performs filtering client-side. During the refreshRemoteState() process, the system fetches all workflows to populate internal remote maps. To avoid redundant API calls, the system filters this cached data locally rather than requesting specific subsets from the n8n API.
  10. Manage n8nac workspace environments

    main

    The n8nac workspace is located at ~/.openclaw/n8nac/. It contains n8nac-config.json (storing workspace environments), AGENTS.md, .agents/skills/, and workflows/.

    API keys and local managed instance state are kept local and are not stored in the config file. You can manually manage environments using the n8nac env command group.

    # Manual environment setup example
    n8nac env add Dev --base-url <url> --workflows-path workflows/dev
    n8nac env auth set Dev --api-key-stdin
    n8nac env use Dev
    n8nac update-ai
    
    # Adding an environment for a local managed instance
    n8n-manager instance list
    n8nac env add Local --managed-instance <id> --workflows-path workflows/local
  11. How Claude interacts with n8n-as-code

    main

    When a user requests a workflow change, the Claude plugin follows this operational flow:

    1. Context Gathering: Claude reads AGENTS.md and local skills.
    2. Environment Check: Claude resolves the current n8nac env status.
    3. File Management: Claude pulls or creates the relevant workflow files.
    4. Knowledge Retrieval: Claude uses n8n node schemas and documentation.
    5. Live Assistance: If the active environment has native MCP live assist configured, Claude uses it to access live n8n state.
    6. Execution: Claude edits and validates the workflow, then pushes changes when requested.
  12. How the VS Code Extension handles workflow tabs and search

    main

    The VS Code extension uses a specific model for managing workflow visibility:

    • Tab-scoped Store: The Redux store is scoped to the active tab. When switching tabs, loadWorkflows() re-fetches with the new filter and replaces the workflow entries. The tree view always reflects the current tab's filter.
    • Global Search: The "Find Workflow" command bypasses the tab-scoped store and calls cli.list() directly with includeArchived: true. This ensures the QuickPick search results include all workflows, regardless of which tab is currently active in the tree view.
    • Auto-switching on Reveal: If a user selects an archived workflow from the QuickPick while the tree is viewing the standard "Workflows" tab, the extension automatically switches the tree to the "All" tab so the selected item is visible. The extension does not automatically revert to the previous tab after the reveal.