Everyday commands

View source

The commands you use all the time. check, build, run, fmt and watch, their options, and what strict checking adds.

This page goes through the commands you use every day. It uses the shapes project from Projects and modules. Run the commands in the project folder, next to Actus.toml.

CommandWhat it does
actus checkreads the program and reports mistakes. Builds nothing.
actus buildcompiles the program to an object file or an executable.
actus runbuilds the program, runs it once, and removes the executable.
actus testruns your tests. See Testing.
actus fmtputs your code in the standard layout.
actus watchchecks again every time a file changes.
actus lockupdates Actus.lock. See Projects and modules.
actus explaintells you what an error code means. See Fixing and explaining errors.
actus fixapplies the fixes that the compiler is sure about. See Fixing and explaining errors.
actus lspstarts the language server for editors. See Editor support.
actus mcpstarts the compiler server for assistants. See Using Actus with AI assistants.

Every command prints actus <command> --help with its options.

The version

bash
actus --version
text
actus 0.3.0 (15b00577e24d)
llvm 23.1.2 verified llvm-23.1.2-actus-2 sha256:3dfe69ed3a2f1cb86e65c417ead3552d6dae6350b70947c3c35ff47cc0adfddc
host x86_64-unknown-linux-gnu
backends llvm, cranelift

The first line is the version of Actus. The host line is your system. The backends line lists the code generators this copy of Actus has. Put these lines in a bug report.

To see only the first line, send the output through head:

bash
actus --version | head -1
text
actus 0.3.0 (15b00577e24d)

head closes the pipe after the first line, and actus stops without an error message. The same is true for the other commands, so a pipe such as actus test --list | head -3 is safe to use.

check

actus check is the fastest way to find out whether your code is correct. It reads the program, checks names, types and ownership, and stops there.

bash
actus check
text
checked `/home/you/shapes/src/main.act` successfully

When an error has a code, actus explain E#### tells you more about it, and actus fix can apply the fix when the compiler knows one that is safe. See Fixing and explaining errors.

