# Configuration layers

> For the complete documentation index, see [llms.txt](https://docs.ringleader.dev/llms.txt).


> A configuration layer is a WorkstationConfig: packages, tools, code and settings you define once and attach to many workstations.


A configuration layer is a WorkstationConfig: packages, tools, code and settings you define
once and attach to many workstations. Setups outlive workstations, so a team's baseline, a
project's toolchain and your own preferences can each be a layer. Several layers can reach
one workstation. Ringleader stacks them by priority, and a higher priority wins. By
default, a project layer refines the team's, and your personal layer sits above both.

A layer reaches a workstation in one of two ways: by label, or by name. Attaching by label
is the usual way. Every workstation that carries the label gets the layer, including
workstations created later, and a labeled workstation gets layers added later too.

## Workstations a layer reaches

A selector never reaches a workstation in another namespace. Inside its namespace, how far
a layer's selector reaches depends on who applied the layer:

- An ordinary member's layer reaches only the workstations that member owns. Labels narrow
  that further, and never widen it to a colleague's workstation.
- A namespace administrator's layer reaches every workstation in the namespace that its
  labels match.
- `spec.selector.ownerScope: true` limits either one to the workstations its author owns.

An Integration has rules of its own, which
[Integration reach](https://docs.ringleader.dev/workstations/configuration/integration-behavior/#integration-reach) describes.

A reference in `spec.configs` is not limited this way: the workstation's owner chose it.
[Roles and RoleBindings](https://docs.ringleader.dev/reference/resources/roles/) describes ownership and roles.

## Layer merge order

Ringleader starts from the workstation's own settings and applies every layer that reaches
it over them, in order of `priority`, lowest first. Each layer has a priority:

- A layer attached by label: 50, unless it sets another.
- A [personal layer](#personal-layers), which reaches every workstation you own: 75,
  unless it sets another.
- A layer attached by name: the priority written on the reference, or 0.
- A layer Ringleader generates from an
  [Integration](https://docs.ringleader.dev/reference/resources/integration/), which connects workstations to
  a shared service: always -100. A layer you write wins over it at any priority above -100.

When layers conflict, the layer applied later wins. A devtool or a tool configuration that more
than one layer declares keeps the highest layer's whole entry. A higher-priority layer
replaces the whole `dotfilesRepo` setting, the workstation's own included. `capabilities`
doesn't merge by priority, as
[Workstation capabilities](https://docs.ringleader.dev/reference/resources/workstationconfig/#workstation-capabilities)
explains.

Only `image`, `defaultLocalBinding` and `tailscale` work the other way. Ringleader applies the
workstation's own value for them after the layers, so the workstation's value wins.

Because the workstation's own settings are the base, a layer that sets the same single
value or variable overrides them, whatever its priority. To override a layer, write a layer
of your own at a higher priority.
[Override an Integration for Claude Code](https://docs.ringleader.dev/workstations/coding-agents/llm-gateways/#override-an-integration-for-claude-code)
shows an example.

Placement and lifetime come from the workstation alone, and a WorkstationConfig that sets
them is refused when you apply it.
[Attachment fields](https://docs.ringleader.dev/reference/resources/workstationconfig/#attachment-fields) lists
the fields it refuses. To see the merged result for a workstation, run
`rl workstation get-resolved-configuration`
with its name,
as [Configuration merging and resolution](https://docs.ringleader.dev/workstations/configuration/configuration-merging-resolution/) describes.

## Layers and the local runtime

The [local container runtime](https://docs.ringleader.dev/reference/local-container-runtime/) is the workstation
that runs Docker on your own computer. It is named `local-runtime`, it is in the `local`
namespace, and it carries one label, `role: local-container-runtime`. A selector treats it
like any other workstation:

- A WorkstationConfig or an Integration in `local` with `ownerScope: true` and no labels
  reaches it, because you own it.
- A selector with labels reaches it only when the runtime carries every one of them.

So in the `local` namespace, give a WorkstationConfig or an Integration labels. A
WorkstationConfig that reaches the runtime installs its packages and tools next to Docker.
An Integration that adds a key there adds it for the runtime. The local runtime installs the
`docker` and `kind` devtools, so its containers trust the certificate an
[Edge](https://docs.ringleader.dev/reference/resources/edge/) presents, when the runtime has one.
[Containers on the workstation](https://docs.ringleader.dev/security/credentials/injection-effects/#containers-on-the-workstation)
explains which connections reach the Edge and what a hand-created kind cluster needs.

To reach the local runtime on purpose, name its label:

```yaml
spec:
  selector:
    matchLabels:
      role: local-container-runtime
```

## Personal layers

A personal layer follows you rather than a group of workstations: it reaches every
workstation you own in the namespace. It is a WorkstationConfig whose selector sets
`ownerScope: true` and names no labels:

```yaml
spec:
  selector:
    ownerScope: true      # no matchLabels, which is what makes it personal
```

Leave out `namespace` from its file, and the same file works in whichever namespace you
apply it to. A personal layer differs from other layers in these ways:

- It defaults to priority 75, above the default of 50 for a layer attached by label. So
  your preferences beat a team default without your picking a number.
- Most of its steps don't block the workstation by default: a failed package, devtool,
  script, source, file or service from a personal layer leaves the workstation `Available`.
  [Step failures and retries](https://docs.ringleader.dev/workstations/configuration/step-failures-retries/)
  lists the steps that still block it.
- It reaches every workstation you own in the namespace, whatever the workstation is for,
  including the [local runtime](#layers-and-the-local-runtime) in `local`.
  [Choose how wide a selector reaches](#choose-how-wide-a-selector-reaches) says what to
  keep in it.
- It doesn't reach a teammate's workstation that you have been granted SSH on. That
  workstation gets its owner's personal layer.
- Editing it reconfigures every workstation you own at once, not just the next one you
  create. To preview an edit before you apply it, run `rl diff -f` on the file.

`ownerScope: true` together with `matchLabels` is not a personal layer. It is a layer that
reaches only its author's workstations with those labels, at the ordinary priority and
with the ordinary failure policy.

To write one step by step, follow
[Bring your setup to every workstation](https://docs.ringleader.dev/guides/bring-setup-every-workstation/).

## Attach a layer by label

To give a group of workstations the same layer, follow these steps:

1. Put a label on each workstation that should get the layer:

   ```yaml
   apiVersion: workstations.ringleader.dev/v1
   kind: Workstation
   metadata:
     name: billing-dev
     namespace: acme
     labels:
       project: billing
   ```

2. Name that label in the layer's `selector`:

   ```yaml
   apiVersion: workstations.ringleader.dev/v1
   kind: WorkstationConfig
   metadata:
     name: billing-tools
     namespace: acme
   spec:
     selector:
       matchLabels:
         project: billing
     packages:
       - postgresql-client
   ```

The selector matches every workstation in its own namespace that carries all the labels it
names. A workstation can carry other labels too. A WorkstationConfig with no labels in its
selector matches nothing, unless it is a [personal layer](#personal-layers).

## Attach a layer by name

To give a layer to one workstation, or a few you pick by hand, list it in each
workstation's `spec.configs`, and give the layer no selector. The layer must be in the
workstation's own namespace, and no other workstation gets it.

```yaml
spec:
  configs:
    - name: team-base
      priority: 100
```

Write the priority on each entry. An entry with no `priority` sits at 0, below every
default, so a personal layer at 75 would override the layer you picked.

## Choose how wide a selector reaches

One edit to a layer changes every workstation its selector matches, at once. A wide
selector also reaches workstations you weren't thinking about: one that does a different
job, or one somebody creates next month. Pick the narrowest of these that
covers the workstations you mean:

- For one workstation, or a few you pick by hand,
  [attach the layer by name](#attach-a-layer-by-name).
- For a group with a shared purpose, select a label that names the purpose, such as
  `project: billing`. A workstation joins the group when someone gives it the label.
- For every workstation you own, use a [personal layer](#personal-layers). Keep it to
  settings that are safe on any workstation, whatever it runs: your dotfiles, your shell, a
  few small packages.

<div class="callout callout-warning">
  <p class="callout-title">Keep network layers behind a label</p>
  <div class="callout-body">
    <p>Each of these changes how a workstation reaches the network, so keep both behind a label:</p>
<ul>
<li>An Integration of <code>type: httpProxy</code>, which adds a key to requests as they leave the
workstation.
<a href="https://docs.ringleader.dev/security/credentials/injection-effects/">Effects of injection on a workstation</a>
lists what changes, for the workstation and for the containers it runs.</li>
<li>A WorkstationConfig with an egress policy, which
restricts outbound connections (see <a href="https://docs.ringleader.dev/security/outbound/outbound-restrictions/">outbound restrictions</a>).</li>
</ul>
  </div>
</div>


To see what a selector reaches, list the workstations that carry the label, then read what
applies to one of them:

```bash
rl workstation get -n acme -l project=billing
rl workstation get-resolved-configuration billing-dev -n acme
```

The second command lists each layer under `appliedConfigs`, with `source: selector` for a
label match. An Integration appears there as `integration-<name>`. In
[`rl tui`](https://docs.ringleader.dev/reference/tui/inspection-views/#related-objects), `x` on a workstation lists the
layers and other resources whose selectors reach it.

## Next steps

- [WorkstationConfig](https://docs.ringleader.dev/reference/resources/workstationconfig/) lists every field a
  layer can set.
- [Selectors](https://docs.ringleader.dev/reference/resources/selectors/) says what a selector with no labels
  matches, for each kind of resource.
- [Integration](https://docs.ringleader.dev/reference/resources/integration/) connects workstations to a shared
  service through a generated layer.

