Skip to content

Architecture Overview

The docs/ARCHITECTURE.md file is an optional configuration that customizes how agents generate and review code in your project. When present, all agents follow its patterns. When absent, agents use generic best practices for your framework.

Optional

Use specialist-agent detect to analyze your project and generate an architecture guide. You can also create docs/ARCHITECTURE.md manually.

How It Works

  1. Run specialist-agent detect to analyze and generate docs/ARCHITECTURE.md
  2. Agents check if the file exists before every action
  3. If found, they follow its patterns for code generation and review
  4. If not found, they use generic best practices
  5. Edit the file anytime to change agent behavior — no restart needed

Default Pattern

When docs/ARCHITECTURE.md is installed, it provides a four-layer architecture as a starting point. This is not mandatory — you can edit or replace it with any pattern that fits your project (Clean Architecture, Hexagonal, DDD, Feature-Sliced Design, or your own).

LayerDoesDoes NOT
ServiceHTTP callstry/catch, transformation, logic
AdapterParse API ↔ App (snake_case → camelCase)HTTP, side effects
LogicOrchestrate service + adapter + stateRender UI
State StoreClient state (UI, filters, preferences)Server state, HTTP
ComponentUI + compositionHeavy business logic

Framework Equivalents

Each framework has its own terminology and idiomatic tools. The table below shows common choices — not prescriptions. Use whatever fits your project:

LayerVueReactNext.jsSvelteKitAngularAstroNuxt
LogicComposableHookHook / Server ActionLoad functionService + inject()EndpointComposable / useFetch
Client statePinia, etc.Zustand, Redux, etc.Zustand, etc.Svelte storesSignals, NgRxPinia / useState
Server stateVue Query, etc.React Query, SWR, etc.RSC, React Query, etc.SvelteKit loadHttpClient, etc.useFetch / useAsyncData
ComponentSFC (.vue)JSX (.tsx)JSX (.tsx).svelteStandalone component.astro / IslandsSFC (.vue)

Modular Structure

Every feature is a self-contained module:

text
src/modules/[feature]/
├── components/     ← UI
├── logic/          ← Orchestration (hooks, composables, load functions)
├── services/       ← Pure HTTP (no try/catch)
├── adapters/       ← Parsers (API ↔ App)
├── stores/         ← Client state only
├── types/          ← .types.ts (API) + .contracts.ts (App)
├── views/          ← Pages
├── __tests__/      ← Tests
└── index.ts        ← Barrel export (public API)

Import Rules

  • Modules → Shared: Allowed
  • Modules → Modules: Never (move shared code to shared/)
  • App → Modules: Router and registration only

Naming Conventions

Files

TypePatternExample
Directorieskebab-caseuser-settings/
ComponentsPascalCaseUserSettingsForm
Views / PagesPascalCaseMarketplaceView
Logic (hooks, etc.)use + PascalCase.tsuseProductsList.ts
Serviceskebab-case-service.tsproducts-service.ts
Adapterskebab-case-adapter.tsproducts-adapter.ts
Typeskebab-case.types.tsproducts.types.ts
Contractskebab-case.contracts.tsproducts.contracts.ts

Code

TypePatternExample
Variables / functionscamelCasegetUserById, isLoading
Types / InterfacesPascalCaseUserProfile, Product
ConstantsUPPER_SNAKE_CASEAPI_BASE_URL, MAX_RETRIES
Booleansis/has/can/shouldisLoading, hasPermission
Event handlershandle + actionhandleSubmit, handleDelete

Key Patterns

  • Stop Prop Drilling: Use composition patterns native to your framework
  • Utils vs Helpers: Utils = pure functions, Helpers = functions with side effects
  • Error Handling: Centralized in the logic layer
  • SOLID: Each file = 1 responsibility

Without ARCHITECTURE.md

When no docs/ARCHITECTURE.md is present:

  • Agents work normally — they fall back to generic patterns for your framework
  • @planner notes the absence and uses generic patterns
  • @builder generates code using standard framework conventions
  • @reviewer reviews against general best practices

To add it later:

bash
# Copy from your installed framework pack
cp node_modules/specialist-agent/packs/{framework}/ARCHITECTURE.md docs/ARCHITECTURE.md

Deep Dive

  • Layers — Detailed examples of each layer
  • Components — Component patterns and composition
  • Full reference: docs/ARCHITECTURE.md in your project (if installed)