[data-reveal]{opacity:1!important;transform:none!important}
DocumentationModule commands

Module commands

Reference for the AntelopeJS module commands, which create modules from templates and run their tests.

Overview

The ajs module command group has two commands. ajs module init creates a module from a template, and ajs module test runs the tests of a module.

ajs module init

Create a module from one of the templates of the interface repository. The interface repository is the git CLI setting (see ajs config), and it lists the available templates and interfaces. The command creates the module from the chosen template, adds the chosen interfaces to its dependencies with the version latest, and installs the dependencies.

The template copy leaves out the template repository's own .git, .agents and .claude/skills entries, which hold its version control and verification tooling, whether they are folders or links. It also leaves out .github/workflows/module-locks.yml, .github/workflows/next-canary.yml and .github/scripts, which maintain the template repository itself. The rest of .claude/, such as settings.json, and of .github/ is kept. Files that the target directory already holds at the excluded paths stay in place. When the command installs the template's dependencies and its sync script runs antelopejs-sync, the command runs that script once the dependencies are installed and the git repository exists, so that the files antelopejs-sync manages, which those folders hold, are written for the new project. A template that installs its dependencies itself gets no sync from the command. A failed sync is reported as a warning and leaves the project in place.

terminal
ajs module init <path> [options]
ArgumentDescription
pathDirectory of the new module
OptionDescription
-g, --git <url>Interface repository URL, overriding the git CLI setting
-t, --template <slug>Template to create the module from, by slug or exact name
--interfaces <names>Interfaces to add as dependencies, separated by commas
--pm <npm|yarn|pnpm>Package manager of the module
--git-init, --no-git-initInitialize a git repository in the module, or do not
-y, --yesAccept the default answer of every question no flag answers

--git also reads the ANTELOPEJS_GIT environment variable.

The command asks for the template, the interfaces to add, the package manager and whether to initialize a git repository. It then creates the module. Every question is answered before anything is written, so cancelling with Ctrl+C leaves the target directory untouched and exits with code 130.

--template takes the slug of a template, its name in lower case with each run of characters other than letters and digits replaced by - ("Blank Typescript" is blank-typescript). The exact name, quoted, still works. An unknown --template or --interfaces name exits with code 2 and lists the available names. A template can require a package manager. The command then uses that package manager without asking, and a different --pm value exits with code 2. --git always takes the repository URL. The git repository question is answered by --git-init or --no-git-init, the same flags as ajs project init.

A template whose manifest entry sets "install": false installs its own dependencies. The command then skips the install and the package manager question (see ajs project init). When copying the template or installing fails, the command removes the directory it created, so it can run again.

Each question has a flag that answers it, so the command runs in scripts and CI. When standard input is not a terminal, or CI is set, the command never prompts. The command checks the target directory and the interface repository first. A target directory that is not empty exits with code 1 and stays untouched, the current directory (.) included, and so does an interface repository that the command cannot read. After these checks, a question that no flag answers makes the command exit with code 2 before it writes anything, and the error lists the flags to pass. Interfaces are optional and default to none. --yes answers the remaining questions with their defaults: the first template, npm, and a git repository.

Examples:

terminal
# Create a module in the modules directory
ajs module init ./modules/my-module

# Use the templates of another interface repository
ajs module init ./modules/my-module --git https://github.com/your-org/interfaces.git

# Answer every question with a flag, for scripts and CI
ajs module init ./modules/my-module --template blank-typescript --interfaces api,logging --pm pnpm --no-git-init

# Accept every default
ajs module init ./modules/my-module --yes

The command ends with a summary such as Created module from template Blank Typescript → ./modules/my-module. To use the module in a project, add it with ajs project modules add:

terminal
ajs module init ./modules/auth
ajs project modules add ./modules/auth --mode local
Tip

Keep your modules in a modules/ directory inside the project. Add them to the project configuration with --mode local.

ajs module test

Run the tests of a module. Without a path, the command runs the tests of the module in the current directory. The module declares its test configuration in the antelopeJs.test entry of its package.json (see Testing). Without that entry, the command fails with exit code 1 and explains how to add one:

text
✖ Module my-module has no test configuration
  The antelopeJs.test field of its package.json does not name a test configuration file.
  → Create antelope.test.ts, exporting defineConfig({ name, modules, test: { folder: "test" } }) from @antelopejs/interface-core/config
  → Point package.json to it: "antelopeJs": { "test": "antelope.test.ts" }
  → Docs: https://antelopejs.com/docs/module-development/testing

The command runs the tests with the mocha package that the module installs, and @antelopejs/core does not install it. When the module has none, the command fails with exit code 1 before it starts any module:

text
✖ mocha is not installed for the module in /path/to/my-module
  ajs module test runs the module's tests with mocha, and @antelopejs/core does not install it.
  → Add it to the module: npm install --save-dev mocha
terminal
ajs module test [path] [options]
ArgumentDescription
pathDirectory of the module (default: current directory)
OptionDescription
-f, --file <path>Test file to run instead of the whole suite. Repeat it for more files.
--timeout <ms>Milliseconds each test and hook may take, interface suites included (default: 2000).

The command resolves each -f path against the current directory, not against the module directory.

--timeout sets the mocha timeout of the whole run: every test and hook of the module, and of each interface suite it runs. A test that sets its own this.timeout keeps that value. The value must be a positive whole number. Any other value stops the command with exit code 2 before a test runs.

Examples:

terminal
# Run all tests for a module
ajs module test ./modules/my-module

# Run tests in the current directory
ajs module test

# Run a specific test file
ajs module test ./modules/my-module -f modules/my-module/test/auth.test.ts

# Run multiple specific test files
ajs module test ./modules/my-module -f modules/my-module/test/auth.test.ts -f modules/my-module/test/session.test.ts

# Give each test and hook up to 10 seconds
ajs module test ./modules/my-module --timeout 10000
Note

Pass -f more than once to run a subset of the test files. Without -f, the command runs every file whose name ends in .test.ts, .spec.ts, .test.js or .spec.js in the test folder that the configuration declares (test by default). It also runs the tests that each interface in the module's antelopeJs.implements ships in its dist/tests folder. The command exits with code 1 when a test fails or when it finds no test file.