The Problem

n8n workflows are typically managed through a click-driven UI, which makes version control, review, and automation difficult. Teams end up exporting JSON, losing history, and re-creating workflows by hand. The real pain is that AI agents lack the structured knowledge to work with n8n accurately — they guess at node schemas, produce broken workflows, and can't integrate with a live instance.

What This Does

n8n-as-code gives AI agents and developers a typed, scriptable interface to n8n. It bundles 537 node schemas, 7,700+ templates, and TypeScript workflow definitions into a local, searchable knowledge base. The core is a CLI (packages/cli) that syncs workflows between a local directory and a live n8n instance — think git pull/push for workflows. It also ships integrations for VS Code (packages/vscode-extension), Claude Code (.claude-plugin), and MCP (packages/mcp).

The transformer (packages/transformer) converts n8n JSON workflows to TypeScript and back, so you can write workflows as code. The skills package (packages/skills) provides the AI context — node schemas, docs, and workflow examples — to ground agent responses.

How It Is Wired

Execution starts at run in packages/cli/src/commands/convert.ts, which reaches 193 functions. The main flow: the CLI parses commands, loads config via config-service.ts, and calls the n8n API through n8n-api-client.ts. The sync-manager.ts orchestrates the git-like pull/push, using workflow-state-tracker.ts to map local files to remote workflow IDs.

The most critical modules are the hub — packages/cli/src/core/types.ts (17 modules depend on it) and packages/cli/src/core/index.ts (12 depend on it). Changes here have wide blast radius. The parse function is called from 34 places; getApiKey from 16. These are the load-bearing functions.

The system makes outbound network calls (n8n API), reads/writes files (workflow JSON), and runs external commands (npx). A typical sync: run -> getHealth (network) then main -> generate -> injectOrUpdate (filesystem). The wiring to the live instance is direct — few hops from CLI to API.

How To Use It

Setup: Clone and install dependencies. The repo uses pnpm (implied by pnpm/action-setup in CI). There is no lockfile committed, so builds are not reproducible — run pnpm install once and commit the lockfile.

Configuration: Copy .env-example to .env and set your n8n instance URL and API key. The config-service.ts reads local config; the CLI expects a workspace with workflow files.

Running it: Use the CLI directly — npx @n8n-as-code/cli sync pull or push. For AI agents, install the Claude plugin via /plugin marketplace add https://github.com/EtienneLescot/n8n-as-code. The VS Code extension activates from the command palette (n8n: Configure).

Real-World Use

A team maintains workflows in a Git repo. A developer writes a workflow in TypeScript, commits it, and CI runs n8n-as-code sync push to deploy to a staging instance. An AI agent, grounded by the bundled schemas, proposes a new workflow — the developer reviews the diff, merges, and the same sync pushes it to production. No manual JSON editing, no drift between environments.

Code Health & Issues

Static analysis found 89 issues (14 high, 75 medium). Key findings:

  • High - Deep nesting in n8n-api-client.ts, workflow-state-tracker.ts (max indentation depth 8). Control flow is hard to follow.
  • High - Duplicated code — 180 repeated 6-line blocks across 61 files. Extract shared helpers.
  • Medium - Empty catch blocks in proxy-service.ts, webview-html.ts, create-test-workflows.mjs — errors silently swallowed.
  • Medium - Hub modules — types.ts and index.ts are chokepoints; keep them stable.

SDLC observations: no lockfile (non-reproducible builds), GitHub Actions pinned to mutable tags (supply-chain risk), and large JSON assets (29MB+) in the repo bloat every clone. CI exists with tests (87 test files), which is good.

The Bottom Line

This is a well-architected tool for teams that want GitOps for n8n and AI-assisted workflow development. The TypeScript transformer and bundled schemas are genuinely useful. The main risks are supply-chain (unpinned actions, no lockfile) and the complexity of the core sync logic. Teams already invested in n8n and AI agents will get the most value; casual users may find the setup overhead not worth it.