Gleam Tooling and Formatting
Gleam ships with a complete built-in toolchain. One CLI handles every task — formatting, building, testing, documentation generation, and package management. No extra tools to install, no configuration files to write, no version conflicts between linter and compiler.
The gleam CLI — Full Reference
gleam CLI Commands
──────────────────────────────────────────────────
Project Management:
gleam new <name> Create a new project
gleam add <package> Add a dependency
gleam remove <package> Remove a dependency
gleam deps download Install all dependencies
gleam deps update Update dependency versions
Build and Run:
gleam build Compile the project
gleam run Compile and run main()
gleam run -m <module> Run a specific module
gleam test Run all tests
gleam clean Delete build artifacts
Code Quality:
gleam format Format all .gleam files
gleam check Type-check without building
gleam fix Auto-fix certain warnings
Documentation:
gleam docs build Build HTML documentation
gleam docs serve Serve docs in browser
gleam docs publish Publish docs to HexDocs
Publishing:
gleam publish Publish to Hex package registry
gleam hex authenticate Log in to Hex
gleam format — Automatic Code Formatting
Gleam has one official style. The formatter enforces it with no configuration:
gleam format // format all .gleam files in src/ and test/
gleam format src/user.gleam // format one specific file
gleam format --check // check without modifying (use in CI)
Before formatting:
──────────────────────────────────────────────────
pub fn add( a:Int,b :Int)->Int{a+b}
After gleam format:
──────────────────────────────────────────────────
pub fn add(a: Int, b: Int) -> Int {
a + b
}
The formatter handles indentation, spacing, line breaks, and import ordering. Every Gleam codebase looks identical — no style debates, no reviewer comments about formatting, no inconsistency across team members.
gleam check — Fast Type Checking
gleam checkType-checks your code without producing output files. Much faster than a full build when you just want to verify types during development. Useful in editor save hooks and pre-commit checks.
gleam docs — Documentation Generation
Gleam generates HTML documentation from doc comments automatically:
/// Calculates the area of a rectangle.
///
/// ## Examples
///
/// ```gleam
/// area(5.0, 3.0)
/// // → 15.0
/// ```
pub fn area(width: Float, height: Float) -> Float {
width *. height
}
Doc Comment Syntax
──────────────────────────────────────────────────
/// → doc comment (appears in generated HTML docs)
// → regular comment (not included in docs)
Support Markdown:
## Section headings
`code inline`
```gleam
code blocks with syntax highlighting
```
- bullet lists
gleam docs build // generates HTML in build/docs/
gleam docs serve // opens docs in browser at localhost:7070
Language Server (LSP)
The Gleam Language Server provides editor intelligence. The gleam CLI installs it automatically when you install Gleam:
LSP Features
──────────────────────────────────────────────────
✓ Syntax highlighting
✓ Real-time type error underlining
✓ Inline type information on hover
✓ Auto-complete for functions, types, modules
✓ Go to definition
✓ Find all references
✓ Rename refactoring
✓ Code actions (add import, fix warnings)
✓ Format on save
Editor Setup
Editor Extension / Config
──────────────────────────────────────────────────
VS Code Install "Gleam" extension from marketplace
Neovim Use nvim-lspconfig with gleam LSP
Helix Built-in LSP support for Gleam
Zed Built-in Gleam support
Emacs gleam-mode + lsp-mode
Sublime Text LSP + LSP-gleam package
Setting Up CI/CD
A minimal GitHub Actions pipeline for a Gleam project:
# .github/workflows/ci.yml
name: CI
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Erlang
uses: erlef/setup-beam@v1
with:
otp-version: "26"
- name: Install Gleam
run: |
curl -L https://github.com/gleam-lang/gleam/releases/download/v1.5.1/gleam-v1.5.1-x86_64-unknown-linux-musl.tar.gz | tar xz
sudo mv gleam /usr/local/bin/
- name: Check formatting
run: gleam format --check
- name: Type check
run: gleam check
- name: Run tests
run: gleam test
Project Configuration Tricks
gleam.toml Options
──────────────────────────────────────────────────
name = "my_app"
version = "1.0.0"
description = "A great Gleam application"
licences = ["Apache-2.0"]
repository = { type = "github", user = "you", repo = "my_app" }
links = [{ title = "Website", href = "https://myapp.dev" }]
target = "erlang" # or "javascript"
[dependencies]
gleam_stdlib = ">= 0.36.0 and < 2.0.0"
[dev-dependencies]
gleeunit = ">= 1.1.0 and < 2.0.0"
Useful gleam run Flags
gleam run --target javascript // compile and run with Node.js
gleam run -m module_name // run a specific module's main()
gleam test --target javascript // run tests in JS environment
gleam build --target javascript // JS-only build
Key Points
Tooling Essentials
──────────────────────────────────────────────────
1. gleam format → auto-format (no config needed)
2. gleam check → fast type check only
3. gleam test → run all tests
4. gleam docs build → generate HTML docs from /// comments
5. gleam format --check → CI formatting enforcement
6. LSP installed automatically — plug into any editor
7. gleam.toml → project metadata and dependencies
8. One tool handles everything — no npm/webpack/eslint juggling
The Gleam toolchain removes the setup friction that plagues many language ecosystems. One binary, one command for each task, zero configuration required. Teams spend their time writing and shipping Gleam code rather than configuring build tools.
