LogoLogo
SlackLogin
  • Overview
    • Welcome
  • Setup & Configuration
    • Connecting to Trunk
    • Managing Your Organization
      • GitHub App Permissions
  • Integration with Slack
  • Flaky Tests (Beta)
    • Overview
    • Get Started
      • Test Frameworks
        • Android
        • Bazel
        • Behave
        • cargo-nextest
        • Cypress
        • Dart Test
        • Go
        • GoogleTest
        • Gradle
        • Jasmine
        • Jest
        • Karma
        • Maven
        • minitest
        • Mocha
        • Nightwatch
        • NUnit
        • Pest
        • PHPUnit
        • Playwright
        • Pytest
        • Robot Framework
        • RSpec
          • RSpec (Manual Uploads)
        • Swift Testing
        • Vitest
        • XCTest
        • Other Test Frameworks
      • CI Providers
        • Azure DevOps Pipelines
        • BitBucket Pipelines
        • Buildkite
        • CircleCI
        • Drone CI
        • GitHub Actions
        • GitLab
        • Jenkins
        • Semaphore CI
        • TeamCity
        • Travis CI
        • Other CI Providers
    • Dashboard
    • Flaky Test Detection
    • Quarantining
    • PR Comments
    • Ticketing Integrations
      • Jira Integration
      • Linear Integration
      • Other Ticketing Platforms
    • Webhooks
      • Slack Integration
      • Microsoft Teams Integration
      • GitHub Issues Integration
      • Linear Integration
    • Uploader CLI Reference
  • Merge Queue
    • Overview
    • How does it work?
    • Setup
      • Quick Start
      • Settings
      • Integration for Slack
    • Concepts and Optimizations
      • Predictive Testing
      • Optimistic Merging
      • Pending Failure Depth
      • Anti-Flake Protection
      • Batching
      • Parallel Queues
        • Bazel
        • Nx
        • API
      • FAQ
    • Priority
    • Managing Merge Queue
      • Using the Merge UI
      • Metrics
      • Command Line
    • Webhooks
    • Reference
  • Code Quality
    • Overview
    • Why Metalinters?
      • How does it work?
      • Why Code Quality?
    • Setup & Installation
      • Initialize Trunk
      • Local Linting
      • Linting in CI
      • Nightly Report (Deprecated)
    • IDE Integration
      • VSCode
      • Neovim
      • GitHub Codespaces
    • Linters
      • Supported Linters
        • Actionlint
        • Ansible-lint
        • Autopep8
        • Bandit
        • Biome
        • Black
        • Brakeman
        • buf
        • Buildifier
        • cfnlint
        • Checkov
        • circleci
        • ClangFormat
        • clang-tidy
        • Clippy
        • cmake-format
        • codespell
        • cspell
        • cue-fmt
        • dart
        • deno
        • Detekt
        • djlint
        • dotenv-linter
        • dotnet-format
        • dustilock
        • ESLint
        • Flake8
        • git-diff-check
        • Gitleaks
        • Gofmt
        • gofumpt
        • goimports
        • gokart
        • golangci-lint
        • golines
        • google-java-format
        • graphql-schema-linter
        • hadolint
        • haml-lint
        • isort
        • iwyu
        • ktlint
        • kube-linter
        • markdown-link-check
        • markdown-table-prettify
        • Markdownlint
        • markdownlint-cli2
        • mypy
        • nancy
        • nixpkgs-fmt
        • opa
        • OSV-Scanner
        • Oxipng
        • perlcritic
        • perltidy
        • php-cs-fixer
        • phpstan
        • pmd
        • pragma-once
        • pre-commit-hooks
        • Prettier
        • prisma
        • psscriptanalyzer
        • Pylint
        • pyright
        • regal
        • remark-lint
        • renovate
        • rome
        • rubocop
        • Ruff
        • rufo
        • rustfmt
        • scalafmt
        • semgrep
        • ShellCheck
        • shfmt
        • sort-package-json
        • sourcery
        • sql-formatter
        • SQLFluff
        • sqlfmt
        • squawk
        • standardrb
        • stringslint
        • stylelint
        • stylua
        • SVGO
        • swiftformat
        • swiftlint
        • taplo
        • Terraform
        • terragrunt
        • terrascan
        • TFLint
        • tfsec
        • tofu
        • Trivy
        • Trufflehog
        • txtpbfmt
        • vale
        • Yamllint
        • yapf
      • Run Linters
      • Manage Linters
      • Configure Linters
      • Ignoring Issues and Files
      • Custom Linters
      • Shared Configs
      • Upgrades
    • Debugging
    • Licensing
  • CLI & API References
    • CLI Reference
      • Install
      • Getting Started
        • Code Quality
        • Merge Queue
        • Flaky Tests
        • Tools
        • Actions
          • Git Hooks
        • Announce
      • Compatibility
      • Caching
      • Commands Reference
        • Code Quality
        • Actions
        • Merge
      • Configuration
        • Plugins
          • Share Config Between Codebases
          • Exporting Linter Configs
        • Runtimes
        • Tools
        • Lint
          • Definitions
          • Commands
          • Output
          • Output Parsing
          • Files and Caching
          • Dependencies
          • Auto-Enable
        • Actions
          • Notifications
          • Logging and Troubleshooting
        • Merge
        • Telemetry
        • Per User Overrides
    • API Reference
      • Flaky Tests
      • Merge Queue
      • Webhooks Reference
  • Pricing & Security
    • Security
  • Billing
  • Community & Support
  • Links
    • Open App
    • Slack Community
    • Changelog
    • Feature Requests
On this page
  • Install the CLI
  • Initializing Trunk
  • Run Linters
  • The .trunk Directory
  • Recommended Linters
  • IDE Integration
  • Move Existing Configs
  • Next Steps
Edit on GitHub
  1. Code Quality
  2. Setup & Installation

Initialize Trunk

Last updated 1 month ago

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.

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 .

You can install the script directly by downloading it through cURL. The launcher script supports both macOS and Linux environments.

curl https://get.trunk.io -fsSL | bash
curl https://get.trunk.io -fsSL | bash -s -- -y

To allow your teammates to use trunk without installing anything, the launcher can be committed directly into your repo:

curl -fsSLO --retry 3 https://trunk.io/releases/trunk
chmod +x ./trunk
git commit ./trunk -m "Commit Trunk to our repo"

Other ways to install

NPM

If your project uses a package.json, you can specify the Trunk Launcher as a dependency so your developers can start using Trunk after installing Node dependencies.

# npm
npm install -D @trunkio/launcher
# pnpm
pnpm add -D @trunkio/launcher
# yarn
yarn add -D @trunkio/launcher
# bun
bun install -D @trunkio/launcher

Then add Trunk Launcher in your package.json as a script:

{
  "scripts": {
    "trunk": "trunk",
    "lint": "trunk check",
    "fmt": "trunk fmt"
  }
}
macOS (using homebrew)
brew install trunk-io
Windows

From git-bash or msys2, download the Bash launcher and add it to your PATH:

curl https://get.trunk.io -fsSL | bash

From powershell, download the powershell launcher:

Invoke-RestMethod -Uri https://trunk.io/releases/trunk.ps1 -OutFile trunk.ps1

Ensure you can execute powershell scripts:

Set-ExecutionPolicy Bypass -Scope CurrentUser

You can then execute trunk as .\trunk.ps1.

Compatibility

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.

./trunk init

Follow the wizard. You'll be prompted with the following options:

  1. Sign up or log in: Connect the CLI with your Trunk account to enable all of Trunk's features.

  2. 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.

  3. 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 aware

Trunk 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.yaml

version: 0.1
cli:
  version: 1.22.2
repo:
  # develop is the branch that everyone's work is merged into
  trunk_branch: develop
... rest of configs

Run Linters

./trunk check

The .trunk Directory

After initialization, a new folder .trunk will be generated with the following content.

.trunk
├── actions/ 
├── configs/ # This is where linter configs live
├── logs/ # Logs for debugging
├── notifications/
├── out/
├── plugins/
├── tools/ 
└── trunk.yaml # Top-level Trunk config

You will spend most of your time configuring Trunk Code Quality's linter definitions trunk.yaml and individual linter configurations in configs.

Recommended Linters

You can enable and disable individual linters by running:

trunk check enable <linter>
trunk check disable <linter>

You can also see all linters and whether they're enabled by running:

trunk check list

IDE Integration

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

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.

🎉
homebrew
Windows
C and C++ runtime libraries
enable the most useful linters
full list of supported linters can be found here
VSCode
Neovim
next steps
recommended set of linters
Gradle Wrapper
Trunk Launcher