Skip to content

feat: Add --global flag to use ~/.claude settings directly#86

Open
ahmet-cetinkaya wants to merge 1 commit into
RchGrav:mainfrom
ahmet-cetinkaya:feat/global-config-flag
Open

feat: Add --global flag to use ~/.claude settings directly#86
ahmet-cetinkaya wants to merge 1 commit into
RchGrav:mainfrom
ahmet-cetinkaya:feat/global-config-flag

Conversation

@ahmet-cetinkaya
Copy link
Copy Markdown

@ahmet-cetinkaya ahmet-cetinkaya commented Nov 6, 2025

Summary

Implements a new --global flag that allows ClaudeBox to use the user's global ~/.claude/ configuration directly instead of creating isolated project configurations.

Problem

Previously, users had to manually copy their global configuration from ~/.claude/ into each project's .claude/ directory. This was inconvenient and not scalable for users who prefer a single, global setup.

Solution

Added a --global flag that:

  • Mounts user's home directories directly (~/.claude, ~/.config, ~/.cache)
  • Uses global configuration stored in ~/.claudebox/global/
  • Creates separate claudebox-global Docker image
  • Maintains full backward compatibility with existing project isolation

Changes Made

CLI Parser (lib/cli.sh)

  • Added --global to HOST_ONLY_FLAGS array
  • Added processing logic to set GLOBAL_MODE=true

Global Mode Logic (lib/project.sh)

  • Added use_global_mode(), init_global_mode(), get_global_dir() functions
  • Modified get_project_folder_name() to return "global" in global mode
  • Modified get_image_name() to return "claudebox-global" for global mode

Docker Mounting (lib/docker.sh)

  • Conditional mounting strategy:
    • Global Mode: Direct mounts to user's home directories
    • Project Mode: Existing slot-based mounting
  • Skip project-specific MCP configurations in global mode

Configuration Handling (lib/config.sh)

  • Updated profile file paths to use global directory in global mode
  • Modified current profiles logic for global mode

Main Script Integration (main.sh)

  • Added global mode detection and setup logic
  • Updated project/slot directory handling for both modes

Usage

# Use global configuration
claudebox --global

# Add profiles to global config
claudebox --global add python rust

# Show global profiles
claudebox --global profiles

# Normal project mode (unchanged)
claudebox add core

Testing

✅ CLI parser correctly recognizes --global flag
✅ Global mode creates separate claudebox-global Docker image
✅ Configuration stored in ~/.claudebox/global/ with proper symlinks
✅ Profile management works in global mode
✅ Project mode continues to work without changes
✅ Complete separation between global and project configurations
✅ Docker mounting works correctly for both modes

Backward Compatibility

All existing functionality works exactly as before when the --global flag is not specified. No breaking changes.

Resolves #85

Summary by Sourcery

Enable a new global mode via --global that mounts and uses the user's home-based ClaudeBox configuration and cache directly, backed by a dedicated Docker image, while preserving the existing per-project isolation workflow by default.

New Features:

  • Add --global flag to enable using a single shared ~/.claudebox configuration across all projects
  • Mount host home directories (~/.claudebox, ~/.claude, ~/.config, ~/.cache) directly in global mode
  • Introduce a dedicated claudebox-global Docker image for global mode

Enhancements:

  • Add global mode helper functions (use_global_mode, init_global_mode, get_global_dir, etc.) and initialize global config directory with symlinks
  • Update CLI parser, main script, project, docker, and config modules to support toggling between global and project modes transparently
  • Maintain backward compatibility so existing project isolation remains unchanged when --global is not specified

Add support for running Claudebox in global mode instead of project-specific mode.
When --global flag is used, the system:
- Uses global configuration at ~/.claudebox/global/
- Mounts user's home directories directly instead of project slot directories
- Provides a fixed container name for global sessions
- Skips project-specific MCP configuration

This allows users to maintain a single, persistent Claudebox environment
across all projects, useful for development environments that need
consistent configuration regardless of the specific project directory.
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented Nov 6, 2025

Reviewer's Guide

