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.
- n8n-skillsSkill
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
- Distinctive: line 69
Only runs in dev mode (not in production compose)
- Very specific: line 115
All env vars are available to n8n services via env_file
- Distinctive: line 125
When creating or modifying a workflow that requires credentials, always complete all steps:
- Distinctive: line 127
Before starting, clarify any ambiguity with the user -- do not assume credential types, env var names, node configurations, or workflow …
- Very specific: line 128
Write the workflow JSON in workflows/ with a credentials reference in the relevant nodes
- Very specific: line 129
Add the credential to credentials/manifest.yml under credentials (manual) or _autoCredentials (auto format)
- Very specific: line 130
Add the env vars to .env with actual secret values
- Very specific: line 131
Add the env vars to .env.example with placeholder values
- Very specific: line 132
Add the env vars to docker-compose.yml under x-n8n-credential-yaml-file with defaults
- Very specific: line 133
If the credential requires a community node, add the npm package to community-nodes.txt
- Distinctive: line 135
Never skip steps 3-5 -- without them the credential will not be available to the init container.
- Distinctive: line 139
All code comments in english, lowercase
- Very specific: line 145
Commit messages: lowercase, max 15 words, prefixed with feat:, bugfix:, hotfix:, chore:, etc.
≈ “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.
Files
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 agentsWorkflow 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 explicitenv_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.tshandles encryption using n8n's Cipher module and inserts credentials into the database on startup- Credential env vars must also be declared in
docker-compose.ymlunderx-n8n-credential-yaml-fileto 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.ymlfor credential changes (fetches schema from n8n API to generate env var placeholders) - Authenticated via
WATCH_SERVER_SECRETheader - Only runs in dev mode (not in production compose)
External hooks
- Location:
hooks/workflowHooks.js - Loaded by n8n via
EXTERNAL_HOOK_FILESenvironment 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:
- Installs community nodes from
community-nodes.txt - Truncates existing workflows from database
- Creates n8n folder structure matching
workflows/subdirectories - Runs
bootstrap-credentials.ts: creates owner account, generates watch-server API key, encrypts and inserts credentials frommanifest.yml - Updates credential IDs in workflow JSON files (maps credential type -> database ID)
- Imports all workflows via
n8n import:workflow, assigns folders, sets active/archived state
- Installs community nodes from
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 JSONEnvironment
- Copy
.env.exampleto.envbefore 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.ymlmappings
- Database:
Workflow + credential checklist
When creating or modifying a workflow that requires credentials, always complete all steps:
- Before starting, clarify any ambiguity with the user -- do not assume credential types, env var names, node configurations, or workflow logic
- Write the workflow JSON in
workflows/with acredentialsreference in the relevant nodes - Add the credential to
credentials/manifest.ymlundercredentials(manual) or_autoCredentials(auto format) - Add the env vars to
.envwith actual secret values - Add the env vars to
.env.examplewith placeholder values - Add the env vars to
docker-compose.ymlunderx-n8n-credential-yaml-filewith defaults - 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.
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
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.