actus check starts at src/main.act and follows the import lines. A file that nothing imports is not checked. To check one file, give its path. Say that src/extra.act holds a verb whose parameter has no role, verb helper(x) {, and a closing brace:

bash
actus check src/extra.act
text
src/extra.act: error[E0003] at 1:13: expected parameter role (`erg`, `abs`, `dat`, or `ins`), found identifier `x`

The command exits with status 1 when it finds an error.

build

actus build compiles the program. Without options it stops early and only writes an object file. To get a program you can run, add --emit exe:

bash
actus build
actus build --emit exe
text
built `/home/you/shapes/capsula/debug/x86_64-unknown-linux-gnu/main.obj`
built `/home/you/shapes/capsula/debug/x86_64-unknown-linux-gnu/main.bin`

Everything the compiler writes goes into the capsula folder, in a folder for the profile and one for your system. You can delete capsula at any time. These options change what build does:

OptionEffect
--emit objwrite an object file. This is the default.
--emit exelink an executable. It needs what Install describes: a C compiler on Linux and macOS, the Build Tools for Visual Studio on Windows.
--releasethe release profile
--profile <name>the profile debug, release or size
--backend llvm|craneliftthe code generator. llvm is the default.
-o <output>where to write the result
--strictuse the strict rules, see Strict checking
[file.act]build this file instead of the project

The three profiles ask the compiler for different things:

  • debug is the default. It does not optimize, so it builds fastest.
  • release optimizes for speed.
  • size optimizes for small code.
bash
actus build --release --emit exe
actus build --profile size --emit exe
text
built `/home/you/shapes/capsula/release/x86_64-unknown-linux-gnu/main.bin`
built `/home/you/shapes/capsula/size/x86_64-unknown-linux-gnu/main.bin`

You can set a default profile in Actus.toml with profile = "release" under [build]. An option on the command line wins over the file. Giving both --release and --profile is an error.

LLVM is the default backend and the one to use. --backend cranelift selects the other code generator that the compiler contains. A backend that is not available is an error. Actus never switches to the other one by itself.

An option that Actus does not know is reported before anything is built. This is true for every command, not only build. The command exits with status 2:

bash
actus build --fast
text
error: unknown option `--fast` for `actus build`

A value that Actus does not know is reported in the same way:

bash
actus build --profile fast
text
error: unsupported build profile `fast`

run

actus run builds the program, runs it, and removes the temporary executable. It takes --release, --profile and --backend like build.

bash
actus run
text
42
26
process exited with status 0

The last line comes from actus run. When your program exits with a status that is not 0, actus run exits with the same status.

Pass arguments to your program

Everything after -- goes to your program, not to actus. A program reads its arguments with std::process. This one prints each argument, except the first one, which is the name of the program itself:

actus
import std::process;

verb main() -> Int {
    erg arguments = process::arguments();
    return case dat arguments {
        Result.Ok(list) => show(args: ins list),
        Result.Err(_) => 1,
    };
}

verb show(ins args: process::Arguments) -> Int {
    erg total = process::count(abs args);
    erg buffer = Buffer[4096];
    for erg i in 0..total {
        erg next = process::next_arg(ins args, ins buffer);
        case dat next {
            Result.Ok(_) => {
                if i > 0 {
                    print(buffer: abs buffer);
                    println(string: "");
                }
            },
            Result.Err(_) => println(string: "error"),
        };
    }
    return 0;
}
bash
actus run -- one two
text
one
two
process exited with status 0

fmt

actus fmt rewrites your files in the standard layout, so that all Actus code looks the same. Without a path it formats every .act file in src and tests:

bash
actus fmt
text
`./src/geometry/geometry.act` is already formatted
`./src/geometry/helpers.act` is already formatted
`./src/geometry/rect.act` is already formatted
`./src/geometry/tests/rect.act` is already formatted
`./src/main.act` is already formatted
`./tests/helpers.act` is already formatted
`./tests/smoke.act` is already formatted
formatted 0 files, 7 already formatted

Here every file was tidy already, so the command reports is already formatted for each one and does not rewrite it. A file that it did change is reported as formatted with its path, and the last line counts both kinds. For example, after one file was untidy, the end of the output is formatted 1 file, 6 already formatted.

To only check, add --check. Nothing is written, and the exit status is 1 if a file needs formatting:

bash
actus fmt --check
text
./src/geometry/geometry.act is formatted
./src/geometry/helpers.act is formatted
./src/geometry/rect.act is formatted
./src/geometry/tests/rect.act is formatted
./src/main.act is formatted
./tests/helpers.act is formatted
./tests/smoke.act is formatted

A file that needs formatting is reported as is not formatted. Use actus fmt --check in a script or a CI job to keep a project tidy.

To format one file, give its path. actus fmt takes a file, not a folder:

bash
actus fmt src/main.act
text
`src/main.act` is already formatted

The formatter keeps lines at 100 columns or less. It wraps a long documentation block, so that the text sits on lines of its own between the """ marks, and it breaks a long expression before an operator. This program has a sum on one long line:

actus
verb main() {
    erg total = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 21 + 22;
    println(int: total);
}
bash
actus fmt

For the file that it changed, the command prints:

text
formatted `./src/main.act`

The file now reads:

actus
verb main() {
    erg total = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19
        + 20 + 21 + 22;
    println(int: total);
}

The formatter also puts several import lines into one block and adds a blank line between the open lines of a facade. A file with a syntax error cannot be formatted, and the command prints the error.

watch

actus watch checks the project, then waits. Whenever a source file changes, it checks again. Leave it running in a second terminal while you edit:

bash
actus watch
text
watching `/home/you/shapes/src/main.act`
checked `/home/you/shapes/src/main.act` successfully

Now change erg height = 7; to erg height: Int = "seven"; and save. The screen is cleared and the new result appears:

text
change detected; checking `/home/you/shapes/src/main.act`
/home/you/shapes/src/main.act: error[E1027] at 5:5: type mismatch for `height`: expected `Int`, found `String`

Put the line back and save again. The screen is cleared once more:

text
change detected; checking `/home/you/shapes/src/main.act`
checked `/home/you/shapes/src/main.act` successfully
watch check passed

Press Ctrl-C to stop it. It also notices changes in the other files of the project, not only in main.act. These options change it:

OptionEffect
--oncecheck one time and exit. The status is 1 if there are errors.
--buildbuild the executable after each change, not only check
--interval <ms>how often to look for changes, in milliseconds
--release, --profile <name>the profile used with --build

Strict checking

--strict makes check, build and test stricter. Use it before you share a project, and in a CI job. It does not change what a correct program does. Add it to the command, as in actus check --strict. Run it on the shapes project:

bash
actus check --strict
text
/home/you/shapes/src/geometry/geometry.act: error[E1840] at 1:1: facade export rect: missing or empty block docstring
/home/you/shapes/src/geometry/geometry.act: error[E1840] at 3:1: facade export helpers: missing or empty block docstring
/home/you/shapes/src/geometry/helpers.act: error[E1840] at 1:6: verb doubled: missing or empty block docstring
/home/you/shapes/src/geometry/rect.act: error[E1840] at 1:6: verb area: missing or empty block docstring
/home/you/shapes/src/geometry/rect.act: error[E1840] at 5:6: verb perimeter: missing or empty block docstring
/home/you/shapes/src/geometry/rect.act: error[E1840] at 9:1: verb is_square: private verb has no block docstring; strict mode documents every verb
/home/you/shapes/src/main.act: error[E1840] at 3:1: verb main: private verb has no block docstring; strict mode documents every verb

The shapes project does not pass yet. Strict mode wants a documentation block on every verb, whether it is open or private, and on every open line of a facade. It checks every file of the project, also a file that nothing imports. A documentation block is text between """ marks, on the lines just above the declaration. It must not be empty. Here is the facade, src/geometry/geometry.act:

actus
"""Arithmetic on rectangles."""
open rect;

"""Helpers that only the geometry module uses."""
open unit helpers;

And src/geometry/rect.act:

actus
"""Return the area of a rectangle: `width` times `height`."""
open verb area(abs width: Int, abs height: Int) -> Int {
    return width * height;
}

"""Return the perimeter of a rectangle: twice the sum of `width` and `height`."""
open verb perimeter(abs width: Int, abs height: Int) -> Int {
    return doubled(value: abs (width + height));
}

"""Return `true` when `width` and `height` are equal."""
verb is_square(abs width: Int, abs height: Int) -> Bool {
    return width == height;
}

Write a block for doubled in src/geometry/helpers.act and for main in src/main.act in the same way. Say what the verb is for, and add its roles, its result and its errors when they matter:

actus
"""Return twice `value`. `value` is only read."""
open verb doubled(abs value: Int) -> Int {
    return value * 2;
}
actus
import geometry;

"""Print the area and the perimeter of a 6 by 7 rectangle."""
verb main() {
    erg width = 6;
    erg height = 7;
    println(int: geometry::area(width: abs width, height: abs height));
    println(int: geometry::perimeter(width: abs width, height: abs height));
}

Then the command passes, and the last line says so:

bash
actus check --strict
text
checked `/home/you/shapes/src/main.act` successfully (strict)

run, fmt and watch do not take --strict. They report it as an unknown option and exit with status 2:

bash
actus run --strict
text
error: unknown option `--strict` for `actus run`; `--strict` is an option of `actus check`, `actus build`, `actus test` and `actus conformance`

Strict mode also applies size limits. They count only lines with code. Blank lines, # comments and documentation blocks do not count, so a full description never makes a file too long. Strict mode reports the highest limit that a verb or a file goes over, as an error, and the command stops with status 1:

WhatPreferred limitMust be splitHard limit
One verbabove 50 lines (E1853)from 60 lines (E1854)above 80 lines (E1855)
One fileabove 500 lines (E1850)from 600 lines (E1851)above 800 lines (E1852)

Normal mode does not look at the size. For example, a documented main with 59 lines of code is over the preferred limit:

text
/home/you/shapes/src/main.act: error[E1853] at 2:1: function `main` has 59 code lines; preferred limit is 50; note: Record decomposition evidence or split the function by responsibility.; help: Reduce the source size or document an approved structural exception.

A verb with 69 lines must be split, and one with 89 lines is over the hard limit:

text
/home/you/shapes/src/main.act: error[E1854] at 2:1: function `main` has 69 code lines; split is required at 60; note: Extract independent validation or transformation stages into named functions.; help: Reduce the source size or document an approved structural exception.
/home/you/shapes/src/main.act: error[E1855] at 2:1: function `main` has 89 code lines; hard limit is 80; note: Split the function into responsibility-specific operations.; help: Reduce the source size or document an approved structural exception.

A file that is too long gets the same kind of message, for example source file has 506 code lines; preferred limit is 500. The usual fix is to split the verb or the file into smaller parts. If you want to turn the limits off for a project, set source_limits = "limitless" under [package] in Actus.toml, and run actus lock, because the lock file records the setting.

What you learned

  • actus check finds mistakes without building. It only follows the imports from src/main.act, unless you give it a file.
  • actus build writes an object file by default. Add --emit exe for a program, and --release or --profile size for another profile.
  • actus run builds and runs once. Arguments for your program go after --.
  • actus fmt formats, actus fmt --check only checks and exits with 1 when a file needs formatting.
  • actus watch checks again after every change.
  • --strict asks for a documentation block on every verb and applies size limits. Use it with check, build and test.
  • actus explain E#### explains an error code, and actus fix applies the safe fixes.

Next: Editor support.