|
| 1 | +# Development Logs |
| 2 | + |
| 3 | +## Issue Analysis: 2025-06-22 |
| 4 | + |
| 5 | +### [bug-fixed] --trace flag doesn't pass --dangerously-skip-permissions in YOLO mode |
| 6 | + |
| 7 | +**Problem**: `claude-yolo --trace .` fails to add `--dangerously-skip-permissions` to the claude command. |
| 8 | + |
| 9 | +**Root Cause Found**: |
| 10 | +- In `claude.sh:562`, when `--trace` is used, the command was incorrectly constructed as: |
| 11 | + ```bash |
| 12 | + claude-trace --include-all-requests --run-with . |
| 13 | + ``` |
| 14 | +- **Missing `claude` command**: Should be `claude-trace --include-all-requests --run-with claude .` |
| 15 | + |
| 16 | +**Two-Part Fix Implemented**: |
| 17 | + |
| 18 | +1. **Fixed command construction** in `claude.sh:562`: |
| 19 | + ```bash |
| 20 | + # Before (broken): |
| 21 | + DOCKER_ARGS+=("claude-trace" "--include-all-requests" "--run-with" "${CLAUDE_ARGS[@]}") |
| 22 | + |
| 23 | + # After (fixed): |
| 24 | + DOCKER_ARGS+=("claude-trace" "--include-all-requests" "--run-with" "claude" "${CLAUDE_ARGS[@]}") |
| 25 | + ``` |
| 26 | + |
| 27 | +2. **Enhanced argument injection** in `docker-entrypoint.sh`: |
| 28 | + ```bash |
| 29 | + elif [ "$cmd" = "claude-trace" ]; then |
| 30 | + # claude-trace --include-all-requests --run-with claude [args] |
| 31 | + # Inject --dangerously-skip-permissions after "claude" |
| 32 | + while parsing args; do |
| 33 | + if [ "${args[$i]}" = "--run-with" ] && [ "${args[$((i+1))]}" = "claude" ]; then |
| 34 | + new_args+=("--run-with" "claude" "--dangerously-skip-permissions") |
| 35 | + fi |
| 36 | + done |
| 37 | + ``` |
| 38 | + |
| 39 | +**Result**: |
| 40 | +- Input: `claude-yolo --trace .` |
| 41 | +- Command: `claude-trace --include-all-requests --run-with claude .` |
| 42 | +- Executed: `claude-trace --include-all-requests --run-with claude --dangerously-skip-permissions .` |
| 43 | + |
| 44 | +**Status**: ✅ **FIXED** - Two-part fix ensures proper command structure and flag injection |
| 45 | + |
| 46 | +--- |
| 47 | + |
| 48 | +### [enhancement] Make dev tool installation more flexible |
| 49 | + |
| 50 | +**Problem**: All dev tools are baked into Dockerfile, requiring full image rebuild for new tools. |
| 51 | + |
| 52 | +**Current State**: |
| 53 | +- Tools installed in Dockerfile:92-117 (gh, delta, claude, claude-trace) |
| 54 | +- Static installation makes customization inflexible |
| 55 | +- Image size grows with every tool added |
| 56 | +- No runtime tool management |
| 57 | + |
| 58 | +**Solution Options**: |
| 59 | + |
| 60 | +#### Option 1: Runtime Package Installation |
| 61 | +```bash |
| 62 | +# Environment-driven installation in entrypoint |
| 63 | +CLAUDE_INSTALL_PACKAGES="gh,terraform,kubectl" |
| 64 | +``` |
| 65 | +Pros: Maximum flexibility, smaller base image |
| 66 | +Cons: Slower startup, network dependency, caching complexity |
| 67 | + |
| 68 | +#### Option 2: Tool Manifest System |
| 69 | +```yaml |
| 70 | +# .claude-tools.yml in project |
| 71 | +tools: |
| 72 | + - gh |
| 73 | + - terraform |
| 74 | + - kubectl |
| 75 | +``` |
| 76 | +Pros: Project-specific tools, version control |
| 77 | +Cons: Added complexity, manifest management |
| 78 | +
|
| 79 | +#### Option 3: Layered Image Approach |
| 80 | +```dockerfile |
| 81 | +FROM lroolle/claude-code-yolo:base |
| 82 | +RUN install-tool gh terraform kubectl |
| 83 | +``` |
| 84 | +Pros: Docker-native, cacheable layers |
| 85 | +Cons: Multiple image variants, registry complexity |
| 86 | + |
| 87 | +#### Option 4: Package Manager Integration |
| 88 | +```bash |
| 89 | +# In entrypoint, detect and install via various PMs |
| 90 | +[ -f requirements.txt ] && pip install -r requirements.txt |
| 91 | +[ -f package.json ] && npm install -g $(jq -r '.globalDependencies[]' package.json) |
| 92 | +``` |
| 93 | +Pros: Leverages existing ecosystem patterns |
| 94 | +Cons: Multiple package manager complexity |
| 95 | + |
| 96 | +**Recommendation**: Start with Option 1 (runtime installation) with intelligent caching. |
| 97 | + |
| 98 | +--- |
| 99 | + |
| 100 | +### [enhancement] Inconsistent authentication handling for dev tools |
| 101 | + |
| 102 | +**Problem**: While Claude auth is seamlessly handled via ~/.claude mounting, other dev tools require manual auth setup inside the container. |
| 103 | + |
| 104 | +**Current Auth State**: |
| 105 | +- ✅ **Claude**: Auto-mounted via `~/.claude` → `/root/.claude` → `/home/claude/.claude` (symlink) |
| 106 | +- ✅ **AWS**: Auto-mounted via `~/.aws` → `/root/.aws` → `/home/claude/.aws` (symlink) |
| 107 | +- ✅ **Google Cloud**: Auto-mounted via `~/.config/gcloud` → `/root/.config/gcloud` → `/home/claude/.config/gcloud` (symlink) |
| 108 | +- ❌ **GitHub CLI**: Requires manual `gh auth login` or token pasting into `/home/claude/.config/gh/` |
| 109 | +- ❌ **Docker Hub**: No auth mounting for `docker login` |
| 110 | +- ❌ **Terraform**: No auth mounting for `.terraform.d/credentials` |
| 111 | +- ❌ **NPM**: No auth mounting for `.npmrc` |
| 112 | + |
| 113 | +**Impact**: Inconsistent developer experience - some tools work seamlessly, others require manual setup. |
| 114 | + |
| 115 | +**Solution Options**: |
| 116 | + |
| 117 | +#### Option 1: Expand Auto-Mounting |
| 118 | +```bash |
| 119 | +# In claude.sh, add more auth directories |
| 120 | +[ -d "$HOME/.config/gh" ] && DOCKER_ARGS+=("-v" "$HOME/.config/gh:/root/.config/gh") |
| 121 | +[ -f "$HOME/.npmrc" ] && DOCKER_ARGS+=("-v" "$HOME/.npmrc:/root/.npmrc") |
| 122 | +[ -d "$HOME/.docker" ] && DOCKER_ARGS+=("-v" "$HOME/.docker:/root/.docker") |
| 123 | +[ -d "$HOME/.terraform.d" ] && DOCKER_ARGS+=("-v" "$HOME/.terraform.d:/root/.terraform.d") |
| 124 | +``` |
| 125 | +**Pros**: Consistent with current approach, minimal complexity |
| 126 | +**Cons**: Hard-coded tool list, doesn't scale |
| 127 | + |
| 128 | +#### Option 2: Generic Config Directory Mounting |
| 129 | +```bash |
| 130 | +# Mount entire config directories |
| 131 | +DOCKER_ARGS+=("-v" "$HOME/.config:/root/.config") |
| 132 | +DOCKER_ARGS+=("-v" "$HOME/.local:/root/.local") |
| 133 | +``` |
| 134 | +**Pros**: Catches all XDG-compliant tools automatically |
| 135 | +**Cons**: Over-broad mounting, potential security concerns |
| 136 | + |
| 137 | +#### Option 3: Selective Config Mounting with Detection |
| 138 | +```bash |
| 139 | +# Auto-detect and mount known auth files/dirs |
| 140 | +AUTH_PATHS=( |
| 141 | + ".config/gh" # GitHub CLI |
| 142 | + ".docker" # Docker Hub |
| 143 | + ".terraform.d" # Terraform |
| 144 | + ".npmrc" # NPM |
| 145 | + ".pypirc" # PyPI |
| 146 | + ".cargo" # Rust Cargo |
| 147 | +) |
| 148 | +``` |
| 149 | +**Pros**: Balanced approach, extensible list |
| 150 | +**Cons**: Requires maintenance of auth path list |
| 151 | + |
| 152 | +#### Option 4: Environment Variable Auth Pass-through |
| 153 | +```bash |
| 154 | +# Pass auth tokens as environment variables |
| 155 | +[ -n "$GH_TOKEN" ] && DOCKER_ARGS+=("-e" "GH_TOKEN=$GH_TOKEN") |
| 156 | +[ -n "$DOCKER_PASSWORD" ] && DOCKER_ARGS+=("-e" "DOCKER_PASSWORD=$DOCKER_PASSWORD") |
| 157 | +[ -n "$NPM_TOKEN" ] && DOCKER_ARGS+=("-e" "NPM_TOKEN=$NPM_TOKEN") |
| 158 | +``` |
| 159 | +**Pros**: Secure, doesn't require file system access |
| 160 | +**Cons**: Token-based only, doesn't work for OAuth flows |
| 161 | + |
| 162 | +**Recommendation**: Combine Option 3 (selective mounting) with Option 4 (env var pass-through) for comprehensive auth support. |
| 163 | + |
| 164 | +**Files Affected**: |
| 165 | +- `claude.sh:354-376` (current auth mounting logic) |
| 166 | +- `docker-entrypoint.sh:91-127` (symlink creation for claude user) |
| 167 | + |
| 168 | +--- |
| 169 | + |
| 170 | +### [enhancement-resolved] Multiple Claude instances workflow |
| 171 | + |
| 172 | +**Original Problem**: Users wanted multiple Claude instances in same project without container name conflicts. |
| 173 | + |
| 174 | +**Original Goal Misunderstanding**: We thought users wanted shared containers, but they actually just wanted **multiple simultaneous instances**. |
| 175 | + |
| 176 | +**Simple Solution Implemented**: |
| 177 | +- **Reverted to process-based naming**: `claude-code-yolo-${CURRENT_DIR_BASENAME}-$$` |
| 178 | +- **Keep `--rm` for auto-cleanup**: Each instance gets its own container |
| 179 | +- **No complexity needed**: Each process gets unique container name via `$$` |
| 180 | + |
| 181 | +**Result**: |
| 182 | +```bash |
| 183 | +# Terminal 1: |
| 184 | +claude-yolo . # → claude-code-yolo-myproject-12345 |
| 185 | + |
| 186 | +# Terminal 2: |
| 187 | +claude-yolo . # → claude-code-yolo-myproject-67890 |
| 188 | + |
| 189 | +# Both run simultaneously, both auto-cleanup |
| 190 | +``` |
| 191 | + |
| 192 | +**Why This Works Better**: |
| 193 | +- ✅ **Simple**: No shared state, no daemon logic, no container reuse |
| 194 | +- ✅ **Isolated**: Each Claude instance in its own container |
| 195 | +- ✅ **Clean**: Containers auto-remove with `--rm` |
| 196 | +- ✅ **Scalable**: Run as many instances as needed |
| 197 | + |
| 198 | +**Key Insight**: Sometimes the simplest solution (unique names per process) is better than complex shared container architecture. |
| 199 | + |
| 200 | +**Status**: ✅ **RESOLVED** - Ultra-simple solution implemented |
| 201 | + |
| 202 | +--- |
| 203 | + |
| 204 | +### [enhancement-completed] Container inspection shortcuts |
| 205 | + |
| 206 | +**Problem**: Container inspection workflow was cumbersome - required multiple steps to access running containers. |
| 207 | + |
| 208 | +**Original Workflow Pain Points**: |
| 209 | +1. **Manual discovery**: Must run `docker ps` → find container → copy name |
| 210 | +2. **Multi-step access**: `docker exec -it <name> /bin/zsh` → `su - claude` to get proper user context |
| 211 | + |
| 212 | +**Solution Implemented**: Added inspection shortcuts to `claude-yolo` wrapper |
| 213 | + |
| 214 | +**Features Added**: |
| 215 | +- `claude-yolo --inspect`: Auto-find and enter container as claude user |
| 216 | +- `claude-yolo --ps`: List all containers for current project |
| 217 | +- **Smart selection**: Auto-select single container, prompt for multiple |
| 218 | +- **Project-aware**: Only shows containers matching current directory pattern |
| 219 | + |
| 220 | +**Implementation Details**: |
| 221 | +```bash |
| 222 | +# Container discovery by pattern |
| 223 | +CONTAINER_PATTERN="claude-code-yolo-${CURRENT_DIR_BASENAME}-" |
| 224 | +find_project_containers() { |
| 225 | + docker ps --filter "name=$CONTAINER_PATTERN" --format "{{.Names}}" 2>/dev/null |
| 226 | +} |
| 227 | + |
| 228 | +# Smart container selection |
| 229 | +if [ $num_containers -eq 1 ]; then |
| 230 | + # Auto-select single container |
| 231 | + exec docker exec -it "$container" gosu claude /bin/zsh |
| 232 | +else |
| 233 | + # Prompt user to choose from multiple |
| 234 | + echo "Multiple containers found for this project:" |
| 235 | + # ... interactive selection |
| 236 | +fi |
| 237 | +``` |
| 238 | + |
| 239 | +**User Experience**: |
| 240 | + |
| 241 | +**Before** (painful): |
| 242 | +```bash |
| 243 | +docker ps # Find container |
| 244 | +docker exec -it claude-code-yolo-proj-12345 /bin/zsh # Enter container |
| 245 | +su - claude # Switch to proper user |
| 246 | +``` |
| 247 | + |
| 248 | +**After** (one command): |
| 249 | +```bash |
| 250 | +claude-yolo --inspect # Auto-find + auto-su to claude user |
| 251 | +``` |
| 252 | + |
| 253 | +**Multiple Container Support**: |
| 254 | +```bash |
| 255 | +claude-yolo --inspect |
| 256 | + |
| 257 | +Multiple containers found for this project: |
| 258 | + 1) claude-code-yolo-myproject-12345 (Up 5 minutes) |
| 259 | + 2) claude-code-yolo-myproject-67890 (Up 2 minutes) |
| 260 | + |
| 261 | +Select container to inspect (1-2): 1 |
| 262 | +Entering container claude-code-yolo-myproject-12345 as claude user... |
| 263 | +``` |
| 264 | + |
| 265 | +**Files Modified**: |
| 266 | +- `claude-yolo`: Enhanced from simple 22-line wrapper to 75-line tool with container management |
| 267 | +- Added help system with `claude-yolo --help` |
| 268 | + |
| 269 | +**Status**: ✅ **COMPLETED** - Issue #4 resolved |
| 270 | + |
| 271 | +--- |
| 272 | + |
| 273 | +## Current Implementation Summary |
| 274 | + |
| 275 | +### What We've Built |
| 276 | + |
| 277 | +**Issue #1**: ✅ Fixed `--trace` flag not passing `--dangerously-skip-permissions` |
| 278 | +- **Solution**: Added explicit `claude-trace` detection in `docker-entrypoint.sh:167,182` |
| 279 | +- **Result**: `claude-yolo --trace .` now works correctly in YOLO mode |
| 280 | + |
| 281 | +**Issue #4**: ✅ Added container inspection shortcuts |
| 282 | +- **Solution**: Enhanced `claude-yolo` with `--inspect` and `--ps` commands |
| 283 | +- **Result**: One-command container access with smart multi-container selection |
| 284 | + |
| 285 | +**Multiple Instances**: ✅ Simplified approach for concurrent Claude instances |
| 286 | +- **Solution**: Reverted to process-based naming `$$` for unique containers |
| 287 | +- **Result**: Multiple `claude-yolo .` commands work simultaneously, auto-cleanup |
| 288 | + |
| 289 | +### Current Architecture |
| 290 | + |
| 291 | +**claude.sh** (578 lines): |
| 292 | +- Main Docker wrapper with authentication, environment setup, and container creation |
| 293 | +- Process-based container naming: `claude-code-yolo-${CURRENT_DIR_BASENAME}-$$` |
| 294 | +- Always uses `--rm` for auto-cleanup |
| 295 | +- Supports 4 auth modes: Claude app, API key, AWS Bedrock, Google Vertex AI |
| 296 | + |
| 297 | +**docker-entrypoint.sh** (194 lines): |
| 298 | +- Container initialization with environment reporting |
| 299 | +- Non-root user setup with proper UID/GID alignment |
| 300 | +- Authentication symlink creation (`/root/.claude` → `/home/claude/.claude`) |
| 301 | +- Fixed pattern matching for Claude commands (including `claude-trace`) |
| 302 | + |
| 303 | +**claude-yolo** (75 lines): |
| 304 | +- Enhanced wrapper with container inspection shortcuts |
| 305 | +- Smart container discovery and selection |
| 306 | +- Simple fallback to `claude.sh --yolo` for normal operations |
| 307 | + |
| 308 | +### Key Design Principles Applied |
| 309 | + |
| 310 | +1. **Simplicity over complexity**: Chose unique container names over shared containers |
| 311 | +2. **User experience focus**: One-command access for common operations |
| 312 | +3. **Pattern matching**: Project-aware container management |
| 313 | +4. **Auto-cleanup**: Containers remove themselves when done |
| 314 | +5. **Smart defaults**: Auto-select single containers, prompt for multiple |
| 315 | + |
| 316 | +--- |
| 317 | + |
| 318 | +## Technical Details |
| 319 | + |
| 320 | +### File Locations |
| 321 | +- Main wrapper: `claude.sh:559` (YOLO trace command) |
| 322 | +- Entrypoint logic: `docker-entrypoint.sh:167-169, 181-183` (dangerous permissions logic) |
| 323 | +- Tool installation: `Dockerfile:92-117` (static tool setup) |
| 324 | + |
| 325 | +### Key Functions |
| 326 | +- `claude.sh` line 557-562: Trace command construction |
| 327 | +- `docker-entrypoint.sh` line 156-189: Command execution with permission handling |
| 328 | +- `docker-entrypoint.sh` line 11-64: Environment reporting |
| 329 | + |
| 330 | +--- |
| 331 | + |
| 332 | +## Next Steps |
| 333 | +1. Create GitHub issues for both problems |
| 334 | +2. Implement trace flag fix (simple pattern matching) |
| 335 | +3. Design runtime tool installation system |
| 336 | +4. Consider adding `.claude-tools` config support |
0 commit comments