feat: Add support for Claude agents in ClaudeBox containers#44
Open
johnhaley81 wants to merge 2 commits intoRchGrav:mainfrom
Open
feat: Add support for Claude agents in ClaudeBox containers#44johnhaley81 wants to merge 2 commits intoRchGrav:mainfrom
johnhaley81 wants to merge 2 commits intoRchGrav:mainfrom
Conversation
- Sync agents from ~/.claude/agents to project-specific directories - Create symlink in containers to make agents available at standard location - Follow same pattern as commands with checksum-based change detection - Enable per-project agent isolation This allows users to use their locally defined Claude agents within ClaudeBox containers, maintaining the same project isolation model used for commands. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Reviewer's GuideThis PR extends the existing project sync workflow by adding per-project agent synchronization (with checksum-based change detection and cleanup) in lib/project.sh and updates the container entrypoint to create the corresponding agents symlink so the Claude CLI finds user agents inside ClaudeBox containers. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey @johnhaley81 - I've reviewed your changes - here's some feedback:
- Consider replacing the manual find/cp loop and checksum logic with an rsync --archive --delete invocation to simplify synchronization and preserve metadata.
- Extract the checksum calculation and sync decision logic into a reusable helper to reduce duplication between commands and agents syncing.
- Allow configuring the agents source path (e.g. via XDG_CONFIG_HOME) instead of hardcoding ~/.claude/agents for better flexibility.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider replacing the manual find/cp loop and checksum logic with an rsync --archive --delete invocation to simplify synchronization and preserve metadata.
- Extract the checksum calculation and sync decision logic into a reusable helper to reduce duplication between commands and agents syncing.
- Allow configuring the agents source path (e.g. via XDG_CONFIG_HOME) instead of hardcoding ~/.claude/agents for better flexibility.
## Individual Comments
### Comment 1
<location> `lib/project.sh:605` </location>
<code_context>
+
+ # Calculate checksum for agents if directory exists
+ if [[ -d "$agents_source" ]]; then
+ agents_checksum=$(find "$agents_source" -type f -exec stat -f "%m" {} \; 2>/dev/null | sort | md5 2>/dev/null || \
+ find "$agents_source" -type f -exec stat -c "%Y" {} \; 2>/dev/null | sort | md5sum | cut -d' ' -f1)
+
+ # Check if sync needed
</code_context>
<issue_to_address>
Checksum calculation uses platform-specific 'stat' and 'md5' commands.
If neither BSD/macOS nor GNU/Linux commands are available, the script may fail without warning. Please add an explicit error message or fallback for unsupported platforms.
</issue_to_address>
<suggested_fix>
<<<<<<< SEARCH
# Calculate checksum for agents if directory exists
if [[ -d "$agents_source" ]]; then
agents_checksum=$(find "$agents_source" -type f -exec stat -f "%m" {} \; 2>/dev/null | sort | md5 2>/dev/null || \
find "$agents_source" -type f -exec stat -c "%Y" {} \; 2>/dev/null | sort | md5sum | cut -d' ' -f1)
# Check if sync needed
=======
# Calculate checksum for agents if directory exists
if [[ -d "$agents_source" ]]; then
if command -v stat >/dev/null 2>&1 && command -v md5 >/dev/null 2>&1; then
# BSD/macOS
agents_checksum=$(find "$agents_source" -type f -exec stat -f "%m" {} \; 2>/dev/null | sort | md5 2>/dev/null)
elif command -v stat >/dev/null 2>&1 && command -v md5sum >/dev/null 2>&1; then
# GNU/Linux
agents_checksum=$(find "$agents_source" -type f -exec stat -c "%Y" {} \; 2>/dev/null | sort | md5sum | cut -d' ' -f1)
else
echo "Error: Required checksum utilities (stat/md5 or stat/md5sum) not found on this platform." >&2
exit 1
fi
# Check if sync needed
>>>>>>> REPLACE
</suggested_fix>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
- Wrap cd command in if statement to handle potential failures - Ensures proper error handling as per shellcheck SC2164 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
johnhaley81
added a commit
to johnhaley81/claudebox
that referenced
this pull request
Aug 13, 2025
…nds_to_project - Wrap cbox and user cd commands in if statements (lines 562, 586) - Add error handling to cd - commands with || true - Makes error handling consistent with agents cd (line 629) - Prevents script exit when command directories don't exist - Fixes MCP server integration breaking with missing directories - Maintains shellcheck SC2164 compliance for all cd operations This ensures both PR RchGrav#43 (MCP) and PR RchGrav#44 (agents) work together without unexpected script termination in edge cases. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implementation Details
Changes Made:
build/docker-entrypoint: Added symlink creation for agents directory (similar to commands)lib/project.sh: Added agent syncing functionality that:~/.claude/agents/to project-specific directoriesHow It Works:
~/.claude/agents/are automatically detected~/.claudebox/projects/{project_hash}/agents/(per-project isolation)~/.claude/agents→~/.claudebox/agentsReview Feedback Addressed
Based on Sourcery AI review:
Testing
User Impact
Users can now use their Claude agents within ClaudeBox containers by:
~/.claude/agents/on their hostThis maintains the same security and isolation model as commands - each project gets its own copy of agents.
🤖 Generated with Claude Code