Skip to main content

Contribution Guide

This section contains documentation for developers and contributors working on n8n-as-code.

๐Ÿ“š Available Documentationโ€‹

Architecture & Designโ€‹

  • Architecture Overview: Understand the n8n-as-code monorepo architecture, component interactions, and design decisions.

Internal Packagesโ€‹

  • Core Package: Internal documentation for the Core package that provides shared business logic for all n8n-as-code components.
  • Agent CLI: Internal documentation for the Agent CLI package used by AI assistants to generate context and snippets.
  • Claude Skill: Internal documentation for the Claude Agent Skill package.

๐Ÿ›  Development Setupโ€‹

Prerequisitesโ€‹

  • Node.js 18+
  • npm 9+
  • Git

Getting Startedโ€‹

  1. Clone the repository
  2. Run npm install in the root directory
  3. Build all packages with npm run build
  4. Run tests with npm test

๐Ÿ“ฆ Package Structureโ€‹

n8n-as-code is organized as a monorepo with the following packages:

PackagePurposePrimary Users
Core (@n8n-as-code/core)Shared logic, API client, synchronizationAll packages
CLI (@n8n-as-code/cli)Command-line interface for workflow managementTerminal users, automation
VS Code ExtensionIntegrated development environmentVS Code users
Agent CLI (@n8n-as-code/agent-cli)AI context generation and node schemasAI assistants, developers

๐Ÿงช Testingโ€‹

Test Structureโ€‹

  • Unit Tests: Individual component testing with Jest
  • Integration Tests: End-to-end workflow tests
  • Snapshot Tests: Ensure generated files match expected format

Running Testsโ€‹

# Run all tests
npm test

# Run tests for specific package
cd packages/core && npm test
cd packages/agent-cli && npm test

๐Ÿ”ง Buildingโ€‹

Development Buildโ€‹

npm run build

Watch Mode (Development)โ€‹

npm run dev

๐Ÿ“ฆ Version Managementโ€‹

n8n-as-code uses Changeset with independent package versioning. Each package evolves independently while Changeset automatically manages internal dependencies.

Current Package Versionsโ€‹

Packages evolve independently with their own version numbers:

  • @n8n-as-code/core: 0.3.0
  • @n8n-as-code/cli: 0.3.0
  • @n8n-as-code/agent-cli: 0.2.0
  • VS Code Extension: 0.2.0

Note: Each package has its own version number. Changeset ensures that when a package depends on another internal package, it always references the current version of that dependency.

Package Publication Strategyโ€‹

The project includes different types of packages:

PackagePublished ToManaged By Changeset
@n8n-as-code/coreNPM Registryโœ… Yes
@n8n-as-code/cliNPM Registryโœ… Yes
@n8n-as-code/agent-cliNPM Registryโœ… Yes
n8n-as-code (VS Code Extension)VS Code Marketplaceโœ… Yes (versioning only)
n8n-as-code-monorepo (root)Not publishedโŒ No (ignored)
docsNot publishedโŒ No (private)

Important: The VS Code extension is marked as "private": true to prevent accidental NPM publication, but it is still managed by Changeset for version numbering and dependency synchronization. Changeset automatically skips private packages during changeset publish.

Release Workflowโ€‹

Step 1: Create Changeset (Developer)โ€‹

After modifying code, document your changes:

npm run changeset

This command:

  • Creates a file .changeset/random-name-123.md
  • Prompts you to select affected packages (including VS Code extension if modified)
  • Asks for version bump type: patch (0.3.0โ†’0.3.1), minor (0.3.0โ†’0.4.0), major (0.3.0โ†’1.0.0)
  • Requests a changelog message

Important: Commit this changeset file with your code changes.

Step 2: Version Packages PR (Automated)โ€‹

