-
Notifications
You must be signed in to change notification settings - Fork 100
feat: Add support for Claude agents in ClaudeBox containers #44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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>
…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>
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