Skip to content

Commit 1750164

Browse files
add agents.md
1 parent e06c3b9 commit 1750164

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

AGENTS.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
## Rules
2+
3+
### 1. File & Folder Organization
4+
- **Domain-driven structure**: Organize code by business domains (`cli/`, `registry/`, `components/`, `utils/`)
5+
- **Subfolder patterns**: Use consistent patterns (`domain/`, `routes/`, `views/`, `middleware/`)
6+
- **File naming**: Use kebab-case for all files and folders (`components-cache`, `package-json-validator`)
7+
- **Module exports**: Use `index.ts` files for clean public APIs and re-exports
8+
- **Centralized types**: Place shared TypeScript interfaces in `src/types.ts`
9+
10+
### 2. TypeScript Coding Standards
11+
- **Strict compilation**: All code must pass TypeScript strict mode checks
12+
- **Interface design**: Use comprehensive interfaces with optional properties (`?` syntax)
13+
- **Type imports**: Use `import type` for type-only dependencies
14+
- **Union types**: Use union types for constrained values (`'oc-registry' | 'oc-registry-local'`)
15+
- **Generic interfaces**: Extend base types like `PackageJson` for specialized interfaces
16+
- **Naming conventions**:
17+
- camelCase for variables/functions (`componentName`, `getComponent`)
18+
- PascalCase for interfaces/types (`Component`, `RegistryOptions`)
19+
- UPPER_CASE for constants (`DEFAULT_PORT`)
20+
21+
### 3. Code Style & Patterns
22+
- **Import organization**: Group imports (Node.js with `node:` prefix, external libraries, local modules)
23+
- **Function style**: Use arrow functions for simple operations, function declarations for main functions
24+
- **Async patterns**: Prefer async/await over Promise chains
25+
- **Object destructuring**: Use destructuring in function parameters
26+
- **Descriptive naming**: Use clear, descriptive function names (`getComponentRetrievingInfo` vs `getComp`)
27+
28+
---
29+
30+
## File Structure Enforcement
31+
32+
### Required Directory Structure
33+
```
34+
src/
35+
├── cli/
36+
│ ├── commands.ts
37+
│ ├── domain/ # Business logic
38+
│ ├── facade/ # Public APIs
39+
│ └── programmatic-api.ts
40+
├── registry/
41+
│ ├── routes/ # Express routes
42+
│ ├── domain/ # Business logic
43+
│ │ └── validators/ # Input validation
44+
│ ├── views/ # JSX components
45+
│ │ └── partials/ # Reusable components
46+
│ └── middleware/ # Express middleware
47+
├── components/ # Component implementations
48+
├── utils/ # Shared utilities
49+
├── types.ts # Centralized type definitions
50+
└── resources/ # Static resources
51+
```
52+
53+
### File Extension Rules
54+
- `.ts` for TypeScript modules and business logic
55+
- `.tsx` for React/JSX components and views
56+
- `index.ts` for module exports and public APIs
57+
58+
---

0 commit comments

Comments
 (0)