Skip to content

Commit 3f558b7

Browse files
committed
add claude instructions
1 parent 31a69f7 commit 3f558b7

File tree

1 file changed

+81
-0
lines changed

1 file changed

+81
-0
lines changed

CLAUDE.md

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Project Structure
6+
7+
This is a Moleculer CLI template for TypeScript projects that generates microservices-based applications. The main template files are located in the `template/` directory, which contains the actual project structure that gets generated when users run `moleculer init project-typescript my-project`.
8+
9+
Key directories:
10+
- `template/` - Contains the actual template files that get generated for new projects
11+
- `template/services/` - Moleculer services (API Gateway, business services)
12+
- `template/mixins/` - Reusable service mixins (database mixin)
13+
- `template/test/` - Test files organized by integration/unit tests
14+
- `test/ci/` - CI test configurations and answer files for automated testing
15+
16+
## Common Commands
17+
18+
**Development of template:**
19+
- `npm run dev` - Initialize template into `tmp/` directory for local testing
20+
- `npm run dev:demo` - Initialize with demo answers for quick testing
21+
- `npm test` - Run CI test with automated answers
22+
- `cd tmp && node node_modules/moleculer/bin/moleculer-runner services` - Start generated services
23+
24+
**Generated project commands (in template/package.json):**
25+
- `npm run dev` - Start development mode with hot-reload and REPL
26+
- `npm run start` - Start production mode
27+
- `npm run build` - Compile TypeScript to JavaScript
28+
- `npm test` - Run tests with coverage using Vitest
29+
- `npm run ci` - Run tests in watch mode
30+
- `npm run lint` - Run ESLint (when enabled)
31+
- `npm run lint:fix` - Auto-fix ESLint issues
32+
33+
## Template Architecture
34+
35+
The template uses Handlebars templating (`{{#condition}}`, `{{variable}}`) to conditionally generate code based on user selections during `moleculer init`:
36+
37+
**Key template variables:**
38+
- `{{projectName}}` - User's project name
39+
- `{{#apiGW}}` - Include API Gateway service
40+
- `{{#dbService}}` - Include database services and mixins
41+
- `{{#lint}}` - Include ESLint configuration
42+
- `{{transporter}}` - Selected message transporter (NATS, Redis, etc.)
43+
- `{{#needChannels}}` - Include Moleculer Channels middleware
44+
- `{{#needWorkflows}}` - Include Moleculer Workflows middleware
45+
46+
**Core services generated:**
47+
- `api.service.ts` - API Gateway with HTTP/GraphQL/Socket.IO support
48+
- `greeter.service.ts` - Sample service with basic actions
49+
- `products.service.ts` - Database service example
50+
- `inventory.service.ts` - Channels middleware example
51+
- `orders.service.ts` - Workflows middleware example
52+
53+
## Database Configuration
54+
55+
The `db.mixin.ts` provides database abstraction:
56+
- **Development:** Uses NeDB file storage (`./data/${collection}.db`)
57+
- **Testing:** Uses in-memory NeDB
58+
- **Production:** Uses MongoDB when `DB_URI` environment variable starts with `mongodb://`
59+
60+
## Testing Framework
61+
62+
- Uses **Vitest** instead of Jest for modern testing
63+
- Test structure: `test/unit/` and `test/integration/`
64+
- Coverage configuration in `vitest.config.ts`
65+
- Supports both unit tests for individual services and integration tests for API endpoints
66+
67+
## TypeScript Configuration
68+
69+
- **Target:** ESNext with NodeNext module resolution
70+
- **Build output:** `dist/` directory with CommonJS modules for production
71+
- **Type checking:** Strict mode enabled
72+
- **Development:** Uses `tsx` for running TypeScript directly
73+
74+
## Development Notes
75+
76+
When modifying templates:
77+
1. Test changes using `npm run dev` to generate in `tmp/`
78+
2. Verify CI tests still pass with `npm test`
79+
3. Template uses Handlebars syntax - be careful with conditional blocks
80+
4. The `meta.js` file contains template metadata and prompts configuration
81+
5. Answer files in `test/ci/` define automated test scenarios

0 commit comments

Comments
 (0)