express
Skill15 starsChanged 2 months agoMITView on GitHub
Expert Express.js assistance covering routing, middleware pipelines, error handling, and REST API design. Use when building Node.js backend services and web APIs.
5 other projects use a version of this.
Adopted by
Most recently taken up by
- Ghost7802/awesome-api-skillstheir own version, first seen Nov 29, 2026
- authdog/agent-skillstheir own version, first seen Sep 18, 2026
- Spardutti/claude-skillstheir own version, first seen Aug 31, 2026
- conjure-3301/skillstheir own version, first seen Aug 17, 2026
- andyrids/icm-spectheir own version, first seen Aug 13, 2026
Other versions5 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 5
- Ghost7802/awesome-api-skills★ 13same name
- Spardutti/claude-skills★ 3same name
- andyrids/icm-spec★ 2same name
- authdog/agent-skills★ 0same name
- conjure-3301/skills★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository350 other files it gives its agents.
- airflowSkill
- catboostSkill
- claudeSkill
- comfyuiSkill
- cursor-aiSkill
- dalleSkill
- daskSkill
- dbtSkill
- deepseekSkill
- fastaiSkill
- geminiSkill
- github-copilotSkill
- huggingfaceSkill
- jaxSkill
- jupyterSkill
- kerasSkill
- langchainSkill
- lightgbmSkill
- llamaindexSkill
- llamaSkill
- matplotlibSkill
- midjourneySkill
- mistralSkill
- mlflowSkill
- nltkSkill
- numpySkill
- ollamaSkill
- openai-gptSkill
- opencvSkill
- pandasSkill
- perplexitySkill
- plotlySkill
- polarsSkill
- pytorchSkill
- raySkill
- scikit-learnSkill
- seabornSkill
- spacySkill
- sparkSkill
- stable-diffusionSkill
- tensorflowSkill
- vaexSkill
- weights-biasesSkill
- whisperSkill
- xgboostSkill
- api-gatewaySkill
- clean-architectureSkill
- cqrsSkill
- domain-driven-designSkill
- event-drivenSkill
- event-sourcingSkill
- graphqlSkill
- grpcSkill
- hexagonalSkill
- microservicesSkill
- modular-monolithSkill
- monolithSkill
- rest-apiSkill
- sagaSkill
- serverlessSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
4 rules. 0 are common, 1 is distinctive, and 3 are very specific to this project.
0
Common
Most of the 5 edited versions we read keep these.
1
Distinctive
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 146
Use an async handler wrapper and centralized error middleware:
- Very specific: line 173
Always mount the 4-argument error-handling middleware ((err, req, res, next)) at the very end of the middleware stack.
- Very specific: line 174
Use helmet() to secure HTTP headers (HSTS, CSP, X-Frame-Options) against common exploits.
- Very specific: line 180
Use synchronous I/O operations (fs.readFileSync) inside route handlers.
“Common” is measured: kept by at least 6 in 10 of the 5 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Express
Express is a minimalist, unopinionated web framework for Node.js, providing robust HTTP utility methods, extensible middleware architectures, and async handler support.
When to Use
- Fast Node.js REST API Development: Building flexible, lightweight HTTP microservices and web backends.
- Established Node.js Ecosystem Services: Leveraging thousands of battle-tested npm middleware packages.
- Web App Routing & Server-Side Rendering: Serving dynamic server-side templates with EJS, Pug, or Handlebars.
- API Gateways & Proxy Layers: Routing, inspecting, and transforming inbound microservice requests.
Quick Start
import express from "express";
const app = express();
// Express 5 handles async errors automatically!
app.get("/", async (req, res) => {
const user = await db.getUser(); // If this throws, Express catches it.
res.json(user);
});
app.listen(3000);Core Concepts
Modular Route Handlers & Express Router
Structuring scalable APIs with decoupled sub-routers:
import express, { Request, Response, NextFunction } from "express";
const userRouter = express.Router();
interface UserPayload {
username: string;
email: string;
}
userRouter.get(
"/:id",
async (req: Request, res: Response, next: NextFunction) => {
try {
const userId = req.params.id;
res.json({ id: userId, username: `user_${userId}`, status: "active" });
} catch (error) {
next(error);
}
},
);
userRouter.post(
"/",
async (
req: Request<{}, {}, UserPayload>,
res: Response,
next: NextFunction,
) => {
try {
const { username, email } = req.body;
if (!username || !email) {
res.status(400).json({ error: "Username and email are required" });
return;
}
res.status(201).json({ id: Date.now(), username, email });
} catch (error) {
next(error);
}
},
);
export default userRouter;Custom Middleware & Security Pipeline
Hardening Express with Helmet, CORS, and compression:
import express from "express";
import helmet from "helmet";
import cors from "cors";
import compression from "compression";
import userRouter from "./userRouter";
const app = express();
app.use(helmet());
app.use(cors({ origin: "https://trusted-domain.com" }));
app.use(compression());
app.use(express.json({ limit: "1mb" }));
app.use(express.urlencoded({ extended: true }));
app.use("/api/v1/users", userRouter);
app.listen(3000, () => {
console.log("Express API listening on port 3000");
});Centralized Error Handling Middleware
Uniform error trapping conforming to 4-argument signature:
import { Request, Response, NextFunction } from "express";
interface AppError extends Error {
statusCode?: number;
}
export function errorHandler(
err: AppError,
req: Request,
res: Response,
next: NextFunction,
): void {
const statusCode = err.statusCode || 500;
console.error(`[Error] ${req.method} ${req.path}:`, err.message);
res.status(statusCode).json({
error: {
message: err.message || "Internal Server Error",
status: statusCode,
timestamp: new Date().toISOString(),
},
});
}Common Patterns
Centralized Async Error Handling Middleware
Problem: Unhandled promise rejections inside async route handlers cause server crashes or hanging requests.
Solution: Use an async handler wrapper and centralized error middleware:
const asyncHandler = (fn) => (req, res, next) => {
Promise.resolve(fn(req, res, next)).catch(next);
};
app.get(
"/api/users/:id",
asyncHandler(async (req, res) => {
const user = await db.findUser(req.params.id);
if (!user) throw new NotFoundError("User not found");
res.json(user);
}),
);
// Centralized error handler (must have 4 arguments)
app.use((err, req, res, next) => {
console.error(err.stack);
res.status(err.statusCode || 500).json({ error: err.message });
});Best Practices
Do:
- Always mount the 4-argument error-handling middleware (
(err, req, res, next)) at the very end of the middleware stack. - Use
helmet()to secure HTTP headers (HSTS, CSP, X-Frame-Options) against common exploits. - Wrap async handler functions or use Express 5 to catch rejected promises automatically.
- Limit request body payload size (
express.json({ limit: '100kb' })) to defend against DoS attacks.
Don't:
- Use synchronous I/O operations (
fs.readFileSync) inside route handlers. - Omit
returnafter sending responses (res.json(...)) inside conditional branches. - Expose stack traces in production error responses (
NODE_ENV === 'production').
Troubleshooting
| Error | Cause | Solution |
Cannot set headers after they are sent to the client | Attempted to call res.json() or res.send() multiple times in handler. | Add return before response calls: return res.status(400).send(...). |
req.body is undefined | Missing body-parsing middleware in application pipeline. | Add app.use(express.json()) and app.use(express.urlencoded({ extended: true })). |
EADDRINUSE: address already in use :::3000 | Port 3000 occupied by previous node process. | Kill process with npx kill-port 3000 or change listening port. |
References
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
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.

