Skip to main content

CLI Overview

What is OpenCore CLI?โ€‹

The OpenCore CLI is the official command-line tool used to build, validate, and orchestrate OpenCore-based projects.

It is not a generic TypeScript compiler.
It understands FiveM/RedM runtimes, OpenCore architecture, and the constraints of each execution environment.

Conceptually, it plays a role similar to:

  • NestJS CLI (project orchestration)
  • Vite (fast, opinionated builds)

โ€ฆbut designed specifically for FiveM and RedM and OpenCore.


What problem does it solve? ๐Ÿง โ€‹

FiveM/RedM is not a single runtime.

You are dealing with:

  • Node.js (server)
  • Neutral JS runtimes (client)
  • Browsers (NUI / Views)

Each with different rules, APIs, and limitations.

The OpenCore CLI:

  • Detects what you are building
  • Validates what is allowed
  • Produces runtime-safe artifacts
  • Fails early when something is invalid

This removes an entire class of hard-to-debug runtime errors.


Core conceptsโ€‹

The CLI understands three types of components:

๐Ÿง  Coreโ€‹

The central brain of your server.

  • Hosts the OpenCore runtime
  • Exposes exports to other resources
  • Owns global systems (commands, players, identity)

There is usually one Core per server.


๐Ÿ›ฐ๏ธ Satellite Resourcesโ€‹

Modular resources that depend on the Core.

  • Contain gameplay logic
  • Register commands and events
  • Delegate shared systems to Core
  • Built for small bundles and fast iteration

This is the recommended way to scale a server.


๐Ÿ“ฆ Standalone Resourcesโ€‹

Independent resources that do not rely on OpenCore.

  • Legacy Lua scripts
  • Utility JS resources
  • Third-party tools

The CLI supports them, but does not enforce framework rules.


High-level build flow ๐Ÿ”โ€‹


Source Code
โ†“
Discovery (server / client / views)
โ†“
Runtime validation
โ†“
Adapter selection
โ†“
Parallel compilation
โ†“
FiveM-ready artifacts

You do not configure this manually.
The CLI infers it from structure and intent.


Why Go? โš™๏ธโ€‹

The CLI and compiler are written in Go (Golang) by design.

Key reasons:

  • Performance: Parallel builds using goroutines
  • Single binary: No Node.js dependency for the tool itself
  • Low memory usage: Stable even with many resources
  • Fast startup: Near-instant command execution

This makes the CLI reliable in both development and CI environments.


CLI syntax basics ๐Ÿงชโ€‹

Command arguments follow a simple convention:

  • <argument> โ†’ required
  • [argument] โ†’ optional

Example:

opencore create <type> [name]

This mirrors standard CLI conventions and avoids ambiguity.


Automatic discovery ๐Ÿ”โ€‹

The CLI performs automatic project analysis:

  • Detects server entrypoints:

    • main.ts, index.ts, server.ts
  • Detects client entrypoints:

    • client.ts, index.ts
  • Discovers NUI / view entrypoints

  • Infers runtime targets per file

No explicit configuration is required.


While npm and yarn are supported, pnpm is strongly recommended.

Reasons:

  • Faster installs
  • Lower disk usage
  • Strict dependency isolation
  • Optimized integration with the CLI linker

The CLI is designed around pnpmโ€™s dependency model.


NUI / Views support ๐Ÿ–ฅ๏ธโ€‹

The compiler automatically detects your UI framework and expects the correct adapters to be installed.

Supported setups include:

  • React โ†’ react, react-dom
  • Vue โ†’ vue, esbuild-plugin-vue3
  • Svelte โ†’ svelte, esbuild-svelte
  • SASS / SCSS โ†’ sass, esbuild-sass-plugin

If required dependencies are missing:

  • The build fails
  • A clear error is shown
  • The exact pnpm add command is suggested

No guessing, no silent failures.


Runtime adapters ๐Ÿง โ€‹

The CLI adapts its behavior based on runtime context:

  • Server (Node.js) Full Node APIs allowed

  • Client (Neutral runtime) Node.js and Web APIs are stripped

  • NUI (Browser) Standard web environment

This ensures:

  • Correct bundling
  • No invalid imports
  • Predictable runtime behavior

Philosophy โœจโ€‹

The OpenCore CLI is opinionated by design.

Its goals are:

  • Safety over flexibility
  • Correctness over convenience
  • Explicit failures instead of silent bugs

You can build your own tooling โ€” but the CLI is the reference implementation for OpenCore projects.


This overview defines what the CLI is. The following sections explain how to use it.