# Technical Documentation: marmelab/Features

> ℹ️ **Provenance:** Multi-Tier Ingestion · [CodeWiki Reference](https://codewiki.google/github.com/marmelab/Features)

### Overview (`README.md`)

# Marmelab Dev Container Features

A collection of custom [dev container Features](https://containers.dev/implementors/features/), published to GitHub Container Registry following the [dev container Feature distribution specification](https://containers.dev/implementors/features-distribution/).

## Features

### `claude-code`

Installs the [Claude Code](https://www.anthropic.com/claude-code) CLI and, in VS Code, the Claude Code extension. See [src/claude-code](src/claude-code).

```jsonc
{
  "image": "mcr.microsoft.com/devcontainers/base:ubuntu",
  "features": {
    "ghcr.io/marmelab/devcontainers/claude-code:1": {},
  },
}
```

```bash
$ claude --version
```

## Repository structure

Each published Feature lives in its own sub-folder under `src`, containing a `devcontainer-feature.json`, an entrypoint `install.sh`, and a `README.md`. Tests live under `test/<feature>`.

```
├── src
│   └── claude-code
│       ├── devcontainer-feature.json
│       ├── install.sh
│       └── README.md
├── test
│   └── claude-code
│       ├── test.sh
│       ├── non_root_user.sh
│       └── scenarios.json
└── .devcontainer
    └── claude-code            # local dogfood copy (see below)
```

## Developing this repository

This repo's own Dev Container installs Claude Code via a local copy of the feature at [.devcontainer/claude-code](.devcontainer/claude-code). It is a separate copy because the Dev Container CLI only resolves local features inside the `.devcontainer/` folder, so the published `src/claude-code` cannot be referenced directly. Keep the two in sync. Credential mounts for the container are declared in [.devcontainer/devcontainer.json](.devcontainer/devcontainer.json).

An [implementing tool](https://containers.dev/supporting#tools) will composite [the documented dev container properties](https://containers.dev/implementors/features/#devcontainer-feature-json-properties) from the feature's `devcontainer-feature.json` file, and execute in the `install.sh` entrypoint script in the container during build time. Implementing tools are also free to process attributes under the `customizations` property as desired.

### Options

All available options for a Feature should be declared in the `devcontainer-feature.json`. The syntax for the `options` property can be found in the [devcontainer Feature json properties reference](https://containers.dev/implementors/features/#devcontainer-feature-json-properties).

For example, the `claude-code` feature exposes a `version` option. If no option is provided in a user's `devcontainer.json`, the value falls back to its default (`latest`).

```jsonc
{
  // ...
  "options": {
    "version": {
      "type": "string",
      "proposals": ["latest", "stable"],
      "default": "latest",
      "description": "Version passed to the official installer.",
    },
  },
}
```

Options are exported as Feature-scoped environment variables. The option name is capitalized and sanitized according to [option resolution](https://containers.dev/implementors/features/#option-resolution).

```bash
#!/bin/bash

echo "Activating feature 'claude-code' (version: ${VERSION})"

...
```

## Distributing Features

### Versioning

Features are individually versioned by the `version` attribute in a Feature's `devcontainer-feature.json`. Features are versioned according to the semver specification. More details can be found in [the dev container Feature specification](https://containers.dev/implementors/features/#versioning).

### Publishing

> NOTE: The Distribution spec can be [found here](https://containers.dev/implementors/features-distribution/).
>
> While any registry [implementing the OCI Distribution spec](https://github.com/opencontainers/distribution-spec) can be used, this template will leverage GHCR (GitHub Container Registry) as the backing registry.

Features are meant to be easily sharable units of dev container configuration and installation code.

This repo contains a **GitHub Action** [workflow](.github/workflows/release.yaml) that will publish each Feature to GHCR.

_Allow GitHub Actions to create and approve pull requests_ should be enabled in the repository's `Settings > Actions > General > Workflow permissions` for auto generation of `src/<feature>/README.md` per Feature (which merges any existing `src/<feature>/NOTES.md`).

By default, each Feature will be prefixed with the `<owner>/<repo>` namespace. For example, the Features in this repository can be referenced in a `devcontainer.json` with:

```
ghcr.io/marmelab/devcontainers/claude-code:1
```

The provided GitHub Action will also publish a "metadata" package with just the namespace, eg: `ghcr.io/marmelab/devcontainers`. This contains information useful for tools aiding in Feature discovery.

'`marmelab/devcontainers`' is known as the feature collection namespace.

### Marking Feature Public

Note that by default, GHCR packages are marked as `private`. To stay within the free tier, Features need to be marked as `public`.

This can be done by navigating to the Feature's "package settings" page in GHCR, and setting the visibility to 'public`. The URL may look something like:

```
https://github.com/users/<owner>/packages/container/<repo>%2F<featureName>/settings
```

<img width="669" alt="image" src="https://user-images.githubusercontent.com/23246594/185244705-232cf86a-bd05-43cb-9c25-07b45b3f4b04.png">

### Adding Features to the Index

If you'd like your Features to appear in our [public index](https://containers.dev/features) so that other community members can find them, you can do the following:

- Go to [github.com/devcontainers/devcontainers.github.io](https://github.com/devcontainers/devcontainers.github.io)
  - This is the GitHub repo backing the [containers.dev](https://containers.dev/) spec site
- Open a PR to modify the [collection-index.yml](https://github.com/devcontainers/devcontainers.github.io/blob/gh-pages/_data/collection-index.yml) file

This index is from where [supporting tools](https://containers.dev/supporting) like [VS Code Dev Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) and [GitHub Codespaces](https://github.com/features/codespaces) surface Features for their dev container creation UI.

#### Using private Features in Codespaces

For any Features hosted in GHCR that are kept private, the `GITHUB_TOKEN` access token in your environment will need to have `package:read` and `contents:read` for the associated repository.

Many implementing tools use a broadly scoped access token and will work automatically. GitHub Codespaces uses repo-scoped tokens, and therefore you'll need to add the permissions in `devcontainer.json`

An example `devcontainer.json` can be found below.

```jsonc
{
  "image": "mcr.microsoft.com/devcontainers/base:ubuntu",
  "features": {
    "ghcr.io/my-org/private-features/hello:1": {
      "greeting": "Hello",
    },
  },
  "customizations": {
    "codespaces": {
      "repositories": {
        "my-org/private-features": {
          "permissions": {
            "packages": "read",
            "contents": "read",
          },
        },
      },
    },
  },
}
```

---

### Overview (`src/claude-code/README.md`)

# Claude Code (claude-code)

Installs the [Claude Code](https://www.anthropic.com/claude-code) CLI (and, in VS Code, the Claude Code extension).

## Example Usage

```json
"features": {
    "ghcr.io/marmelab/devcontainers/claude-code:1": {}
}
```

## Options

| Options Id | Description                                                                                          | Type   | Default Value |
| ---------- | ---------------------------------------------------------------------------------------------------- | ------ | ------------- |
| version    | Version passed to the official installer: 'latest', 'stable', or a specific version such as '1.0.0'. | string | latest        |

## What it does

- Downloads and runs the official installer from `https://claude.ai/install.sh` as the container user.
- Symlinks the CLI into `/usr/local/bin` so it is on `PATH` in login, non-interactive, and CI shells, and adds `$HOME/.local/bin` to `~/.bashrc` and `~/.zshrc` for interactive shells.
- In VS Code, installs the `Anthropic.claude-code` extension.

Installs `curl` and CA certificates first if they are missing (Debian/Ubuntu bases).

## Using your Claude credentials

The feature does not mount credentials, because bind mounts are host-specific and
belong in the consuming `devcontainer.json`. To authenticate Claude Code inside the
container from your host setup, add the mounts yourself:

```jsonc
{
  "features": {
    "ghcr.io/marmelab/devcontainers/claude-code:1": {},
  },
  "mounts": [
    {
      "type": "bind",
      "source": "${localEnv:HOME}/.claude.json",
      "target": "/home/<user>/.claude.json",
    },
    {
      "type": "bind",
      "source": "${localEnv:HOME}/.claude",
      "target": "/home/<user>/.claude",
    },
  ],
}
```

Replace `<user>` with your container user (for example `node` or `vscode`). The host
`~/.claude.json` file and `~/.claude` directory must already exist, otherwise the bind
mount fails the container build.

---

### Overview (`src/playwright/README.md`)

# Playwright integration

Installs Playwright system dependencies (via the `playwright-deps` feature) and
persists downloaded browsers in a named volume across container rebuilds.

See [install.sh](install.sh), [install-browsers.sh](install-browsers.sh), and
[devcontainer-feature.json](devcontainer-feature.json).

## Options

| Option     | Type   | Default                   | Description                                                                                                              |
| ---------- | ------ | ------------------------- | ------------------------------------------------------------------------------------------------------------------------ |
| `browsers` | string | `chromium,firefox,webkit` | Comma-separated browsers to download at container creation. Use `all` for every browser, or `none` to skip the download. |

```jsonc
{
  "features": {
    "./playwright": { "browsers": "chromium" },
  },
}
```

The selected browsers are downloaded by [install-browsers.sh](install-browsers.sh)
(run via `postStartCommand`), which reads the selection persisted by
`install.sh` and calls `npx playwright install`. It runs at post-start rather
than post-create because
Feature lifecycle commands always run before the user's own commands of the
same stage: a post-create hook here would fire before your `npm install`, so
`playwright` would not exist yet. The download uses `npx --no-install`, so it
only ever uses the project's own `playwright` and skips cleanly (with a hint) if
none is installed, instead of fetching an arbitrary version from the registry.

## System dependencies

OS-level browser dependencies are installed at build time by the
[`playwright-deps`](https://github.com/postfinance/devcontainer-features)
feature, declared in `dependsOn`. Per the dev container spec, `dependsOn` values
are static and cannot reference this feature's options, so dependencies for all
three browsers are always installed regardless of the `browsers` option. The
option only controls which browser binaries are downloaded (the main disk and
time cost).

## Cache folder

Browsers are cached at `PLAYWRIGHT_BROWSERS_PATH` (default `/mnt/ms-playwright`).
To change the folder, override this env var in your `devcontainer.json`; the
volume mount follows automatically:

```jsonc
{
  "features": { "./playwright": {} },
  "containerEnv": { "PLAYWRIGHT_BROWSERS_PATH": "/custom/path" },
}
```

---

--- METRICS ---
- Files Extracted: 3
- Estimated Token Budget: ~2917 tokens
- Canonical Reference: https://codewiki.google/github.com/marmelab/Features
