CLI Reference
CLI Reference
Section titled “CLI Reference”The Jac CLI provides commands for running, building, testing, and deploying Jac applications.
💡 Enhanced Output: For beautiful, colorful terminal output with Rich formatting, install the optional
jac-superplugin:pip install jac-super. All CLI commands will automatically use enhanced output with themes, panels, and spinners.
Quick Reference
Section titled “Quick Reference”| Command | Description |
|---|---|
jac run | Execute a Jac file |
jac start | Start REST API server (use --scale for K8s deployment) |
jac create | Create new project |
jac check | Type check code |
jac test | Run tests |
jac format | Format code |
jac clean | Clean project build artifacts |
jac purge | Purge global bytecode cache (works even if corrupted) |
jac enter | Run specific entrypoint |
jac dot | Generate graph visualization |
jac debug | Interactive debugger |
jac plugins | Manage plugins |
jac config | Manage project configuration |
jac destroy | Remove Kubernetes deployment (jac-scale) |
jac add | Add packages to project |
jac install | Install project dependencies |
jac remove | Remove packages from project |
jac update | Update dependencies to latest compatible versions |
jac jacpack | Manage project templates (.jacpack files) |
jac grammar | Extract and print the Jac grammar |
jac script | Run project scripts |
jac py2jac | Convert Python to Jac |
jac jac2py | Convert Jac to Python |
jac tool | Language tools (IR, AST) |
jac lsp | Language server |
jac js | JavaScript output |
jac build | Build for target platform (jac-client) |
jac setup | Setup build target (jac-client) |
Core Commands
Section titled “Core Commands”jac run
Section titled “jac run”Execute a Jac file.
Note: jac <file> is shorthand for jac run <file> - both work identically.
jac run [-h] [-m] [--no-main] [-c] [--no-cache] [--profile PROFILE] filename [args ...]| Option | Description | Default |
|---|---|---|
filename | Jac file to run | Required |
-m, --main | Treat module as __main__ | True |
-c, --cache | Enable compilation cache | True |
--profile | Configuration profile to load (e.g. prod, staging) | "" |
args | Arguments passed to the script (available via sys.argv[1:]) |
Like Python, everything after the filename is passed to the script. Jac flags must come before the filename.
Examples:
# Run a filejac run main.jac
# Run without cache (flags before filename)jac run --no-cache main.jac
# Pass arguments to the scriptjac run script.jac arg1 arg2
# Pass flag-like arguments to the scriptjac run script.jac --verbose --output result.txtPassing arguments to scripts:
Arguments after the filename are available in the script via sys.argv:
# greet.jacimport sys;
with entry { name = sys.argv[1] if len(sys.argv) > 1 else "World"; print(f"Hello, {name}!");}jac run greet.jac Alice # Hello, Alice!jac run greet.jac # Hello, World!sys.argv[0] is the script filename (like Python). For scripts that accept
flags, use Python’s argparse module:
import argparse;
with entry { parser = argparse.ArgumentParser(); parser.add_argument("--name", default="World"); args = parser.parse_args(); print(f"Hello, {args.name}!");}jac run greet.jac --name Alicejac start
Section titled “jac start”Start a Jac application as an HTTP API server. With the jac-scale plugin installed, use --scale to deploy to Kubernetes. Use --dev for Hot Module Replacement (HMR) during development.
jac start [-h] [-p PORT] [-m] [--no-main] [-f] [--no-faux] [-d] [--no-dev] [-a API_PORT] [-n] [--no-no_client] [--scale] [--no-scale] [-b] [--no-build] [filename]| Option | Description | Default |
|---|---|---|
filename | Jac file to serve | main.jac |
-p, --port | Port number | 8000 |
-m, --main | Treat as __main__ | True |
-f, --faux | Print docs only (no server) | False |
-d, --dev | Enable HMR (Hot Module Replacement) mode | False |
--api_port | Separate API port for HMR mode (0=same as port) | 0 |
--no_client | Skip client bundling/serving (API only) | False |
--scale | Deploy to Kubernetes (requires jac-scale) | False |
-b, --build | Build Docker image before deploy (with --scale) | False |
Examples:
# Start with default main.jac on default portjac start
# Start on custom portjac start -p 3000
# Start with Hot Module Replacement (development)jac start --dev
# HMR mode without client bundling (API only)jac start --dev --no-client
# Deploy to Kubernetes (requires jac-scale plugin)jac start --scale
# Build and deploy to Kubernetesjac start --scale --buildNote:
- If your project uses a different entry file (e.g.,
app.jac,server.jac), you can specify it explicitly:jac start app.jac
jac create
Section titled “jac create”Initialize a new Jac project with configuration. Creates a project folder with the given name containing the project files.
jac create [-h] [-f] [-u USE] [-l] [name]| Option | Description | Default |
|---|---|---|
name | Project name (creates folder with this name) | Current directory name |
-f, --force | Overwrite existing project | False |
-u, --use | Jacpac template: registered name, file path, or URL | default |
-l, --list-jacpacks | List available jacpack templates | False |
Examples:
# Create basic project (creates myapp/ folder)jac create myappcd myapp
# Create full-stack project with client template (requires jac-client)jac create myapp --use client
# Create from a local .jacpack filejac create myapp --use ./my-template.jacpack
# Create from a local template directoryjac create myapp --use ./my-template/
# Create from a URLjac create myapp --use https://example.com/template.jacpack
# List available jacpack templatesjac create --list-jacpacks
# Force overwrite existingjac create myapp --force
# Create in current directoryjac createSee Also: Use jac jacpack to create and bundle custom templates.
jac check
Section titled “jac check”Type check Jac code for errors.
jac check [-h] [-e] [-w] [--ignore PATTERNS] [-p] [--nowarn] paths [paths ...]| Option | Description | Default |
|---|---|---|
paths | Files/directories to check | Required |
-e, --print_errs | Print detailed error messages | True |
-w, --warnonly | Treat errors as warnings | False |
--ignore | Comma-separated list of files/folders to ignore | None |
-p, --parse_only | Only check syntax (skip type checking) | False |
--nowarn | Suppress warning output | False |
Examples:
# Check a filejac check main.jac
# Check a directoryjac check src/
# Warnings only modejac check main.jac -w
# Check directory excluding specific folders/filesjac check myproject/ --ignore fixtures tests
# Check excluding multiple patternsjac check . --ignore node_modules dist __pycache__jac test
Section titled “jac test”Run tests in Jac files.
jac test [-h] [-t TEST_NAME] [-f FILTER] [-x] [-m MAXFAIL] [-d DIRECTORY] [-v] [filepath]| Option | Description | Default |
|---|---|---|
filepath | Test file to run | None |
-t, --test_name | Specific test name | None |
-f, --filter | Filter tests by pattern | None |
-x, --xit | Exit on first failure | False |
-m, --maxfail | Max failures before stop | None |
-d, --directory | Test directory | None |
-v, --verbose | Verbose output | False |
Examples:
# Run all tests in a filejac test main.jac
# Run tests in directoryjac test -d tests/
# Run specific testjac test main.jac -t my_test
# Stop on first failurejac test main.jac -x
# Verbose outputjac test main.jac -vjac format
Section titled “jac format”Format Jac code according to style guidelines. For auto-linting (code corrections like combining consecutive has statements, converting @staticmethod to static), use jac lint --fix instead.
jac format [-h] [-s] [-l] paths [paths ...]| Option | Description | Default |
|---|---|---|
paths | Files/directories to format | Required |
-s, --to_screen | Print to stdout instead of writing | False |
-l, --lintfix | Also apply auto-lint fixes in the same pass | False |
Examples:
# Preview formattingjac format main.jac -t
# Apply formattingjac format main.jac
# Format entire directoryjac format .Note: For auto-linting (code corrections), use
jac lint --fixinstead. Seejac lintbelow.
jac lint
Section titled “jac lint”Lint Jac files and report violations. Use --fix to auto-fix violations.
jac lint [-h] [-f] [--ignore IGNORE] paths [paths ...]| Option | Description | Default |
|---|---|---|
paths | Files/directories to lint | Required |
-f, --fix | Auto-fix lint violations | False |
--ignore | Comma-separated files/folders to ignore | "" |
Examples:
# Report lint violationsjac lint main.jac
# Auto-fix violationsjac lint main.jac --fix
# Lint entire directoryjac lint .
# Lint excluding foldersjac lint . --ignore fixturesLint Rules: Configure rules via
[check.lint]injac.toml. All enabled rules are treated as errors.
jac enter
Section titled “jac enter”Run a specific entrypoint in a Jac file.
jac enter [-h] [-m] [-r ROOT] [-n NODE] filename entrypoint [args ...]| Option | Description | Default |
|---|---|---|
filename | Jac file | Required |
entrypoint | Function/walker to invoke (positional) | Required |
args | Arguments to pass | None |
-m, --main | Treat as __main__ | True |
-r, --root | Root executor ID | None |
-n, --node | Starting node ID | None |
Examples:
# Run specific entrypointjac enter main.jac my_walker
# With argumentsjac enter main.jac process_data arg1 arg2
# With root and nodejac enter main.jac my_walker -r root_id -n node_idVisualization & Debug
Section titled “Visualization & Debug”jac dot
Section titled “jac dot”Generate DOT graph visualization.
jac dot [-h] [-s SESSION] [-i INITIAL] [-d DEPTH] [-t] [-b] [-e EDGE_LIMIT] [-n NODE_LIMIT] [-o SAVETO] [-p] [-f FORMAT] filename [connection ...]| Option | Description | Default |
|---|---|---|
filename | Jac file | Required |
-s, --session | Session identifier | None |
-i, --initial | Initial node ID | None |
-d, --depth | Max traversal depth | -1 (unlimited) |
-t, --traverse | Enable traversal mode | False |
-c, --connection | Connection filters | None |
-b, --bfs | Use BFS traversal | False |
-e, --edge_limit | Max edges | 512 |
-n, --node_limit | Max nodes | 512 |
-o, --saveto | Output file path | None |
-p, --to_screen | Print to stdout | False |
-f, --format | Output format | dot |
Examples:
# Generate DOT outputjac dot main.jac -s my_session --to_screen
# Save to filejac dot main.jac -s my_session --saveto graph.dot
# Limit depthjac dot main.jac -s my_session -d 3jac debug
Section titled “jac debug”Start interactive debugger.
jac debug [-h] [-m] [-c] filename| Option | Description | Default |
|---|---|---|
filename | Jac file to debug | Required |
-m, --main | Run main entry | True |
-c, --cache | Use cache | False |
Examples:
# Start debuggerjac debug main.jacPlugin Management
Section titled “Plugin Management”jac plugins
Section titled “jac plugins”Manage Jac plugins.
jac plugins [-h] [-v] [action] [names ...]| Action | Description |
|---|---|
list | List installed plugins (default) |
info | Show plugin information |
enable | Enable plugins |
disable | Disable plugins |
disabled | List disabled plugins |
| Option | Description | Default |
|---|---|---|
-v, --verbose | Verbose output | False |
Examples:
# List plugins (action defaults to 'list')jac plugins
# Explicitly list pluginsjac plugins list
# Show info about a pluginjac plugins info byllm
# Disable a pluginjac plugins disable byllm
# Enable a pluginjac plugins enable byllm
# List disabled pluginsjac plugins disabledNote: To install or uninstall plugins, use
pip install/pip uninstalldirectly. Thejac pluginscommand manages enabled/disabled state for already-installed plugins.💡 Popular Plugins:
- jac-super: Enhanced console output with Rich formatting, colors, and spinners (
pip install jac-super)- jac-client: Full-stack web development with client-side rendering (
pip install jac-client)- jac-scale: Kubernetes deployment and scaling (
pip install jac-scale)
Configuration Management
Section titled “Configuration Management”jac config
Section titled “jac config”View and modify project configuration settings in jac.toml.
jac config [action] [key] [value] [-g GROUP] [-o FORMAT]| Action | Description |
|---|---|
show | Display explicitly set configuration values (default) |
list | Display all settings including defaults |
get | Get a specific setting value |
set | Set a configuration value |
unset | Remove a configuration value (revert to default) |
path | Show path to config file |
groups | List available configuration groups |
| Option | Description | Default |
|---|---|---|
key | Configuration key (positional, e.g., project.name) | None |
value | Value to set (positional) | None |
-g, --group | Filter by configuration group | None |
-o, --output | Output format (table, json, toml) | table |
Configuration Groups:
project- Project metadata (name, version, description)run- Runtime settings (cache, session)build- Build settings (typecheck, output directory)test- Test settings (verbose, filters)serve- Server settings (port, host)format- Formatting optionscheck- Type checking optionsdot- Graph visualization settingscache- Cache configurationplugins- Plugin managementenvironment- Environment variables
Examples:
# Show explicitly set configurationjac config show
# Show all settings including defaultsjac config list
# Show settings for a specific groupjac config show -g project
# Get a specific valuejac config get project.name
# Set a valuejac config set project.version "2.0.0"
# Remove a value (revert to default)jac config unset run.cache
# Show config file pathjac config path
# List available groupsjac config groups
# Output as JSONjac config show -o json
# Output as TOMLjac config list -o tomlDeployment (jac-scale)
Section titled “Deployment (jac-scale)”jac start —scale
Section titled “jac start —scale”Deploy to Kubernetes using the jac-scale plugin. See the jac start command above for full options.
jac start --scale # Deploy without buildingjac start --scale --build # Build and deployjac destroy
Section titled “jac destroy”Remove a deployment.
jac destroy [-h] file_path| Option | Description | Default |
|---|---|---|
file_path | Jac file to undeploy | Required |
Examples:
jac destroy main.jacPackage Management
Section titled “Package Management”jac add
Section titled “jac add”Add packages to your project’s dependencies. Requires at least one package argument (use jac install to install all existing dependencies). When no version is specified, the package is installed unconstrained and then the installed version is queried to record a ~=X.Y compatible-release spec in jac.toml.
jac add [-h] [-d] [-g GIT] [-v] [packages ...]| Option | Description | Default |
|---|---|---|
packages | Package specifications (required) | None |
-d, --dev | Add as dev dependency | False |
-g, --git | Git repository URL | None |
-v, --verbose | Show detailed output | False |
With jac-client plugin:
| Option | Description | Default |
|---|---|---|
--npm | Add as client-side (npm) package | False |
Examples:
# Add a package (records ~=2.32 based on installed version)jac add requests
# Add with explicit version constraintjac add "numpy>=1.24"
# Add multiple packagesjac add numpy pandas scipy
# Add as dev dependencyjac add pytest --dev
# Add from git repositoryjac add --git https://github.com/user/package.git
# Add npm package (requires jac-client)jac add react --npmjac install
Section titled “jac install”Sync the project environment to jac.toml. Installs all Python (pip), git, and plugin-provided (npm, etc.) dependencies in one command. Creates or validates the project virtual environment at .jac/venv/.
jac install [-h] [-d] [-v]| Option | Description | Default |
|---|---|---|
-d, --dev | Include dev dependencies | False |
-v, --verbose | Show detailed output | False |
Examples:
# Install all dependenciesjac install
# Install including dev dependenciesjac install --dev
# Install with verbose outputjac install -vjac remove
Section titled “jac remove”Remove packages from your project’s dependencies.
jac remove [-h] [-d] [packages ...]| Option | Description | Default |
|---|---|---|
packages | Package names to remove | None |
-d, --dev | Remove from dev dependencies | False |
With jac-client plugin:
| Option | Description | Default |
|---|---|---|
--npm | Remove client-side (npm) package | False |
Examples:
# Remove a packagejac remove requests
# Remove multiple packagesjac remove numpy pandas
# Remove dev dependencyjac remove pytest --dev
# Remove npm package (requires jac-client)jac remove react --npmjac update
Section titled “jac update”Update dependencies to their latest compatible versions. For each updated package, the installed version is queried and a ~=X.Y compatible-release spec is written back to jac.toml.
jac update [-h] [-d] [-v] [packages ...]| Option | Description | Default |
|---|---|---|
packages | Specific packages to update (all if empty) | None |
-d, --dev | Include dev dependencies | False |
-v, --verbose | Show detailed output | False |
Examples:
# Update all dependencies to latest compatible versionsjac update
# Update a specific packagejac update requests
# Update all including dev dependenciesjac update --devjac clean
Section titled “jac clean”Clean project build artifacts from the .jac/ directory.
jac clean [-h] [-a] [-d] [-c] [-p] [-f]| Option | Description | Default |
|---|---|---|
-a, --all | Clean all .jac artifacts (data, cache, packages, client) | False |
-d, --data | Clean data directory (.jac/data) | False |
-c, --cache | Clean cache directory (.jac/cache) | False |
-p, --packages | Clean virtual environment (.jac/venv) | False |
-f, --force | Force clean without confirmation prompt | False |
By default (no flags), jac clean removes only the data directory (.jac/data).
Examples:
# Clean data directory (default)jac clean
# Clean all build artifactsjac clean --all
# Clean only cachejac clean --cache
# Clean data and cache directoriesjac clean --data --cache
# Force clean without confirmationjac clean --all --force💡 Troubleshooting Tip: If you encounter unexpected syntax errors, “NodeAnchor is not a valid reference” errors, or other strange behavior after modifying your code, try clearing the cache with
jac clean --cache(rm -rf .jac) orjac purge. Stale bytecode can cause issues when source files change.
jac purge
Section titled “jac purge”Purge the global bytecode cache. Works even when the cache is corrupted.
jac purgeWhen to use:
- After upgrading Jaseci packages
- When encountering cache-related errors (
jaclang.pycore,NodeAnchor, etc.) - When setup stalls during first-time compilation
| Command | Scope |
|---|---|
jac clean --cache | Local project (.jac/cache/) |
jac purge | Global system cache |
Template Management
Section titled “Template Management”jac jacpack
Section titled “jac jacpack”Manage project templates. Bundle template directories into distributable .jacpack files or list available templates.
jac jacpack [action] [path] [-o OUTPUT]| Action | Description |
|---|---|
pack | Bundle a template directory into a .jacpack file |
list | List available templates (default) |
info | Show information about a template |
| Option | Description | Default |
|---|---|---|
path | Template directory (for pack) or .jacpack file (for info) | None |
-o, --output | Output file path for bundled template | <name>.jacpack |
Template Directory Structure:
A template directory should contain:
jac.toml- Project config with a[jacpack]section for metadata- Template files (
.jac,.md, etc.) with{{name}}placeholders
To make any Jac project packable as a template, simply add a [jacpack] section to your jac.toml. All other sections become the config for created projects.
Example jac.toml for a template:
# Standard project config (becomes the created project's jac.toml)[project]name = "{{name}}"version = "0.1.0"entry-point = "main.jac"
[dependencies]
# Jacpac metadata - used when packing, stripped from created projects[jacpack]name = "mytemplate"description = "My custom project template"jaclang = "0.9.0"
[[jacpack.plugins]]name = "jac-client"version = "0.1.0"
[jacpack.options]directories = [".jac"]root_gitignore_entries = [".jac/"]Examples:
# List available templatesjac jacpack list
# Bundle a template directoryjac jacpack pack ./my-template
# Bundle with custom output pathjac jacpack pack ./my-template -o custom-name.jacpack
# Show template infojac jacpack info ./my-templatejac jacpack info mytemplate.jacpackUsing Templates with jac create:
Once a template is registered, use it with the --use flag:
jac create myproject --use mytemplatejac js
Section titled “jac js”Generate JavaScript output from Jac code (used for jac-client frontend compilation).
jac js [-h] filename| Option | Description | Default |
|---|---|---|
filename | Jac file to compile to JS | Required |
Examples:
# Generate JS from Jac filejac js app.jacUtility Commands
Section titled “Utility Commands”jac grammar
Section titled “jac grammar”Extract and print the Jac grammar.
jac grammar [-h] [--lark] [-o OUTPUT]| Option | Description | Default |
|---|---|---|
--lark | Output in Lark format instead of EBNF | False |
-o, --output | Write output to file instead of stdout | None |
Examples:
# Print grammar in EBNF formatjac grammar
# Print in Lark formatjac grammar --lark
# Save to filejac grammar -o grammar.ebnfjac script
Section titled “jac script”Run custom scripts defined in the [scripts] section of jac.toml.
jac script [-h] [-l] [name]| Option | Description | Default |
|---|---|---|
name | Script name to run | None |
-l, --list_scripts | List available scripts | False |
Examples:
# Run a scriptjac script dev
# List available scriptsjac script --listSee Configuration: Scripts for defining scripts in jac.toml.
jac py2jac
Section titled “jac py2jac”Convert Python code to Jac.
jac py2jac filenameExamples:
jac py2jac script.pyjac jac2py
Section titled “jac jac2py”Convert Jac code to Python.
jac jac2py filenameExamples:
jac jac2py main.jacjac tool
Section titled “jac tool”Access language tools (IR, AST, etc.).
jac tool tool [args ...]Available tools:
# View IR optionsjac tool ir
# View ASTjac tool ir ast main.jac
# View symbol tablejac tool ir sym main.jac
# View generated Pythonjac tool ir py main.jacjac completions
Section titled “jac completions”Generate and install shell completion scripts for the jac CLI.
jac completions [-h] [-s SHELL] [-i] [--no-install]| Option | Description | Default |
|---|---|---|
-s, --shell | Shell type (bash, zsh, fish) | bash |
-i, --install | Auto-install completion to shell config | False |
When --install is used, the completion script is written to ~/.jac/completions.<shell> (e.g. ~/.jac/completions.bash) and a source line is added to your shell config file (~/.bashrc, ~/.zshrc, or ~/.config/fish/config.fish).
Installed files:
| Shell | Completion script | Config modified |
|---|---|---|
| bash | ~/.jac/completions.bash | ~/.bashrc |
| zsh | ~/.jac/completions.zsh | ~/.zshrc |
| fish | ~/.jac/completions.fish | ~/.config/fish/config.fish |
Examples:
# Print bash completion script to stdoutjac completions
# Auto-install for bash (writes to ~/.jac/completions.bash)jac completions --install
# Generate zsh completionsjac completions --shell zsh
# Auto-install for fishjac completions --shell fish --installNote: After installing, run
source ~/.bashrc(or restart your shell) to activate completions. Completions cover subcommands, options, and file paths.
jac lsp
Section titled “jac lsp”Start the Language Server Protocol server (for IDE integration).
jac lspPlugin Commands
Section titled “Plugin Commands”Plugins can add new commands and extend existing ones. These commands are available when the corresponding plugin is installed.
jac-client Commands
Section titled “jac-client Commands”Requires: pip install jac-client
jac build
Section titled “jac build”Build a Jac application for a specific target.
jac build [filename] [--client TARGET] [-p PLATFORM]| Option | Description | Default |
|---|---|---|
filename | Path to .jac file | main.jac |
--client | Build target (web, desktop) | web |
-p, --platform | Desktop platform (windows, macos, linux, all) | Current platform |
Examples:
# Build web target (default)jac build
# Build desktop appjac build --client desktop
# Build for Windowsjac build --client desktop --platform windowsjac setup
Section titled “jac setup”One-time initialization for a build target.
jac setup <target>Examples:
# Setup Tauri for desktop buildsjac setup desktopExtended Flags
Section titled “Extended Flags”| Base Command | Added Flag | Description |
|---|---|---|
jac create | --use client | Create full-stack project template |
jac create | --skip | Skip npm package installation |
jac start | --client <target> | Client build target for dev server |
jac add | --npm | Add npm (client-side) dependency |
jac remove | --npm | Remove npm (client-side) dependency |
Common Workflows
Section titled “Common Workflows”Development
Section titled “Development”# Create projectjac create myappcd myapp
# Runjac run main.jac
# Testjac test -v
# Lint and fixjac lint . --fixProduction
Section titled “Production”# Start locallyjac start -p 8000
# Deploy to Kubernetesjac start main.jac --scale
# Remove deploymentjac destroy main.jac