Skip to content

feat(presets): 10 built-in architecture presets + presets CLI - #2

Merged
leofmarciano merged 1 commit into
mainfrom
feat/presets
Jun 8, 2026
Merged

feat(presets): 10 built-in architecture presets + presets CLI#2
leofmarciano merged 1 commit into
mainfrom
feat/presets

Conversation

@leofmarciano

Copy link
Copy Markdown
Owner

What

Adds architecture presets — activate a strict, senior-grade rule bundle by name:

version: 1
project: { name: my-service }
presets: [clean-architecture]   # merged UNDER your config — you always win

10 built-in presets, researched against each framework's official docs:

Preset Based on
clean-architecture, hexagonal, node-service Clean Architecture / Ports & Adapters
nestjs-clean, nextjs, tanstack-starter, elysiajs Clean Architecture overlay
nest-js, adonisjs, encore-ts the framework's own official conventions

Opinionated frameworks (NestJS, AdonisJS, Encore.ts) follow their own recommended structure; unopinionated ones (ElysiaJS, TanStack Start, Next.js) get Clean Architecture for the business core.

Mechanism

  • applyPresets() resolves presets (string | string[]), deep-merges fragments left-to-right, then the user config on top, strips the key — the result flows through the unchanged zod schema + normalize.
  • Merge: layers/rules/expectations override by name; ruleset replaces per layer (not unioned); paths.include replace / exclude concat.
  • A shared _clean-arch-base builder removes duplication; 3 framework-official presets stand alone.
  • UnknownPresetError → exit 2 with a Levenshtein "did you mean".

DX

  • arch-contract presets [name] — list all / show one (layers + ruleset + rules).
  • arch-contract init --preset <name> — scaffold a config that uses it.
  • Per-preset docs under docs/presets/.

Engine

Implemented namespaceExport / star-export (export *) detection — it was schema-accepted but a silent no-op, so the domain-purity preset rules are now honest.

Tests

351 green — merge semantics, per-preset resolution (zero semantic issues), per-preset behavioral (compliant fixture → 0 errors; violating fixture → the targeted rule fires), CLI/DX, and the namespaceExport regression. Self-dogfooded (arch:check + arch:docs:check).

🤖 Generated with Claude Code

Adds 'presets: [<name>]' to the config: a partial fragment merged under the
user's config (user always wins — override by name, ruleset replaces per layer).

Presets (strict, severity error):
- clean-architecture, hexagonal, node-service  (Clean Arch / Ports & Adapters)
- nestjs-clean, nest-js, nextjs, tanstack-starter, adonisjs, elysiajs, encore-ts

Opinionated frameworks (Nest/Adonis/Encore) follow their official conventions;
unopinionated ones (Elysia/TanStack/Next) get Clean Architecture for the core.
Researched against each framework's official docs.

Mechanism: applyPresets() resolves + deep-merges fragments before zod; a shared
_clean-arch-base builder removes duplication; UnknownPresetError gives a
'did you mean' hint (exit 2).

DX: 'arch-contract presets [name]' lists/shows presets; 'init --preset <name>'
scaffolds. Engine: implemented namespaceExport/star-export detection (was a
silent no-op). Per-preset docs under docs/presets/.

351 tests (merge, per-preset resolution + behavioral compliant/violating, DX);
self-dogfooded.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@leofmarciano
leofmarciano merged commit c34e5a1 into main Jun 8, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant