Before you can start using Trunk Code Quality, you need to install and initialize Trunk in your repo. This page covers the initialization process.Documentation Index
Fetch the complete documentation index at: https://trunk-4cab4936-sam-gutentag-flaky-tests-new-monitors.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Install the CLI
The Trunk CLI can be installed in many different ways depending on your use case.We recommend installing the CLI via NPM if you’re already using NPM, or using cURL and committing the launcher to Git for all other projects. Both methods allow your teammates to use Trunk without needing an additional install step.
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.trunk without installing anything, the launcher can be committed directly into your repo:
Other ways to install
NPM
NPM
If your project uses a Then add Trunk Launcher in your
package.json, you can specify the Trunk Launcher as a dependency so your developers can start using Trunk after installing Node dependencies.package.json as a script:macOS (using homebrew)
macOS (using homebrew)
You can run the following command if you prefer to install this tool via homebrew. Keep in mind that other developers on your team will also have to install manually.
Windows
Windows
From From Ensure you can execute powershell scripts:You can then execute trunk as
git-bash or msys2, download the Bash launcher and add it to your PATH:powershell, download the powershell launcher:.\trunk.ps1.CompatibilityOnly some versions of Trunk are compatible with Windows. See the compatibility page for Windows to learn more.You will also need to install C and C++ runtime libraries in order to run some linters.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 theinit command.
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.
Trunk is Git awareTrunk speeds up your linting process by running on only the files that have changed in your branch compared to upstream. This means if you’re using a base/trunk branch that’s not
master or main, you will need to specify it in your .trunk/trunk.yamlRun 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.
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: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.