Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Gleam Knowledge Patch?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/nevaberry-gleam-knowledge-patch-nevaberry-plugins)
---
name: gleam-knowledge-patch
description: Gleam
version: "1.19.2"
license: MIT
metadata:
author: Nevaberry
---
# Gleam compatibility guidance
Load this skill when upgrading Gleam code or dependencies, configuring builds,
working with editor actions, or writing Erlang and JavaScript externals.
Use the topic references for detailed behavior, examples, and version attribution.
## Reference index
| Reference | Topics |
| --- | --- |
| [Conventions and patterns](references/conventions-and-patterns.md) | Naming, source import boundaries, HTTP interfaces, library failures |
| [Editor and refactoring](references/editor-and-refactoring.md) | Navigation, renaming, generation, patterns, extraction, labels, formatting |
| [Language and diagnostics](references/language-and-diagnostics.md) | Deprecations, records, constants, assertions, bit arrays, warnings, error recovery |
| [Packages, build, and configuration](references/packages-build-and-config.md) | Dependencies, Hex, publishing, project configuration, documentation, exports |
| [Standard-library migrations and behavior](references/stdlib-migrations-and-behavior.md) | Removed APIs, decoders, collections, bit arrays, strings, URI behavior |
| [Targets and FFI](references/targets-and-ffi.md) | External declarations, JavaScript representations, Erlang integration, runtimes, source maps |
## Deprecated syntax and configuration
- When `value |> add_by(2)` relies on the fallback meaning `add_by(2)(value)`,
write `value |> add_by(2)()`. The language server offers a quick fix.
- Bind values directly instead of using discard aliases: the formatter rewrites
`let _ as value = read()` to `let value = read()`.
- In `gleam.toml`, use `[dev_dependencies]` and `[repository]`'s `tag_prefix`.
The old `dev-dependencies` and `tag-prefix` spellings still work and are deprecated.
- Run `gleam fix` in the project to rewrite deprecated Gleam code during an upgrade.
See [language guidance](references/language-and-diagnostics.md) and
[configuration guidance](references/packages-build-and-config.md).
## Standard-library migrations
| Old API or behavior | Supported migration |
| --- | --- |
| `dynamic.decodeN` combinators | Use `gleam/dynamic/decode`. |
| `dynamic.from` | Use the constructor for the input type: `dynamic.array`, `bit_array`, `bool`, `float`, `int`, `list`, `nil`, `properties`, or `string`. |
| `dynamic.classify` category `"Tuple"` | Match `"Array"` for Erlang tuples and JavaScript arrays. |
| `list.range` | Use `int.range`. |
| `result.then` | Use `result.try`. |
| `result.nil_error` | Use `result.replace_error(value, Nil)`. |
| `list.concat` | Use `list.flatten` for a list of lists. |
| Original `dict.update` | Use `dict.upsert`. |
| `gleam/iterator`, `gleam/queue`, `gleam/regex` | Use `gleam_yielder`, `gleam_deque`, `gleam_regexp`, respectively. |
| `gleam/string_builder`, `gleam/bytes_builder` | Use `gleam/string_tree`, `gleam/bytes_tree`. |
| `int.to_base_string` invalid-base error | Match `Error(Nil)` instead of `InvalidBase`. |
Other removals include `result.unwrap_both`, `int.digits`, `int.undigits`,
`function.compose`, `function.constant`, the `function.apply*` and `function.curry*`
families, `function.tap`, `list.pop`, `list.pop_map`, and `list.at`.
The [standard-library reference](references/stdlib-migrations-and-behavior.md)
records the applicable releases and behavioral changes.
## Hex authentication and publishing
Gleam authenticates to Hex exclusively through OAuth2 and revokes locally stored
legacy tokens on its first use with Hex after upgrading. The local token encryption
password must be at least eight characters long.
- Set `HEXPM_READ_API_KEY` to a Hex API key with read permissions for higher
authenticated rate limits. Gleam uses this key only for read operations.
- Set `GLEAM_CACERTS_PATH` to your CA certificate path for requests to Hex.
- `gleam publish` rejects packages with a missing or default generated README,
and packages containing modules with no public definitions.
- Publishing flags remaining `echo` expressions, warns and asks for confirmation
about top-level module namespace pollution, and confirms major-version-zero releases.
- A package name beginning with `gleam_` requires a longer typed confirmation.
- `gleam hex owner transfer` takes the recipient's username with `--user`;
`gleam hex owner add` takes the package name with `--package`.
## Dependencies and project commands
```sh
gleam build --warnings-as-errors
gleam deps tree
gleam deps tree --package package_c
gleam deps tree --invert package_b
gleam deps outdated
```
Warnings fail the build with `--warnings-as-errors`. Dependency trees show resolved
versions; `--package` shows a subtree and `--invert` traces paths back to the project.
Passing both flags to `gleam deps tree` fails; run the views separately.
`gleam deps outdated` compares resolved versions with repository releases and counts
packages with newer versions, including when that count is zero.
Git dependencies use `git` and `ref` in `gleam.toml`; `ref` accepts a tag, branch,
or commit SHA. Add optional `path` when the package is in a repository subdirectory.
To adopt a major version outside a declared dependency range, update the constraint
in `gleam.toml`. A dependency can appear in only one of `[dependencies]` and
`[dev_dependencies]`; development dependencies are excluded from published packages.
## Development modules and configuration
Modules in `dev/` can import `src/`, use development dependencies, and import test
helpers from `test/`. They are excluded from production builds. Tests can import
all three source directories and both dependency scopes; production code imports
`src/` modules and regular dependencies.
For a package named `my_app`, `gleam dev` calls `main` in `dev/my_app_dev.gleam`.
Use `gleam dev --no-print-progress` to hide compilation and launch progress while
keeping program output. Put file-based tool settings under `tools.<tool_name>`
in `gleam.toml`. Gleam commands accept TOML 1.1, including multiline inline tables.
## Language features and diagnostics
- Record updates can change generic type arguments when updated and retained
fields fit the result type. Constant record updates use `Constructor(..base, field: value)`.
- A known variant permits access to its specific fields and plain `let`
destructuring of a type with multiple variants.
- Put `@deprecated("…")` directly above a constructor to deprecate only that variant.
- Put `|` between complete case patterns; alternatives must bind the same names
with the same types. Repeat surrounding list or record patterns in each alternative.
- Case guards support string concatenation with `<>`. The right side of `<-` in
`use` can be an expression yielding a callback-taking function.
- `assert` panics on `False`, carrying the source expression and values such as
operands or function arguments. An optional `as` message can accompany it.
- `echo 11 as "lucky number"` prints a label beside its source location, above the value.
- `{}` is a placeholder expression that warns while surrounding code is checked.
- Constants support list prepending with `..` and `todo` placeholders. Replace
constant `todo` before running the program, since constants evaluate at compile time.
- A discarded standalone call recognized as side-effect-free warns; use the returned
value, such as the updated request from `request.set_header`.
- Use `items != []` for non-emptiness checks without traversing the list.
## Bit arrays and target behavior
Use `:bits` for any bit-array length and `:bytes` for byte-aligned data.
A `:float` segment defaults to 64 bits; float literals can omit `:float`.
Pattern sizes accept arithmetic, including values bound by earlier segments.
UTF-16 and UTF-32 codepoint segments accept `little` or `big` byte order.
On JavaScript, bit arrays support partial bytes, runtime pattern sizes, `unit(n)`,
16-bit floats, UTF-16, and UTF-32. Zero-width segments contribute no bits.
16-bit float segments round exact midpoints to the nearest value with an even significand.
Integer patterns wider than 52 bits warn and truncate to the first 52 bits;
use a `bytes` segment to retain original data when its size is a whole number of bytes.
On BEAM, `Float` overflow raises an error. On JavaScript, it produces `Infinity`
or `-Infinity`, and dividing two infinite values produces `NaN`.
## Externals and runtime tooling
A function can have both `@external` and a Gleam body: the declared target calls
the external implementation and the other target uses the Gleam body.
Use a dedicated external type for foreign values with restricted representations;
a `Dynamic` parameter accepts wrapped data of any type.
JavaScript externals can import generated constructors, variant tests, and field
accessors. Type-level field access requires a shared label at the same position in
every variant. Return `undefined` for Gleam `Nil`; consult the
[FFI reference](references/targets-and-ffi.md) for lists, results, dictionaries,
bit-array accessors, relative module paths, and TypeScript predicates.
Set `[javascript]`'s `source_maps = true` and serve the maps alongside the generated
JavaScript for Gleam breakpoints and original exception locations.
`typescript_declarations = true` enables declarations; generation defaults to off.
Runtime choices are `"node"` (default), `"deno"`, and `"bun"`, with a `--runtime` override.
Rebuild affected projects with Gleam 1.19.2 or later before running Dialyzer to
avoid the invalid Erlang output for user-defined types fixed in that release.
## Editor actions
The language server supports project-wide Rename and Find References, record field
navigation and renaming across modules, and import updates when the editor reports
a module file move. Type-variable Rename updates occurrences in its declaration.
- Generate Function infers annotations and inserts `todo`; it can target an imported module.
- Generate Missing Type supplies needed type parameters; Create Module handles unresolved imports.
- Pattern Match on Value wraps a function call in a `case` based on its return type.
- Fill Labels can use an in-scope variable with a matching name and type, otherwise `todo`.
- Generate Dynamic Decoder handles labelled records, multi-variant types, and `Nil`.
- Generate JSON Encoder uses explicit record patterns so added fields cause a compile error.
- Extract Variable, Constant, and Function cover expressions and additional pipeline cases;
callback, block, qualification, and cleanup actions are detailed in the editor reference.
For a manual integration, run `gleam lsp` from the workspace root. It checks unsaved
buffers across projects using each project's target and stops before code generation
or Erlang and Elixir compilation. Standalone files receive only formatting.