nodejs-quickstart-structure 1.14.0 → 1.15.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,25 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [1.15.1] - 2026-03-12
9
+
10
+ ### Added
11
+ - **Magic AI Scaffolding**: Automated AI context generation ( `.cursorrules`, `prompts/`) by intelligently inferring project goals from the project name, removing the need for manual business domain prompts.
12
+ - **Enhanced README**: Added specialized guidance for AI-native development with Cursor and LLMs.
13
+
14
+ ### Fixed
15
+ - **GitHub Actions Compliance**: Fully resolved Node.js 20 deprecation warnings by moving `FORCE_JAVASCRIPT_ACTIONS_TO_NODE24` to global workflow scope.
16
+ - **CI Modernization**: Upgraded daily audit and GitLab CI runners to Node.js 22.
17
+ - **CI Enforcement**: Updated all CI/CD templates (GitHub, GitLab, Jenkins) to strictly enforce the >70% test coverage gate.
18
+
19
+ ## [1.15.0] - 2026-03-12
20
+ ### Added
21
+ - **AI-Native Scaffolding & Agent Skill Templates:**
22
+ - Added a new CLI prompt for `businessDomain` to inject custom domain knowledge into generated templates.
23
+ - Generates a `.cursorrules` file at the root to enforce >70% Test coverage and Architecture patterns automatically for AI Code Editors.
24
+ - Scaffolds a `prompts/` directory with specialized Agent Skill templates (`project-context.md`, `add-feature.md`, `troubleshoot.md`) designed to provide deep structural understanding to LLMs like ChatGPT or Claude.
25
+ - Added an "AI-Native Development" section to the generated `README.md` and prominent print messages in the CLI upon successful completion.
26
+
8
27
  ## [1.14.0] - 2026-03-09
9
28
  ### Added
10
29
  - **Unit test:**
package/bin/index.js CHANGED
@@ -1,81 +1,85 @@
1
1
  #!/usr/bin/env node
2
-
3
- import { Command } from 'commander';
4
- import chalk from 'chalk';
5
- import { getProjectDetails } from '../lib/prompts.js';
6
- import { generateProject } from '../lib/generator.js';
7
- import { readFileSync } from 'fs';
8
- import { join, dirname } from 'path';
9
- import { fileURLToPath } from 'url';
10
-
11
- const __dirname = dirname(fileURLToPath(import.meta.url));
12
- const pkg = JSON.parse(readFileSync(join(__dirname, '../package.json'), 'utf-8'));
13
-
14
- const program = new Command();
15
-
16
- program
17
- .name('nodejs-quickstart')
18
- .description('šŸš€ CLI to scaffold production-ready Node.js microservices.\n\nGenerates projects with:\n- MVC or Clean Architecture\n- REST or Kafka\n- MySQL, PostgreSQL, or MongoDB\n- Docker, Flyway & Mongoose support')
19
- .version(pkg.version, '-v, --version', 'Output the current version')
20
- .addHelpText('after', `
21
- \n${chalk.yellow('Example:')}
22
- $ nodejs-quickstart init ${chalk.gray('# Start the interactive setup')}
23
- `);
24
-
25
- program
26
- .command('init')
27
- .description('Initialize a new Node.js project')
28
- .option('-n, --project-name <name>', 'Project name')
29
- .option('-l, --language <language>', 'Language (JavaScript, TypeScript)')
30
- .option('-a, --architecture <architecture>', 'Architecture (MVC, Clean Architecture)')
31
- .option('--view-engine <view>', 'View Engine (None, EJS, Pug) - MVC only')
32
- .option('-d, --database <database>', 'Database (MySQL, PostgreSQL)')
33
- .option('--db-name <name>', 'Database name')
34
- .option('-c, --communication <communication>', 'Communication (REST APIs, GraphQL, Kafka)')
35
- .option('--ci-provider <provider>', 'CI/CD Provider (None, GitHub Actions, Jenkins)')
36
- .option('--caching <type>', 'Caching Layer (None/Redis)')
37
- .action(async (options) => {
38
- // Fix for Commander camelCase conversion
39
- if (options.ciProvider) {
40
- options.ciProvider = options.ciProvider;
41
- }
42
-
43
- console.log(chalk.blue('Welcome to the Node.js Quickstart Generator!'));
44
-
45
- try {
46
- const answers = await getProjectDetails(options);
47
- console.log(chalk.green('\nConfiguration received:'));
48
- console.log(JSON.stringify(answers, null, 2));
49
-
50
- console.log(chalk.yellow('\nGenerating project...'));
51
- await generateProject(answers);
52
-
53
- console.log(chalk.green('\nāœ” Project generated successfully!'));
54
-
55
- let manualStartInstructions = `\n${chalk.yellow('Development:')}\n cd ${answers.projectName}\n npm install`;
56
-
57
- const needsInfrastructure = answers.database !== 'None' || answers.caching === 'Redis' || answers.communication === 'Kafka';
58
-
59
- if (needsInfrastructure) {
60
- let servicesToStart = '';
61
- if (answers.database !== 'None') servicesToStart += ' db';
62
- if (answers.caching === 'Redis') servicesToStart += ' redis';
63
- if (answers.communication === 'Kafka') servicesToStart += ' zookeeper kafka';
64
-
65
- manualStartInstructions += `\n docker-compose up -d${servicesToStart} # Start infrastructure first\n npm run dev`;
66
- } else {
67
- manualStartInstructions += `\n npm run dev`;
68
- }
69
-
70
- console.log(chalk.cyan(`\nNext steps:\n cd ${answers.projectName}\n npm install\n docker-compose up\n-----------------------${manualStartInstructions}\n\n${chalk.yellow('Production (PM2):')}\n npm run build\n npm run deploy\n npx pm2 logs`));
71
-
72
- } catch (error) {
73
- console.error(chalk.red('Error generating project:'), error);
74
- process.exit(1);
75
- }
76
- });
77
- program.parse(process.argv);
78
-
79
- if (!process.argv.slice(2).length) {
80
- program.outputHelp();
81
- }
2
+
3
+ import { Command } from 'commander';
4
+ import chalk from 'chalk';
5
+ import { getProjectDetails } from '../lib/prompts.js';
6
+ import { generateProject } from '../lib/generator.js';
7
+ import { readFileSync } from 'fs';
8
+ import { join, dirname } from 'path';
9
+ import { fileURLToPath } from 'url';
10
+
11
+ const __dirname = dirname(fileURLToPath(import.meta.url));
12
+ const pkg = JSON.parse(readFileSync(join(__dirname, '../package.json'), 'utf-8'));
13
+
14
+ const program = new Command();
15
+
16
+ program
17
+ .name('nodejs-quickstart')
18
+ .description('šŸš€ CLI to scaffold production-ready Node.js microservices.\n\nGenerates projects with:\n- MVC or Clean Architecture\n- REST or Kafka\n- MySQL, PostgreSQL, or MongoDB\n- Docker, Flyway & Mongoose support')
19
+ .version(pkg.version, '-v, --version', 'Output the current version')
20
+ .addHelpText('after', `\n${chalk.yellow('Example:')}\n $ nodejs-quickstart init ${chalk.gray('# Start the interactive setup')}\n`);
21
+
22
+ program
23
+ .command('init')
24
+ .description('Initialize a new Node.js project')
25
+ .option('-n, --project-name <name>', 'Project name')
26
+ .option('-l, --language <language>', 'Language (JavaScript, TypeScript)')
27
+ .option('-a, --architecture <architecture>', 'Architecture (MVC, Clean Architecture)')
28
+ .option('--view-engine <view>', 'View Engine (None, EJS, Pug) - MVC only')
29
+ .option('-d, --database <database>', 'Database (MySQL, PostgreSQL)')
30
+ .option('--db-name <name>', 'Database name')
31
+ .option('-c, --communication <communication>', 'Communication (REST APIs, GraphQL, Kafka)')
32
+ .option('--ci-provider <provider>', 'CI/CD Provider (None, GitHub Actions, Jenkins)')
33
+ .option('--caching <type>', 'Caching Layer (None/Redis)')
34
+ .action(async (options) => {
35
+ // Fix for Commander camelCase conversion
36
+ if (options.ciProvider) {
37
+ options.ciProvider = options.ciProvider;
38
+ }
39
+
40
+ console.log(chalk.blue('Welcome to the Node.js Quickstart Generator!'));
41
+
42
+ try {
43
+ const answers = await getProjectDetails(options);
44
+ console.log(chalk.green('\nConfiguration received:'));
45
+ console.log(JSON.stringify(answers, null, 2));
46
+
47
+ console.log(chalk.yellow('\nGenerating project...'));
48
+ await generateProject(answers);
49
+
50
+ console.log(chalk.green('\nāœ” Project generated successfully!'));
51
+
52
+ console.log(chalk.magenta('\nšŸš€ Project is AI-Ready!'));
53
+ console.log(chalk.magenta('-----------------------------------------'));
54
+ console.log(chalk.magenta('šŸ¤– We detected you are using AI tools.'));
55
+ console.log(chalk.magenta(`šŸ“ Use Cursor? We've configured '.cursorrules' for you.`));
56
+ console.log(chalk.magenta(`šŸ“ Use ChatGPT/Gemini? Check the 'prompts/' folder for Agent Skills.`));
57
+ console.log(chalk.magenta('-----------------------------------------'));
58
+
59
+ let manualStartInstructions = `\n${chalk.yellow('Development:')}\n cd ${answers.projectName}\n npm install`;
60
+
61
+ const needsInfrastructure = answers.database !== 'None' || answers.caching === 'Redis' || answers.communication === 'Kafka';
62
+
63
+ if (needsInfrastructure) {
64
+ let servicesToStart = '';
65
+ if (answers.database !== 'None') servicesToStart += ' db';
66
+ if (answers.caching === 'Redis') servicesToStart += ' redis';
67
+ if (answers.communication === 'Kafka') servicesToStart += ' zookeeper kafka';
68
+
69
+ manualStartInstructions += `\n docker-compose up -d${servicesToStart} # Start infrastructure first\n npm run dev`;
70
+ } else {
71
+ manualStartInstructions += `\n npm run dev`;
72
+ }
73
+
74
+ console.log(chalk.cyan(`\nNext steps:\n cd ${answers.projectName}\n npm install\n docker-compose up\n-----------------------${manualStartInstructions}\n\n${chalk.yellow('Production (PM2):')}\n npm run build\n npm run deploy\n npx pm2 logs`));
75
+
76
+ } catch (error) {
77
+ console.error(chalk.red('Error generating project:'), error);
78
+ process.exit(1);
79
+ }
80
+ });
81
+ program.parse(process.argv);
82
+
83
+ if (!process.argv.slice(2).length) {
84
+ program.outputHelp();
85
+ }
package/lib/generator.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import path from 'path';
2
2
  import { fileURLToPath } from 'url';
3
3
  import { setupProjectDirectory, copyBaseStructure, copyCommonFiles } from './modules/project-setup.js';
4
- import { renderPackageJson, renderDockerCompose, renderReadme, renderDockerfile, renderProfessionalConfig, setupCiCd, renderTestSample, renderEnvExample, renderPm2Config } from './modules/config-files.js';
4
+ import { renderPackageJson, renderDockerCompose, renderReadme, renderDockerfile, renderProfessionalConfig, setupCiCd, renderTestSample, renderEnvExample, renderPm2Config, renderAiNativeFiles } from './modules/config-files.js';
5
5
  import { renderIndexFile, renderEnvConfig, renderErrorMiddleware, renderDynamicComponents, renderSwaggerConfig, setupViews as setupSrcViews, processAllTests } from './modules/app-setup.js';
6
6
  import { setupDatabase } from './modules/database-setup.js';
7
7
  import { setupKafka, setupViews } from './modules/kafka-setup.js';
@@ -81,6 +81,9 @@ export const generateProject = async (config) => {
81
81
  await renderProfessionalConfig(templatesDir, targetDir, config);
82
82
  await renderTestSample(templatesDir, targetDir, config);
83
83
 
84
+ // 13.5 AI-Native Scaffolding
85
+ await renderAiNativeFiles(templatesDir, targetDir, config);
86
+
84
87
  // 14. CI/CD
85
88
  await setupCiCd(templatesDir, targetDir, config);
86
89
 
@@ -114,6 +117,13 @@ export const generateProject = async (config) => {
114
117
  āœ… Docker: Production-ready multi-stage build
115
118
  ${config.ciProvider !== 'None' ? `āœ… CI/CD: ${config.ciProvider} Workflow ready` : 'āŒ CI/CD: Skipped (User preferred)'}
116
119
 
120
+ ----------------------------------------------------
121
+ šŸš€ Project is AI-Ready!
122
+ ----------------------------------------------------
123
+ šŸ¤– We detected you are using AI tools.
124
+ šŸ“ Use Cursor? We've configured '.cursorrules' for you.
125
+ šŸ“ Use ChatGPT/Gemini? Check the 'prompts/' folder for Agent Skills.
126
+
117
127
  ----------------------------------------------------
118
128
  šŸ‘‰ Next Steps:
119
129
  ----------------------------------------------------
@@ -49,6 +49,31 @@ export const renderProfessionalConfig = async (templatesDir, targetDir, config)
49
49
  await fs.writeFile(path.join(targetDir, 'jest.config.js'), jestContent);
50
50
  };
51
51
 
52
+ export const renderAiNativeFiles = async (templatesDir, targetDir, config) => {
53
+ // 1. .cursorrules
54
+ const cursorRulesPath = path.join(targetDir, '.cursorrules');
55
+ const cursorRulesTemplate = await fs.readFile(path.join(templatesDir, 'common', '.cursorrules.ejs'), 'utf-8');
56
+ const cursorRulesContent = ejs.render(cursorRulesTemplate, { ...config });
57
+ await fs.writeFile(cursorRulesPath, cursorRulesContent);
58
+
59
+ // 2. prompts/
60
+ const promptsDirTarget = path.join(targetDir, 'prompts');
61
+ await fs.ensureDir(promptsDirTarget);
62
+
63
+ const promptsSourceDir = path.join(templatesDir, 'common', 'prompts');
64
+ const promptFiles = await fs.readdir(promptsSourceDir);
65
+
66
+ for (const file of promptFiles) {
67
+ if (file.endsWith('.ejs')) {
68
+ const templatePath = path.join(promptsSourceDir, file);
69
+ const targetFilePath = path.join(promptsDirTarget, file.replace('.ejs', ''));
70
+ const templateContent = await fs.readFile(templatePath, 'utf-8');
71
+ const renderedContent = ejs.render(templateContent, { ...config });
72
+ await fs.writeFile(targetFilePath, renderedContent);
73
+ }
74
+ }
75
+ };
76
+
52
77
  export const setupCiCd = async (templatesDir, targetDir, config) => {
53
78
  const { ciProvider } = config;
54
79
  if (ciProvider === 'GitHub Actions') {
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "nodejs-quickstart-structure",
3
- "version": "1.14.0",
3
+ "version": "1.15.1",
4
4
  "type": "module",
5
- "description": "A CLI to scaffold Node.js microservices with MVC or Clean Architecture",
5
+ "description": "The ultimate nodejs quickstart structure CLI to scaffold Node.js microservices with MVC or Clean Architecture",
6
6
  "main": "bin/index.js",
7
7
  "bin": {
8
8
  "nodejs-quickstart": "./bin/index.js"
@@ -16,12 +16,17 @@
16
16
  },
17
17
  "keywords": [
18
18
  "nodejs",
19
+ "node",
20
+ "quickstart",
21
+ "structure",
19
22
  "cli",
20
23
  "scaffold",
21
24
  "mvc",
22
25
  "clean-architecture",
23
26
  "microservices",
24
- "backend"
27
+ "backend",
28
+ "generator",
29
+ "boilerplate"
25
30
  ],
26
31
  "author": "Pau Dang <[EMAIL_ADDRESS]>",
27
32
  "repository": {
@@ -0,0 +1,60 @@
1
+ # Cursor AI Coding Rules for <%= projectName %>
2
+
3
+ ## Project Context
4
+ You are an expert working on **<%= projectName %>**.
5
+ - **Project Goal**: [Replace this with your business logic, e.g., E-commerce API]
6
+ - **Language**: <%= language %>
7
+ - **Architecture**: <%= architecture %>
8
+ - **Database**: <%= database %>
9
+ - **Communication**: <%= communication %>
10
+
11
+ ## Excluded Files/Folders
12
+ When indexing or searching the workspace, ignore the following paths to prevent context pollution:
13
+ - `node_modules/`
14
+ - `dist/`
15
+ - `build/`
16
+ - `coverage/`
17
+ - `.git/`
18
+
19
+ ## Strict Rules
20
+
21
+ ### 1. Testing First
22
+ - Every new service or controller method MUST have a test file in `tests/`.
23
+ - **Coverage Gate**: Aim for > 70% coverage (Statement/Line/Function/Branch).
24
+ - **Format**: Use Jest with the AAA (Arrange, Act, Assert) pattern.
25
+ - **Isolation**: Mock external dependencies (DB, Redis, etc.) using `jest.mock()`.
26
+
27
+ ### 2. Error Handling
28
+ - Do NOT use generic `Error`.
29
+ - Use custom classes from `src/errors/` (e.g., `ApiError`, `NotFoundError`, `BadRequestError`).
30
+ <% if (language === 'TypeScript') { -%>
31
+ - Use `HTTP_STATUS` constants from `@/utils/httpCodes` for status codes.
32
+ <% } else { -%>
33
+ - Use `HTTP_STATUS` constants from `../utils/httpCodes.js` for status codes.
34
+ <% } -%>
35
+
36
+ ### 3. File Naming & Style
37
+ - **Controllers**: camelCase (e.g., `userController.<% if (language === 'TypeScript') { %>ts<% } else { %>js<% } %>`).
38
+ - **Services**: camelCase (e.g., `userService.<% if (language === 'TypeScript') { %>ts<% } else { %>js<% } %>`).
39
+ - **Routes**: camelCase (e.g., `userRoutes.<% if (language === 'TypeScript') { %>ts<% } else { %>js<% } %>`).
40
+ <% if (language === 'TypeScript') { -%>
41
+ - **Imports**: Use path aliases (e.g., `@/services/...`) instead of relative paths.
42
+ - **Typing**: Ensure strong typing for interfaces and DTOs. Do not use `any` unless absolutely necessary.
43
+ <% } else { -%>
44
+ - **Imports**: Use relative paths as dictated by the directory structure.
45
+ <% } -%>
46
+
47
+ ### 4. Architecture Standards
48
+ <% if (architecture === 'Clean Architecture') { -%>
49
+ - Enforce strict separation of concerns:
50
+ - `domain`: Entities and enterprise business rules.
51
+ - `usecases`: Application business rules.
52
+ - `interfaces`: Controllers and Routes.
53
+ - `infrastructure`: Frameworks, Database, Caching, and Web Server.
54
+ - Dependencies point inward toward the `domain`.
55
+ <% } else { -%>
56
+ - Enforce MVC standards:
57
+ - `models`: Data layer.
58
+ - `controllers`: Request handlers and business logic.
59
+ - `routes`: Define endpoints routing to controllers.
60
+ <% } -%>
@@ -8,3 +8,5 @@ README.md
8
8
  docker-compose.yml
9
9
  test_results.log
10
10
  flyway/sql
11
+ .cursorrules
12
+ prompts
@@ -12,24 +12,24 @@ cache:
12
12
 
13
13
  install_dependencies:
14
14
  stage: .pre
15
- image: node:18-alpine
15
+ image: node:22-alpine
16
16
  script:
17
17
  - npm ci
18
18
 
19
19
  lint_code:
20
20
  stage: lint
21
- image: node:18-alpine
21
+ image: node:22-alpine
22
22
  script:
23
23
  - npm run lint
24
24
 
25
25
  run_tests:
26
26
  stage: test
27
- image: node:18-alpine
27
+ image: node:22-alpine
28
28
  script:
29
- - npm test
29
+ - npm run test:coverage
30
30
 
31
31
  build_app:
32
32
  stage: build
33
- image: node:18-alpine
33
+ image: node:22-alpine
34
34
  script:
35
35
  - npm run build --if-present
@@ -21,7 +21,7 @@ pipeline {
21
21
 
22
22
  stage('Test') {
23
23
  steps {
24
- sh 'npm test'
24
+ sh 'npm run test:coverage'
25
25
  }
26
26
  }
27
27
 
@@ -217,4 +217,14 @@ docker-compose down
217
217
  - **Helmet**: Sets secure HTTP headers.
218
218
  - **CORS**: Configured for cross-origin requests.
219
219
  - **Rate Limiting**: Protects against DDoS / Brute-force.
220
- - **HPP**: Prevents HTTP Parameter Pollution attacks.
220
+ - **HPP**: Prevents HTTP Parameter Pollution attacks.
221
+
222
+
223
+ ## šŸ¤– AI-Native Development
224
+
225
+ This project is "AI-Ready" out of the box. We have pre-configured industry-leading AI context files to bridge the gap between "Generated Code" and "AI-Assisted Development."
226
+
227
+ - **Magic Defaults**: We've automatically tailored your AI context to focus on **<%= projectName %>** and its specific architectural stack (<%= architecture %>, <%= database %>, etc.).
228
+ - **Use Cursor?** We've configured **`.cursorrules`** at the root. It enforces project standards (70% coverage, MVC/Clean) directly within the editor.
229
+ - *Pro-tip*: You can customize the `Project Goal` placeholder in `.cursorrules` to help the AI understand your specific business logic!
230
+ - **Use ChatGPT/Gemini/Claude?** Check the **`prompts/`** directory. It contains highly-specialized Agent Skill templates. You can copy-paste these into any LLM to give it a "Senior Developer" understanding of your codebase immediately.
@@ -1,5 +1,8 @@
1
1
  name: Node.js CI
2
2
 
3
+ env:
4
+ FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: 'true'
5
+
3
6
  on:
4
7
  push:
5
8
  branches: [ "main" ]
@@ -13,13 +16,13 @@ jobs:
13
16
 
14
17
  strategy:
15
18
  matrix:
16
- node-version: [18.x, 20.x]
19
+ node-version: [20.x, 22.x]
17
20
 
18
21
  steps:
19
- - uses: actions/checkout@v3
22
+ - uses: actions/checkout@v4
20
23
 
21
24
  - name: Use Node.js ${{ matrix.node-version }}
22
- uses: actions/setup-node@v3
25
+ uses: actions/setup-node@v4
23
26
  with:
24
27
  node-version: ${{ matrix.node-version }}
25
28
  cache: 'npm'
@@ -31,7 +34,7 @@ jobs:
31
34
  run: npm run lint
32
35
 
33
36
  - name: Run Tests
34
- run: npm test
37
+ run: npm run test:coverage
35
38
 
36
39
  - name: Build
37
40
  run: npm run build --if-present
@@ -0,0 +1,26 @@
1
+ # Add New Feature
2
+
3
+ I want to add a new feature to the existing application.
4
+ Please follow the strict standards defined in the project context.
5
+
6
+ ## Feature Description
7
+ [INSERT EXPLANATION OF WHAT YOU WANT TO ADD HERE]
8
+
9
+ ## Implementation Guidelines
10
+
11
+ Please provide the code implementation following these steps:
12
+
13
+ 1. **Plan first**: Outline the files you need to create/modify and the logic they'll contain.
14
+ <% if (architecture === 'Clean Architecture') { -%>
15
+ 2. **Domain/Entity**: Define the core entity structure or interfaces if applicable.
16
+ 3. **Use Case**: Implement the business logic handling the feature.
17
+ 4. **Adapter (Controller & Route)**: Create the necessary endpoints and validate input.
18
+ 5. **Infrastructure (Repository)**: Implement database queries or external service calls.
19
+ <% } else { -%>
20
+ 2. **Model**: Define the database schema/model if applicable.
21
+ 3. **Controller**: Implement the business logic and request handling.
22
+ 4. **Route**: Create the API endpoints and wire them to the controller.
23
+ <% } -%>
24
+ 6. **Testing**: Write comprehensive Jest unit tests covering the "Happy Path" and "Edge Cases/Errors" (AAA pattern). Remember, our coverage requirement is > 70%!
25
+
26
+ Please provide the plan first so I can review it before we write the code.
@@ -0,0 +1,43 @@
1
+ # Project Context
2
+
3
+ Hello AI! I am working on a Node.js project. Here is the context to help you understand the architecture, domain, and standards.
4
+
5
+ ## Domain Overview
6
+ **Project Name**: <%= projectName %>
7
+ You are an expert working on **<%= projectName %>**.
8
+ **Project Goal**: [Replace this with your business logic, e.g., E-commerce API]
9
+ *(Keep this goal in mind when writing business logic, proposing data schemas, or considering edge cases like security and performance.)*
10
+
11
+ ## Tech Stack
12
+ - **Language**: <%= language %>
13
+ - **Architecture**: <%= architecture %>
14
+ - **Database**: <%= database %>
15
+ - **Communication Protocol**: <%= communication %>
16
+ <% if (caching !== 'None') { -%>
17
+ - **Caching**: <%= caching %>
18
+ <% } -%>
19
+
20
+ ## High-Level Architecture
21
+ <% if (architecture === 'Clean Architecture') { -%>
22
+ We use Clean Architecture. The project separates concerns into:
23
+ - `src/domain`: Core entities and rules. No external dependencies.
24
+ - `src/usecases`: Application business logic.
25
+ - `src/interfaces`: Adapters (Controllers, Routes) that mediate between the outside world and use cases.
26
+ - `src/infrastructure`: External tools (Database, Web Server, Config, Caching).
27
+ <% } else { -%>
28
+ We use the MVC (Model-View-Controller) pattern.
29
+ - `src/models`: Database schemas/models.
30
+ - `src/controllers`: Handling incoming requests and implementing business logic.
31
+ - `src/routes`: API endpoints mapped to controllers.
32
+ <% } -%>
33
+
34
+ ## Core Standards
35
+ 1. **Testing**: We enforce > 70% coverage. Tests use Jest and the AAA (Arrange, Act, Assert) pattern.
36
+ 2. **Error Handling**: We use centralized custom errors (e.g., `ApiError`) and global error middleware. Status codes come from standard constants, not hardcoded numbers.
37
+ 3. **Paths & Naming**:
38
+ <% if (language === 'TypeScript') { -%>
39
+ - We use `@/` path aliases for internal imports.
40
+ <% } -%>
41
+ - Files are mostly `camelCase`.
42
+
43
+ Please acknowledge you understand this context by saying "Context loaded successfully! How can I help you build the <%= projectName %>?"
@@ -0,0 +1,28 @@
1
+ # Troubleshoot Error
2
+
3
+ I am encountering an error in the <%= projectName %> application. Please help me diagnose and fix it based on our architectural standards.
4
+
5
+ ## The Error Log / Issue Description
6
+ \`\`\`
7
+ [PASTE YOUR ERROR LOG OR DESCRIBE THE ISSUE HERE]
8
+ \`\`\`
9
+
10
+ ## Context Variables
11
+ - **Architecture**: <%= architecture %>
12
+ - **Language**: <%= language %>
13
+
14
+ ## Guidelines for Fixing
15
+
16
+ When analyzing this error, please keep these project standards in mind:
17
+
18
+ 1. **Centralized Error Handling**:
19
+ - Ensure the error uses the standard custom error classes from `src/errors/` (e.g., `ApiError`, `NotFoundError`, `BadRequestError`).
20
+ - If an error occurs in a controller, it should be passed to the global error middleware via `throw` (for async handlers, or `next(error)` in MVC).
21
+ 2. **Standard Status Codes**:
22
+ - Verify that appropriate status codes from `httpCodes` are being used correctly, rather than generic 500s unless unexpected.
23
+ 3. **Dependencies**:
24
+ - Check if this is a connection issue (e.g., Database, Kafka, Redis) and see if our standard configuration or health checks provide hints.
25
+ 4. **Fix Suggestion**:
26
+ - Explain *why* the error happened.
27
+ - Provide a targeted code fix matching our coding style (<%= language %>, <%= architecture %>).
28
+ - Only modify what is strictly necessary to solve the issue.