This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
kubesess is a Rust CLI tool for Kubernetes context and namespace management. It provides session-isolated configuration, preventing accidental operations on unintended clusters. The tool is significantly faster than kubectx/kubens by directly parsing kubeconfig files instead of calling kubectl.
cargo build --release # Build optimized binary
cargo check # Check compilation without building
cargo clippy # Run linter
make deploy_local # Build and install to ~/.kube/kubesess and /usr/local/bin
make benchmark # Run performance benchmarkscargo test --all # Run all tests
cargo test [test_name] # Run specific test (e.g., cargo test set_context)
cargo test -- --nocapture # Run with output visibleTests are in tests/cli.rs and use assert_cmd with #[serial] for sequential execution.
Entry point: src/main.rs - CLI parsing with clap, mode dispatch, KUBECONFIG path resolution
Core modules:
src/modes.rs- Mode handlers for context/namespace operations (session and global)src/commands.rs- Business logic: TUI selector (skim), kubectl calls for namespacessrc/config.rs- Kubeconfig parsing, merging multiple files, session config generationsrc/error.rs- Error types using thiserror
Data flow:
- CLI parses mode and flags
- Mode handler loads/merges kubeconfig files from KUBECONFIG env or ~/.kube/
- User selects context/namespace via skim TUI (or passes via -v flag)
- Session commands write minimal config to
~/.kube/kubesess/cache/ - Global commands use kubectl config to modify actual kubeconfig
- Output is a KUBECONFIG path for shell eval
Shell integration: scripts/sh/ and scripts/fish/ contain wrapper functions (kc, kcd, kn, knd) that eval kubesess output to set KUBECONFIG.
- clap - CLI argument parsing with derive macros
- kube + k8s-openapi - Kubernetes config types
- skim - Fuzzy selector TUI (fzf-like)
- serde_yaml - YAML parsing
Workflows in .github/workflows/:
run_tests.yaml- Runscargo checkandcargo test --allrun_linters.yaml- Clippy on PRspackage_and_release.yaml- Multi-platform builds (Linux/macOS, x86_64/ARM64)