Harness Intelligence Wiki
Grilling

Frontend Composition Layer Brainstorm Brief

Frontend Composition Layer Brainstorm Brief

Context

  • Source: user /brainstorm direction, 2026-10-22, T3 thread on frontend-domain-structure.
  • User direction, verbatim: "we have a soup of weird mixed modules etc... when instead we should bring a proper strucutre of frontend code that tighlty follows our /frontend-domain-structure" and "we need the same kind of convention in frontend domain structure skill to enable the highest abastraction module layer, where we combine modules and features for stuff like shells, provider. in general compositions that go into actual pages".
  • System under change: wearedevpunks/skills skills/agnostic/frontend/frontend-domain-structure/ (SKILL.md, references/structure.md, references/react/structure.md) at 21a3cac, plus a new managed lint asset for the frontend Pack in apps/cli.
  • Evidence repositories, read at latest main: pegasus@bf896c7, apito@3b59cee, emera@b1e86e1, assolombarda@0da85a7, ci-app@973e1843.

Problem

The current skill places shells, layouts and providers in framework composition (app/), and forbids modules from importing features. A shell or provider that combines features therefore has no legal owner. Agents place it in features/, components/ or a catch-all modules/.

RepositoryComposition todayObserved damage
pegasusroot/ + templates/{layout,pages} above features/; order in ARCHITECTURE.md, enforced by apps/web/src/architecture.test.tsmodules/ catch-all (staff login workflow, filterCatalog policy, shell UI, worst-case dev dataset loaded by production modules); templates deep-import features; test misses relative imports
apitofeatures/area-riservata/shell, 4 page-frame.tsx, dashboard/registry.tsx, components/providers.tsxfeatures import shell 24×, shell imports chat/session; company↔dashboard and company↔profilo cycles; site-remake-prototype is the live site and a data source
emeraportal/{delta,forms,shell,screens}, portal-provider, features/search/use-corpus15-file cycle; 64 peer-feature imports; 27 upward feature→shell/screens imports
assolombardashell intranet/home-prototype; components/providers.tsx imports features; 11 identical layout.tsxmock/ owns real state machines; *-prototype dirs are production UI; 17 peer prototype imports
ci-appfe-studio runtime → builtins → contents/features → modules; dashboard routes → root/layouts/page-templates → features → entitieslayer exists under different names per app; few reverse edges; no frontend lint enforcement

ci-app backend declares ... → platform → features → app → composition (apps/backend/AGENTS.md:9); its architecture lint plugin exists but is not enabled. Its abstractions/ is a bottom contract layer; the user scoped that meaning out of this topic.

Accepted Shape

  1. Layer order: app → composition → features → modules → integrations. Each layer imports only lower layers.
  2. Routes in app/ import only composition/.
  3. composition/ owns app-wide providers, surface shells, page templates, and cross-feature registries and aggregators.
  4. A surface is a subfolder of composition/ only (composition/site/, composition/admin/). Features stay flat.
  5. Features never import peer features. The nearest composition that holds both connects them through props, slots or callbacks.
  6. A shell splits: what features consume (navigation registry, header slot, toast or assistant channel) is a module; the shell assembly is composition.
  7. Mock data, demo data and fake runtimes are integrations. Only composition or tests select them. No production UI lives in a folder named "prototype".
  8. Layer folder names are fixed; the skill drops "These labels may differ between projects".
  9. A custom lint rule enforcing the structure is mandatory and ships as a lint asset of the frontend Pack.
  10. Only the skill changes. Each repository migrates later by running the skill.

Rejected Shapes

  • Top layer named abstractions/ or root/ + templates/: user chose composition/.
  • Features nested by surface (features/<surface>/<feature>) and surface mini-apps: user chose surface folders inside composition/ only.
  • Modules as the deepest layer without integrations/: user reversed to keep integrations/.
  • Routes importing module readers directly: user chose composition only.
  • Recommended (not mandatory) enforcement; skill-shipped lint script.

Open Forks

  1. What the lint rule checks: layer order, peer-feature ban, public entrypoints only, relative imports, "prototype" folder names. Proposed default: all five.
  2. Where app-local shared presentation goes (pegasus ui/) and at what level. Proposed default: no app-local ui/; reusable primitives live in the shared UI package, app-specific presentation lives with its owner.
  3. Where server code inside a Next app goes (pegasus server/api, app/api handlers). Proposed default: outside this layer model, governed by effect-backend-structure; app/api handlers import only server/.
  4. Route data under accepted shape 2: notFound, generateMetadata and data readers come through composition entrypoints. Proposed default: accept.
  5. Canonical glossary for Surface, Composition and the four layer names.
  6. Cross-skill ripple: contract test, create-plan architecture convergence, implement-spec architecture conformance, ask-hi references move with the skill.

On this page