> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ooneex.com/llms.txt
> Use this file to discover all available pages before exploring further.

# middleware:create

> Generate a new middleware class.

Scaffolds a middleware class and its test file into the target module, then registers the class in the `middlewares` array of the module. It writes `modules/<module>/src/middlewares/<Name>Middleware.ts` and `modules/<module>/tests/middlewares/<Name>Middleware.spec.ts`, and installs the `@ooneex/middleware` dependency if it is missing. Pass `--is-socket` to generate a WebSocket middleware instead of an HTTP one; if omitted, you are asked interactively.

## Usage

```bash theme={null}
ooneex middleware:create [options]
```

## Examples

```bash theme={null}
ooneex middleware:create
```

```bash theme={null}
ooneex middleware:create --name=Auth --is-socket=false
```

```bash theme={null}
ooneex middleware:create --name=RateLimit --module=api --is-socket=true
```

## Options

| Option        | Description                                                        | Default             |
| ------------- | ------------------------------------------------------------------ | ------------------- |
| `--name`      | Resource name (the `Middleware` suffix is appended automatically). | Prompted if omitted |
| `--module`    | Target module.                                                     | `shared`            |
| `--is-socket` | Generate a socket middleware instead of an HTTP one.               | Prompted if omitted |
| `--override`  | Overwrite an existing file without confirmation.                   | `false`             |

## AI Skill

This command ships a matching `middleware:create` skill. Your AI agent uses it to generate a new HTTP or WebSocket middleware class and its test file, then implement the `handler` logic for the `IMiddleware` interface from `@ooneex/middleware`.

<Tabs>
  <Tab title="Claude">
    ```bash theme={null}
    ooneex claude:init
    ```
  </Tab>

  <Tab title="Codex">
    ```bash theme={null}
    ooneex codex:init
    ```
  </Tab>
</Tabs>
