CLI generators
Scaffold REST and GraphQL applications, detect project templates automatically, and generate feature modules with the LykosJS CLI.
Overview
LykosJS provides a dedicated command-line interface (CLI) to streamline project setup and feature development. It includes project scaffolding and module generators for both REST and GraphQL applications.
The CLI automatically detects the current project's template and selects the appropriate module generator. You do not need to specify REST or GraphQL when generating a module.

Create a project
Start a new LykosJS application using Bun:
1bun create lykosjs my-appDuring project creation, select the API architecture you want to use:
- REST API: A controller and router-based application with validation rules.
- GraphQL: A schema-first application organized around GraphQL schemas and resolvers.
The CLI provides an interactive selection interface. You can navigate using the arrow keys, j and k,Tab, or 1 and 2, then confirm with Enter. Press Esc orCtrl+C to cancel.
Generate a module
Generate a feature module inside an existing LykosJS project:
1bun run lykosjs g module usersYou can also use the full command:
1bun run lykosjs generate module usersThe CLI detects the project template and automatically invokes the corresponding generator.
Automatic project detection
LykosJS identifies the project type by reading thepackage.json file in the current working directory. GraphQL projects contain a template marker:
1{2 "lykosAPI": {3 "template": "graphql"4 }5}If the marker is set to "graphql", the GraphQL generator is selected. Otherwise, the project is treated as REST, including projects created before this marker was introduced.
REST module generator
For REST projects, the generator creates a feature directory under src/modules. It generates controllers, routers, modules, schemas, validation rules, and tests.
Before generating the files, the CLI asks whether you want to include a service:
1? Do you want to generate a Service?2❯ Yes3 No4↑/↓ to move · enter to select · esc to cancelSelecting Yes generates a service and connects it to the controller through constructor injection. SelectingNo generates the controller without a service.
The REST generator produces the following structure when service generation is enabled:
1src/modules/users/2├── users.service.ts3├── users.controller.ts4├── users.route.ts5├── users.module.ts6├── schemas/7│ └── user.schema.ts8├── rules/9│ ├── create.ts10│ └── update.ts11└── tests/12 ├── users.controller.test.ts13 └── users.service.test.tsWhen service generation is disabled, the service file and service test are omitted. The remaining REST module files are still generated.
Generated REST components
- Controller: Provides the request handlers for creating, retrieving, updating, and deleting resources.
- Router: Registers REST endpoints and separates public routes from routes protected by authentication middleware.
- Module: Registers the generated controller and router using LykosJS dependency injection.
- Service: Provides a starting point for business logic when service generation is enabled.
- Schema: Creates a schema file for the singular resource name.
- Rules: Creates separate files for create and update validation rules.
- Tests: Generates basic Bun test files for the controller and, optionally, the service.
GraphQL module generator
For GraphQL projects, the CLI uses a dedicated schema-first generator. It creates a GraphQL schema, resolver, service, module, and test files.
Unlike the REST generator, GraphQL module generation does not ask whether to create a service. The service is always included.
1bun run lykosjs g module postsExample generated structure:
1src/modules/posts/2├── graphql-schema/3│ └── posts.graphql4├── posts.module.ts5├── posts.service.ts6├── posts.resolver.ts7└── tests/8 ├── posts.service.test.ts9 └── posts.resolver.test.tsGenerated GraphQL components
- GraphQL schema: Defines the resource type, create and update inputs, queries, and mutations.
- Resolver: Exposes query and mutation handlers and delegates operations to the service.
- Service: Provides methods for creating, retrieving, updating, and deleting resources.
- Module: Registers the service and resolver using
bind(). - Tests: Creates separate test files for the resolver and service.
The generated schema includes list and single-resource queries, along with create, update, and delete mutations. The generated resolver delegates these operations to the corresponding service methods.
Module naming conventions
Module names must start with a letter and contain only letters, numbers, hyphens, or underscores. Names are normalized into kebab-case for directories and filenames, and PascalCase for generated class names.
1bun run lykosjs g module users2bun run lykosjs g module billing-events3bun run lykosjs g module user_profilesFor GraphQL modules, the generator also derives singular and plural names for schema types and query fields. Use a plural resource name when generating a GraphQL module, so the CLI can derive distinct singular and plural forms.
1# Valid example2bun run lykosjs g module posts3 4# Invalid for GraphQL generation:5bun run lykosjs g module postFile safety
Before writing files, the generators check whether any target file already exists. If a conflict is found, generation stops with an error instead of overwriting existing files.
If an error occurs while writing generated files, the CLI attempts to remove files created during that generation operation.
CLI commands
Use the following commands to access the CLI:
1# Show available commands2bun run lykosjs --help3 4# Generate a module5bun run lykosjs g module users6 7# Alternative command syntax8bun run lykosjs generate module users9 10# Display CLI version information11bun run lykosjs --versionThe CLI also supports -h as an alias for--help, and -v as an alias for--version.