CLI Commands
The rustscript command-line tool compiles, runs, formats, and manages RustScript projects. The short alias rsc is also available.
rustscript init
Create a new project:
rustscript init my-project
Creates a directory with rustscript.json, a generated Cargo.toml, .gitignore, and src/main.rts.
Templates
rustscript init my-api --template web-server # axum web server
rustscript init my-tool --template cli # CLI application
rustscript init my-wasm --template wasm # WebAssembly project
rustscript build
Compile to a native binary:
rustscript build
This:
- Parses
.rtsfiles - Type-checks
- Lowers to Rust
- Emits
.rsfiles in-place next to source files - Merges detected dependencies into the project root
Cargo.toml - Runs
cargo build
The output binary is in target/debug/.
rustscript run
Build and execute in one step:
rustscript run
Pass arguments to the compiled binary with --:
rustscript run -- --port 8080 --verbose
Everything after -- is forwarded to your program, not to the compiler.
rustscript check
Type-check without building:
rustscript check
Faster than rustscript build because it skips code generation and cargo build. Use it for quick validation while editing.
rustscript dev
Watch mode — rebuilds on file changes:
rustscript dev
Watches src/ for .rts file changes and recompiles automatically.
rustscript fmt
Format .rts source files:
rustscript fmt
Applies consistent formatting to all .rts files in the project. Analogous to prettier for TypeScript or rustfmt for Rust.
rustscript test
Compile and run tests:
rustscript test
rustscript types
Generate TypeScript type definitions from your RustScript source:
rustscript types --out frontend/src/types/
Emits .d.ts files for types that derive Serialize or Deserialize. Use this to share types between a RustScript backend and a TypeScript frontend.
rustscript add / remove
Manage dependencies:
rustscript add serde --version 1 --features derive
rustscript remove serde
Reads and writes the dependencies section of rustscript.json.
rustscript eject
Convert a RustScript project to pure Rust:
rustscript eject
This:
- Removes
rustscript.json(the RustScript manifest) - Removes
/src/*.rsfrom.gitignoreso the generated Rust files are tracked - Leaves you with a standard Cargo project you can continue in pure Rust
Use this when you want to graduate a project out of RustScript without losing any code. The generated .rs files are idiomatic, human-readable Rust — they're a clean starting point.
Common workflows
Development loop
rustscript dev # Watch mode
rustscript check # Quick type check
rustscript fmt # Format before committing
Production build
rustscript build # Compile to native binary
./target/debug/my-project # Run the binary directly
Exit codes
| Code | Meaning |
|------|---------|
| 0 | Success |
| 1 | Compilation error (parse, type check, or lowering) |
| Non-zero | cargo build or runtime failure |