agentsclimarketplace

Express best practices

Skill piyushzala158/agent-skills/express-best-practices

collection of reusable engineering skills for AI coding agents

Install
npx -y skills add piyushzala158/agent-skills --skill express-best-practices

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 1 stars1 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its author says it does

Copied from the file, not written here

Build, refactor, review, and debug Express applications and APIs. Use when Codex works on Express routing, middleware order, error handling, request validation, security headers, async handlers, REST endpoints, application structure, or production readiness for Node.js HTTP services.

SKILL.md

3.1 KB, as published. Nobody here has run it

Express Best Practices

Purpose

Help the agent build reliable Express services with clear routing, predictable middleware, safe error handling, and production-ready defaults.

Use this skill when

  • Creating Express routes or middleware
  • Refactoring Express application structure
  • Reviewing Express API code
  • Fixing request, response, or error handling bugs
  • Hardening an Express service for production

Goals

  • Clear route and middleware boundaries
  • Consistent error handling
  • Explicit validation
  • Secure production defaults
  • Testable service code

Core Principles

  • Keep middleware order intentional.
  • Validate input at the boundary.
  • Centralize error handling.
  • Avoid leaking implementation details in responses.
  • Keep route handlers thin and move business logic into services.
  • Prefer async error flow that is compatible with the Express version in use.
  • Follow the existing project structure before introducing new layers.

Best Practices

  • Mount shared middleware before routes that depend on it.
  • Put the error-handling middleware after routes.
  • Return consistent response shapes for success and failure.
  • Use helmet or equivalent security headers where appropriate.
  • Use trusted reverse proxy settings only when the deployment requires them.
  • Separate routing, validation, services, and persistence code.
  • Add integration tests for important routes.

Anti-patterns

  • Throwing async errors that the installed Express version does not catch.
  • Mixing database calls, business rules, and response formatting in one handler.
  • Returning raw error objects to clients.
  • Registering catch-all middleware before specific routes.
  • Trusting request body, params, headers, or query strings without validation.

Decision Rules

If code reads request input, validate and normalize it before business logic.

If a handler has branching business rules, move those rules into a service or use case module.

If an error is expected, convert it into a typed application error and let the error middleware format the HTTP response.

If a route needs authentication or authorization, mount that middleware close to the protected route or router.


Completion Checklist

Before finishing, ensure:

  • Middleware order is correct.
  • Inputs are validated.
  • Async errors reach the error middleware.
  • Error responses do not leak internals.
  • Route handlers stay focused.
  • Security headers and production settings are considered.
  • Tests cover important success and failure paths.

Additional Resources

Read these supporting files when the task needs more detail:

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.