Skip to content

feat: add justfile with sandbox management targets - #79

Closed
vinodmut wants to merge 1 commit into
AgentToolkit:mainfrom
vinodmut:sandbox
Closed

feat: add justfile with sandbox management targets#79
vinodmut wants to merge 1 commit into
AgentToolkit:mainfrom
vinodmut:sandbox

Conversation

@vinodmut

@vinodmut vinodmut commented Feb 25, 2026

Copy link
Copy Markdown
Contributor

Adds a justfile at the repo root with five targets to simplify common Docker sandbox operations: sandbox-build, sandbox-setup, sandbox-run, sandbox-test, and sandbox-clean.

Summary by CodeRabbit

  • New Features

    • Added sandbox workflow: build, setup, interactive run, one-shot prompt, smoke test, and cleanup commands for local sandbox use.
  • Documentation

    • New example demonstrating learning-from-failure in sandboxed environments and guidance to prefer standard-library parsing when external tools are unavailable.
    • Expanded walkthrough showing multi-session preference learning and entity injection.
  • Chores

    • Sample sandbox environment variables added for debug and sandbox mode.

@coderabbitai

coderabbitai Bot commented Feb 25, 2026

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f5975c8 and bed75b2.

⛔ Files ignored due to path filters (1)
  • demo/workspace/sample.jpg is excluded by !**/*.jpg
📒 Files selected for processing (3)
  • KAIZEN_LITE.md
  • justfile
  • sandbox/sample.env

📝 Walkthrough

Walkthrough

Adds a Justfile implementing a Docker-based sandbox workflow, updates KAIZEN_LITE.md with a new sandbox-focused example and learning guidance, and modifies sandbox/sample.env to enable debugging and sandbox mode.

Changes

Cohort / File(s) Summary
Sandbox Make-like Tasks
justfile
Adds a Justfile with variables and targets: sandbox-build, sandbox-setup, sandbox-run, sandbox-prompt, sandbox-test, sandbox-clean, and a default --list target.
Documentation / Examples
KAIZEN_LITE.md
Adds Example 2 (sandbox learning), renames/restructures Example 1, expands multi-session walkthroughs, updates Entities guidance to prefer Python stdlib parsing in sandboxed environments, and updates stored-entity examples.
Sandbox env defaults
sandbox/sample.env
Enables KAIZEN_DEBUG=1 and IS_SANDBOX=1 in the sample environment file.

Sequence Diagram(s)

sequenceDiagram
    participant Dev as Developer
    participant Host as Host (Docker)
    participant Sandbox as Sandbox Container
    participant Workspace as Workspace (mounted)

    Dev->>Host: just sandbox-build (build image)
    Host-->>Dev: Docker image created
    Dev->>Host: just sandbox-setup (copy sample.env -> myenv)
    Host-->>Dev: env file prepared
    Dev->>Host: just sandbox-run (docker run --env-file, mount workspace)
    Host->>Sandbox: start container with env and mounts
    Sandbox->>Workspace: access code and mounts
    Dev->>Host: just sandbox-test / sandbox-prompt (execute claude inside container)
    Host->>Sandbox: run one-shot command or interactive shell
    Sandbox-->>Dev: command output / test results
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • visahak
  • jayaramkr

Poem

🐰 I hopped into a sandbox, built with care,
Commands and containers dancing in the air.
I copied envs, I ran a test or two,
Claudes and code and logs in view—hooroo! 🥕

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and accurately describes the main change: adding a justfile with sandbox management targets, which matches the PR's core objective.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (2)
justfile (2)

14-20: Use {{sandbox_dir}} consistently instead of hardcoding sandbox/sample.env.

Line 16 hardcodes sandbox/sample.env while the declared variable {{sandbox_dir}} exists for exactly this purpose. If sandbox_dir is ever changed, the source path in cp will silently drift.

♻️ Proposed fix
-        cp sandbox/sample.env {{env_file}}; \
+        cp {{sandbox_dir}}/sample.env {{env_file}}; \
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@justfile` around lines 14 - 20, The sandbox-setup recipe hardcodes the source
file path "sandbox/sample.env"; update it to use the sandbox_dir variable
instead so the cp uses {{sandbox_dir}}/sample.env; change the cp invocation in
the sandbox-setup target (which references env_file) to build the source path
from {{sandbox_dir}} and keep the existing env_file usage for the destination so
the copy respects future sandbox_dir changes.

1-8: Move variable declarations above the default target.

Having variables defined after the recipe they conceptually configure is unconventional and harder to scan. just resolves all declarations regardless of position, so this is purely a readability nit.

♻️ Suggested layout
+image       := "claude-sandbox"
+env_file    := "sandbox/myenv"
+sandbox_dir := "sandbox"
+
 # Default: list available targets
 default:
     `@just` --list
-
-image := "claude-sandbox"
-env_file := "sandbox/myenv"
-sandbox_dir := "sandbox"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@justfile` around lines 1 - 8, Move the variable declarations (image,
env_file, sandbox_dir) above the default recipe so configuration appears before
the recipe it affects; update the file so the variables are declared at top of
the justfile and then the default: recipe (the default target) follows, keeping
the same variable names (image, env_file, sandbox_dir) and values unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@justfile`:
- Around line 31-32: The sandbox-clean target currently runs "docker rmi
{{image}}" which fails if stopped containers still reference the image; update
the sandbox-clean target to force-remove the image by adding the force flag
(e.g., change docker rmi {{image}} to use -f/--force) so the command will remove
images even when referenced by stopped containers.
- Around line 23-24: Update the sandbox-run recipe so the docker run command
sets the container working directory to the mounted path: add the flag --workdir
/workspace to the docker run invocation used by sandbox-run so the interactive
shell starts inside the mounted "$(pwd)" directory instead of the image's
default WORKDIR.
- Around line 27-28: The sandbox-test justfile target can block indefinitely if
the Claude API call hangs; wrap the Docker run invocation in a timeout (e.g.,
GNU coreutils timeout) so the target exits after a bounded period (choose a
sensible value like 30–60s) and return a non-zero status on timeout; update the
sandbox-test target that currently runs `docker run --rm --env-file {{env_file}}
{{image}} claude -p "who are you"` to invoke it via timeout so CI won't hang.

---

Nitpick comments:
In `@justfile`:
- Around line 14-20: The sandbox-setup recipe hardcodes the source file path
"sandbox/sample.env"; update it to use the sandbox_dir variable instead so the
cp uses {{sandbox_dir}}/sample.env; change the cp invocation in the
sandbox-setup target (which references env_file) to build the source path from
{{sandbox_dir}} and keep the existing env_file usage for the destination so the
copy respects future sandbox_dir changes.
- Around line 1-8: Move the variable declarations (image, env_file, sandbox_dir)
above the default recipe so configuration appears before the recipe it affects;
update the file so the variables are declared at top of the justfile and then
the default: recipe (the default target) follows, keeping the same variable
names (image, env_file, sandbox_dir) and values unchanged.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between aa34fc4 and f5975c8.

📒 Files selected for processing (1)
  • justfile

Comment thread justfile Outdated
Comment on lines +23 to +24
sandbox-run:
docker run --rm -it --env-file {{env_file}} -v "$(pwd)":/workspace {{image}}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Add --workdir /workspace so the interactive shell lands in the mounted directory.

Without it the container starts at the Dockerfile's WORKDIR, forcing the user to cd /workspace manually every session.

🐛 Proposed fix
-    docker run --rm -it --env-file {{env_file}} -v "$(pwd)":/workspace {{image}}
+    docker run --rm -it --env-file {{env_file}} -v "$(pwd)":/workspace --workdir /workspace {{image}}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
sandbox-run:
docker run --rm -it --env-file {{env_file}} -v "$(pwd)":/workspace {{image}}
sandbox-run:
docker run --rm -it --env-file {{env_file}} -v "$(pwd)":/workspace --workdir /workspace {{image}}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@justfile` around lines 23 - 24, Update the sandbox-run recipe so the docker
run command sets the container working directory to the mounted path: add the
flag --workdir /workspace to the docker run invocation used by sandbox-run so
the interactive shell starts inside the mounted "$(pwd)" directory instead of
the image's default WORKDIR.

Comment thread justfile
Comment on lines +27 to +28
sandbox-test:
docker run --rm --env-file {{env_file}} {{image}} claude -p "who are you"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Add a timeout to the smoke-test to prevent indefinite blocking.

If the Claude API call hangs (network issue, bad key, etc.) this target blocks forever, which is especially problematic in CI. Using timeout (GNU coreutils) keeps the test bounded.

🐛 Proposed fix
-    docker run --rm --env-file {{env_file}} {{image}} claude -p "who are you"
+    docker run --rm --env-file {{env_file}} {{image}} timeout 30 claude -p "who are you"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
sandbox-test:
docker run --rm --env-file {{env_file}} {{image}} claude -p "who are you"
sandbox-test:
docker run --rm --env-file {{env_file}} {{image}} timeout 30 claude -p "who are you"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@justfile` around lines 27 - 28, The sandbox-test justfile target can block
indefinitely if the Claude API call hangs; wrap the Docker run invocation in a
timeout (e.g., GNU coreutils timeout) so the target exits after a bounded period
(choose a sensible value like 30–60s) and return a non-zero status on timeout;
update the sandbox-test target that currently runs `docker run --rm --env-file
{{env_file}} {{image}} claude -p "who are you"` to invoke it via timeout so CI
won't hang.

Comment thread justfile
Comment on lines +31 to +32
sandbox-clean:
docker rmi {{image}}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

docker rmi fails when stopped containers still reference the image.

After a sandbox-run session the stopped container keeps a reference to the image; a subsequent sandbox-clean errors out with "image is being used by stopped container". Adding -f (or --force) handles this gracefully for a local dev workflow.

🐛 Proposed fix
-    docker rmi {{image}}
+    docker rmi -f {{image}}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@justfile` around lines 31 - 32, The sandbox-clean target currently runs
"docker rmi {{image}}" which fails if stopped containers still reference the
image; update the sandbox-clean target to force-remove the image by adding the
force flag (e.g., change docker rmi {{image}} to use -f/--force) so the command
will remove images even when referenced by stopped containers.

Add justfile targets for running prompts in the Docker sandbox with
optional trace and learn flags. Document a second Kaizen Lite example
showing how the agent learns to avoid dead ends (exiftool, Pillow) and
go straight to Python stdlib for EXIF parsing in sandboxed environments.
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.

1 participant