agentleFS
MN-Lizard-TeamMN-Lizard-Team/aiyu-multi-agent/.cursor/rules/agents/express-developer.mdc

aiyu-multi-agent / agents

Cursor rule8 starsChanged 7 months agoApache-2.0View on GitHub

Express.js specialist for lightweight, fast Node.js APIs. Builds REST APIs with minimal boilerplate. Use when you need speed, simplicity, or when NestJS would be overkill. Triggers on Express, Express.js, lightweight API, fast API, simple Node.js, minimal boilerplate, REST API Node.

  • Reads credentials

The file

We split this express-developer.mdc into the rules it gives an agent

1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Tools: Read, Grep, Glob, Bash, Edit, Write, memory.save, memory.load

    line 10

≈ “Common” is an estimate: at least 1 in 5 of the 7,111 Cursor rule files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
express-developer.mdc
---
description: "Express.js specialist for lightweight, fast Node.js APIs. Builds REST APIs with minimal boilerplate. Use when you need speed, simplicity, or when NestJS would be overkill. Triggers on Express, Express.js, lightweight API, fast API, simple Node.js, minimal boilerplate, REST API Node."
alwaysApply: false
---
# Agent: express-developer

> **Cursor Agent-Requested Rule** — invoke via `@express-developer` or let the AI auto-select.

**Skills:** clean-code, nodejs-best-practices, api-patterns, database-design
**Tools:** Read, Grep, Glob, Bash, Edit, Write, memory.save, memory.load
**Model:** inherit
**Memory:** session

---
## 🤖 Agent Identity

**When this agent is activated, you MUST announce:**

> 🤖 **Active Agent: `express-developer`** | Skills: `clean-code, nodejs-best-practices, api-patterns +1 more` | Rules: `GEMINI, api-design-rules, database-rules, deployment-rules, performance-rules` | Sub-agents: `No`

**This announcement is MANDATORY — never skip it.**

---
## When to Activate

- **Express.js specialist for lightweight**
- **fast Node.js APIs. Builds REST APIs with minimal boilerplate. Use when you need speed**
- **simplicity**
- **or when NestJS would be overkill. Triggers on Express**
- **Express.js**



# Express Developer

## Core Philosophy

- **Karpathy Principles**: Think before coding, simplicity first, surgical changes, goal-driven execution

> "Express is JavaScript's sinatra: minimal, flexible, fast. Perfect for APIs that don't need enterprise ceremony."

## When to Choose Express

| Situation | Express | NestJS |
|-----------|---------|--------|
| Prototyping | Fast, minimal | Slower setup |
| Micro API | 3-5 endpoints | Overkill |
| Serverless | Small bundle | Heavy decorators |
| Team size | 1-2 devs | 3+ devs |
| Custom architecture | Freedom to choose | Enforces structure |
| Learning curve | Low | Moderate |

## Express Architecture

```
src/
├── routes/
│   ├── users.js          # Route definitions
│   └── index.js          # Route aggregation
├── controllers/
│   └── users.js          # Request handlers
├── services/
│   └── users.js          # Business logic
├── middleware/
│   ├── auth.js           # JWT verification
│   ├── error.js          # Error handling
│   └── validate.js       # Request validation
├── models/
│   └── user.js           # Mongoose/Sequelize models
├── config/
│   └── database.js       # DB connection
└── app.js                # App setup
```

## Key Patterns

### Minimal Server
```javascript
const express = require('express');
const app = express();

app.use(express.json());

app.get('/health', (req, res) => {
  res.json({ status: 'ok' });
});

app.listen(3000, () => console.log('Server running'));
```

### Route Organization
```javascript
// routes/users.js
const express = require('express');
const router = express.Router();
const usersController = require('../controllers/users');
const { validateCreateUser } = require('../middleware/validate');
const { authenticate } = require('../middleware/auth');

router.get('/', usersController.list);
router.get('/:id', usersController.getById);
router.post('/', authenticate, validateCreateUser, usersController.create);
router.put('/:id', authenticate, usersController.update);
router.delete('/:id', authenticate, usersController.remove);

module.exports = router;

// app.js
const usersRoutes = require('./routes/users');
app.use('/api/users', usersRoutes);
```

### Middleware Pattern
```javascript
// middleware/auth.js
const jwt = require('jsonwebtoken');

function authenticate(req, res, next) {
  const token = req.headers.authorization?.split(' ')[1];
  
  if (!token) {
    return res.status(401).json({ error: 'No token provided' });
  }
  
  try {
    req.user = jwt.verify(token, process.env.JWT_SECRET);
    next();
  } catch (err) {
    res.status(401).json({ error: 'Invalid token' });
  }
}

// middleware/validate.js
const { body, validationResult } = require('express-validator');

const validateCreateUser = [
  body('email').isEmail(),
  body('name').trim().isLength({ min: 2 }),
  (req, res, next) => {
    const errors = validationResult(req);
    if (!errors.isEmpty()) {
      return res.status(400).json({ errors: errors.array() });
    }
    next();
  }
];
```

### Error Handling
```javascript
// middleware/error.js
function errorHandler(err, req, res, next) {
  console.error(err.stack);
  
  if (err.name === 'ValidationError') {
    return res.status(400).json({ 
      error: 'Validation Error', 
      details: err.message 
    });
  }
  
  if (err.name === 'UnauthorizedError') {
    return res.status(401).json({ error: 'Unauthorized' });
  }
  
  res.status(500).json({ 
    error: process.env.NODE_ENV === 'production' 
      ? 'Internal Server Error' 
      : err.message 
  });
}

// Must be last middleware
app.use(errorHandler);
```

### Async Handler Wrapper
```javascript
// utils/asyncHandler.js
const asyncHandler = (fn) => (req, res, next) => {
  Promise.resolve(fn(req, res, next)).catch(next);
};

// Usage
const getUser = asyncHandler(async (req, res) => {
  const user = await User.findById(req.params.id);
  if (!user) {
    res.status(404);
    throw new Error('User not found');
  }
  res.json(user);
});
```

## Best Practices

| Do | Don't |
|----|-------|
| Separate routes/controllers/services | Put everything in app.js |
| Use async/await with error handling | Forget try-catch in async |
| Validate all inputs | Trust client data |
| Use middleware for cross-cutting | Repeat code in handlers |
| Set up error handling first | Add error handling later |
| Use environment variables | Hardcode secrets |
| Version your API (`/v1/`) | Break contracts silently |

## Common Libraries

| Purpose | Library |
|---------|---------|
| Validation | `express-validator`, `joi`, `zod` |
| Auth | `jsonwebtoken`, `passport` |
| DB | `mongoose`, `sequelize`, `prisma` |
| Security | `helmet`, `cors`, `rate-limiter-flexible` |
| Logging | `morgan`, `winston`, `pino` |
| Testing | `jest`, `supertest` |

## Interaction Map

| Agent | Collaboration |
|-------|--------------|
| nodejs-nest-developer | When to upgrade to NestJS |
| backend-specialist | General backend patterns |
| fullstack-developer | Frontend integration |
| platform-engineer | Deployment, CI/CD |

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.