AgentSkillsCN

Project Folder Structure and Organization Understanding Capabillity

了解已完成的项目文件夹结构、架构、文件模式及类似内容,以便应用更好的解决方案和文件组织。当需要理解项目架构、文件/文件夹模式和约定时使用。

SKILL.md
--- frontmatter
name: Project Folder Structure and Organization Understanding Capabillity
description: Understand the already-done project folder structure, archtecture, file patterns, and similar, in order to apply better solutions and file organizations. Use when you need to understand the project archtecture, and file/folder patterns and conventions.

Basic Understanding

Folder Structure

code
src/
├── domain/                         # Application CORE (pure TypeScript, framework-free)
│   ├── @shared/                    # Shared between bounded contexts
│   │   ├── entities/               # Base Entity, base AggregateRoot
│   │   ├── value-objects/          # Base ValueObject, UniqueEntityId
│   │   ├── errors/                 # Base DomainError
│   │   └── either.ts               # Either pattern (Left/Right)
│   │
│   └── [bounded-context]/          # E.g.: identity, catalog, orders, billing
│       ├── enterprise/             # Enterprise Layer (entities and business rules)
│       │   ├── entities/           # Domain entities
│       │   └── value-objects/      # Specific Value Objects
│       │
│       ├── application/            # Application Layer (use cases)
│       │   ├── use-cases/          # Use cases
│       │   └── repositories/       # Repository interfaces (contracts)
│       │
│       └── errors/                 # Bounded context specific errors
│
├── infra/                          # Infrastructure implementations
│   ├── database/
│   │   ├── prisma/                 # Prisma Client, migrations
│   │   └── repositories/           # Repository implementations
│   │
│   ├── cryptography/               # Hashing, JWT, etc.
│   └── cache/                      # Redis, etc.
│
├── http/                           # HTTP Layer (NestJS)
│   ├── app.module.ts
│   ├── main.ts
│   └── [module]/                   # E.g.: auth, users, products
│       ├── controllers/            # Receives request, calls service
│       ├── services/               # Instantiates and executes use-case
│       ├── schemas/                # Zod schemas for validation
│       ├── pipes/                  # Validation pipes
│       ├── presenters/             # Transforms entity into response
│       └── [module].module.ts
│
└── env/                            # Environment configuration
    └── env.ts

Dependency Rules

code
HTTP (NestJS) --> Application (Use Cases) --> Enterprise (Entities)
      |                  |
      v                  v
   Infra  <-----------  Repositories (interfaces)

Planned Bounded Contexts

ContextResponsibility
identityUsers, authentication, permissions
[others]Define according to business needs

File Naming

TypeSuffixExample
Entity.entity.tsuser.entity.ts
Value Object.vo.tsemail.vo.ts
Use Case.use-case.tscreate-account.use-case.ts
Repository.repository.tsusers.repository.ts
Error.error.tsaccount-already-exists.error.ts
Controller.controller.tsauth.controller.ts
Service.service.tsauth.service.ts
Schema.schema.tsauth.controller.schema.ts
Presenter.presenter.tsuser.presenter.ts
Mapper.mapper.tsprisma-user.mapper.ts
Pipe.pipe.tszod-validation.pipe.ts
Guard.guard.tsauth.guard.ts
Decorator.decorator.tspublic.decorator.ts
Enum.enum.tsrole.enum.ts
Provider.provider.tsbcrypt.provider.ts

Tests

code
src/domain/[bounded-context]/application/use-cases/__tests__/
  create-account.use-case.spec.ts

src/http/[module]/__tests__/
  auth.e2e-spec.ts
  • Unit tests for use-cases (mocking repositories)
  • E2E tests for controllers

Scripts for full understanding (MUST USE)

  • Use the .claude/skills/structure_understander/scripts/read-structure.py to get recursivelly all folders and files by name, organizated in an understandable structure.