Xec
Xec turns operational commands into reusable TypeScript workflows. Run a local check, inspect several SSH hosts, execute inside a container, or give a project its own CLI. The same execution API carries output, exit status and errors across those targets; the target's shell, permissions and installed tools still matter.
Choose an entry point
| Your task | Use | Why |
|---|---|---|
| Run a command on a host, container or pod | Built-in CLI commands | Select a target without writing a program. |
| Combine commands with parsing, conditions or cleanup | TypeScript scripts | Use normal control flow and typed execution results. |
| Execute commands inside an existing application | @xec-sh/core | Import the library without adopting the CLI. |
| Give a repository named repeatable actions | YAML tasks | Keep commands and their parameters in project configuration. |
| Offer options, help and a deliberate operator interface | Dynamic project commands | Register commands in .xec/commands/. |
| Coordinate a dependency graph, matrix or release | Ops | Compose the execution engine through the owning orchestration API. |
| Build a terminal application | Kit | Reuse prompts, progress, formatting and keyboard interaction. |
These are composable layers. A project command can call an Ops pipeline, whose steps use Core. A task can invoke an existing package build tool. You do not need a separate implementation for the terminal, CI and an AI agent.
Start with an observable operation
In a project with @xec-sh/core installed, this ESM script reports the current
Git revision and uncommitted changes:
import { $ } from '@xec-sh/core';
const revision = await $`git rev-parse --short HEAD`.text();
const changes = await $`git status --short`.text();
console.log({ revision, changes });Run a TypeScript file through xec run inspect.ts, or import Core in an existing
TypeScript application. The quick start supplies the complete
installation, file and command sequence.
Select where a command runs
import { $ } from '@xec-sh/core';
const localVersion = await $`node --version`.text();
console.log(localVersion);
// Requires an existing SSH host with a configured credential and trusted key.
const host = $.ssh({ host: 'build.example.com', username: 'deploy' });
try {
console.log(await host`node --version`.text());
} finally {
await $.dispose();
}Docker execution runs inside a container; Kubernetes execution runs inside a
pod. Commands such as kubectl rollout normally run on the operator's machine
with its cluster credentials, not inside an application pod. See
targets for those boundaries.
What Xec owns
Xec owns command construction, target adapters and the workflow mechanisms you choose to use. It does not infer an application's deployment policy from shell commands. A successful command does not by itself prove a service is ready, a backup is restorable or a rollout can be reversed.
Keep responsibility with the right component:
Turbo or another build tool can own the package dependency graph and build cache.
Omnitron or a service manager can own long-running application lifecycle.
A provisioning system can own desired infrastructure state.
Xec can orchestrate these tools and make their outcomes visible through one project interface.
For a critical change, define its target, expected prior state, acceptance check and recovery behavior in the workflow. Reconcile an uncertain remote outcome before repeating the effect. TypeScript types and escaped arguments help; they do not replace authorization or state verification.
Read the documentation by goal
Installation and quick start: run a first project.
Core concepts: understand execution, targets and outcomes.
When to use Xec: select the appropriate layer and boundaries.
Design a project workflow: grow from a script to a project interface.
Package ecosystem: choose the APIs your application needs.