> ## 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.

# controller:create

> Generate a new controller class with its route configuration and test file.

Generates a controller class in the target module. It writes `modules/<module>/src/controllers/<Name>Controller.ts` and a mirrored `modules/<module>/tests/controllers/<Name>Controller.spec.ts`, registers the controller into the module's `controllers` array, and installs the `@ooneex/controller` dependency when missing. It supports both HTTP and WebSocket (socket) controllers and configures the route name, path, and method.

## Usage

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

## Examples

Run with no flags to be prompted for the name, controller type, and route name, path, and method:

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

Create an HTTP controller non-interactively:

```bash theme={null}
ooneex controller:create --name=UserCreate --module=user --is-socket=false --route-name=user.create --route-path=/users --route-method=post
```

Create a socket controller:

```bash theme={null}
ooneex controller:create --name=ChatMessage --module=chat --is-socket=true --route-name=chat.message --route-path=/chat
```

## Options

| Option           | Description                                                                      | Default                               |
| ---------------- | -------------------------------------------------------------------------------- | ------------------------------------- |
| `--name`         | Controller name (normalized to PascalCase, the `Controller` suffix is appended). | Prompted if omitted                   |
| `--module`       | Target module.                                                                   | `shared`                              |
| `--is-socket`    | Generate a WebSocket socket controller instead of an HTTP one.                   | Prompted if omitted                   |
| `--override`     | Overwrite an existing controller file without confirmation.                      | `false`                               |
| `--route-name`   | Route name in dot notation (e.g. `user.create`).                                 | Prompted if omitted                   |
| `--route-path`   | Route URL path (e.g. `/users`).                                                  | Prompted if omitted (defaults to `/`) |
| `--route-method` | HTTP route method (HTTP controllers only).                                       | Prompted if omitted                   |

## AI Skill

This command ships a matching `controller:create` skill. The skill generates the controller class, route type, and test file, then completes the implementation — keeping the controller thin, wiring validation and role-based access, and refreshing any SDK that exposes the route. Your AI agent uses it when creating a new HTTP or WebSocket controller with routing, validation, and access control.

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

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