Commands reference
In this guide, we cover the usage of all the commands shipped with the framework core and the official packages. You may also view the commands help using the node ace list command or the node ace <command-name> --help command.
node ace list
The output of the help screen is formatted as per the http://docopt.org standard
serve
The serve uses the
@adonisjs/assembler
package to start the AdonisJS application in development environment. You can optionally watch for file changes and restart the HTTP server on every file change.
node ace serve --hmr
The serve command starts the development server (via the bin/server.ts file) as a child process. If you want to pass
node arguments
to the child process, you can define them before the command name.
node ace --no-warnings --inspect serve --hmr
In both --watch and --hmr modes, the development server restarts when one of the environment files loaded by your application changes, such as .env or .env.local. Files loaded from a custom ENV_PATH directory are watched as well, so you do not have to restart the command manually after editing environment variables.
When running in an interactive terminal, the development server also listens for keyboard shortcuts. Press r to restart the server, c to clear the console, o to open the application in your browser, and h to list the shortcuts.
Following is the list of available options you can pass to the serve command. Alternatively, use the --help flag to view the command's help.
--hmr
Watch the filesystem and reload the server in HMR mode.
--watch
Watch the filesystem and always restart the process on file change.
--poll
Use polling to detect filesystem changes. You might want to use polling when using a Docker container for development.
--clear | --no-clear
Clear the terminal after every file change and before displaying the new logs. Use the --no-clear flag to retain old logs.
build
The build command uses the
@adonisjs/assembler
package to create the production build of your AdonisJS application. See
Creating the production build
for the steps performed during the build.
node ace build
Following is the list of available options you can pass to the build command. Alternatively, use the --help flag to view the command's help.
--ignore-ts-errors
The build command terminates the build process when your project has TypeScript errors. However, you can ignore those errors and finish the build using the --ignore-ts-errors flag.
--package-manager
The build command copies the package.json file alongside the lock file of the package manager your application is using.
We detect the package manager using the @antfu/install-pkg package. However, you can turn off detection by explicitly providing the package manager's name.
--tsconfig
Define the path to the tsconfig file used to compile the application. By default, the build uses the tsconfig.json file from the application root. The outDir of this file determines the build output directory.
node ace build --tsconfig=tsconfig.build.json
codegen
The codegen command uses the
@adonisjs/assembler
package to regenerate the contents of the .adonisjs directory without starting the HTTP server.
node ace codegen
During normal development, Assembler refreshes generated files as part of other workflows. The development server, test runner, and bundler generate file-based indexes, while the development server also generates route-derived types. The codegen command runs both stages explicitly, making it useful in CI before typechecking.
npm ci
node ace codegen
npm run typecheck
The command writes index files first because preload files import them. It then warms up the application, collects its registered routes, and generates route types. The HTTP server is never started and provider ready hooks do not run. Provider start hooks do run, so they must respect the
application mode
before starting workers or other long-running side effects.
Run codegen with development dependencies installed. The command relies on @adonisjs/assembler, which is normally installed as a development dependency. In CI, run it after npm ci and before pruning development dependencies.
See the code generation guide to learn what AdonisJS generates and whether to commit those files.
add
The add command combines the npm install <package-name> and node ace configure commands. So, instead of running two separate commands, you can install and configure the package in one go using the add command.
The add command will automatically detect the package manager used by your application and use that to install the package. However, you can always opt for a specific package manager using the --package-manager CLI flag.
# Install and configure the @adonisjs/lucid package
node ace add @adonisjs/lucid
# Install the package as a development dependency and configure it
node ace add my-dev-package --dev
If the package can be configured using flags, you can pass them directly to the add command. Every unknown flag will be passed down to the configure command.
node ace add @adonisjs/lucid --db=sqlite
--verbose
Enable verbose mode to display the package installation and configuration logs.
--force
Passed down to the configure command. Force overwrite files when configuring the package. See the configure command for more information.
--package-manager
Define the package manager to use for installing the package. The value must be npm, pnpm, bun or yarn.
--dev
Install the package as a development dependency.
configure
Configure a package after it has been installed. The command accepts the package name as the first argument.
node ace configure @adonisjs/lucid
--verbose
Enable verbose mode to display the package installation logs.
--force
The stubs system of AdonisJS does not overwrite existing files. For example, if you configure the @adonisjs/lucid package and your application already has a config/database.ts file, the configure process will not overwrite the existing config file.
However, you can force overwrite files using the --force flag.
eject
Eject stubs from a given package to your application stubs directory. In the following example, we copy the make/controller stubs to our application for modification.
See also: Customizing stubs
# Copy stub from @adonisjs/core package
node ace eject make/controller
# Copy stub from @adonisjs/bouncer package
node ace eject make/policy --pkg=@adonisjs/bouncer
generate:key
Generate a cryptographically secure random key and write to the .env file as the APP_KEY environment variable.
See also: App key
node ace generate:key
--show
Display the key on the terminal instead of writing it to the .env file. By default, the key is written to the env file.
--force
The generate:key command does not write the key to the .env file when running your application in production. However, you can use the --force flag to override this behavior.
make commands
The make:* commands shipped with the framework core accept the following flags in addition to their command-specific flags.
--force | -f
Overwrite the file when it already exists. Without this flag, the command skips existing files.
node ace make:controller users --force
--contents-from
Replace the generated contents with the contents of the given file. The output is still written to the location defined by the command's stub. Relative paths are resolved from the application root.
node ace make:service invoice --contents-from=stubs/custom/invoice_service.ts
make:controller
Create a new HTTP controller class. Controllers are created inside the app/controllers directory and use the following naming conventions.
- Form:
plural - Suffix:
controller - Class name example:
UsersController - File name example:
users_controller.ts
node ace make:controller users
You also generate a controller with custom action names, as shown in the following example.
# Generates controller with "index", "show", and "store" methods
node ace make:controller users index show store
--singular
Force the controller name to be in singular form.
--resource
Generate a controller with methods to perform CRUD operations on a resource.
--api
The --api flag is similar to the --resource flag. However, it does not define the create and the edit methods since they are used to display forms.
make:middleware
Create a new middleware for HTTP requests. Middleware are stored inside the app/middleware directory and uses the following naming conventions.
- Form:
singular - Suffix:
middleware - Class name example:
BodyParserMiddleware - File name example:
body_parser_middleware.ts
node ace make:middleware bodyparser
--stack
Skip the
middleware stack
selection prompt by defining the stack explicitly. The value must be server, named, or router.
node ace make:middleware bodyparser --stack=router
make:event
Create a new event class. Events are stored inside the app/events directory and use the following naming conventions.
- Form:
NA - Suffix:
NA - Class name example:
OrderShipped - File name example:
order_shipped.ts - Recommendation: You must name your events around the lifecycle of an action. For example:
MailSending,MailSent,RequestCompleted, and so on.
node ace make:event orderShipped
make:validator
Create a new VineJS validator file. The validators are stored inside the app/validators directory, and each file may export multiple validators.
- Form:
singular - Suffix:
NA - File name example:
user.ts - Recommendation: You must create validator files around the resources of your application.
# A validator for managing a user
node ace make:validator user
# A validator for managing a post
node ace make:validator post
--resource
Create a validator file with pre-defined validators for create and update actions.
node ace make:validator post --resource
make:listener
Create a new event listener class. The listener classes are stored inside the app/listeners directory and use the following naming conventions.
- Form:
NA - Suffix:
NA - Class name example:
SendShipmentNotification - File name example:
send_shipment_notification.ts - Recommendation: The event listeners must be named after the action they perform. For example, a listener that sends the shipment notification email should be called
SendShipmentNotification.
node ace make:listener sendShipmentNotification
--event
Generate an event class alongside the event listener.
node ace make:listener sendShipmentNotification --event=shipment_received
make:service
Create a new service class. Service classes are stored inside the app/services directory and use the following naming conventions.
A service has no pre-defined meaning, and you can use it to extract the business logic inside your application. For example, if your application generates a lot of PDFs, you may create a service called PdfGeneratorService and reuse it in multiple places.
- Form:
singular - Suffix:
service - Class name example:
InvoiceService - File name example:
invoice_service.ts
node ace make:service invoice
make:exception
Create a new
custom exception class
. Exceptions are stored inside the app/exceptions directory.
- Form:
NA - Suffix:
exception - Class name example:
CommandValidationException - File name example:
command_validation_exception.ts
node ace make:exception commandValidation
make:transformer
Create a new
transformer
class. Transformers are stored inside the app/transformers directory and use the following naming conventions.
- Form:
singular - Suffix:
transformer - Class name example:
UserTransformer - File name example:
user_transformer.ts
node ace make:transformer user
make:command
Create a new Ace command. By default, the commands are stored inside the commands directory at the root of your application.
Commands from this directory are imported automatically by AdonisJS when you try to execute any Ace command. You may prefix the filename with an _ to store additional files that are not Ace commands in this directory.
- Form:
NA - Suffix:
NA - Class name example:
ListRoutes - File name example:
list_routes.ts - Recommendation: Commands must be named after the action they perform. For example,
ListRoutes,MakeController, andBuild.
node ace make:command listRoutes
make:view
Create a new Edge.js template file. The templates are created inside the resources/views directory.
- Form:
NA - Suffix:
NA - File name example:
posts/view.edge - Recommendation: You must group templates for a resource inside a subdirectory. For example:
posts/list.edge,posts/create.edge, and so on.
node ace make:view posts/create
node ace make:view posts/list
make:page
Create a new Inertia page component inside the inertia/pages directory. The command is registered by the @adonisjs/inertia package. It detects the frontend framework from the existing pages and prompts you when it cannot decide.
- Form:
NA - Suffix:
NA - File name example:
posts/index.tsxorposts/index.vue
node ace make:page posts/index
# ./inertia/pages/posts/index.tsx
--react | --vue
Skip framework detection and create a React or Vue component.
node ace make:page posts/index --vue
# ./inertia/pages/posts/index.vue
--contents-from
Use the contents of an existing file instead of the default stub. This is useful when scaffolding pages from your own templates.
node ace make:page posts/index --contents-from=stubs/page.tsx
--force | -f
Overwrite the page component if it already exists.
make:provider
Create a
service provider file
. Providers are stored inside the providers directory at the root of your application and use the following naming conventions.
- Form:
singular - Suffix:
provider - Class name example:
AppProvider - File name example:
app_provider.ts
node ace make:provider app
--environments
Define environments in which the provider should get imported. Learn more about app environments
node ace make:provider app -e=web -e=console
make:preload
Create a new
preload file
. Preload files are stored inside the start directory.
node ace make:preload view
--environments
Define environments in which the preload file should get imported. Learn more about app environments
node ace make:preload view app -e=web -e=console
make:test
Create a new test file inside the tests/<suite> directory.
- Form: NA
- Suffix:
.spec - File name example:
posts/list.spec.ts,posts/update.spec.ts
node ace make:test --suite=unit
--suite
Define the suite for which you want to create the test file. Otherwise, the command will display a prompt for suite selection.
make:mail
Create a new mail class inside the app/mails directory. The mail classes are suffixed with the Notification keyword. However, you may define a custom suffix using the --intent CLI flag.
- Form: NA
- Suffix:
Intent - Class name example: ShipmentNotification
- File name example: shipment_notification.ts
node ace make:mail shipment
# ./app/mails/shipment_notification.ts
--intent
Define a custom intent for the mail.
node ace make:mail shipment --intent=confirmation
# ./app/mails/shipment_confirmation.ts
node ace make:mail storage --intent=warning
# ./app/mails/storage_warning.ts
--contents-from
Use the contents of the given file as the generated mail class instead of the default stub.
node ace make:mail shipment --contents-from=./stubs/shipment_mail.ts
--force | -f
Overwrite the mail file if it already exists.
make:policy
Create a new Bouncer policy class. The policies are stored inside the app/policies folder and use the following naming conventions.
- Form:
singular - Suffix:
policy - Class name example:
PostPolicy - File name example:
post_policy.ts
node ace make:policy post
Pass action names after the policy name to pre-define them as methods. The --model flag defines the model imported by the policy. It defaults to the policy name.
node ace make:policy post view edit delete --model=Article
inspect:rcfile
View the contents of the adonisrc.ts file after merging the defaults. You may use this command to inspect the available configuration options and override them per your application requirements.
See also: AdonisRC file
node ace inspect:rcfile
list:routes
View list of routes registered by your application. This command will boot your AdonisJS application in the console environment.
node ace list:routes
You may pass a keyword to only display the routes whose name, pattern, or controller name matches it.
node ace list:routes users
Also, you can see the routes list from the VSCode activity bar if you are using our official VSCode extension .
--json
View routes as a JSON string. The output will be an array of object.
--jsonl
View routes as JSON Lines, with one JSON object per route. This format is compact and easy to stream, which makes it a good fit for AI agents and other CLI tools consuming the routes list.
--table
View routes inside a CLI table. By default, we display routes inside a compact, pretty list.
--middleware
Filter routes list and include the ones using the mentioned middleware. You may use the * keyword to include routes using one or more middleware.
--ignore-middleware
Filter routes list and include the ones NOT using the mentioned middleware. You may use the * keyword to include routes that do not use any middleware.
env:add
The env:add command allows you to add a new environment variables to the .env, .env.example files and will also define the validation rules in the start/env.ts file.
You can just run the command and it will prompt you for the variable name, value, and validation rules. Or you can pass them as arguments.
# Will prompt for the variable name, value, and validation rules
node ace env:add
# Define the variable name, value, and validation rule
node ace env:add MY_VARIABLE value --type=string
--type
Define the type of the environment variable. The value must be one of the following: string, secret, boolean, number, enum.
--enum-values
Define the allowed values for the environment variable when the type is enum.
node ace env:add MY_VARIABLE foo --type=enum --enum-values=foo --enum-values=bar