> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ankra.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# ankra exec

> Run a heavy command for this worktree in its Ankra Workspace, streaming the output back

## ankra exec

Run a command (go test, golangci-lint run, pnpm typecheck, vitest run, a
Playwright suite) for this git worktree in your Ankra Workspace instead of on
this machine. Output streams back live and the exit code is the remote
command's own.

The worktree is sent as it is - tracked files plus untracked files that are
not ignored - as a snapshot commit built in a temporary index (the branch, the
index and the working tree are untouched). Only what the workspace lacks is
uploaded: which commits it holds is recorded under refs/ankra-exec/synced/.
The command runs in the same relative directory, with only an allowlisted
environment forwarded (GOFLAGS, NODE\_OPTIONS, TZ, ... and the names in
ANKRA\_EXEC\_FORWARD\_ENV).

The workspace is this checkout's (origin remote, a repository connected to
Ankra Pipelines) of the `--kind` given, brought up on first use.

```text theme={null}
--apply       the command rewrites files (gofmt -w, go generate): its changes
              come back as a patch applied to this worktree. A patch that no
              longer applies is kept under .git/ankra-exec-unapplied-<run>.patch.
--fetch DIR   copy DIR back from the workspace after the run, replacing the
              local one, whatever the exit code (test-results, reports).
--check       exit 0 when this worktree can use a workspace (cheap, cached).
```

Exit codes: the remote command's own when it ran; 196 when it did not run
remotely (and \$ANKRA\_EXEC\_NOTRUN\_FILE is created when set, which is what the
routing shims fall back on); 130 after Ctrl-C, which stops the remote command;
2 for a usage error. Each run appends a line to \~/.claude/logs/ankra-exec.log
(ANKRA\_EXEC\_LOG).

```bash theme={null}
ankra exec [flags] [--] <command> [args...]
```

**Examples**

```bash theme={null}
ankra exec -- go test ./internal/...
  ankra exec pnpm typecheck
  ankra exec --apply -- gofmt -w ./cmd
  ankra exec --kind playwright --fetch test-results -- pnpm test:e2e
  ankra exec --check && echo routable
```

**Flags**

| Flag | Default | Description |
| - | - | - |
| `--apply` | `false` | Apply the changes the command makes in the workspace to this worktree |
| `--check` | `false` | Exit 0 when this worktree can use a workspace, 1 otherwise |
| `--fetch` | `[]` | Copy this directory back from the workspace after the run (repeatable) |
| `--kind` | | Workspace kind (default: the repository's default workspace) |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.