xiaohongshu
xiaohongshu
[PROJECT] file and directory structure conventions and enforcement
Full skill instructions
Template for project-specific file organization skill Define WHERE every type of file belongs in your codebase
Project: [PROJECT NAME] Structure Type: [CUSTOMIZE: Monorepo / Multi-repo / Monolith / Microservices] Last Updated: [DATE]
[CUSTOMIZE WITH YOUR PROJECT LAYOUT]
[PROJECT-ROOT]/
├── [CUSTOMIZE: backend/ or src/main/ or app/]
├── [CUSTOMIZE: frontend/ or client/ or web/]
├── [CUSTOMIZE: shared/ or common/ or libs/]
├── [CUSTOMIZE: tests/ or test/]
├── [CUSTOMIZE: docs/]
├── [CUSTOMIZE: scripts/]
├── [CUSTOMIZE: .github/ or .gitlab/]
└── [CUSTOMIZE: docker/]
Example (Monorepo):
project-root/
├── backend/ # Spring Boot backend
├── frontend/ # React frontend
├── shared/ # Shared types, utils
├── docs/ # Documentation
├── scripts/ # Build scripts
└── .github/ # CI/CD workflows
Example (Backend-only):
project-root/
├── src/
│ ├── main/
│ └── test/
├── docs/
└── .github/
[CUSTOMIZE WITH YOUR BACKEND ORGANIZATION]
Base Path: [CUSTOMIZE: src/main/java/com/company/ or src/ or app/]
Directory Layout:
[CUSTOMIZE: Show your backend structure]
Example (Java Spring Boot):
src/main/java/com/company/projectname/
├── controller/ # REST controllers ONLY
│ ├── UserController.java
│ └── OrderController.java
├── service/ # Business logic ONLY
│ ├── UserService.java
│ └── OrderService.java
├── repository/ # Data access ONLY
│ ├── UserRepository.java
│ └── OrderRepository.java
├── entity/ # JPA entities ONLY
│ ├── User.java
│ └── Order.java
├── dto/ # Data transfer objects ONLY
│ ├── UserDTO.java
│ ├── UserCreateRequest.java
│ └── UserUpdateRequest.java
├── exception/ # Custom exceptions ONLY
│ ├── UserNotFoundException.java
│ └── DuplicateEmailException.java
├── config/ # Configuration classes
│ └── SecurityConfig.java
└── util/ # Utility classes
└── DateUtil.java
Example (Node.js/Express):
src/
├── controllers/ # Route handlers
├── services/ # Business logic
├── repositories/ # Database access
├── models/ # Mongoose/Sequelize models
├── dto/ # Request/response types
├── middleware/ # Express middleware
├── config/ # Configuration
└── utils/ # Utilities
Example (Python/Django):
app/
├── views/ # ViewSets
├── serializers/ # DRF serializers
├── models.py # Django models
├── services/ # Business logic
├── exceptions.py # Custom exceptions
└── utils/ # Utilities
Controllers/Routes:
Services/Business Logic:
Repositories/Data Access:
Entities/Models:
DTOs/Request-Response:
Exceptions/Errors:
Configuration:
Utilities/Helpers:
[CUSTOMIZE WITH YOUR FRONTEND ORGANIZATION]
Base Path: [CUSTOMIZE: src/ or app/]
Organization Pattern: [CUSTOMIZE: By-feature / By-type / Atomic design / Hybrid]
Example - By-Type (Traditional):
[CUSTOMIZE: Show your frontend structure]
Example (React):
src/
├── components/ # Reusable components ONLY
│ ├── common/ # Shared (Button, Card, Badge)
│ ├── layout/ # Layout components (Header, Sidebar)
│ └── features/ # Feature-specific (UserList, ProductCard)
├── pages/ # Page components ONLY
│ ├── Dashboard.tsx
│ ├── Users.tsx
│ └── Settings.tsx
├── services/ # API clients ONLY
│ ├── UserService.ts
│ └── api.ts
├── hooks/ # Custom hooks ONLY (React)
│ ├── useUsers.ts
│ └── useAuth.ts
├── contexts/ # React Context providers ONLY
│ └── AuthContext.tsx
├── types/ # TypeScript types/interfaces ONLY
│ ├── User.ts
│ └── api.types.ts
├── utils/ # Utility functions ONLY
│ ├── format.ts
│ └── validation.ts
├── assets/ # Static assets ONLY
│ ├── images/
│ ├── fonts/
│ └── styles/
└── config/ # Configuration ONLY
└── constants.ts
Example (Angular):
src/app/
├── components/ # Standalone components
├── pages/ # Page components
├── services/ # Injectable services
├── guards/ # Route guards
├── interceptors/ # HTTP interceptors
├── models/ # TypeScript interfaces
├── pipes/ # Custom pipes
└── directives/ # Custom directives
Example (Vue):
src/
├── components/ # Vue components
├── views/ # Page views
├── composables/ # Composition functions
├── stores/ # Pinia stores
├── router/ # Vue Router
├── types/ # TypeScript types
└── assets/ # Static assets
Example - By-Feature (Modern):
src/
├── features/
│ ├── users/
│ │ ├── components/ # UserList, UserCard
│ │ ├── services/ # UserService
│ │ ├── hooks/ # useUsers
│ │ ├── types/ # User types
│ │ └── tests/ # Feature tests
│ └── products/
│ ├── components/
│ ├── services/
│ └── ...
├── shared/ # Shared across features
│ ├── components/ # Button, Card
│ ├── hooks/ # useApi
│ └── utils/
└── core/ # App-level
├── layout/
├── routing/
└── config/
Components:
Pages/Views:
Services/API Clients:
Hooks/Composables (if applicable):
Types/Interfaces:
Utilities:
Assets (Images, Fonts, Global CSS):
[CUSTOMIZE WITH YOUR TEST ORGANIZATION]
Co-located (next to source):
[CUSTOMIZE if using co-located tests]
Example:
src/services/
├── UserService.ts
├── UserService.test.ts <- Next to source
Separate Test Directory:
[CUSTOMIZE if using separate test dirs]
Example:
src/services/UserService.ts
test/services/UserService.test.ts <- Mirrors structure
Convention: [CUSTOMIZE: .test.ts / .spec.ts / Test.java / _test.py / _spec.rb]
Examples:
[CUSTOMIZE WITH YOUR CONFIG ORGANIZATION]
Where Config Files Go:
| File Type | Location | Example |
|---|---|---|
| Environment vars | [CUSTOMIZE: .env / config/ / env/] | .env.development |
| App config | [CUSTOMIZE: config/ / src/config/] | database.config.ts |
| CI/CD | [CUSTOMIZE: .github/workflows/ / .gitlab-ci.yml] | ci.yml |
| Docker | [CUSTOMIZE: root / docker/] | Dockerfile, docker-compose.yml |
| Package manager | [CUSTOMIZE: root] | package.json, pom.xml |
| Linting | [CUSTOMIZE: root] | .eslintrc.json, .prettierrc |
| TypeScript | [CUSTOMIZE: root] | tsconfig.json |
[CUSTOMIZE WHERE BUILD ARTIFACTS GO]
Backend:
Frontend:
Rules:
[CUSTOMIZE WITH PROJECT-SPECIFIC VIOLATIONS]
NEVER DO:
ALWAYS DO:
[CUSTOMIZE WITH PROJECT STANDARDS]
Controllers: [CUSTOMIZE: UserController.java / users.controller.ts / user_controller.py] Services: [CUSTOMIZE: UserService.java / user.service.ts / user_service.py] Repositories: [CUSTOMIZE: UserRepository.java / user.repository.ts] Entities: [CUSTOMIZE: User.java / user.entity.ts / user.model.ts] DTOs: [CUSTOMIZE: UserDTO.java / user.dto.ts / UserCreateRequest.java] Tests: [CUSTOMIZE: UserServiceTest.java / user.service.test.ts]
Components: [CUSTOMIZE: UserList.tsx / user-list.component.ts / UserList.vue] Pages: [CUSTOMIZE: Dashboard.tsx / dashboard.page.ts] Services: [CUSTOMIZE: UserService.ts / user.service.ts] Hooks: [CUSTOMIZE: useUsers.ts / use-users.ts] Types: [CUSTOMIZE: User.ts / user.types.ts / IUser.ts] Styles: [CUSTOMIZE: UserList.module.css / user-list.component.css / UserList.styles.ts]
[CUSTOMIZE WITH ENFORCEMENT RULES]
Rule 1: One Concern Per Directory
Rule 2: Consistent Depth
Rule 3: Test Mirror Source
src/service/UserService.javaRule 4: No Code in Root
project-root/UserController.java[CUSTOMIZE: Add more rules]
If file in wrong location:
[CUSTOMIZE: Show how to reorganize]
Example:
# Found: src/UserController.java (WRONG - in root of src/)
# Should: src/controller/UserController.java
# Action:
mkdir -p src/controller
mv src/UserController.java src/controller/
# Update imports in other files
Pattern:
[CUSTOMIZE: Show bulk move commands]
Example:
# Find all controllers in wrong places
find src -name "*Controller.java" -not -path "*/controller/*"
# Move to correct location
[CUSTOMIZE WITH IMPORT RULES]
Convention:
[CUSTOMIZE: Show import organization]
Examples:
1. Standard library imports
2. Third-party imports
3. Internal imports (relative)
OR:
1. Framework imports (React, Angular, Django)
2. Third-party libraries
3. Internal absolute imports
4. Internal relative imports
5. Type imports (TypeScript)
Configured Aliases:
[CUSTOMIZE: List path aliases if used]
Examples:
- @/components -> src/components
- @/services -> src/services
- ~/utils -> src/utils
[CUSTOMIZE WITH SPECIAL FOLDERS]
Location: [CUSTOMIZE: generated/ or .generated/ or codegen/] Rule: Never edit manually, always in .gitignore
Location: [CUSTOMIZE: db/migrations/ or migrations/ or alembic/versions/] Naming: [CUSTOMIZE: V1__create_users.sql or 001_create_users.py]
Location: [CUSTOMIZE: db/seeds/ or fixtures/ or test/fixtures/]
[CUSTOMIZE WITH PROJECT STANDARDS]
Recommended Limits:
When to Split:
[CUSTOMIZE - COMPLETE MAPPING]
| File Type | Exact Location | Naming Pattern | Example |
|---|---|---|---|
| REST Controller | [CUSTOMIZE] | [CUSTOMIZE] | UserController.java |
| Service Class | [CUSTOMIZE] | [CUSTOMIZE] | UserService.java |
| Repository | [CUSTOMIZE] | [CUSTOMIZE] | UserRepository.java |
| Entity | [CUSTOMIZE] | [CUSTOMIZE] | User.java |
| DTO (Request) | [CUSTOMIZE] | [CUSTOMIZE] | UserCreateRequest.java |
| DTO (Response) | [CUSTOMIZE] | [CUSTOMIZE] | UserDTO.java |
| Custom Exception | [CUSTOMIZE] | [CUSTOMIZE] | UserNotFoundException.java |
| React Component | [CUSTOMIZE] | [CUSTOMIZE] | UserList.tsx |
| React Page | [CUSTOMIZE] | [CUSTOMIZE] | Dashboard.tsx |
| API Service | [CUSTOMIZE] | [CUSTOMIZE] | UserService.ts |
| Custom Hook | [CUSTOMIZE] | [CUSTOMIZE] | useUsers.ts |
| Type Definition | [CUSTOMIZE] | [CUSTOMIZE] | User.ts |
| Utility Function | [CUSTOMIZE] | [CUSTOMIZE] | formatDate.ts |
| Test File | [CUSTOMIZE] | [CUSTOMIZE] | UserService.test.ts |
| Config File | [CUSTOMIZE] | [CUSTOMIZE] | database.config.ts |
[CUSTOMIZE WITH VALIDATION STEPS]
Run before committing:
[CUSTOMIZE - ADD YOUR CONVENTIONS]
Backend Quick Lookup:
Frontend Quick Lookup:
Customization Complete: Replace all [CUSTOMIZE] sections with project structure.
Auto-generated by: /add-skill file-organization command (via codebase analysis)
Used by: project-structure-manager agent (consulted before file creation)
xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience