feat: add docker-sandbox skill and fix strategic-compact session-start-hook - #216
Conversation
Co-Authored-By: Claude <noreply@anthropic.com>
- Based on Ubuntu 24.04 - Installs Node.js 20.x from NodeSource - Installs Claude Code CLI globally via npm - Creates non-root 'claude' user for security - Includes essential tools: git, jq, bash, tmux Co-Authored-By: Claude <noreply@anthropic.com>
Add main test runner script that orchestrates Docker container creation, test execution, and result verification. Features: - Loads test definitions from YAML files - Manages Docker container lifecycle with cleanup traps - Retrieves OAuth tokens from environment or macOS Keychain - Executes Claude Code prompts in isolated containers - Verifies output against expected results - Reports test results with duration Co-Authored-By: Claude <noreply@anthropic.com>
Add comprehensive SKILL.md documentation for docker-sandbox testing. Includes critical requirements, helper library patterns, anti-patterns, CI/CD considerations, and comparison with tmux-testing. Co-Authored-By: Claude <noreply@anthropic.com>
Add Docker lifecycle management functions for Claude Code testing. Provides container creation, execution, and cleanup utilities. Co-Authored-By: Claude <noreply@anthropic.com>
Add test execution and verification functions library for the docker-sandbox skill testing framework. Co-Authored-By: Claude <noreply@anthropic.com>
- Replace standard BATS assertions with project-compatible patterns: - assert_success → [ "$status" -eq 0 ] - assert_failure → [ "$status" -ne 0 ] - assert_file_exists → [ -f "$file" ] - assert_file_executable → [ -x "$file" ] - assert_output --partial → [[ "$output" == *"text"* ]] - Fix trap quoting to defer variable expansion: - trap "cleanup_container '$CONTAINER_NAME'" EXIT - + trap 'cleanup_container "$CONTAINER_NAME"' EXIT Co-Authored-By: Claude <noreply@anthropic.com>
- Remove unused TEST_EXPECTED_NOT_CONTAINS variable - Fix SC2155 warnings by declaring local variables separately from assignment - Add shellcheck disable directive for TEST_PROMPT (used by run-docker-test.sh) Co-Authored-By: Claude <noreply@anthropic.com>
Mock docker function instead of PATH manipulation, which didn't reliably make docker unavailable on macOS.
- Remove ENTRYPOINT from Dockerfile that breaks binary execution as non-root - Fix YAML parsing in test-helpers.sh (grep -A1 to -A2) The ENTRYPOINT directive was causing all binary commands to fail with "cannot execute binary file" error when running as non-root user. Container creation script already provides the command (sleep infinity). The YAML parsing was only capturing one line after test_target:, but YAML has two lines (type and name), so grep needed -A2 instead of -A1. Co-Authored-By: Claude <noreply@anthropic.com>
The 'command' is a bash builtin, not accessible via docker exec directly. Must use 'bash -c "command -v claude"' to check if claude exists.
|
Caution Review failedThe pull request is closed. 📝 WalkthroughWalkthroughThis PR introduces a complete Docker-based testing infrastructure for Claude Code components. It adds configuration updates, comprehensive documentation, a Dockerfile for an Ubuntu 24.04 test environment with Node.js and Claude Code CLI, helper libraries for Docker operations and test execution, a test orchestration script, example test definitions in YAML format, and a BATS test suite validating the infrastructure itself. Changes
Sequence Diagram(s)sequenceDiagram
participant User as Test Runner
participant TestOrch as run-docker-test.sh
participant DockerHelper as docker-helpers.sh
participant Docker as Docker Daemon
participant Container as Test Container
participant TestHelper as test-helpers.sh
User->>TestOrch: Execute with test definition file
TestOrch->>TestHelper: load_test_definition()
TestHelper-->>TestOrch: Parsed test config
TestOrch->>DockerHelper: build_claude_image()
DockerHelper->>Docker: Build image
Docker-->>DockerHelper: Image ready
TestOrch->>DockerHelper: create_container()
DockerHelper->>Docker: Create/start container
Docker->>Container: Start with sleep entrypoint
DockerHelper->>TestOrch: Container name
TestOrch->>DockerHelper: wait_for_claude_ready()
DockerHelper->>Container: Poll for claude CLI
Container-->>DockerHelper: Claude ready
TestOrch->>DockerHelper: exec_in_container_capture()
DockerHelper->>Container: Execute test prompt
Container->>Container: Run test
Container-->>DockerHelper: Captured output
DockerHelper-->>TestOrch: Output
TestOrch->>TestHelper: verify_contains()
TestHelper-->>TestOrch: Verification result
TestOrch->>DockerHelper: cleanup_container()
DockerHelper->>Docker: Stop/remove container
Docker-->>DockerHelper: Container cleaned
TestOrch-->>User: Test result (pass/fail)
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes Possibly related PRs
Poem
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
docker-sandbox Skill
New skill for reproducible Docker-based testing with:
docker-helpers.sh,test-helpers.sh)Strategic Compact SessionStart Hook Fix
Fixed
session-start-hook.shto properly:~/.claude/strategic-compact/session-{session_id}.envTest Plan
bats tests/docker-sandbox.bats)🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Documentation
Tests
✏️ Tip: You can customize this high-level summary in your review settings.