Introduces a new global mode via the --global flag to mount and manage a single ~/.claudebox configuration across projects, implemented by extending CLI parsing, project scripts, Docker mounts, config handlers, and main initialization while preserving existing project isolation.

Sequence diagram for --global flag initialization and configuration setup

sequenceDiagram
    actor User
    participant CLI as "CLI Parser (cli.sh)"
    participant Main as "Main Script (main.sh)"
    participant Project as "Project Logic (project.sh)"
    participant Docker as "Docker Mounting (docker.sh)"
    participant Config as "Config Handler (config.sh)"
    User->>CLI: Run `claudebox --global`
    CLI->>Main: Set GLOBAL_MODE=true
    Main->>Project: use_global_mode() check
    Project->>Project: init_global_mode()
    Project->>Main: get_global_dir()
    Main->>Docker: Prepare Docker args for global mode
    Docker->>Docker: Mount ~/.claudebox, ~/.claude, ~/.config, ~/.cache
    Docker->>Config: Use global profiles.ini
    Config->>Config: get_profile_file_path() (global dir)
    User->>CLI: Run profile commands (e.g. add, profiles)
    CLI->>Config: get_current_profiles() (global dir)
Loading

Class diagram for new and modified functions supporting global mode

classDiagram
    class CLI {
      +process_host_flags()
      HOST_ONLY_FLAGS: [--verbose, rebuild, --global]
    }
    class Main {
      +main()
      +PROJECT_PARENT_DIR
      +PROJECT_SLOT_DIR
    }
    class Project {
      +use_global_mode()
      +init_global_mode()
      +get_global_dir()
      +get_global_container_name()
      +should_use_slots()
      +get_project_folder_name()
      +get_image_name()
    }
    class Docker {
      +run_claudebox_container()
      +Mounting logic (global vs project)
    }
    class Config {
      +get_profile_file_path()
      +get_current_profiles()
    }
    CLI --> Main
    Main --> Project
    Main --> Docker
    Docker --> Config
    Project --> Docker
    Project --> Config
Loading

File-Level Changes

Change Details Files
Extend CLI parser to recognize and export the --global flag
  • Added --global to HOST_ONLY_FLAGS
  • Export GLOBAL_MODE when --global is passed
lib/cli.sh
Implement global mode functions and adapt project utilities
  • Added use_global_mode, init_global_mode, get_global_dir, get_global_container_name, should_use_slots
  • Updated get_project_folder_name to initialize and return “global” in global mode
  • Updated get_image_name to return claude­box­-global in global mode
lib/project.sh
Adjust Docker mounting logic for global versus project mode
  • Global mode mounts user’s ~/.claudebox, ~/.claude, ~/.config, ~/.cache
  • Project mode retains slot-based mounts and MCP merging
  • Added debug output and skip project MCP config in global mode
lib/docker.sh
Route profile and config file paths to the global directory
  • get_profile_file_path returns ~/.claudebox/global/profiles.ini in global mode
  • get_current_profiles reads from global profiles.ini when enabled
lib/config.sh
In main script, detect global mode and set up directories accordingly
  • Global mode branch calls init_global_mode and sets PROJECT_PARENT_DIR to global dir
  • Project mode branch remains unchanged
  • PROJECT_SLOT_DIR assignment adjusted for global mode
main.sh

Assessment against linked issues

Issue Objective Addressed Explanation
#85 Add a --global flag to the claudebox CLI that allows users to use the configuration from ~/.claude directly, bypassing project-level isolation.
#85 Ensure that when --global is used, claudebox mounts and uses the user's home configuration directories (e.g., ~/.claude, ~/.config, ~/.cache) and stores global configuration in ~/.claudebox/global/.
#85 Maintain backward compatibility so that existing project-level isolation and workflows are unchanged when --global is not specified.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@ahmet-cetinkaya
Copy link
Copy Markdown
Author

I'm having a timeout issue with the Custom API URL, it's not ready for merge until it's resolved.

@agentfarmx
Copy link
Copy Markdown

agentfarmx Bot commented Nov 6, 2025

No operation ID found for this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Add a --global flag to use ~/.claude settings directly

1 participant