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

# Quickstart

> From install to an agent working in a workspace, in five minutes.

<Steps>
  <Step title="Install">
    ```bash theme={null}
    npm install nativeharness
    ```

    Node 22+, and a container engine for the sandbox — `podman` or `docker`. Check with
    `npx nativesandbox doctor`, or see [requirements](/getting-started/requirements).
  </Step>

  <Step title="Run a command in a sandbox">
    ```ts theme={null}
    import { Harness } from "nativeharness";

    const harness = new Harness({ root: "./data" });
    const workspace = await harness.workspace({ name: "demo", actor: "user-42" });

    await workspace.write("/main.js", "console.log(41 + 1)");
    const { result } = await workspace.exec("node main.js && echo built > out.txt");

    result.stdout;                         // "42\n"
    result.files.changed;                  // ["/out.txt"]
    await workspace.readText("/out.txt");  // "built\n"
    ```

    The file you wrote was hydrated into a fresh sandbox, the command ran there, and the file the
    command created was **synced back**. The sandbox is disposable; the workspace is what survives.

    No model is needed for any of this.
  </Step>

  <Step title="Add a model">
    ```ts theme={null}
    import { AnthropicAdapter } from "@nativeharness/adapter-anthropic";

    const harness = new Harness({ root: "./data", model: new AnthropicAdapter() });
    ```

    Reads `ANTHROPIC_API_KEY`. Four other adapters ship — OpenAI and compatible services, Gemini,
    Cohere, and local models through Ollama. See [models](/guides/models).
  </Step>

  <Step title="Let it work">
    ```ts theme={null}
    for await (const event of workspace.chat("read main.js and make it print the date too")) {
      if (event.type === "token")  process.stdout.write(event.payload.text);
      if (event.type === "output") process.stdout.write(event.payload.chunk);
      if (event.type === "done")   console.log("\n", event.payload.status);
    }
    ```

    Tokens stream as the model writes them, commands print as they run, and the files it changed
    are in the workspace when the turn is done. Every event is persisted before it is emitted, so
    a client that reconnects can replay exactly what it missed.
  </Step>

  <Step title="Do it for a second user">
    ```ts theme={null}
    const other = await harness.workspace({ name: "demo", actor: "user-99" });
    ```

    A different workspace, a different sandbox, different files. Neither agent can reach the
    other's work — see [your users](/guides/your-users).
  </Step>
</Steps>

## From the terminal

The same thing without writing any code:

```bash theme={null}
npm install -g @nativeharness/cli

nhar create demo                     # a workspace, with you granted access
nhar exec <id> "npm test"            # a command in its sandbox, streamed
nhar chat <id> -m "fix the failing test"
```

See [the CLI](/cli/nhar).

## Next

<CardGroup cols={2}>
  <Card title="How it works" icon="diagram-project" href="/concepts/how-it-works">
    What happens between `chat()` and the file appearing in your workspace.
  </Card>

  <Card title="Your UI" icon="window" href="/guides/your-ui">
    Rendering the event stream in a browser.
  </Card>
</CardGroup>
