# Command Execution **Last Updated:** 2025-01 **Confidence:** High ## Summary rdev executes commands (Claude, shell, git) in Kubernetes pods via kubectl exec. Commands can run synchronously or be queued for async processing with SSE output streaming. **Key Facts:** - Commands run in pods with label `rdev.orchard9.ai/project=true` - Three types: `claude`, `shell`, `git` - Async queue with status tracking (pending → running → completed/failed) - Output streamed via SSE to `/projects/{id}/events/{stream_id}` - All commands logged to audit trail **File Pointers:** - Executor: `internal/adapter/kubernetes/executor.go` - Queue: `internal/adapter/postgres/queue.go` - Worker: `internal/worker/queue.go` - Handler: `internal/handlers/projects.go` ## Command Flow ``` Handler → Service → Queue (postgres) ↓ Worker polls ↓ Executor (kubectl exec) ↓ StreamPublisher (SSE) ↓ Webhook dispatch ``` ## Request/Response ``` POST /projects/{id}/claude Body: { "prompt": "write a hello world" } Response: { "command_id": "cmd-abc123", "stream_url": "/projects/my-project/events/stream-xyz" } ``` ## Status Transitions | Status | Description | |--------|-------------| | `pending` | In queue, not started | | `running` | Currently executing | | `completed` | Finished successfully (exit 0) | | `failed` | Error or non-zero exit | ## Related Topics - [SSE Streaming](./sse-streaming.md) - [Project Service](../services/project-service.md)