Esta página se muestra en inglés. Una traducción al español está en curso.
SkillsApr 16, 2026·3 min de lectura

Pkl — Configuration as Code Language by Apple

Pkl is a programmable configuration language with rich validation, templating, and IDE support, designed to replace YAML and JSON sprawl.

Listo para agents

Instalación con revisión previa

Este activo requiere revisión. El prompt copiado pide dry-run, muestra escrituras y continúa solo tras confirmación.

Needs Confirmation · 64/100Política: confirmar
Superficie agent
Cualquier agent MCP/CLI
Tipo
Skill
Instalación
Single
Confianza
Confianza: Established
Entrada
Pkl Overview
Comando con revisión previa
npx -y tokrepo@latest install 8e845296-3997-11f1-9bc6-00163e2b0d79 --target codex

Primero dry-run, confirma las escrituras y luego ejecuta este comando.

TL;DR
Pkl replaces YAML and JSON configuration sprawl with a typed, programmable configuration language by Apple.
§01

What it is

Pkl is a programmable configuration language developed by Apple. It provides typed schemas, validation constraints, templating, and IDE support for configuration files. Instead of writing raw YAML or JSON with no validation until runtime, you define configuration as Pkl code with types, defaults, and constraints that are checked at evaluation time.

Pkl is designed for platform engineers, DevOps teams, and application developers who manage complex configuration across multiple environments and want compile-time safety.

§02

How it saves time or tokens

YAML and JSON configuration files are error-prone: a mistyped key, a wrong type, or a missing field causes runtime failures. Pkl catches these errors at evaluation time before deployment. The language supports modules, imports, and inheritance, so you can define a base configuration once and override per environment. This eliminates copy-paste duplication across dev/staging/production configs and reduces configuration-related incidents.

§03

How to use

  1. Install the Pkl CLI:
curl -L https://github.com/apple/pkl/releases/latest/download/pkl-linux-amd64 -o pkl
chmod +x pkl && sudo mv pkl /usr/local/bin/
  1. Create a Pkl configuration file:
// config.pkl
module Config

name: String = 'my-app'
port: Int(this >= 1024 && this <= 65535) = 8080
debug: Boolean = false
database {
  host: String = 'localhost'
  port: Int = 5432
  name: String = 'mydb'
}
  1. Evaluate to YAML or JSON:
pkl eval config.pkl -f yaml
pkl eval config.pkl -f json
§04

Example

Environment-specific configuration with inheritance:

// base.pkl
module BaseConfig

name: String
replicas: Int = 1
resources {
  cpu: String = '100m'
  memory: String = '256Mi'
}

// production.pkl
amends "base.pkl"

name = 'api-server'
replicas = 3
resources {
  cpu = '500m'
  memory = '1Gi'
}

pkl eval production.pkl -f yaml outputs the merged configuration with production overrides applied.

§05

Related on TokRepo

§06

Common pitfalls

  • Trying to use Pkl as a general-purpose programming language. Pkl is designed for configuration, not application logic. It has deliberate limitations (no loops with side effects, no I/O) to keep configurations deterministic.
  • Not leveraging the type system. Writing Pkl without type annotations and constraints misses the main benefit. Add types and validation constraints to catch errors before deployment.
  • Forgetting that Pkl evaluates to a data format (YAML, JSON, plist). Your tooling consumes the output, not Pkl files directly. Ensure your CI pipeline includes a pkl eval step.

Preguntas frecuentes

Can Pkl generate Kubernetes manifests?+

Yes. Pkl can generate YAML for Kubernetes manifests. Apple provides a Kubernetes module (pkl-k8s) with typed schemas for all Kubernetes API objects, giving you type-safe Kubernetes configuration.

How does Pkl compare to CUE or Dhall?+

All three are typed configuration languages. Pkl emphasizes readability and IDE support with a familiar syntax. CUE focuses on data validation and unification. Dhall provides a dependently-typed functional approach. Pkl is backed by Apple and has strong IDE integration.

Does Pkl have IDE support?+

Yes. Pkl provides plugins for IntelliJ, VS Code, and Neovim with syntax highlighting, autocompletion, inline validation, and go-to-definition. The language server protocol (LSP) implementation powers these features.

Can I use Pkl with existing YAML workflows?+

Yes. Pkl evaluates to YAML, JSON, or plist output. You write configuration in Pkl, generate YAML/JSON, and your existing tools consume the output. This means you can adopt Pkl incrementally without changing downstream tooling.

Is Pkl open source?+

Yes. Pkl is open source under the Apache 2.0 license. Apple released it publicly with the CLI, language server, and standard library all available on GitHub.

Referencias (3)

Discusión

Inicia sesión para unirte a la discusión.
Aún no hay comentarios. Sé el primero en compartir tus ideas.

Activos relacionados