ClaudeKit CLI is a command-line tool for bootstrapping and updating ClaudeKit projects from private GitHub repository releases. Built with Bun and TypeScript, it provides secure, fast project setup and maintenance with comprehensive features for downloading, extracting, and merging project templates.
Version: 1.16.0 Total TypeScript Files: 47 (33 source + 14 test support) Commands: 6 (new, init/update, versions, doctor, diagnose, uninstall) Core Libraries: 26 modules Utilities: 14 modules
- Bun: Primary runtime and package manager (>=1.3.2)
- TypeScript: Type-safe development (v5.7.2, strict mode)
- Node.js: Compatible with Node.js LTS environments
- @octokit/rest: GitHub API client for repository interactions
- @clack/prompts: Beautiful interactive CLI prompts
- cac: Command-line argument parser
- keytar: Secure credential storage using OS keychain
- extract-zip: ZIP archive extraction
- tar: TAR.GZ archive handling
- fs-extra: Enhanced filesystem operations
- ignore: Glob pattern matching for file filtering
- zod: Runtime type validation and schema parsing
- cli-progress: Progress bar rendering
- ora: Terminal spinners
- picocolors: Terminal colors
- Biome: Fast linting and formatting
- Semantic Release: Automated versioning and publishing
- GitHub Actions: CI/CD automation with multi-platform binary builds
- macOS (arm64, x64)
- Linux (x64)
- Windows (x64)
claudekit-cli/
├── bin/ # Binary distribution
│ └── ck.js # Platform detection wrapper
├── src/ # Source code (43 TS files)
│ ├── commands/ # Command implementations (6 files)
│ │ ├── new.ts # Create new project
│ │ ├── update.ts # Update existing project (init alias)
│ │ ├── version.ts # List available versions
│ │ ├── diagnose.ts # Authentication diagnostics
│ │ ├── doctor.ts # System dependencies checker/installer
│ │ └── uninstall.ts # Uninstall ClaudeKit installations
│ ├── lib/ # Core business logic (26 files)
│ │ ├── auth.ts # Multi-tier authentication manager
│ │ ├── github.ts # GitHub API client wrapper
│ │ ├── download.ts # Download and extraction manager
│ │ ├── merge.ts # Smart file merger with conflict detection
│ │ ├── ownership-checker.ts # File ownership tracking via checksums
│ │ ├── prompts.ts # Interactive prompt manager
│ │ ├── release-cache.ts # Release data caching
│ │ ├── release-filter.ts # Release filtering logic
│ │ ├── version-cache.ts # Version check caching
│ │ ├── version-checker.ts # Update notification system
│ │ ├── version-display.ts # Version formatting
│ │ ├── version-formatter.ts # Release date formatting
│ │ ├── version-selector.ts # Interactive version selection
│ │ ├── fresh-installer.ts # Fresh installation handler
│ │ ├── commands-prefix.ts # Command namespace transformer
│ │ ├── global-path-transformer.ts # Global path transformations
│ │ ├── config-validator.ts # API key validation patterns
│ │ ├── config-generator.ts # .env file generation
│ │ ├── setup-wizard.ts # Interactive setup wizard
│ │ ├── skills-manifest.ts # Manifest generation and validation
│ │ ├── skills-detector.ts # Migration detection
│ │ ├── skills-migrator.ts # Migration orchestrator
│ │ ├── skills-backup-manager.ts # Backup and restore
│ │ ├── skills-customization-scanner.ts # Customization detector
│ │ ├── skills-mappings.ts # Category mappings
│ │ └── skills-migration-prompts.ts # Migration UI
│ ├── utils/ # Utility modules (14 files)
│ │ ├── config.ts # Configuration manager
│ │ ├── path-resolver.ts # Platform-aware path resolution
│ │ ├── logger.ts # Logging with sanitization
│ │ ├── file-scanner.ts # File discovery
│ │ ├── safe-prompts.ts # Promise-safe prompt wrapper
│ │ ├── safe-spinner.ts # Safe spinner for CI
│ │ ├── claudekit-scanner.ts # ClaudeKit project detection
│ │ ├── dependency-checker.ts # Dependency validation
│ │ ├── dependency-installer.ts # Dependency installation
│ │ ├── directory-selector.ts # Directory selection
│ │ ├── package-installer.ts # Package manager detection
│ │ ├── environment.ts # Environment detection
│ │ └── ...
│ ├── index.ts # CLI entry point
│ └── types.ts # Type definitions and schemas
├── tests/ # Comprehensive test suite
│ ├── commands/ # Command tests
│ ├── lib/ # Library tests
│ └── utils/ # Utility tests
├── docs/ # Documentation
├── plans/ # Implementation plans
├── .github/workflows/ # CI/CD configuration
│ ├── release.yml # Release automation
│ └── build-binaries.yml # Multi-platform binary builds
├── package.json # Package manifest
└── tsconfig.json # TypeScript configuration
Foundation interfaces and types for the custom help renderer.
Core Interfaces:
- CommandHelp: Complete help data for a single command (name, description, usage, examples, optionGroups, sections, aliases, deprecated)
- HelpExample: Single usage example with command and description (max 2 per command)
- OptionGroup: Logical grouping of related options with title (e.g., "Output Options", "Filter Options")
- OptionDefinition: Single option with flags, description, defaultValue, and deprecation info
- DeprecatedInfo: Deprecation metadata (message, alternative, removeInVersion)
- HelpSection: Generic help section for additional content (notes, warnings, related commands)
Rendering Configuration:
- ColorTheme: Color theme interface with banner, command, heading, flag, description, example, warning, error, muted, success
- ColorFunction: Type for color formatting functions (respects NO_COLOR)
- HelpOptions: Renderer config (showBanner, showExamples, maxExamples, interactive, width, theme, noColor)
- HelpRenderContext: Context passed to renderer (command, globalHelp, options)
Type Utilities:
- CommandRegistry: Record<string, CommandHelp> for all command definitions
- HelpFormatter: Custom formatter function type (help, context) => string
- GlobalHelp: Global help data (name, description, version, usage, commands, globalOptions)
Design Principles:
- Conciseness over completeness (max 2 examples per command)
- Accessibility (NO_COLOR environment variable support)
- Extensibility (custom formatters, pluggable themes)
- Interactive support (scrolling for long content)
Test Coverage: 36 passing tests with 108 assertions
Create new ClaudeKit projects from releases with interactive or non-interactive mode.
Features:
- Interactive kit selection
- Directory validation
- Force overwrite option
- Exclude pattern support
- Optional package installation (OpenCode, Gemini)
- Skills dependencies installation
- Command prefix support (/ck: namespace)
Update existing projects while preserving customizations.
Features:
- Smart preservation of custom files
- Protected file detection
- Conflict detection with user confirmation
- Global flag support (--global/-g)
- Fresh installation mode (--fresh)
- Beta version display (--beta)
- Skills migration detection
- Command prefix support
Deprecation: update command renamed to init, shows deprecation warning
List available releases with filtering and pagination.
Features:
- Filter by kit type
- Show beta/prerelease versions (--all)
- Configurable limit (default 30)
- Parallel fetching for multiple kits
- Release metadata display
Verify GitHub authentication and repository access.
Features:
- GitHub authentication verification
- Repository access checks
- Release availability validation
- Verbose logging support
Check system dependencies and offer auto-installation.
Features:
- Checks Claude CLI, Python, pip, Node.js, npm
- Auto-installation with user confirmation
- Platform detection (macOS, Linux, Windows, WSL)
- Package manager support (Homebrew, apt, dnf, pacman)
- ClaudeKit setup detection (global and project)
- Component counts (agents, commands, workflows, skills)
- Non-interactive mode for CI/CD
- Manual fallback instructions
Test Coverage: 50 passing tests with 324 assertions
Remove ClaudeKit installations safely.
Features:
- Detects local and global installations
- Validates via metadata.json
- Interactive confirmation (unless --yes)
- Cross-platform safe deletion
- Clear path display before deletion
Multi-tier authentication fallback system.
Tiers:
- GitHub CLI (gh auth token)
- Environment variables (GITHUB_TOKEN, GH_TOKEN)
- Config file (~/.claudekit/config.json)
- OS Keychain (via keytar)
- User prompt with save option
Features:
- Token format validation
- Secure keychain integration
- In-memory caching
- Authentication method tracking
Octokit-based GitHub API wrapper.
Operations:
- Release fetching (latest or by tag)
- Repository access verification
- Smart asset selection with priority
- Comprehensive error handling
Asset Priority:
- ClaudeKit official package
- Custom uploaded archives
- GitHub automatic tarball (fallback)
Streaming downloads with security validation.
Features:
- Streaming downloads with progress bars
- Archive extraction (TAR.GZ and ZIP)
- Path traversal protection
- Archive bomb prevention (500MB limit)
- Wrapper directory detection
- Exclude pattern support
- Percent-encoded path handling
Smart file conflict detection and selective preservation.
Features:
- Conflict detection before merging
- Protected pattern matching
- User confirmation for overwrites
- Custom file preservation
- Merge statistics tracking
File ownership classification using SHA-256 checksums (pip RECORD pattern).
Ownership Classifications:
- "ck": CK-owned and pristine (file in metadata with matching checksum)
- "ck-modified": User-modified CK files (file in metadata with different checksum)
- "user": User-created files (not in metadata)
Core Methods:
calculateChecksum(filePath): SHA-256 hash with streaming (memory-efficient)checkOwnership(filePath, metadata, claudeDir): Classify single file ownership
Features:
- Memory-efficient streaming for large files
- Windows path normalization (backslash → forward slash)
- Fallback to "user" ownership for legacy installs (no metadata)
- Non-existent file handling (exists: false)
Test Coverage: 11 passing tests covering all ownership scenarios
- release-cache.ts: Local caching of release data (default 1hr TTL)
- release-filter.ts: Filter releases by prerelease/draft status
- version-cache.ts: Update notification caching (7-day cache)
- version-checker.ts: Version comparison and update notifications
- version-display.ts: Formatted version output
- version-formatter.ts: Relative date formatting
- version-selector.ts: Interactive version selection UI
- fresh-installer.ts: Fresh installation with confirmation prompts
- commands-prefix.ts: Transform commands to /ck: namespace
- global-path-transformer.ts: Global path transformation utilities
config-validator.ts: API key and configuration value validation patterns
- Validates Gemini API keys (AIza prefix, 35-character alphanumeric + underscore/hyphen)
- Validates Discord webhook URLs (https://discord.com/api/webhooks/)
- Validates Telegram bot tokens (numeric ID + colon + 35-character alphanumeric + underscore/hyphen)
- Function:
validateApiKey(value: string, pattern: RegExp): boolean
config-generator.ts: .env file generation utility
- Generates .env files with provided key-value pairs
- Adds header comment indicating file was generated by ClaudeKit CLI
- Skips empty values to avoid cluttering config file
- Appends newline for proper file formatting
- Function:
generateEnvFile(targetDir: string, values: Record<string, string>): Promise<void>
setup-wizard.ts: Interactive setup wizard for essential configuration
- Interactive prompts using @clack/prompts for user-friendly input
- Configuration options for Gemini API, Discord webhook, Telegram bot token
- Global vs. local configuration distinction:
- Global mode: Shared defaults across all projects
- Local mode: Project-specific settings with inheritance from global config
- Masked display of sensitive values (shows first 8 chars + "...")
- Default value inheritance: Local mode inherits from global .env if available
- Validation against patterns with user-friendly error messages
- Cancellation handling with warning message
- Function:
runSetupWizard(options: SetupWizardOptions): Promise<boolean> - Interface:
SetupWizardOptions { targetDir: string, isGlobal: boolean }
Test Coverage:
- config-validator: 5 tests (Gemini, Discord, Telegram validation)
- config-generator: 3+ tests (.env generation, empty values, header comments)
- setup-wizard: 2+ tests (.env existence check, global inheritance detection)
skills-manifest.ts: Manifest generation with SHA-256 hashing skills-detector.ts: Manifest-based + heuristic detection skills-migrator.ts: Orchestrates migration workflow skills-backup-manager.ts: Backup creation and restore skills-customization-scanner.ts: Detects user modifications skills-mappings.ts: Category to skill mappings skills-migration-prompts.ts: Interactive migration prompts
Migration Flow:
Detection → User Confirmation → Backup → Migration → Manifest → Success/Rollback
Manages user configuration with global flag support.
Paths:
- Local mode (default): ~/.claudekit/config.json
- Global mode: Platform-specific (XDG-compliant)
Platform-aware path resolution for config and cache.
Methods:
- getConfigDir(global): Config directory path
- getCacheDir(global): Cache directory path
- getPathPrefix(global): Directory prefix (".claude" or "")
- buildSkillsPath(baseDir, global): Skills directory path
- buildComponentPath(baseDir, component, global): Component paths
- getGlobalKitDir(): Global kit installation directory
XDG Compliance:
- Config: XDG_CONFIG_HOME or ~/.config
- Cache: XDG_CACHE_HOME or ~/.cache
Structured logging with token sanitization.
Log Levels:
- debug (verbose only)
- info
- success
- warning
- error
- verbose
Security:
- Token sanitization (ghp_, github_pat_)
- Log file output support
- Environment variable activation
Recursive directory scanning and custom file detection.
Operations:
- getFiles(dir): All files with relative paths
- findCustomFiles(dest, source, subdir): Custom files in dest
- dependency-checker.ts: Validates Claude CLI, Python, pip, Node.js, npm
- dependency-installer.ts: Cross-platform installation with package manager detection
- package-installer.ts: Detects npm, yarn, pnpm, bun
- safe-prompts.ts: CI-safe interactive prompt wrapper
- safe-spinner.ts: Safe spinner for non-TTY environments
- claudekit-scanner.ts: Detects ClaudeKit installations
- environment.ts: Platform detection and adaptive concurrency tuning
- Platform detection: isMacOS(), isWindows(), isLinux(), isCIEnvironment()
- Concurrency optimization: getOptimalConcurrency() (macOS: 10, Windows: 15, Linux: 20)
- Used by download.ts (native unzip fallback), manifest-writer.ts (parallel tracking)
- directory-selector.ts: Interactive directory selection
- KitType: "engineer" | "marketing"
- ExcludePatternSchema: Validates exclude patterns
- NewCommandOptionsSchema: New command options
- UpdateCommandOptionsSchema: Update command options (with global flag)
- VersionCommandOptionsSchema: Version command options
- UninstallCommandOptionsSchema: Uninstall command options
- UpdateCliOptionsSchema: CLI self-update options
- ConfigSchema: User configuration
- GitHubReleaseSchema: GitHub API response
- KitConfigSchema: Kit configuration
- SkillsManifestSchema: Skills manifest structure
- InstallationOptionsSchema: Optional package installation
- FileOwnership: Type union ("ck" | "user" | "ck-modified")
- TrackedFileSchema: File tracking record with checksum and ownership
- MetadataSchema: Installation metadata with enhanced file tracking
- ClaudeKitError: Base error class
- AuthenticationError: Authentication failures (401)
- GitHubError: GitHub API errors
- DownloadError: Download failures
- ExtractionError: Archive extraction failures
- SkillsMigrationError: Migration failures
- AVAILABLE_KITS: Kit repository configurations
- PROTECTED_PATTERNS: File patterns to preserve during updates
- Parse and validate command options
- Authenticate with GitHub (multi-tier fallback)
- Select kit (interactive or via flag)
- Select version (interactive or latest)
- Validate target directory
- Verify repository access
- Download archive (with progress)
- Extract with security validation
- Apply exclude patterns
- Copy files to target
- Optional: Install packages (OpenCode, Gemini)
- Optional: Install skills dependencies
- Optional: Apply command prefix (/ck:)
- Success message with next steps
- Parse and validate options (including --global, --fresh, --beta)
- Handle fresh installation if --fresh flag
- Set global flag in ConfigManager
- Authenticate with GitHub
- Select kit and version (show beta if --beta)
- Download and extract to temp
- Detect skills migration need (manifest or heuristics)
- Execute migration if needed (with backup/rollback)
- Scan for custom .claude files
- Merge with conflict detection
- Optional: Apply command prefix
- Generate new skills manifest
- Success message
GH CLI → Env Vars → Config → Keychain → Prompt User
↓ ↓ ↓ ↓ ↓
Success Success Success Success Save to Keychain?
↓ ↓ ↓ ↓ ↓
Return Token with Method
Detection (Manifest or Heuristics)
↓
User Confirmation (Interactive Mode)
↓
Backup Creation (with compression)
↓
Migration Execution
↓
Generate New Manifest
↓
Success or Rollback on Error
- Application Layer: Token sanitization, input validation (Zod)
- Download Layer: Path traversal prevention, archive bomb detection
- Extraction Layer: Exclude pattern enforcement, size limits
- Storage Layer: OS keychain encryption, protected file preservation
- Resolve paths to canonical forms
- Reject relative paths with ".."
- Verify target starts with base path
- Maximum extraction size: 500MB
- Tokens never logged or exposed
- Automatic sanitization in logs
- Keychain integration for secure storage
- Token format validation (ghp_, github_pat_)
Always skipped during updates:
- .env, .env.local, .env.*.local
- *.key, *.pem, *.p12
- node_modules/, .git/
- dist/, build/
- .gitignore, .repomixignore, .mcp.json, CLAUDE.md
- Streaming downloads (no memory buffering)
- Parallel release fetching
- In-memory token caching
- Efficient glob pattern matching
- SHA-256 hashing for change detection
- Release data caching (1hr TTL, configurable)
- Version check caching (7-day cache)
- Maximum extraction size: 500MB
- Request timeout: 30 seconds
- Progress bar chunk size: 1MB
- Cache TTL: 3600s (configurable via CK_CACHE_TTL)
- Bun's --compile flag for standalone binaries
- Multi-platform builds via GitHub Actions
- Platform detection wrapper script (bin/ck.js)
- Published to npm registry
- Global installation via npm, yarn, pnpm, or bun
- Semantic versioning with automated releases
- Push to main branch
- Build binaries (parallel, all platforms)
- Run type checking, linting, tests
- Semantic Release determines version
- Create GitHub release with binaries
- Publish to npm registry
- Discord notification (optional)
- Init command: Renamed from update (deprecation warning)
- Fresh installation: --fresh flag for clean reinstall
- Beta versions: --beta flag for pre-release visibility
- Command prefix: --prefix flag for /ck: namespace
- Optional packages: OpenCode and Gemini integration
- Skills dependencies: --install-skills for auto-setup
- Update notifications: 7-day cached version checks with color-coded display
- Release caching: Configurable TTL for release data
- Parallel file tracking: Batch processing with p-limit for faster installs
- Platform optimizations: macOS native unzip fallback, adaptive concurrency
- Slow extraction warnings: 30-second threshold notifications
- Environment detection: Platform-aware concurrency tuning (macOS: 10, Windows: 15, Linux: 20)
Flexible authentication with automatic fallback for seamless UX across environments.
Intelligent conflict handling and customization preservation during updates.
Automated migration from flat to categorized structures with zero data loss guarantee.
Platform-aware paths with XDG compliance and Windows support.
Interactive version selection, beta version support, release caching.
Auto-detection and installation of system dependencies (doctor command).
- Structured error classes with status codes
- User-friendly error messages
- Stack traces in verbose mode
- Graceful fallbacks (asset → tarball)
- Migration-specific errors with rollback
- Automatic fallback to tarball on asset failure
- Temporary directory cleanup on errors
- Safe prompt cancellation
- Non-TTY environment detection
- Backup restoration on migration failure
- GitHub API: Repository and release management
- npm Registry: Package distribution
- OS Keychain: Secure credential storage (macOS, Linux, Windows)
- Discord Webhooks: Release notifications
- Configuration (local): ~/.claudekit/config.json
- Configuration (global): Platform-specific (XDG-compliant)
- Cache: ~/.claudekit/cache or platform-specific
- Global kit installation: ~/.claude/
- Local project installations: {project}/.claude/
- Skills manifest: .claude/skills/.skills-manifest.json
- Skills backups: .claude/backups/skills/
- Temporary files: OS temp directory
bun install # Install dependencies
bun run dev # Run in development mode
bun test # Run tests
bun run typecheck # Type checking
bun run lint # Lint code
bun run format # Format codebun run compile # Compile standalone binary
bun run compile:binary # Compile to bin/ck
bun run build:platform-binaries # Build all platforms- Unit tests for all core libraries
- Command integration tests
- Authentication flow tests
- Download and extraction tests
- Skills migration system tests (6 test files)
- Doctor command tests (50 tests, 324 assertions)
- Mirrors source structure (tests/ matches src/)
- Uses Bun's built-in test runner
- Setup/teardown for filesystem operations
- Temporary directories for isolation
- Marketing kit support (infrastructure ready)
- Enhanced progress reporting
- Diff preview before merging
- Plugin system
- Modular command structure
- Pluggable authentication providers
- Customizable protected patterns
- Kit configuration extensibility
- Category mappings extensibility