When changesets are pushed to main, the CI creates a "Version Packages" Pull Request automatically:

  • Reads all .changeset/*.md files
  • Updates package.json versions for ALL packages (including private ones)
  • Automatically updates internal dependencies across all packages
  • Generates/updates CHANGELOG.md files
  • Deletes processed changeset files
  • Creates a single PR with all these changes

Step 3: Merge & Publish (Automated)โ€‹

When the "Version Packages" PR is merged:

  1. NPM Publication:

    • Builds all packages
    • Publishes public packages to NPM registry (@n8n-as-code/core, @n8n-as-code/cli, @n8n-as-code/agent-cli)
    • Skips private packages automatically (monorepo root, VS Code extension, docs)
    • Creates Git tags for each published package (e.g., @n8n-as-code/core@0.3.1)
  2. VS Code Extension:

    • Separately publishes to VS Code Marketplace using the version from package.json
    • No Git tag created for the extension (private package)
  3. GitHub Releases:

    • ENABLED - One GitHub Release is created per published package
    • Each package has its own release timeline (e.g., @n8n-as-code/core@0.3.1, @n8n-as-code/cli@0.3.2)
    • Release notes are automatically extracted from each package's CHANGELOG.md
    • Private packages (VS Code extension) do not get GitHub Releases automatically

Example: How Internal Dependencies Stay Synchronizedโ€‹

Let's say you fix a bug in @n8n-as-code/core:

# 1. Create a changeset for the core fix
npm run changeset
# Select: @n8n-as-code/core
# Type: patch (0.3.0 โ†’ 0.3.1)

# 2. Apply versions
npm run version-packages

Result:

  • @n8n-as-code/core: 0.3.0 โ†’ 0.3.1 โœ…
  • @n8n-as-code/cli: 0.3.0 โ†’ 0.3.1 (auto-bumped because it depends on core) โœ…
  • @n8n-as-code/agent-cli: 0.2.0 (unchanged, no dependency on core) โœ…
  • VS Code Extension: 0.2.0 โ†’ 0.2.1 (auto-bumped because it depends on core) โœ…

All packages that depend on core will have their package.json updated to reference "@n8n-as-code/core": "0.3.1".

Workflow Summary Diagramโ€‹

Developer makes changes
โ†“
npm run changeset (creates .changeset/xyz.md)
โ†“
git commit + git push
โ†“
CI detects changeset files โ†’ Creates "Version Packages" PR
โ†“
Maintainer reviews & merges PR
โ†“
CI automatically:
โ”œโ”€โ†’ Publishes to NPM (@n8n-as-code/*)
โ”œโ”€โ†’ Creates Git tags (one per package)
โ””โ”€โ†’ Publishes VS Code extension to Marketplace

Key Rulesโ€‹

  • Never manually edit versions in package.json
  • Always use Changeset even for small fixes
  • Include VS Code extension in changesets when you modify it - this ensures dependencies stay synchronized
  • Internal dependencies are automatically updated thanks to "updateInternalDependencies": "patch" in Changeset config
  • Private packages are safe - Changeset will manage their versions but never publish them to NPM
  • Use npm run check-versions to verify all internal dependencies are up-to-date
  • Git tags are created automatically for each published NPM package
  • GitHub Releases are created automatically - One release per package with its own timeline
  • Each package has independent releases - No global monorepo release

GitHub Releases per Packageโ€‹

When a "Version Packages" PR is merged, Changeset automatically creates:

For each published NPM package:

  • โœ… GitHub Release (e.g., @n8n-as-code/core@0.3.1)
  • โœ… Git Tag with the same name
  • โœ… Release notes extracted from the package's CHANGELOG.md

For private packages (VS Code extension):

  • โŒ No GitHub Release (private packages are skipped)
  • โ„น๏ธ You can create manual releases if needed

Example timeline on GitHub:

Releases
โ”œโ”€ @n8n-as-code/core@0.3.2 (Jan 20, 2024)
โ”œโ”€ @n8n-as-code/cli@0.4.1 (Jan 20, 2024)
โ”œโ”€ @n8n-as-code/agent-cli@0.3.0 (Jan 18, 2024)
โ”œโ”€ @n8n-as-code/core@0.3.1 (Jan 15, 2024)
โ””โ”€ @n8n-as-code/cli@0.4.0 (Jan 15, 2024)

Each package maintains its own release history!

๐Ÿ“ Contribution Guidelinesโ€‹

Code Styleโ€‹

  • Use TypeScript with strict type checking
  • Follow ESLint configuration
  • Write comprehensive tests for new features

Pull Request Processโ€‹

  1. Create a feature branch from main
  2. Make your changes with tests
  3. Ensure all tests pass
  4. Submit a pull request with clear description

Documentationโ€‹

  • Update relevant documentation when adding features
  • Include JSDoc comments for public APIs
  • Keep the contributors documentation up to date

โ“ Need Help?โ€‹

  • Check the existing documentation in this section
  • Look at the source code for examples
  • Open an issue on GitHub for specific questions
  • Join discussions in the GitHub forum

This documentation is maintained by the n8n-as-code development team.