agentleFS
gabry-tsgabry-ts/n8n-starter/CLAUDE.md

n8n-starter

CLAUDE.md9 starsChanged 9 months agoMITView on GitHub

n8n-starter is a GitOps system for n8n. The Git repository is the single source of truth for workflows and credentials. On startup, an init container imports everything into n8n. At runtime, a watch-server receives webhook events from n8n external hooks and exports changes back to disk. AI agents interact with this system by reading and writing files in the repo -- no n8n UI access required.

  • Reads credentials
  • In this repositoryOne other file it gives its agents.

The file

Show its rules and text

We split this CLAUDE.md into the rules it gives an agent

13 rules. About 0 are common, 5 are distinctive, and 8 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈5

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 8

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Only runs in dev mode (not in production compose)

    line 69
  2. Very specific:

    All env vars are available to n8n services via env_file

    line 115
  3. Distinctive:

    When creating or modifying a workflow that requires credentials, always complete all steps:

    line 125
  4. Distinctive:

    Before starting, clarify any ambiguity with the user -- do not assume credential types, env var names, node configurations, or workflow …

    line 127
  5. Very specific:

    Write the workflow JSON in workflows/ with a credentials reference in the relevant nodes

    line 128
  6. Very specific:

    Add the credential to credentials/manifest.yml under credentials (manual) or _autoCredentials (auto format)

    line 129
  7. Very specific:

    Add the env vars to .env with actual secret values

    line 130
  8. Very specific:

    Add the env vars to .env.example with placeholder values

    line 131
  9. Very specific:

    Add the env vars to docker-compose.yml under x-n8n-credential-yaml-file with defaults

    line 132
  10. Very specific:

    If the credential requires a community node, add the npm package to community-nodes.txt

    line 133
  11. Distinctive:

    Never skip steps 3-5 -- without them the credential will not be available to the init container.

    line 135
  12. Distinctive:

    All code comments in english, lowercase

    line 139
  13. Very specific:

    Commit messages: lowercase, max 15 words, prefixed with feat:, bugfix:, hotfix:, chore:, etc.

    line 145

≈ “Common” is an estimate: at least 1 in 5 of the 29,248 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
CLAUDE.md

CLAUDE.md

Project overview

n8n-starter is a GitOps system for n8n. The Git repository is the single source of truth for workflows and credentials. On startup, an init container imports everything into n8n. At runtime, a watch-server receives webhook events from n8n external hooks and exports changes back to disk. AI agents interact with this system by reading and writing files in the repo -- no n8n UI access required.

Repository structure

n8n-starter/
├── docker-compose.yml          # all services: postgres, n8n, init, watch-server
├── docker-compose.prd.yml      # production: no watch-server, import-only
├── .env.example                # environment variables template
├── package.json                # single package with helper scripts
├── tsconfig.json               # typescript config
├── community-nodes.txt         # npm packages to install at init (one per line)
├── workflows/                  # workflow JSON files (subdirs = n8n folders)
├── credentials/
│   ├── manifest.yml            # credential definitions with env var mappings
│   └── .n8n-api-key            # generated API key for watch-server (gitignored)
├── hooks/
│   └── workflowHooks.js        # n8n external hooks: workflow + credential events
├── init/
│   ├── Dockerfile              # node:24-alpine + n8n 2.11.3 + pg + jq
│   ├── init.sh                 # shell: community nodes, folders, workflow import
│   └── bootstrap-credentials.ts  # owner account setup + credential encryption
├── scripts/
│   ├── watch-server.ts         # express server receiving hook webhook events
│   ├── update-n8n-skills.sh    # update n8n-skills knowledge base
│   └── lib/
│       ├── types.ts            # payload interfaces
│       ├── utils.ts            # logging, path resolution helpers
│       ├── workflows.ts        # save/delete workflow files on disk
│       └── credentials.ts      # read/write manifest.yml, fetch credential schemas
├── examples/                   # example workflow JSON files
├── README.md                   # project documentation
└── .claude/skills/n8n-skills/  # n8n node knowledge base for AI agents

Workflow files

  • Location: workflows/
  • Format: n8n workflow JSON (exported format)
  • Subdirectories map to n8n folders (auto-created on import)
  • Filename convention: slugified workflow name, e.g. my-workflow.json
  • On startup, init container truncates existing workflows and imports all JSON files from this directory
  • To create a new workflow: write a valid n8n JSON file here and run docker compose up -d
  • To modify: edit the JSON directly or use n8n UI (watch-server will export changes back)
  • Files named my-workflow* are gitignored (n8n default workflows)

