Skip to content

Latest commit

 

History

History
74 lines (58 loc) · 2.88 KB

File metadata and controls

74 lines (58 loc) · 2.88 KB

CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

Project Overview

Xcode Theme Generator - A conversational Swift CLI that generates custom Xcode color themes. User provides a starting color, the tool guides them through choices (dark/light, vibe) and generates a complete .xccolortheme file with OKLCH-based color palette generation and WCAG contrast enforcement.

Build & Run Commands

# Build the project
swift build

# Run interactive theme wizard
swift run xcode-theme-generator

# Run with specific subcommand
swift run xcode-theme-generator generate    # Interactive theme creation (default)
swift run xcode-theme-generator list        # List existing custom themes

# Non-interactive mode
swift run xcode-theme-generator generate \
  --color "#6366f1" \
  --dark \
  --vibe vibrant \
  --name "My Theme" \
  --no-install  # Optional: save to current dir instead of Xcode

Architecture

Sources/XcodeThemeGenerator/
├── Commands/
│   └── GenerateCommand.swift     # ArgumentParser CLI entry point and commands
├── Color/
│   ├── OKLCHColor.swift          # OKLCH color space implementation, RGB conversion
│   ├── ColorPalette.swift        # Palette generation for all syntax roles
│   └── ContrastChecker.swift     # WCAG contrast ratio validation
├── Rules/
│   └── ThemeRules.swift          # Theme rules protocol, dark/light implementations
├── Conversation/
│   ├── Prompter.swift            # Terminal UI: prompts, color swatches, styling
│   └── ThemeWizard.swift         # Conversation flow orchestration
├── Theme/
│   ├── XcodeTheme.swift          # Theme model, .xccolortheme plist generation
│   ├── ThemeGenerator.swift      # Applies rules + vibe to generate theme
│   └── ThemeInstaller.swift      # Installs to ~/Library/.../FontAndColorThemes/
└── Preview/
    └── TerminalPreview.swift     # ANSI-colored Swift code sample preview

Key Concepts

  • OKLCH Color Space: Perceptually uniform color model (L: lightness 0-1, C: chroma 0-0.4, H: hue 0-360)
  • Contrast Enforcement: Minimum 4.5:1 for text (WCAG AA), auto-adjusts lightness if needed
  • Vibe Adjustments: vibrant (high saturation), muted (low saturation), warm (red-shifted), cool (blue-shifted)
  • Theme Installation: Writes to ~/Library/Developer/Xcode/UserData/FontAndColorThemes/

Interactive Adjustment Mode

After initial selections, an interactive mode allows real-time color tweaking:

Key Action
h/l or / Rotate hue
j/k or / Adjust chroma (saturation)
v Cycle through vibes
d Toggle dark/light mode
1-9 Jump to preset colors
Enter/q Confirm and continue

Use --quick flag to skip this mode for faster generation.