agentleFS
decocmsdecocms/studio/.claude/skills/run-local-freestyle/SKILL.md

run-local-freestyle

Skill415 starsChanged 3 months agoMITView on GitHub

Run Studio locally with chats and task runs executing in real Freestyle sandboxes, reachable through an ngrok tunnel. Use when asked to "run locally with Freestyle", "test claude-code chats locally", "run the sandbox harness end to end", or to try daemon/harness-runner changes in a real sandbox.

  • Reads credentials

We split this skill into the rules it gives an agent

8 rules. About 0 are common, 2 are distinctive, and 6 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 6

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use ngrok. Do not use a cloudflared quick tunnel: it buffers server-sent events until the stream closes, so chat output never streams and …

    line 23
  2. Very specific:

    Always set KUBECONFIG=/dev/null.

    line 37
  3. Very specific:

    Always override STUDIO_PUBLIC_URL and MESH_PUBLIC_URL.

    line 38
  4. Very specific:

    If you change the tunnel URL, restart Studio with the new one.

    line 40
  5. Very specific:

    Do not build packages/sandbox/image/Dockerfile for amd64 on Apple Silicon.

    line 62
  6. Very specific:

    Keep --chmod=755 on the runner copy.

    line 63
  7. Distinctive:

    Use a new tag for every rebuild.

    line 64
  8. Very specific:

    Stop bun run dev and ngrok.

    line 93

≈ “Common” is an estimate: at least 1 in 5 of the 308,232 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Run Studio locally on Freestyle

Freestyle VMs call back into Studio (the studio MCP, org-fs), so a local Studio needs a public URL. The browser must use that same URL: auth trusts only BASE_URL.

Prerequisites

  • FREESTYLE_API_KEY in the repo-root .env.
  • ngrok with an auth token (ngrok config add-authtoken <token>).
  • Docker with buildx and Go, only if you changed packages/sandbox/daemon-go or packages/harness-runner.

1. Tunnel

ngrok http 4000
URL=$(curl -s localhost:4040/api/tunnels | grep -o '"public_url":"https[^"]*' | cut -d'"' -f4)
  • Use ngrok. Do not use a cloudflared quick tunnel: it buffers server-sent events until the stream closes, so chat output never streams and queued messages look stuck.
  • Point the tunnel at Vite (4000), not the API (3000). Vite proxies /api.

2. Start Studio

KUBECONFIG=/dev/null \
STUDIO_AGENT_SANDBOX_ENABLED=true \
STUDIO_SANDBOX_FREESTYLE_SHARE=1 \
STUDIO_PUBLIC_URL=$URL MESH_PUBLIC_URL=$URL \
__VITE_ADDITIONAL_SERVER_ALLOWED_HOSTS=.ngrok-free.app \
bun run dev --base-url $URL --no-tui
  • Always set KUBECONFIG=/dev/null. Without it the Kubernetes provider is built from your default context, and a Freestyle fallback could provision there.
  • Always override STUDIO_PUBLIC_URL and MESH_PUBLIC_URL. A stale value in .env wins over BASE_URL for minted MCP URLs, and runs fail with studio MCP is unusable.
  • Open $URL in the browser and log in there, not on localhost. Click through ngrok's one-time warning page.
  • If you change the tunnel URL, restart Studio with the new one.

3. Sandbox image (only for daemon or runner changes)

Freestyle runs ghcr.io/decocms/studio/studio-sandbox-go:<packages/sandbox version> by default. To run local daemon or runner code, overlay it on that image:

O=$(mktemp -d); mkdir $O/runner
(cd packages/sandbox/daemon-go && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -trimpath -ldflags="-s -w" -o $O/daemon-go .)
cp packages/harness-runner/package.json $O/runner/
for f in packages/harness-runner/*.ts; do [[ $f == *.test.ts ]] || cp "$f" $O/runner/; done
cat > $O/Dockerfile <<'EOF'
FROM ghcr.io/decocms/studio/studio-sandbox-go:<version>
COPY --chown=sandbox:sandbox daemon-go /opt/sandbox-daemon/daemon-go
COPY --chown=sandbox:sandbox --chmod=755 runner/ /usr/local/lib/node_modules/@decocms/harness-runner/
EOF
TAG=ttl.sh/studio-sandbox-$(uuidgen | tr A-Z a-z | cut -c1-12):24h
docker buildx build --platform linux/amd64 -t $TAG --load $O && docker push $TAG

Then add STUDIO_SANDBOX_FREESTYLE_IMAGE=$TAG to the start command.

  • Do not build packages/sandbox/image/Dockerfile for amd64 on Apple Silicon. Chromium and the Claude Code CLI crash under QEMU.
  • Keep --chmod=755 on the runner copy. main.ts is the bin target, and without the execute bit runs fail with executable file not found in $PATH.
  • Use a new tag for every rebuild. The base snapshot is keyed by the image name, so a reused tag keeps serving the old snapshot.
  • Copy every file listed in packages/harness-runner/package.json files, and rebuild the base image instead if the runner's dependencies changed.

4. Pre-build the base snapshot

The first sandbox for an image builds a base snapshot (about 2 minutes). Build it before you chat:

cd packages/sandbox && bun --env-file=../../.env -e '
const { FreestyleSandboxProvider } = await import("./server/provider/freestyle.ts");
const p = new FreestyleSandboxProvider({ apiKey: process.env.FREESTYLE_API_KEY, image: process.env.IMAGE });
await p.warm(); p.close(); process.exit(0)'

Set IMAGE to the image Studio runs (your $TAG, or the default above).

5. Run chats on claude-code

Turn on Settings → General → Code Agents → "Run every chat with Claude Code in its own sandbox" (chat_harness_sandbox_only). A chat that already has a sandbox keeps its image; start a new chat after changing images.

Debugging

  • Studio log: [sandbox-dispatch] run ended reports chunks, duration and the harness error.
  • Local database: postgresql://postgres:postgres@localhost:<port>/postgres, with the port from the System Database URL line in the dev log. Read stored parts from thread_message_parts.
  • Claude Code's MCP log for a run: it lives inside the sandbox container at $HOME/.cache/claude-cli-nodejs/*/mcp-logs-studio/*.jsonl. Reach it with the Freestyle SDK: look the VM up by slug (the sandbox handle), then exec docker exec sandbox ….
  • Claude Code aborts an MCP call 90 seconds after any transport error on that server ("transport dropped mid-call", about 2 minutes total). Find the first error in its MCP log.

Clean up

Stop bun run dev and ngrok. Freestyle VMs pause after 5 minutes idle and are deleted after a day; ttl.sh images expire with their tag.

Download now (ZIP)

  • Other versions2 projects use a version of this.

    Word for word · 0

    None found.

    Edited · 2

    1. decocms/admin★ 40998% same
    2. decocms/mesh★ 40998% same

    Wrote their own version · 0

    None found.

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • In this repository4 other files it gives its agents.

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

Reviews can't be read right now.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.