Skip to content

giantswarm/klausctl

Repository files navigation

klausctl

CLI for managing local klaus instances.

klausctl is the local-mode counterpart to the Helm chart and the klaus-operator. It produces the same env vars, flags, and file mounts that the klaus Go binary expects, but through a developer-friendly CLI backed by Docker or Podman.

Features

  • Container lifecycle management -- start, stop, status, logs for local klaus instances
  • Plugin fetching via ORAS -- pull Claude Code plugins from OCI registries before container start, with digest-based caching
  • Config rendering -- generate .mcp.json, settings.json, SKILL.md files from a single config file
  • Container runtime auto-detection -- Docker or Podman, with preference configurable
  • Environment variable forwarding -- pass secrets from host to container
  • Self-update -- klausctl update to fetch the latest release from GitHub

Quick Start

# Create a default configuration
klausctl config init

# Edit the configuration
$EDITOR ~/.config/klausctl/instances/default/config.yaml

# Set your API key
export ANTHROPIC_API_KEY=sk-ant-...

# Start a klaus instance
klausctl start default

# Check status
klausctl status default

# View logs
klausctl logs default -f

# Stop the instance
klausctl stop default

Usage

klausctl create <name> [workspace]   # Create and start a named instance
klausctl list                         # List known instances
klausctl delete <name>                # Delete an instance (container + files)
klausctl start <name>                 # Start an instance
klausctl start <name> --workspace .   # Start with workspace override
klausctl stop <name>                  # Stop an instance
klausctl status <name>                # Show instance status (running, MCP endpoint, uptime)
klausctl logs <name>                  # Stream container logs (-f to follow, --tail N for last N lines)
klausctl config               # Manage configuration (init, show, path, validate)
klausctl self-update           # Update klausctl to the latest release (--yes to skip prompt)
klausctl version              # Show version information

start, stop, status, and logs currently default to default when <name> is omitted. This implicit default is deprecated; use default explicitly to avoid future breakage.

Configuration

Config file at ~/.config/klausctl/instances/default/config.yaml:

# Container runtime (auto-detected if not set)
runtime: docker  # or: podman

# Klaus image
image: gsoci.azurecr.io/giantswarm/klaus:latest

# Workspace to mount
workspace: ~/projects/my-repo

# Port for the MCP endpoint
port: 8080

# Claude configuration
claude:
  model: sonnet
  systemPrompt: "You are a helpful coding assistant."
  maxBudgetUsd: 5.0
  permissionMode: plan

# Forward host environment variables
envForward:
  - GITHUB_TOKEN

# Inline skills
skills:
  api-conventions:
    description: "API design patterns"
    content: |
      When writing API endpoints...

# Subagents (JSON format, highest priority)
agents:
  reviewer:
    description: "Reviews code changes"
    prompt: "You are a senior code reviewer..."

# Lifecycle hooks
hooks:
  PreToolUse:
    - matcher: "Bash"
      hooks:
        - type: command
          command: /etc/klaus/hooks/block-dangerous.sh

# MCP servers
mcpServers:
  github:
    type: http
    url: https://api.githubcopilot.com/mcp/
    headers:
      Authorization: "Bearer ${GITHUB_TOKEN}"

# OCI plugins (pulled via ORAS before container start)
plugins:
  - repository: gsoci.azurecr.io/giantswarm/klaus-plugins/gs-platform
    tag: v1.2.0

The configuration intentionally mirrors the Helm chart values structure so that knowledge transfers between local, standalone, and operator-managed modes.

Architecture

~/.config/klausctl/instances/default/config.yaml
         |
         v
    klausctl CLI
         |
         +-- ORAS client (pkg/oci/)
         |      Pull plugins to ~/.config/klausctl/plugins/
         |
         +-- Config renderer (pkg/renderer/)
         |      Generate mcp-config.json, settings.json, SKILL.md files
         |      in ~/.config/klausctl/instances/default/rendered/
         |
         +-- Container runtime (Docker or Podman, auto-detect)
                docker/podman run with:
                  -e ANTHROPIC_API_KEY=...
                  -e CLAUDE_AGENTS=...
                  -e CLAUDE_ADD_DIRS=/etc/klaus/extensions
                  -e CLAUDE_PLUGIN_DIRS=/var/lib/klaus/plugins/gs-platform,...
                  -v ~/.config/klausctl/plugins/gs-platform:/var/lib/klaus/plugins/gs-platform
                  -v ~/.config/klausctl/instances/default/rendered/extensions:/etc/klaus/extensions
                  -v ~/workspace:/workspace
                  -p 8080:8080
                  gsoci.azurecr.io/giantswarm/klaus:latest

Development

# Build
go build -o klausctl .

# Run
./klausctl version

# Run tests
go test ./...

See docs/development.md for development instructions.

License

Apache 2.0 -- see LICENSE.

About

CLI for managing local klaus instances

Resources

License

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors