Skip to content

Commit cc254cd

Browse files
fix: address Copilot review comments
- README: fix ESLint ecmaVersion (latest), npm start description (no auto-reload), lint section (test:lint vs lint), docker image (pierreb/node) - skill/verify: use npm run test:lint instead of npm run lint - skill/naming: fix model patterns (model.mongoose.js, schema.js), optional name segment - skill/create-module: align module structure with actual tasks template (controller.js, data.service.js, model.mongoose.js, schema.js, unit+integration tests) - skill/feature: fix responses helper signature (responses.success(res, msg)(data))
1 parent 0db45bd commit cc254cd

5 files changed

Lines changed: 47 additions & 36 deletions

File tree

.claude/skills/create-module/SKILL.md

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Search and replace the following tokens across the new module:
4444

4545
Files to check in `modules/{new-module-name}/`:
4646

47-
- File names (controllers, services, repositories, models, policies, routes, tests)
47+
- File names (controllers, services, repositories, models, schemas, policies, routes, tests)
4848
- Mongoose model name and collection name
4949
- Route paths and prefixes
5050
- Joi validation schemas
@@ -66,7 +66,7 @@ Use safe search+replace to avoid false positives:
6666
### 7. Run verify
6767

6868
```bash
69-
npm run lint
69+
npm run test:lint
7070
npm test
7171
```
7272

@@ -77,30 +77,35 @@ Provide a summary:
7777
- ✅ Module created at: `modules/{new-module-name}`
7878
- ✅ Renamed tokens: `tasks``{new-module-name}`, etc.
7979
- ✅ Verification: lint passed, tests passed
80-
- 📝 Next steps: Customize the model schema, update business logic in services, register routes in `lib/services/express.js` if needed
80+
- 📝 Next steps: Customize the schema, update business logic in services, register routes in `lib/services/express.js` if needed
8181

8282
## Module Structure
8383

8484
```
8585
modules/{new-module-name}/
8686
├── controllers/
87-
│ └── {module}.crud.controller.js
87+
│ └── {module}.controller.js
8888
├── services/
89-
│ └── {module}.crud.service.js
89+
│ └── {module}.service.js
90+
│ └── {module}.data.service.js
9091
├── repositories/
9192
│ └── {module}.repository.js
9293
├── models/
93-
│ └── {module}.model.js
94+
│ └── {module}.model.mongoose.js
95+
│ └── {module}.model.sequelize.js (optional)
96+
│ └── {module}.schema.js
9497
├── policies/
95-
│ └── {module}.crud.policy.js
98+
│ └── {module}.policy.js
9699
├── routes/
97100
│ └── {module}.routes.js
98101
└── tests/
99-
└── {module}.integration.tests.js
102+
├── {module}.integration.tests.js
103+
└── {module}.unit.tests.js
100104
```
101105

102106
## Notes
103107

104108
- Preserves the layered architecture: controllers → services → repositories → models
105109
- Follows modularity rules: keeps the module self-contained
106110
- Policy functions control route authorization — update them for your use case
111+
- Remove `{module}.model.sequelize.js` if not using SQL

.claude/skills/feature/SKILL.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Routes → Controllers → Services → Repositories → Models
2929
- **Controllers** (`controllers/`): Handle HTTP req/res, call services, format responses via `lib/helpers/responses.js`
3030
- **Services** (`services/`): Business logic, call repositories, throw `AppError` for domain errors
3131
- **Repositories** (`repositories/`): Database access only, use Joi schemas for validation
32-
- **Models** (`models/`): Mongoose schema definition
32+
- **Models** (`models/`): Mongoose schema definition (`*.model.mongoose.js`) and Joi schema (`*.schema.js`)
3333

3434
### 3. Apply modularity rules
3535

@@ -39,13 +39,13 @@ Routes → Controllers → Services → Repositories → Models
3939
- Place it in `lib/helpers/` or `lib/services/`
4040
- Provide **explicit justification** for why it must be shared
4141
- Keep these inside the module (`modules/{module}/**`):
42-
- Controllers, services, repositories, models, policies, routes, tests
42+
- Controllers, services, repositories, models, schemas, policies, routes, tests
4343

4444
### 4. Use existing helpers
4545

4646
Before writing new utilities, check:
4747

48-
- `lib/helpers/responses.js` — JSend response wrapper (`success`, `error`)
48+
- `lib/helpers/responses.js` — JSend response wrapper
4949
- `lib/helpers/AppError.js` — Custom error class for domain errors
5050
- `lib/helpers/errors.js` — Error formatting utilities
5151
- `lib/helpers/joi.js` — Shared Joi validation helpers
@@ -54,19 +54,19 @@ Before writing new utilities, check:
5454

5555
### 5. Follow API response format
5656

57-
All API responses must use the JSend wrapper:
57+
All API responses must use the JSend wrapper from `lib/helpers/responses.js`:
5858

5959
```js
6060
// Success
61-
res.status(200).json(responses.success(data));
62-
// Error (caught by controller)
63-
res.status(err.status).json(responses.error(err.message, err.errors));
61+
responses.success(res, 'task list')(data);
62+
// Error
63+
responses.error(res, 422, 'Unprocessable Entity', errors.getMessage(err))(err);
6464
```
6565

6666
### 6. Run verify
6767

6868
```bash
69-
npm run lint
69+
npm run test:lint
7070
npm test
7171
```
7272

.claude/skills/naming/SKILL.md

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,33 +11,37 @@ Audit or apply the project's file and folder naming conventions.
1111

1212
### Folders
1313

14-
| Location | Case | Example |
15-
| --------------- | ---------- | -------------------------------- |
16-
| Top-level dirs | kebab-case | `lib/`, `modules/`, `config/` |
17-
| Module dirs | kebab-case | `modules/tasks/`, `modules/home/`|
14+
| Location | Case | Example |
15+
| --------------- | ----------- | --------------------------------- |
16+
| Top-level dirs | kebab-case | `lib/`, `modules/`, `config/` |
17+
| Module dirs | kebab-case | `modules/tasks/`, `modules/home/` |
1818
| Module sub-dirs | fixed names | `controllers/`, `services/`, `repositories/`, `models/`, `policies/`, `routes/`, `tests/`, `config/`, `doc/` |
1919

2020
### Files
2121

22-
| Type | Pattern | Example |
23-
| ----------- | ------------------------------ | -------------------------------- |
24-
| Controller | `{module}.{name}.controller.js`| `tasks.crud.controller.js` |
25-
| Service | `{module}.{name}.service.js` | `tasks.crud.service.js` |
26-
| Repository | `{module}.repository.js` | `tasks.repository.js` |
27-
| Model | `{module}.model.js` | `tasks.model.js` |
28-
| Policy | `{module}.{name}.policy.js` | `tasks.crud.policy.js` |
29-
| Router | `{module}.routes.js` | `tasks.routes.js` |
30-
| Test | `{module}.{type}.tests.js` | `tasks.integration.tests.js` |
31-
| Config | `{name}.js` | `app.js`, `default.js` |
22+
| Type | Pattern | Example |
23+
| --------------- | ------------------------------------- | ---------------------------------------------------------- |
24+
| Controller | `{module}[.{name}].controller.js` | `tasks.controller.js` |
25+
| Service | `{module}[.{name}].service.js` | `tasks.service.js`, `tasks.data.service.js` |
26+
| Repository | `{module}.repository.js` | `tasks.repository.js` |
27+
| Mongoose Model | `{module}.model.mongoose.js` | `tasks.model.mongoose.js` |
28+
| Sequelize Model | `{module}.model.sequelize.js` | `tasks.model.sequelize.js` |
29+
| Schema | `{module}.schema.js` | `tasks.schema.js` |
30+
| Policy | `{module}[.{name}].policy.js` | `tasks.policy.js` |
31+
| Router | `{module}.routes.js` | `tasks.routes.js` |
32+
| Test | `{module}.{type}.tests.js` | `tasks.integration.tests.js`, `tasks.unit.tests.js` |
33+
| Config | `{name}.js` | `app.js`, `default.js` |
34+
35+
> `[.{name}]` is optional — the reference `tasks` module uses the short form (e.g., `tasks.controller.js`, `tasks.service.js`).
3236
3337
### Naming Tokens
3438

3539
From a module name (e.g., `my-feature`):
3640

3741
- **kebab-case**: `my-feature` (folder names, file prefixes, route paths)
38-
- **PascalCase**: `MyFeature` (class names, Mongoose model names)
42+
- **PascalCase**: `MyFeature` (Mongoose model names, class names)
3943
- **lowerCamelCase**: `myFeature` (variable names, function names, JS exports)
40-
- **UPPER_SNAKE_CASE**: `MY_FEATURE` (constants, env keys)
44+
- **UPPER_SNAKE_CASE**: `MY_FEATURE` (constants)
4145

4246
## Layer Order
4347

.claude/skills/verify/SKILL.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@ Run lint → tests and report results.
99

1010
## Steps
1111

12-
1. Run `npm run lint` to check code quality
12+
1. Run `npm run test:lint` to check code quality (read-only, no auto-fix)
1313
2. Run `npm test` to run all tests
1414
3. Summarize results:
1515
- ✅ All checks passed → ready to commit
1616
- ❌ Some checks failed → show what failed and suggest next action
1717

1818
## Notes
1919

20+
- Use `npm run test:lint` (not `npm run lint`) — `lint` auto-fixes files which is not suitable for verification
2021
- Does not run tests in watch mode (use `npm run test:watch` manually for that)
2122
- Does not run coverage (use `npm run test:coverage` manually for that)
2223
- Does not commit or push changes

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Designed to be cloned into downstream projects and kept up-to-date via `git merg
2222
| Upload | [Mongo GridFS](https://docs.mongodb.com/manual/core/gridfs/) - [Multer](https://github.com/expressjs/multer) - [Sharp](https://github.com/lovell/sharp) - Image stream, all content types |
2323
| Testing | [Jest](https://github.com/facebook/jest) - [SuperTest](https://github.com/visionmedia/supertest) - Coverage & Watch |
2424
| CI | [GitHub Actions](https://github.com/pierreb-devkit/Node/actions) |
25-
| Linter | [ESLint](https://github.com/eslint/eslint) ecmaVersion 10 (2019) |
25+
| Linter | [ESLint](https://github.com/eslint/eslint) ecmaVersion latest |
2626
| Developer | [Dependabot](https://dependabot.com/) - [Snyk](https://snyk.io/test/github/pierreb-devkit/node) <br> [semantic-release](https://github.com/semantic-release/semantic-release) - [commitlint](https://github.com/conventional-changelog/commitlint) - [commitizen](https://github.com/commitizen/cz-cli) |
2727
| Dependencies | [npm](https://www.npmjs.com) |
2828
| Deliver | Docker & Docker-compose |
@@ -62,7 +62,7 @@ npm install
6262
npm start
6363
```
6464

65-
Runs dev server with auto-reload at `http://localhost:3000/`
65+
Runs the server at `http://localhost:3000/`. For auto-reload during development, use `npm run debug` (nodemon).
6666

6767
**CORS Note:** When connecting to the Vue stack, ensure CORS is configured:
6868

@@ -89,7 +89,8 @@ Tests are organized per module in `modules/*/tests/`
8989
### Code Quality
9090

9191
```bash
92-
npm run lint # Check code quality
92+
npm run test:lint # Check code quality (read-only)
93+
npm run lint # Check and auto-fix code quality issues
9394
```
9495

9596
### Database Seeding

0 commit comments

Comments
 (0)