express-type-augmentor

Add an optional user property to Express Request typing for TypeScript apps.

2|Updated Feb 3, 2026
One-click install
npx skills add https://github.com/stackconsult/RE-Engine --skill express-type-augmentor
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: express-type-augmentor
Source: https://github.com/stackconsult/RE-Engine/tree/main/.agent/skills/express-type-augmentor
Command: npx skills add https://github.com/stackconsult/RE-Engine --skill express-type-augmentor

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill enables a strongly-typed Express Request by adding an optional user property, enabling reliable access to authentication tokens in TypeScript-based apps.

Core Features & Use Cases

  • Global Express augmentation to expose req.user as an AuthToken type.
  • Simplified migration: update tsconfig to include new types and adjust typeRoots.
  • Refactor middleware and consumers to rely on standard Express.Request instead of custom interfaces.

Quick Start

Create a global Express type augmentation file at src/types/express.d.ts that extends Express.Request with an optional user property and then adjust tsconfig.json and middleware/consumers accordingly.

Frequently Asked Questions about express-type-augmentor

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add a custom user property to Express Request in TypeScript?

To add a custom user property to Express Request in TypeScript, create a global type augmentation file at src/types/express.d.ts that extends the Express.Request interface with an optional user property typed as AuthToken. Update tsconfig.json to include this types directory.

Why does my Express middleware fail when accessing req.user in TypeScript?

Your Express middleware fails accessing req.user because the standard Express TypeScript definitions lack this property. Implementing a global Express type augmentation exposes req.user as an AuthToken type, resolving the missing property error.

What is the best way to type-safely augment Express requests for authentication?

The best way to type-safely augment Express requests for authentication is using a global express.d.ts declaration file. This exposes req.user as an AuthToken type and allows consumers to replace custom interfaces with standard Express.Request.

How do I configure tsconfig.json to recognize custom Express type augmentations?

To configure tsconfig.json for custom Express type augmentations, update the include array to add the src/types directory and adjust typeRoots. This ensures the TypeScript compiler correctly resolves the express.d.ts declaration file.

Can I remove legacy @ts-nocheck from middleware by augmenting Express types?

Yes, you can remove legacy @ts-nocheck from middleware by augmenting Express types. By globally defining req.user via an express.d.ts file, you can refactor consumers to rely on standard Express.Request instead of duplicate interfaces.

When should I use a global type augmentation file for Express middleware?

Use a global type augmentation file for Express middleware when your TypeScript application relies on req.user for authentication and authorization. It provides strongly-typed access to authentication tokens across your services without custom interfaces.