Free 40-page Claude guide — setup, 120 prompt codes, MCP servers, AI agents. Download free →
CLSkills
Backendbeginner

Express Setup

Share

Scaffold Express.js app with best practices

Works with OpenClaude

You are a Node.js backend developer. The user wants to scaffold a production-ready Express.js application with current best practices.

What to check first

  • Run node --version to ensure Node.js 16+ is installed
  • Verify npm --version or yarn --version is available
  • Check that the target directory is empty or create a new folder with mkdir my-express-app && cd my-express-app

Steps

  1. Initialize the project with npm init -y to generate package.json
  2. Install core Express dependencies: npm install express dotenv cors helmet morgan
  3. Install dev dependencies for development: npm install --save-dev nodemon @types/node
  4. Create the directory structure: mkdir -p src/routes src/middleware src/config
  5. Create .env file in root with PORT=3000 and NODE_ENV=development
  6. Create .gitignore file and add node_modules/, .env, .DS_Store
  7. Set up package.json scripts with "start": "node src/index.js" and "dev": "nodemon src/index.js"
  8. Create src/index.js with Express server initialization, middleware setup, and error handling
  9. Create a basic route file in src/routes/health.js for health checks
  10. Add src/middleware/errorHandler.js for centralized error handling

Code

// src/index.js
const express = require('express');
const cors = require('cors');
const helmet = require('helmet');
const morgan = require('morgan');
require('dotenv').config();

const app = express();
const PORT = process.env.PORT || 3000;
const NODE_ENV = process.env.NODE_ENV || 'development';

// Security middleware
app.use(helmet());
app.use(cors({
  origin: process.env.CORS_ORIGIN || '*',
  credentials: true,
}));

// Logging middleware
app.use(morgan(NODE_ENV === 'development' ? 'dev' : 'combined'));

// Body parsing middleware
app.use(express.json({ limit: '10mb' }));
app.use(express.urlencoded({ limit: '10mb', extended: true }));

// Health check route
app.get('/health', (req, res) => {
  res.json({
    status: 'ok',
    timestamp: new Date().toISOString(),
    environment: NODE_ENV,
  });
});

// 404 handler
app.use((req, res) => {
  res.status(404).json({
    error: 'Route not found',
    path: req.path,
    method: req.method,
  });
});

// Error handling middleware (must be last)
app.use((err, req, res, next) => {
  const status = err.status || 500;
  const message =

Note: this example was truncated in the source. See the GitHub repo for the latest full version.

Common Pitfalls

  • Treating this skill as a one-shot solution — most workflows need iteration and verification
  • Skipping the verification steps — you don't know it worked until you measure
  • Applying this skill without understanding the underlying problem — read the related docs first

When NOT to Use This Skill

  • When a simpler manual approach would take less than 10 minutes
  • On critical production systems without testing in staging first
  • When you don't have permission or authorization to make these changes

How to Verify It Worked

  • Run the verification steps documented above
  • Compare the output against your expected baseline
  • Check logs for any warnings or errors — silent failures are the worst kind

Production Considerations

  • Test in staging before deploying to production
  • Have a rollback plan — every change should be reversible
  • Monitor the affected systems for at least 24 hours after the change

Quick Info

CategoryBackend
Difficultybeginner
Version1.0.0
AuthorClaude Skills Hub
backendexpressnode

Install command:

curl -o ~/.claude/skills/express-setup.md https://claude-skills-hub.vercel.app/skills/backend/express-setup.md

Related Backend Skills

Other Claude Code skills in the same category — free to download.

Want a Backend skill personalized to YOUR project?

This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.