klausctl

command module
v0.0.50 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 9, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

README

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.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
Package cmd implements the klausctl CLI commands using Cobra.
Package cmd implements the klausctl CLI commands using Cobra.
internal
server
Package server provides the MCP server context for klausctl.
Package server provides the MCP server context for klausctl.
tools/artifact
Package artifact implements MCP tool handlers for artifact discovery: toolchain list, personality list, and plugin list.
Package artifact implements MCP tool handlers for artifact discovery: toolchain list, personality list, and plugin list.
tools/instance
Package instance implements MCP tool handlers for klaus instance lifecycle management (create, start, stop, delete, status, logs, list), archive operations (list, show, tag), and aggregate stats (summary, spend, trends, list, top).
Package instance implements MCP tool handlers for klaus instance lifecycle management (create, start, stop, delete, status, logs, list), archive operations (list, show, tag), and aggregate stats (summary, spend, trends, list, top).
tools/muster
Package muster implements MCP tool handlers for muster bridge lifecycle management (start, stop, status).
Package muster implements MCP tool handlers for muster bridge lifecycle management (start, stop, status).
tools/workspace
Package workspace implements MCP tool handlers for workspace registry management: listing, adding, removing organizations and repos, and fetching cached repositories.
Package workspace implements MCP tool handlers for workspace registry management: listing, adding, removing organizations and repos, and fetching cached repositories.
pkg
agentclient
Package agentclient provides a lightweight HTTP client for querying the klaus agent's /status endpoint.
Package agentclient provides a lightweight HTTP client for querying the klaus agent's /status endpoint.
archive
Package archive persists agent transcript summaries for stopped/deleted instances so they can be reviewed after the container is gone.
Package archive persists agent transcript summaries for stopped/deleted instances so they can be reviewed after the container is gone.
config
Package config defines the klausctl configuration types and handles loading from the user's config file.
Package config defines the klausctl configuration types and handles loading from the user's config file.
instance
Package instance tracks the state of running klausctl container instances.
Package instance tracks the state of running klausctl container instances.
mcpclient
Package mcpclient provides a lightweight MCP HTTP client for communicating with klaus agent instances.
Package mcpclient provides a lightweight MCP HTTP client for communicating with klaus agent instances.
mcpserverstore
Package mcpserverstore manages the global registry of managed MCP server definitions for klausctl.
Package mcpserverstore manages the global registry of managed MCP server definitions for klausctl.
musterbridge
Package musterbridge manages the lifecycle of a shared local muster process that aggregates stdio MCP servers behind an HTTP endpoint.
Package musterbridge manages the lifecycle of a shared local muster process that aggregates stdio MCP servers behind an HTTP endpoint.
oauth
Package oauth provides OAuth 2.0 authentication for remote MCP servers.
Package oauth provides OAuth 2.0 authentication for remote MCP servers.
orchestrator
Package orchestrator provides shared container lifecycle logic used by both the CLI commands and the MCP server tool handlers.
Package orchestrator provides shared container lifecycle logic used by both the CLI commands and the MCP server tool handlers.
renderer
Package renderer generates the configuration files that are mounted into the klaus container.
Package renderer generates the configuration files that are mounted into the klaus container.
runtime
Package runtime provides a container runtime abstraction for Docker and Podman.
Package runtime provides a container runtime abstraction for Docker and Podman.
secret
Package secret provides a file-permission-protected secret store for klausctl.
Package secret provides a file-permission-protected secret store for klausctl.
workspace
Package workspace manages a registry of GitHub repositories and a local clone cache.
Package workspace manages a registry of GitHub repositories and a local clone cache.
worktree
Package worktree manages cloned workspaces for instance isolation.
Package worktree manages cloned workspaces for instance isolation.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL