Skip to content

feat(cli): forkd ls + forkd kill — direct sandbox lifecycle#138

Merged
WaylandYang merged 2 commits into
mainfrom
feat/cli-ls-kill
May 21, 2026
Merged

feat(cli): forkd ls + forkd kill — direct sandbox lifecycle#138
WaylandYang merged 2 commits into
mainfrom
feat/cli-ls-kill

Conversation

@WaylandYang
Copy link
Copy Markdown
Contributor

Summary

Two small subcommands that wrap GET /v1/sandboxes and DELETE /v1/sandboxes/:id so users don't have to hand-write curl. Same ergonomics as `docker ps` / `docker rm`.

E2E test on dev box

```
$ forkd ls
no live sandboxes

spawn 2 sandboxes via curl, then ls/kill

$ forkd ls
ID SNAPSHOT PID NETNS GUEST_ADDR
sb-6a0e9ea4-002d coding-agent-fork-prewarm-v1 76604 forkd-child-1 10.42.0.2:8888
sb-6a0e9ea4-002e coding-agent-fork-prewarm-v1 76614 forkd-child-2 10.42.0.2:8888

2 sandboxes

$ forkd kill --all
✓ sb-6a0e9ea4-002d
✓ sb-6a0e9ea4-002e

$ forkd ls
no live sandboxes
```

Surfaces

  • `forkd ls` — formatted table (id / snapshot / pid / netns / guest_addr)
  • `forkd kill ...` — kill one or more
  • `forkd kill --all` — kill every live sandbox
  • `forkd kill --tag ` — kill every sandbox forked from a given snapshot
  • `--all` and `--tag` are mutually exclusive (clap enforces)

Files

  • `crates/forkd-cli/src/sandbox.rs` (new, ~170 LOC) — `ls` + `kill` + tiny ureq client
  • `crates/forkd-cli/src/main.rs` — `mod sandbox;` + `Cmd::Ls` / `Cmd::Kill` variants + dispatch (~40 lines)

Reads `FORKD_URL` / `FORKD_TOKEN` from env like the rest of the daemon-talking commands.

🤖 Generated with Claude Code

…start

The 3 CLI commands shipped 2026-05-21 (#134, #135, #136) collapse the
new-user setup from 4 hand-pasted commands to a single \`forkd doctor\`
+ \`forkd from-image\` flow. Surface this prominently in Quick start so
visitors landing from a Twitter / blog link see the modern story.

- README.md: new \"Confirm your host is ready\" subsection leads with
  \`forkd doctor\`. New \"From a Docker image (one command)\" subsection
  shows \`forkd from-image python:3.12-slim --tag py-numpy\`. New
  \"Probe your install's latency\" subsection shows \`forkd bench\` with
  example output.
- README-zh.md: parallel sections in Chinese.

The original Hub-pull, from-source, and multi-child-fork-out sections
are unchanged — those audiences still need them. New subsections come
first since they're the most-likely user path.

No code changes.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Two small subcommands that wrap GET /v1/sandboxes and DELETE
/v1/sandboxes/:id so users don't have to hand-write curl. Same
ergonomics as \`docker ps\` / \`docker rm\`.

  forkd ls
    ID                    SNAPSHOT                       PID       NETNS           GUEST_ADDR
    sb-6a0e8d4f-0023      coding-agent-fork-prewarm-v1   123456    forkd-child-1   10.42.0.2:8888
    sb-6a0e8d50-0024      speculative-1234               123457    forkd-child-2   10.42.0.2:8888
    ...
    2 sandboxes

  forkd kill sb-6a0e8d4f-0023
    ✓ sb-6a0e8d4f-0023

  forkd kill --all
  forkd kill --tag speculative-1234

Implementation in crates/forkd-cli/src/sandbox.rs (~170 LOC), wired
in main.rs as Cmd::Ls / Cmd::Kill. Reads FORKD_URL / FORKD_TOKEN
from env like the other daemon-talking commands.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@WaylandYang WaylandYang merged commit 81fc4d5 into main May 21, 2026
2 checks passed
@WaylandYang WaylandYang deleted the feat/cli-ls-kill branch May 21, 2026 07:07
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