Command line
Skala includes a command line tool, called SkalaCLI. It can build Skala documents without opening Skala, which makes it perfect for scripts, build systems, and continuous integration. It also contains an MCP server, so AI agents can read, edit, and export Skala documents.
Location #
SkalaCLI lives inside the Skala app bundle. If Skala is in your Applications folder, the full path is:
/Applications/Skala.app/Contents/SharedSupport/SkalaCLI
If you use it often, it can be handy to add an alias to your shell’s configuration file.
alias skala="/Applications/Skala.app/Contents/SharedSupport/SkalaCLI"
To see the available commands and options, run SkalaCLI with --help. Each command has its own help as well.
/Applications/Skala.app/Contents/SharedSupport/SkalaCLI --help
/Applications/Skala.app/Contents/SharedSupport/SkalaCLI build --help
Building a document #
The build command is the equivalent of choosing File › Build All for the specified document. Every build group and build task in the document is run, and the files are written to the export paths set in the document’s build settings.
/Applications/Skala.app/Contents/SharedSupport/SkalaCLI build MyGreatDesign.skala
Export paths are usually relative to the Skala document, so the files end up in the same place they would if you chose Build All in Skala, no matter which folder you run the command from.
Older scripts may use the -b flag instead of the build command. It does exactly the same thing, and still works.
/Applications/Skala.app/Contents/SharedSupport/SkalaCLI -b MyGreatDesign.skala
Further reading: Exporting and build settings
Overriding the output folder #
The -o (or --output) option sends everything to a different folder, instead of the export paths in the document’s build tasks.
/Applications/Skala.app/Contents/SharedSupport/SkalaCLI build MyGreatDesign.skala -o ~/Downloads/Temp/
Build tasks with a relative export path keep their last folder name inside the output folder, so tasks that write to different folders don’t collide. For example, a task that exports to Skala Export/ writes to ~/Downloads/Temp/Skala Export/. Build tasks with an absolute export path write directly into the output folder.
Results and exit codes #
When a build succeeds, SkalaCLI prints how many files were written. Warnings and errors are printed to standard error, along with the name of the layer they relate to.
- An exit code of
0means the build succeeded. There may still be warnings, like a layer that has nothing visible to export. - An exit code of
1means the document couldn’t be opened, at least one asset couldn’t be written, or Skala isn’t licensed on the Mac. When assets couldn’t be written, SkalaCLI prints “Build failed”. Running SkalaCLI with no arguments at all also returns1. - An exit code of
64means the command itself wasn’t valid, likebuildwithout a document path.
Further reading: Build settings
Automation and continuous integration #
Because SkalaCLI returns a non-zero exit code when something goes wrong, it can be dropped straight into build scripts, Xcode build phases, Makefiles, or continuous integration jobs. A failed export stops the build, rather than quietly shipping stale images.
#!/bin/bash
set -e
SKALA="/Applications/Skala.app/Contents/SharedSupport/SkalaCLI"
"$SKALA" build Design/Icons.skala -o Build/Icons/
"$SKALA" build Design/Buttons.skala -o Build/Buttons/
The machine running the build needs Skala installed, because SkalaCLI runs from inside the app bundle. Skala itself doesn’t need to be open.
SkalaCLI uses Skala’s license or trial, so Skala needs to have been opened on the Mac at least once, to start a trial or enter a license. If the trial has ended, or the license hasn’t been validated for too long, SkalaCLI prints a message and exits with a code of 1.