Credential management

  • Manifest location: credentials/manifest.yml
  • Two sections:
    • credentials -- manual definitions with explicit env_mapping (field name -> env var name)
    • _autoCredentials -- auto-generated by watch-server when credentials are created in the n8n UI, uses ${ENV_VAR} placeholder syntax
  • Secret values go in .env, never in the manifest -- manifest only maps field names to env var names
  • bootstrap-credentials.ts handles encryption using n8n's Cipher module and inserts credentials into the database on startup
  • Credential env vars must also be declared in docker-compose.yml under x-n8n-credential-yaml-file to be passed to the init container

Watch-server (auto-export)

  • Express server on port 3456 (configurable via WATCH_SERVER_PORT)
  • Receives webhook POSTs from n8n external hooks on workflow save/delete and credential save/delete
  • Endpoints: /webhook/workflow-save, /webhook/workflow-delete, /webhook/credential-save, /webhook/credential-delete
  • Writes workflow JSON back to workflows/ directory (slugified filename, preserves folder structure)
  • Updates manifest.yml for credential changes (fetches schema from n8n API to generate env var placeholders)
  • Authenticated via WATCH_SERVER_SECRET header
  • Only runs in dev mode (not in production compose)

External hooks

  • Location: hooks/workflowHooks.js
  • Loaded by n8n via EXTERNAL_HOOK_FILES environment variable
  • Triggered on: workflow update, activate, deactivate, delete; credential create, update, delete
  • Sends POST requests to watch-server with workflow/credential data
  • Cleans volatile fields (createdAt, updatedAt, versionId, statistics, etc.) before sending
  • Maintains an in-memory cache for workflow names (needed for delete events which only provide an ID)

Init container

  • Dockerfile: init/Dockerfile (node:24-alpine + n8n@2.11.3 + postgresql-client + jq)
  • Runs once on startup after n8n passes its healthcheck
  • Steps in order:
    1. Installs community nodes from community-nodes.txt
    2. Truncates existing workflows from database
    3. Creates n8n folder structure matching workflows/ subdirectories
    4. Runs bootstrap-credentials.ts: creates owner account, generates watch-server API key, encrypts and inserts credentials from manifest.yml
    5. Updates credential IDs in workflow JSON files (maps credential type -> database ID)
    6. Imports all workflows via n8n import:workflow, assigns folders, sets active/archived state

Development commands

# dev
docker compose up -d                      # start all services
docker compose logs -f                    # follow logs
docker compose down                       # stop services
docker compose down -v                    # stop and reset all data

# production
docker compose -f docker-compose.prd.yml up -d

# database
yarn n8n:backup                           # pg_dump to backup-<timestamp>.sql
yarn n8n:restore < backup.sql             # restore from backup

# credentials
yarn n8n:export-credentials               # export decrypted credentials to JSON

Environment

  • Copy .env.example to .env before first run
  • All env vars are available to n8n services via env_file
  • Key variables:
    • Database: POSTGRES_HOST, POSTGRES_USER, POSTGRES_PASSWORD, POSTGRES_DB
    • n8n: N8N_ENCRYPTION_KEY (min 24 chars, must be consistent across services), N8N_HOST, WEBHOOK_URL
    • Owner: N8N_OWNER_EMAIL, N8N_OWNER_PASSWORD
    • Watch-server: WATCH_SERVER_PORT, WATCH_SERVER_SECRET
    • Credential secrets: add custom vars matching your manifest.yml mappings

Workflow + credential checklist

When creating or modifying a workflow that requires credentials, always complete all steps:

  1. Before starting, clarify any ambiguity with the user -- do not assume credential types, env var names, node configurations, or workflow logic
  2. Write the workflow JSON in workflows/ with a credentials reference in the relevant nodes
  3. Add the credential to credentials/manifest.yml under credentials (manual) or _autoCredentials (auto format)
  4. Add the env vars to .env with actual secret values
  5. Add the env vars to .env.example with placeholder values
  6. Add the env vars to docker-compose.yml under x-n8n-credential-yaml-file with defaults
  7. If the credential requires a community node, add the npm package to community-nodes.txt

Never skip steps 3-5 -- without them the credential will not be available to the init container.

Conventions

  • All code comments in english, lowercase
  • No emojis anywhere
  • Readme files in english, precise and short
  • Workflow files: one JSON per workflow, slugified filename
  • Credentials: env var names in SCREAMING_SNAKE_CASE
  • Branch strategy: main = production, other branches = staging/dev
  • Commit messages: lowercase, max 15 words, prefixed with feat:, bugfix:, hotfix:, chore:, etc.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.