CLAUDE.md
packages/cli/src/modules/n8n-packages/CLAUDE.mdCLAUDE.md
Quality
69/100
Scores the file, not the repository.Length
595 words
6 headings · 1 code blocksRepository
199k
— · pushed 0 days agoLast changed
3 days ago
First indexed 3 days ago.1# n8n-packages module — Agent Guidelines23This module powers package **import/export** (`.n8np`). The feature is4**public-API-first; the CLI wraps the API.** A single import/export option5therefore lives in up to four layers across three packages.67## ⚠️ Propagate new properties through every layer89**When you add, rename, or remove a property on the import or export request,10carry it through all four layers below.** A property that stops at the module11is invisible to public-API and CLI users — and an out-of-date OpenAPI spec or12CLI flag is a silent bug, not a compile error.1314```mermaid15flowchart LR16 M["1. Module<br/>(this package)"] --> D["2. DTO<br/>@n8n/api-types"]17 D --> A["3. Public API<br/>handler + OpenAPI spec"]18 A --> C["4. CLI<br/>@n8n/cli"]19```2021### Importer rules22- Importers **plan and decide**; they must never touch a repository directly. All persistence and23 lookups go through a **service**.24- Prefer an **existing** domain service from the main n8n codebase (`FolderService`, `ProjectService`,25 `WorkflowService`, …). When the importer needs a capability the service lacks — reusing a source id,26 or a fetch-by-ids for matching — **extend that existing service with a general method** rather than27 reaching for the repository or spinning up an import-only service. Canonical examples:28 `ProjectService.createTeamProject(data, overrides)` (preset id + description) and29 `FolderService.createFolder(dto, projectId, id?)` / `FolderService.getFoldersByIds(ids)`.30- `N8nPackagesService.importPackage` is a thin **dispatcher**: it builds the reader, reads the manifest,31 and delegates to a per-package-shape importer. Shapes mirror export's mutual exclusivity — a **project32 package** (projects defined by the package) → `ProjectPackageImporter`, or a **workflow package** (loose33 workflows + their folder shells + credential deps into a target project) → `WorkflowPackageImporter`.34- `WorkflowPackageImporter` resolves the target scope from the request, then delegates the plan/gate/apply35 work to `ImportOrchestrator` (brings folders + workflows + credential deps into one project scope).36 `ProjectPackageImporter` creates the project shells, then reuses `ImportOrchestrator` per project to37 bring each one's own folders + workflows + credential deps into scope. Don't split folder vs workflow:38 they share target resolution, credential resolution, and publishing.3940### Adding an IMPORT property41421. **Module** (here)43 - `n8n-packages.types.ts` — add the field to `ImportPackageRequest`44 (or `ImportWorkflowProperties` / `ImportCredentialProperties`). For a new45 enum, add a `XxxPolicy` / `XxxMode` const **and** its derived type46 (follow `WorkflowIdPolicy`). New single-value modes are RFC seams — keep47 the function-table convention (`workflow-conflict-policy.ts` etc.), don't48 add handler classes for pure logic.49 - Implement the behaviour (e.g. `entities/workflow/workflow-importer.ts`)50 and thread it through `n8n-packages.service.ts` `importPackage`.512. **DTO** — `@n8n/api-types/src/dto/packages/import-package-request.dto.ts`52 - Add the field to `ImportPackageRequestDto` (zod), **and** add its name to53 `IMPORT_PACKAGE_REQUEST_FORM_FIELDS` (multipart text fields).54 - Update `__tests__/import-package-request.dto.test.ts`.553. **Public API** — `packages/cli/src/public-api/v1/handlers/n8n-packages/`56 - `n8n-packages.handler.ts` — pass `payload.data.<field>` into the service.57 - `spec/paths/n8n-packages.import.yml` — add the property to the inline58 `multipart/form-data` request schema (type/enum/description; update59 `required` if needed). **Easy to forget — the spec is hand-written.**604. **CLI** — `packages/@n8n/cli/`61 - `src/client.ts` — add to `ImportPackageFields`.62 - `src/commands/package/import.ts` — add a `Flags.string({...})` (with a63 kebab-case alias) and pass it into `client.importPackage(...)`.64 - `docs/commands/package.md` + the `README.md` flag table.6566### Adding an EXPORT property67681. **Module** — `n8n-packages.types.ts` `ExportPackageRequest`; implement in69 `n8n-packages.service.ts` `exportPackage` (+ `io/` writer or70 `entities/*/` exporter as needed).712. **DTO** — `@n8n/api-types/src/dto/packages/export-package-request.dto.ts`72 (`ExportPackageRequestDto`, zod).733. **Public API** — `n8n-packages.handler.ts` `exportPackage` reads from74 `payload.data`; update the **separate** schema file75 `spec/schemas/exportPackageRequest.yml` (export's request schema is a76 `$ref`, unlike import's inline schema).774. **CLI** — `src/client.ts` `exportPackage(...)`,78 `src/commands/package/export.ts` flag, and the docs/README.7980## Reference: the `workflowIdPolicy` change8182The in-tree addition of `workflowIdPolicy` is the canonical example — it landed83in the module types + importer, the DTO (+ form-fields list), the handler, and84the CLI. Grep `workflowIdPolicy` to see every site a new import knob must touch.85
Also in n8n-io/n8n
Diff this repo’s formatsOne repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| n8n-io/n8n.agents/skills/AGENTS.md · 199k | AGENTS.md | setuparchagent-behaviour | 58/100 | 3 days ago | |
| n8n-io/n8n.github/CLAUDE.md · 199k | CLAUDE.md | styleagent-behaviour | 48/100 | 3 days ago | |
| n8n-io/n8nAGENTS.md · 199k | AGENTS.md | setupbuildtestlint-format+8 | 96/100 | 3 days ago | |
| n8n-io/n8npackages/@n8n/ai-workflow-builder.ee/AGENTS.md · 199k | AGENTS.md | agent-behaviour | 53/100 | 3 days ago | |
| n8n-io/n8npackages/@n8n/db/AGENTS.md · 199k | AGENTS.md | database | 39/100 | 3 days ago | |
| n8n-io/n8npackages/@n8n/engine/AGENTS.md · 199k | AGENTS.md | archdo-not | 59/100 | 3 days ago | |
| n8n-io/n8npackages/@n8n/instance-ai/CLAUDE.md · 199k | CLAUDE.md | buildteststyletesting-strategy+1 | 89/100 | 3 days ago | |
| n8n-io/n8npackages/cli/AGENTS.md · 199k | AGENTS.md | lint-format | 55/100 | 3 days ago | |
| n8n-io/n8npackages/frontend/AGENTS.md · 199k | AGENTS.md | style | 40/100 | 3 days ago | |
| n8n-io/n8npackages/frontend/editor-ui/src/app/stores/workflowDocument/CLAUDE.md · 199k | CLAUDE.md | styleagent-behaviour | 58/100 | 3 days ago | |
| n8n-io/n8npackages/nodes-base/AGENTS.md · 199k | AGENTS.md | teststylearchtypes+5 | 89/100 | 3 days ago | |
| n8n-io/n8npackages/testing/playwright/AGENTS.md · 199k | AGENTS.md | setupbuildtestlint-format+8 | 96/100 | 3 days ago | |
| n8n-io/n8npackages/@n8n/agents/AGENTS.md · 199k | AGENTS.md | buildteststylearch+3 | 100/100 | 3 days ago | |
| n8n-io/n8nscripts/instance-seeding/AGENTS.md · 199k | AGENTS.md | setupstyledo-not | 65/100 | 3 days ago |
Diff against .agents/skills/AGENTS.md Diff against .github/CLAUDE.md Diff against AGENTS.md Diff against packages/@n8n/ai-workflow-builder.ee/AGENTS.md Diff against packages/@n8n/db/AGENTS.md Diff against packages/@n8n/engine/AGENTS.md Diff against packages/@n8n/instance-ai/CLAUDE.md Diff against packages/cli/AGENTS.md Diff against packages/frontend/AGENTS.md Diff against packages/frontend/editor-ui/src/app/stores/workflowDocument/CLAUDE.md Diff against packages/nodes-base/AGENTS.md Diff against packages/testing/playwright/AGENTS.md Diff against packages/@n8n/agents/AGENTS.md Diff against scripts/instance-seeding/AGENTS.md
Similar configs
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| dotCMS/corecore-web/CLAUDE.md · 950 | CLAUDE.md | teststylearchtesting-strategy+3 | 100/100 | 3 days ago | |
| Adit-Jain-srm/NightmareNetCLAUDE.md · 45 | CLAUDE.md | buildtestlint-formatstyle+6 | 100/100 | 3 days ago | |
| nimbalyst/nimbalystpackages/android/CLAUDE.md · 1.4k | CLAUDE.md | setupbuildstylearch+2 | 100/100 | 3 days ago | |
| microsoft/playwrightCLAUDE.md · 94k | CLAUDE.md | buildtestlint-formatstyle+7 | 100/100 | 3 days ago | |
| dotCMS/coreCLAUDE.md · 950 | CLAUDE.md | setupbuildteststyle+7 | 99/100 | 3 days ago | |
| lollipopkit/flutter_server_boxCLAUDE.md · 8.3k | CLAUDE.md | buildteststylearch+2 | 98/100 | 3 days ago | |
| oven-sh/buntest/CLAUDE.md · 95k | CLAUDE.md | teststyletesting-strategydo-not | 97/100 | 3 days ago | |
| MetaMask/metamask-design-systemCLAUDE.md · 34 | CLAUDE.md | buildtestlint-formatstyle+5 | 97/100 | 3 days ago |
