Initialize Trunk
Last updated
Last updated
Before you can start using Trunk Code Quality, you need to install and initialize Trunk in your repo. This page covers the initialization process.
The Trunk CLI can be installed in many different ways depending on your use case.
The easiest way to give everyone access to Trunk is to use the Trunk launcher. The Trunk launcher is a small script that will automatically install and run Trunk when invoked for the first time, similar to other command line tools like the .
You can install the script directly by downloading it through cURL. The launcher script supports both macOS and Linux environments.
To allow your teammates to use trunk
without installing anything, the launcher can be committed directly into your repo:
Before you can use Trunk, you need to initialize Trunk in your repo. Initializing Trunk will generate the necessary config files, recommend linters based on your project files, and configure githooks.
Initialize Trunk by running the init
command.
Follow the wizard. You'll be prompted with the following options:
Sign up or log in
: Connect the CLI with your Trunk account to enable all of Trunk's features.
Trunk will manage your git hooks and enable some built-in hooks.
: This sets up Trunk to run automatically on commit and before you push, saving you time waiting for CI only to have it fail.
Trunk will now run a local, one-time scan of your code and report any issues it finds
: This initial scan will give you a good overview of the problem areas in your code. Subsequent scans will only run on changed lines using hold-the-line.
After initialization, a new folder .trunk
will be generated with the following content.
You will spend most of your time configuring Trunk Code Quality's linter definitions trunk.yaml
and individual linter configurations in configs
.
You can enable and disable individual linters by running:
You can also see all linters and whether they're enabled by running:
If you have existing linter configs in your repo, you can move them into the .trunk/configs
folder. These config files will be symlinked in during any trunk check
run.
If you're using an IDE Extension like clangd
with an LSP that relies on those configs being in the root, you must create an additional symlink from the hidden config to the workspace root.
You can run the following command if you prefer to install this tool via . Keep in mind that other developers on your team will also have to install manually.
Only some versions of Trunk are compatible with Windows. See the compatibility page for to learn more.
You will also need to install in order to run some linters.
Trunk will automatically based on the files in your repo.
After initialization, you can run the by running:
And just like that, you're ready to start using Trunk Code Quality.
During initialization, Trunk Code Quality will recommend some linters based on files found in your project. Trunk Code Quality will recommend common linters for your language, but the .
Trunk Code Quality supports and through extensions. Using VSCode and Neovim will provide inline linter annotations as you code.
After initializing Trunk Code Quality, you can check for issues and configure Code Quality. The in Setup & Installation will walk you through this process.