Initialize Trunk
Before you can start using Trunk Code Quality, you need to install and initialize Trunk in your repo. This page covers the initialization process.
Install the CLI
The Trunk CLI can be installed in many different ways depending on your use case.
The Trunk Launcher
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 Gradle Wrapper.
You can install the Trunk Launcher 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:
Other ways to install
Initializing Trunk
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 automatically enable the most useful linters based on the files in your repo.
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.
Run Linters
After initialization, you can run the recommended set of linters by running:
The .trunk Directory
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
.
Recommended Linters
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 full list of supported linters can be found here.
You can enable and disable individual linters by running:
You can also see all linters and whether they're enabled by running:
IDE Integration
Trunk Code Quality supports VSCode and Neovim through extensions. Using VSCode and Neovim will provide inline linter annotations as you code.
Move Existing Configs
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.
Next Steps
After initializing Trunk Code Quality, you can check for issues and configure Code Quality. The next steps in Setup & Installation will walk you through this process.
Last updated