Section 02 · 8 rules

Project structure

src/
  app/              entry, providers, navigation root
  features/
    <feature>/      named by product domain: gold, transfer, profile
      screens/
      components/
      hooks/
      api/
      types.ts
      index.ts      the feature's public API
  shared/
    ui/             primitives + slot templates
    lib/            API client, formatters, analytics, storage
    hooks/          generic hooks only (useDebounce)
    theme/          design tokens
  • S1 MUST put new feature code under src/features/<feature>/, named by product domain, never by type (features/gold, not features/cards).
  • S2 MUST keep imports one-way. NEVER import app/ from a feature, and NEVER import features/ from shared/.
  • S3 NEVER import another feature’s internals. Cross-feature use goes through that feature’s index.ts only. If two features keep needing each other, stop and ask the human: merge them, or move the shared part.
  • S4 SHOULD create only the subfolders a feature needs. A one-screen feature can be PromoScreen.tsx + index.ts.
  • S5 MUST, with Expo Router, keep route files in the root app/ thin: import the screen from its feature, no logic in the route file.
  • S6 NEVER restructure existing code unasked. If the repo is type-based (screens/, components/ at the top), ask once whether new work follows the existing layout or starts features/, then follow the answer.
  • S7 MUST stay a single app. NEVER add workspaces or a monorepo unless a second app or web target exists and the human asks for it.
  • S8 MUST name files consistently: components PascalCase.tsx, one exported component per file; hooks useThing.ts; everything else camelCase.ts.

Enforcement grows with the team. The agent applies the current level and NEVER moves up a level on its own; it suggests the next level when the trigger shows.

Level When Boundary enforcement
Starter 1–3 devs S1–S8 by convention and review
Growing 4–10 devs, or a cross-feature break has happened Lint import-x/no-restricted-paths or eslint-plugin-boundaries, as warn first, error at zero violations
Scale 10+ devs or several squads Lint as error, CODEOWNERS per feature, shared/ owned by a core team