No. 119 Write the change

Node.js and Express.js Best Practices

Use when the behavior is already chosen and a file should change

  • Claude Code
  • Codex
  • Cursor
  • Write the change

Prompt

# Node.js and Express.js Best Practices

## Project Structure
- Use proper directory structure
- Implement proper module organization
- Use proper middleware organization
- Keep routes organized by domain
- Implement proper error handling
- Use proper configuration management

## Express Setup
- Use proper middleware setup
- Implement proper routing
- Use proper error handling
- Configure proper security middleware
- Implement proper validation
- Use proper static file serving

## API Design
- Use proper REST principles
- Implement proper versioning
- Use proper request validation
- Handle errors properly
- Implement proper response formats
- Document APIs properly

## Database Integration
- Use proper ORM/ODM
- Implement proper migrations
- Use proper connection pooling
- Implement proper transactions
- Use proper query optimization
- Handle database errors properly

## Authentication
- Implement proper JWT handling
- Use proper password hashing
- Implement proper session management
- Use proper OAuth integration
- Implement proper role-based access
- Handle auth errors properly

## Security
- Use proper CORS setup
- Implement proper rate limiting
- Use proper security headers
- Implement proper input validation
- Use proper encryption
- Handle security vulnerabilities

## Performance
- Use proper caching
- Implement proper async operations
- Use proper connection pooling
- Implement proper logging
- Use proper monitoring
- Handle high traffic properly

## Testing
- Write proper unit tests
- Implement proper integration tests
- Use proper test runners
- Implement proper mocking
- Test error scenarios
- Use proper test coverage

## Deployment
- Use proper Docker setup
- Implement proper CI/CD
- Use proper environment variables
- Configure proper logging
- Implement proper monitoring
- Handle deployment errors

## Best Practices
- Follow Node.js best practices
- Use proper async/await
- Implement proper error handling
- Use proper logging
- Handle process signals properly
- Document code properly

When to use

“Node.js and Express.js Best Practices” fits when the behavior is already chosen and a file should change, because it says “Node.js and Express.js Best Practices”, and it is written to stay in force on later turns rather than to finish one task.

With “Node.js and Express.js Best Practices” loaded, the user message can be as small as “fix the empty-cart total in src/cart.js and do not touch the test runner”, because “Node.js and Express.js Best Practices” is already in force.

When not to use

Leave “Node.js and Express.js Best Practices” unused when you only wanted the file explained, or two designs are still open, because “Node.js and Express.js Best Practices” points the other way

How to run it

Claude Code

Claude Code loads “Node.js and Express.js Best Practices” from .claude/rules on later sessions, so “Node.js and Express.js Best Practices” survives a new chat, which a one-off paste does not.

Codex

Codex keeps “Node.js and Express.js Best Practices” only if you put “Node.js and Express.js Best Practices” in AGENTS.md, or in AGENTS.override.md beside the directory that should inherit it. A paste that is not saved is gone next thread.

Cursor

Cursor keeps “Node.js and Express.js Best Practices” by saving “Node.js and Express.js Best Practices” as .cursor/rules. The chat transcript alone will not reload it tomorrow.

Comparison

对比待补

This before-and-after was not run on this machine.

Related

来源:PatrickJS awesome-cursorrules · https://github.com/PatrickJS/awesome-cursorrules/blob/main/rules/node-express.mdc · CC0-1.0 · 2026-12-01