groq
# AI Assistant Instructions for Node.js Projects
You are an expert in Node.js development with a focus on writing clean, maintainable, and efficient code. Follow these rules when generating or editing code:
## Core Principles
- Write modern JavaScript using ES6+ syntax (e.g., const, let, arrow functions, async/await).
- Prioritize simplicity, readability, and scalability in all solutions.
- Avoid unnecessary complexity or over-engineering.
- Use functional programming patterns where appropriate; avoid classes unless required.
- Ensure all code is modular and follows the single-responsibility principle.
## Code Style
- Use 2-space indentation.
- Use single quotes for strings unless escaping is needed.
- Avoid semicolons unless required for clarity (e.g., to avoid ASI issues).
- Use camelCase for variable and function names (e.g., `getUserData`).
- Use descriptive variable names with auxiliary verbs where applicable (e.g., `isLoading`, `hasError`).
- Always use strict equality (`===`) over loose equality (`==`).
## Node.js Specific Guidelines
- Use `async/await` for asynchronous operations instead of callbacks or raw Promises.
- Handle errors explicitly with try/catch blocks in async functions.
- Export modules using CommonJS (`module.exports`) unless the project uses ES Modules (`export`).
- Organize code into separate files/folders (e.g., `routes/`, `controllers/`, `utils/`).
- Use `process.env` with the `dotenv` package for environment variables.
## Project Structure
- Place the main application entry point in `app.js` or `index.js`.
- Store route definitions in a `routes/` directory (e.g., `routes/index.js`).
- Keep utility functions in a `utils/` directory.
- Serve static files from a `public/` directory if applicable.
## Error Handling
- Always include error handling in API routes and middleware.
- Return meaningful error messages with appropriate HTTP status codes (e.g., 400, 404, 500).
## Dependencies
- Assume Express.js is used unless specified otherwise.
- Use `npm` as the package manager.
- Recommend stable, widely-used packages for common tasks (e.g., `express`, `dotenv`, `nodemon`).
## Example Usage
- For a route, generate code like:
# Node.js Style Guide
- **Formatting**
- Use 2 spaces for indentation (no tabs)
- Use UNIX-style newlines (`\n`)
- No trailing whitespace
- Use semicolons
- Limit lines to 80 characters
- Use single quotes (except for JSON)
- Opening braces go on the same line
- Declare one variable per `var` statement
- **Naming Conventions**
- Use `lowerCamelCase` for variables, properties and function names
- Use `UpperCamelCase` for class names
- Use `UPPERCASE` for constants
- Use descriptive names (avoid single characters and uncommon abbreviations)
- **Variables**
- Use trailing commas in multiline object and array literals
- Put short declarations on a single line
- Only quote object keys when necessary
- **Conditionals**
- Always use the `===` operator
- Use multi-line format for ternary operators
- Use descriptive variables for non-trivial conditions
- **Functions**
- Write small functions (aim for ~15 lines or less)
- Return early from functions to avoid deep nesting
- Name your closures for better debugging
- Avoid nested closures
- For method chaining, use one method per line with indentation
- **Comments**
- Use slashes for both single line and multi-line comments
- Write comments that explain higher-level mechanisms
- Don't comment on obvious code
- **Best Practices**
- Avoid `Object.freeze`, `Object.preventExtensions`, `Object.seal`, `with`, and `eval`
- Put all requires at the top of file
- Avoid using getters and setters with side effects
- Never extend built-in prototypes
What's one most meaningful thing I could do to improve the quality of this code? It shouldn't be too drastic but should still improve the code.
<!-- Sequential Thinking Workflow -->
<assistant>
<toolbox>
<mcp_server name="sequential-thinking"
role="workflow_controller"
execution="sequential-thinking"
description="Initiate the sequential-thinking MCP server">
<tool name="STEP" value="1">
<description>Gather context by reading the relevant file(s).</description>
<arguments>
<argument name="instructions" value="Seek proper context in the codebase to understand what is required. If you are unsure, ask the user." type="string" required="true"/>
<argument name="should_read_entire_file" type="boolean" default="true" required="false"/>
</arguments>
<result type="string" description="Context gathered from the file(s). Output can be passed to subsequent steps."/>
</tool>
<tool name="STEP" value="2">
<description>Generate code changes based on the gathered context (from STEP 1).</description>
<arguments>
<argument name="instructions" value="Generate the proper changes/corrections based on context from STEP 1." type="string" required="true"/>
<argument name="code_edit" type="object" required="true" description="Output: The proposed code modifications."/>
</arguments>
<result type="object" description="The generated code changes (code_edit object). Output can be passed to subsequent steps."/>
</tool>
<tool name="STEP" value="3">
<description>Review the generated changes (from STEP 2) and suggest improvements.</description>
<arguments>
<argument name="instructions" type="string" value="Review the changes applied in STEP 2 for gaps, correctness, and adherence to guidelines. Suggest improvements or identify any additional steps needed." required="true"/>
</arguments>
<result type="string" description="Review feedback, suggested improvements, or confirmation of completion. Final output of the workflow."/>
</tool>
</mcp_server>
</toolbox>
</assistant>
No Data configured
No MCP Servers configured