Skip to content

SoureCode/devcontainer-features

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SoureCode Devcontainer Features

A small collection of Dev Container Features that extend the official anthropics/devcontainer-features/claude-code feature with rtk and context-mode.

Published to Docker Hub under the sourecode namespace.

Features

Feature OCI reference Summary
rtk docker.io/sourecode/rtk:1 Installs rtk, an LLM token-reducing CLI proxy; auto-patches Claude Code if present.
context-mode docker.io/sourecode/context-mode:1 Installs the context-mode Claude Code plugin.

Both features depend on the Claude Code CLI, which they declare via installsAfter: ghcr.io/anthropics/devcontainer-features/claude-code so the runtime orders installations automatically when Anthropic's feature is also requested.

Using the features

Add them to any .devcontainer/devcontainer.json, on top of whatever base image you already use:

{
  "image": "debian:trixie-slim",
  "features": {
    "ghcr.io/anthropics/devcontainer-features/claude-code:1": {},
    "docker.io/sourecode/rtk:1": {
      "autoPatchClaude": true
    },
    "docker.io/sourecode/context-mode:1": {}
  }
}

Features run inside the image during build (as root), installing into the container's remoteUser home. After rebuild, the tools are available on the user's PATH.

Feature options

rtk

Option Type Default Purpose
autoPatchClaude boolean true Run rtk init -g --auto-patch to wire rtk's hook into Claude Code. No-op if the claude CLI is not on the user's PATH.

context-mode

No options. Fails if the claude CLI is not on the user's PATH — add the official ghcr.io/anthropics/devcontainer-features/claude-code feature as well (the installsAfter hint then makes the CLI resolve the correct install order automatically).

Persisting Claude Code state

Claude login (~/.claude/.credentials.json) and chat history (projects/, sessions/, session-env/) are not persisted across rebuilds by default. See docs/persistence.md for mount strategies (host login bind mount, per-project credentials, or a shared named volume).

Developing on this repo

Repository layout

.github/workflows/
  publish-features.yml            # publishes every src/<id>/ to Docker Hub
src/
  rtk/
    devcontainer-feature.json
    install.sh
  context-mode/
    devcontainer-feature.json
    install.sh
docs/
  persistence.md

Each feature directory follows the Dev Container Features spec: a devcontainer-feature.json with metadata and options, plus an install.sh that runs as root inside the container during the build.

Writing an install.sh

  • install.sh starts as root. To land files in the remote user's home, resolve the user via _REMOTE_USER / _REMOTE_USER_HOME (set by the devcontainer runtime) and su - "$USER" for user-scoped steps.
  • Feature options are exposed as uppercased environment variables (e.g. option autoPatchClaude$AUTOPATCHCLAUDE). Always apply a default: "${FOO:-true}".
  • The working directory when install.sh runs is the extracted feature folder, so sibling files are accessible via "$(dirname "$0")/...".
  • Don't assume the base image has any particular tools — install curl, ca-certificates, etc. from apt-get if absent. Keep installs idempotent where reasonable.
  • Declare dependencies with installsAfter so the runtime orders features correctly (e.g. both features here list ghcr.io/anthropics/devcontainer-features/claude-code).

Testing a feature locally

Using the @devcontainers/cli:

npm i -g @devcontainers/cli

# Test a feature in isolation against a chosen base image:
devcontainer features test \
  --features rtk \
  --base-image debian:trixie-slim \
  .

Adding a new feature

  1. mkdir -p src/<id>
  2. Write src/<id>/devcontainer-feature.json with id, version, name, description, options, and optional installsAfter.
  3. Write src/<id>/install.sh (make it executable: chmod +x install.sh).
  4. Bump the version for every change (MAJOR.MINOR.PATCH). The publish workflow pushes each declared version plus rolling MAJOR, MAJOR.MINOR, and latest tags.
  5. Commit to master — the Publish Features workflow runs on push and pushes to docker.io/sourecode/<id>:<tags>.

Publishing

The Publish Features workflow (.github/workflows/publish-features.yml) uses the official devcontainers/action@v1 with publish-features: true and targets Docker Hub:

  • oci-registry: registry-1.docker.io (the real Docker Hub v2 endpoint — docker.io returns HTML for some unauthenticated calls)
  • features-namespace: sourecode

Docker Hub uses flat namespace/repo paths (no nested subpaths), so each feature publishes to docker.io/sourecode/<feature-id>.

Required repository secrets:

  • DOCKERHUB_USERNAME — the Docker Hub user or org that owns sourecode/*.
  • DOCKERHUB_TOKEN — a Docker Hub access token with read, write, delete permission on the target repositories.

The workflow triggers on pushes to master that touch src/** or the workflow file, and can also be run manually via Run workflow in the Actions tab.

Bumping versions

Update version in devcontainer-feature.json. Each push that lands in master publishes:

  • docker.io/sourecode/<id>:<MAJOR>.<MINOR>.<PATCH>
  • docker.io/sourecode/<id>:<MAJOR>.<MINOR>
  • docker.io/sourecode/<id>:<MAJOR>
  • docker.io/sourecode/<id>:latest

License

MIT — see LICENSE.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages