agentleFS
INERATEINERATE/atelier/skills/structure-law/SKILL.md

structure-law

Skill2 starsChanged 53 days agoMITView on GitHub

The Atelier Structure Law — canonical, industrial-standard file structures per stack (Next.js, FastAPI, monorepo, full platform), naming rules, and the intake questions that settle layout once. Load before scaffolding or moving files.

  • Reads credentials

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Every stack has ONE canonical layout.

    line 8

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill 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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Structure Law

Every stack has ONE canonical layout. Repos never invent their own. Structure is settled at intake and recorded in projects — never re-litigated per task.

The structure ladder (pick by project size, once)

There is no single "correct" structure — there is one correct structure per project size. Climb only as far as the project demands:

Project shapeStructure
Portfolio, practice app, tiny siteFlat — src/{components,pages,assets}
Medium app, small teamType-based — src/{components,hooks,services,utils,context,pages,types}
Production app, SaaS, dashboardsFeature-based — src/features/<name>/{components,hooks,api,pages,types,index.ts} + shared/ layouts/ routes/
Design system / component libraryAtomic — components/{atoms,molecules,organisms,templates,pages}
Large multi-domain SaaS / enterpriseDomain-driven — src/modules/{users,orders,payments,…}

Rules of the ladder:

  • Feature-based is the production default. Related files stay together; features ship and delete as units. Type-based scatters one feature across seven folders — acceptable only below ~30 components.
  • Atomic only for reusable component libraries. In a product app it forces "is this a molecule or organism?" debates that produce zero user value.
  • Never scaffold a higher rung "for later" — a flat project moves to feature-based when the second real feature lands, not before (ponytail).
  • Each feature exports through its own index.ts; nothing deep-imports across features. But no giant root barrels — one index.ts re-exporting the world breaks tree-shaking and creates circular imports.
  • Colocate what only one route uses (App Router: _components/ inside the route). Promote to shared/ on second use, never on first.

Intake questions (asked once)

  1. Frontend and backend: separate repos or one? (default: one repo, separated apps)
  2. Multiple frontends? → Turborepo monorepo. Single app? → plain Next.js.
  3. Frontend folder name: frontend/ or product name? (default: apps/<name>)
  4. Model serving / workers as separate services? (default: yes if AI/ML or long jobs exist)

Next.js app (App Router)

app/            # routes; server components by default
components/     # one component per file; ui/ for primitives
hooks/          # use*.ts
lib/            # pure utils, api clients, auth
services/       # domain logic calling APIs
public/         # assets: images/ fonts/ icons/ (industry conventions)
styles/         # globals.css, tokens

Turborepo monorepo (multiple frontends)

apps/           # app/ marketing/ studio/ admin/ … (one Next.js app each)
packages/       # ui/ auth/ config/ types/ eslint-config/
turbo.json  pnpm-workspace.yaml

FastAPI backend

app/
  api/v1/endpoints/   # thin route handlers
  services/           # business logic, LLM/external APIs
  core/               # config, db, redis, security — no business logic
  workers/            # celery tasks
  models/  schemas/   # SQLAlchemy | Pydantic
database/schema.sql   # single source of truth

Full platform (frontend + backend + ML + infra)

apps/{frontend…, backend-api, worker, model-serving}
packages/   docs/   infra/{docker, cloudflared}   scripts/   .github/workflows/
docker-compose.yml   .env.example   README.md

Naming conventions

WhatConventionExample
Folders (frontend + backend)kebab-caseuser-profile/, order-history/
React component filesPascalCase.tsx, filename = exportUserCard.tsx
HookscamelCase, use prefixuseAuthSession.ts
Non-component TS/JS filescamelCaseformatCurrency.ts
Python files/functions/varssnake_caseuser_service.py, get_user_by_id()
Python classesPascalCaseclass UserService:
DB tables/columnssnake_case, tables pluralusers, order_items, created_at
API route segmentskebab-case, plural nouns/api/v1/user-profiles/{id}
Env varsSCREAMING_SNAKE_CASEDATABASE_URL
ConstantsSCREAMING_SNAKE_CASEMAX_RETRIES

One convention per language, applied everywhere — a mixed-case codebase is a review failure, not a style choice.

Rules

  • URL pattern for APIs: /api/v1/{feature}/{action} (path versioning — the default, what Stripe/GitHub/most SaaS expose publicly). Bump to /v2 only on a breaking change; additive fields never bump. Alternative seen at scale (Stripe internally): a date-based version header instead of a path segment — only reach for it if you truly need per-customer version pinning; path versioning is simpler and is the default. Keep endpoints thin, logic in services.
  • public/ mirrors industry conventions; docs live in docs/, never scattered.
  • Shared code goes to packages//lib/ on second use — DRY is structural.
  • Env: every var documented in .env.example; secrets never committed.
  • New file? It has exactly one obvious home in the trees above. If it doesn't, the task is misdesigned — stop and fix the plan.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.