一键导入
architecture-ref
Architecture patterns and structure reference. Load when creating endpoints, features, designing folder structure, or asking about architecture.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Architecture patterns and structure reference. Load when creating endpoints, features, designing folder structure, or asking about architecture.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | architecture-ref |
| description | Architecture patterns and structure reference. Load when creating endpoints, features, designing folder structure, or asking about architecture. |
| user-invocable | false |
Quick reference for project architecture conventions. Auto-loaded for structural decisions.
Read .claude/project.config.json and scan src/ structure to identify the pattern in use:
| Pattern | Indicators | Structure |
|---|---|---|
| Vertical Slicing | Feature folders with all layers inside | src/{domain}/{slice}/ |
| Layered | Separate folders per layer | src/controllers/, src/services/ |
| Feature-based | Features grouped but layers separated inside | src/features/{name}/ |
| DDD | Domain-driven with bounded contexts | src/domain/, src/application/ |
Glob: src/**/
src/{name}/{name}.controller.* + src/{name}/{name}.service.* → Vertical Slicingsrc/controllers/ + src/services/ + src/models/ → Layeredsrc/features/{name}/ → Feature-basedsrc/domain/ + src/application/ + src/infrastructure/ → DDDsrc/
├── {domain}/ # Business domain
│ ├── {slice}/ # One slice per use case
│ │ ├── {slice}.controller.*
│ │ ├── {slice}.service.*
│ │ ├── {slice}.dto.*
│ │ ├── {slice}.spec.*
│ │ └── anatomy.md # Slice documentation
│ │
│ ├── domain/ # Domain entities and contracts
│ │ ├── {entity}.entity.*
│ │ └── {entity}.repository.* # Interface
│ │
│ └── {domain}.module.* # Domain module
│
└── shared/ # Cross-cutting concerns
├── database/
├── guards/
├── decorators/
└── utils/
src/
├── controllers/ # HTTP layer
├── services/ # Business logic
├── models/ # Data models
├── middleware/ # Request pipeline
├── utils/ # Shared utilities
└── config/ # Configuration
src/
├── features/ # Business domains
│ └── {domain}/
│ ├── {slice}/
│ │ ├── {Slice}Page.*
│ │ ├── {Component}.*
│ │ ├── use{Hook}.*
│ │ ├── {slice}.schema.*
│ │ └── index.*
│ └── shared/ # Domain-shared components
│
├── shared/ # Cross-cutting
│ ├── components/
│ ├── lib/
│ ├── hooks/
│ └── types/
│
└── app/ # Routing / entry point
ALLOWED:
- /{domainA}/ can import from /shared/
- /{domainA}/{slice}/ can import from /{domainA}/domain/
- /{domainA}/ can import from /{domainB}/domain/ (interfaces only)
FORBIDDEN:
- /{domainA}/ CANNOT import from /{domainB}/{slice}/ (implementation)
- Slices CANNOT import from other slices in the same domain
- /shared/ NEVER imports from domains
FLOW:
Slices → Domain → Shared
| Type | Max Lines | If Exceeded |
|---|---|---|
| Service/Use Case | ~100 lines | Split into sub-cases |
| Controller/Route | ~150 lines | Create sub-controllers |
| Component (UI) | ~150 lines | Extract sub-components |
| Hook/Composable | ~80 lines | Split responsibilities |
| DTO/Schema | ~50 lines | One DTO per file |
| Any file | ~400 lines | Must split (configurable in project.config.json) |
ONE pattern per area. Do not mix competing solutions.
| Area | Pick ONE | Document in |
|---|---|---|
| Server state | (e.g., TanStack Query, SWR, Apollo) | docs/architecture.md |
| Forms | (e.g., react-hook-form, Formik, native) | docs/architecture.md |
| Validation | (e.g., Zod, Yup, Joi, class-validator) | docs/architecture.md |
| Styling | (e.g., Tailwind, CSS Modules, styled-components) | docs/architecture.md |
| API Client | (e.g., Axios, fetch wrapper, generated client) | docs/architecture.md |
| Routing | (e.g., constants file, type-safe routes) | docs/architecture.md |
Once chosen, prohibit alternatives in the same area. Document the chosen pattern and why.
Each new feature/slice SHOULD include an anatomy.md:
# Anatomy: {Slice Name}
> **Domain**: {domain name}
> **Type**: {CRUD | Process | Query | Integration}
## Purpose
{What business problem this solves}
## Data Flow
{ASCII diagram or description}
## Business Rules
{List of rules}
## File Structure
| File | Responsibility |
|------|---------------|
| `{slice}.controller.*` | HTTP handling |
| `{slice}.service.*` | Business logic |
| `{slice}.dto.*` | Input/output shapes |
| `{slice}.spec.*` | Tests |
.claude/project.config.jsondocs/architecture.md.claude/MANUAL.mdFinish feature with tests, commit, and session closure
Start feature with branch and session tracking
Interactive wizard to configure the project
System-wide code audit with 8 modules
Environment-aware deployment with pre/post checks
Methodical codebase exploration and understanding