Cupid app architecture

From different-ai/the-factory · View interactive version

Cupid app architecture is an AI agent skill from the GitHub repository different-ai/the-factory. CUPID app architecture guidance for apps/app/src/app/**

How to use this skill

Skill file

Purpose

Use this skill when changing ownership, file placement, or structure inside apps/app/src/app/**.

This is an incremental migration guide, not a rewrite mandate.

Goals:

Applies to

Do not use this skill to justify broad rewrites. Move one coherent slice at a time.

Core rules

Target domain map

Use these domains for apps/app/src/app/** work:

shell

Owns app-wide composition only:

Examples today:

Shell should orchestrate domains, not absorb their feature logic.

workspace

Owns workspace lifecycle and workspace-scoped controls:

Examples today:

session

Owns active task/session experience:

Examples today:

connections

Owns connections to external capabilities and providers:

Examples today:

Practical rule:

automations

Owns scheduled or repeatable work setup:

Examples today:

cloud

Owns hosted OpenWork and Den-specific flows:

Examples today:

app-settings

Owns app-wide preferences and local app controls:

Examples today:

kernel

Kernel is the smallest shared layer.

Only put code here when all of the following are true:

Good fits:

Bad fits:

Ownership rules

Use these defaults when deciding where code belongs:

If a feature has one clear user-facing owner, keep its state, view pieces, and helpers there.

Dependency direction

Prefer this direction:

shell -> domain public API -> local domain internals

Rules:

Colocation rules

Within one domain, colocate:

Do not split code across components/, context/, lib/, and utils/ just because those buckets already exist.

When touching existing generic folders, prefer creating a domain subfolder and moving only the code you are already changing.

When to keep code in shell

Keep code in shell only if it is truly app-global:

If logic answers a domain question like “how do workspaces connect?” or “how does provider auth start?”, it probably does not belong in shell.

When a new domain is warranted

Create a new domain only when the work has:

Do not create a new domain for one helper or one modal.

If the work is still clearly part of workspace/session/connections/automations/cloud/app-settings, use a subfolder there instead.

Migration heuristics

When touching existing app architecture:

  1. Identify the owning workflow.
  2. Pick the smallest slice you can move safely.
  3. Create or extend a local domain folder.
  4. Move state, view, and helpers together when practical.
  5. Leave a thin adapter behind if needed to keep imports stable.
  6. Verify behavior before considering any further cleanup.

Good incremental moves:

Bad moves:

Anti-patterns to avoid

Step-by-step refactor procedure

For app-architecture work:

  1. Confirm the exact workflow you are changing.
  2. Name the owning domain.
  3. Check whether shell is doing domain work that should move out.
  4. Move the smallest coherent slice possible.
  5. Keep public imports small and intention-revealing.
  6. Avoid behavior rewrites during moves.
  7. Run the nearest focused verification.
  8. Leave follow-up cleanup for a later change unless it directly blocks the move.

PR acceptance checklist

If the answer to several of these is “no”, stop and simplify the move.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.