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

# Hello World

> Create a sandbox, run a command, and print the output — the simplest possible Declaw example.

## What You'll Learn

* Creating a sandbox with `Sandbox.create()`
* Running a shell command with `sbx.commands.run()`
* Reading command output via `result.stdout` and `result.exit_code`
* Using the async API with `AsyncSandbox` (Python)
* Proper cleanup with `try/finally` and `sbx.kill()`

## Prerequisites

<Snippet file="snippets/env-setup.mdx" />

## Code Walkthrough

<Tabs>
  <Tab title="Python">
    Import both the synchronous and asynchronous sandbox classes:

    ```python theme={null}
    from declaw import AsyncSandbox, Sandbox
    ```

    **Synchronous usage** — create a sandbox, run a command, clean up:

    ```python theme={null}
    def sync_example() -> None:
        sbx = Sandbox.create(template="base", timeout=300)
        try:
            print(f"Sandbox created: {sbx.sandbox_id}")

            result = sbx.commands.run('echo "Hello from Declaw sandbox!"')
            print(f"stdout: {result.stdout}")
            print(f"exit_code: {result.exit_code}")
        finally:
            sbx.kill()
            print("Sandbox killed.")
    ```

    **Async usage** — identical flow using `await`:

    ```python theme={null}
    async def async_example() -> None:
        sbx = await AsyncSandbox.create(template="base", timeout=300)
        try:
            print(f"Sandbox created: {sbx.sandbox_id}")

            result = await sbx.run_command('echo "Hello from async Declaw sandbox!"')
            print(f"stdout: {result.stdout}")
            print(f"exit_code: {result.exit_code}")
        finally:
            await sbx.kill()
            print("Sandbox killed.")
    ```

    Run both from `main()`:

    ```python theme={null}
    import asyncio

    def main() -> None:
        sync_example()
        asyncio.run(async_example())
    ```
  </Tab>

  <Tab title="TypeScript">
    Import the `Sandbox` class:

    ```typescript theme={null}
    import { Sandbox } from "@declaw/sdk";
    ```

    Create a sandbox, run a command, and clean up in a `try/finally` block:

    ```typescript theme={null}
    async function main(): Promise<void> {
      const sbx = await Sandbox.create({ template: "base", timeout: 300 });
      try {
        console.log(`Sandbox created: ${sbx.sandboxId}`);

        const result = await sbx.commands.run('echo "Hello from Declaw sandbox!"');
        console.log(`stdout: ${result.stdout}`);
        console.log(`exit_code: ${result.exitCode}`);
      } finally {
        await sbx.kill();
        console.log("Sandbox killed.");
      }
    }

    main().catch(console.error);
    ```

    <Note>
      The TypeScript SDK uses camelCase properties (`sandboxId`, `exitCode`) while Python uses snake\_case (`sandbox_id`, `exit_code`).
    </Note>
  </Tab>
</Tabs>

## Expected Output

```
==================================================
Declaw Hello World Example
==================================================

--- Sync: Creating Sandbox ---
Sandbox created: sbx_abc123

--- Sync: Running Command ---
stdout: Hello from Declaw sandbox!
exit_code: 0

--- Sync: Cleaning Up ---
Sandbox killed.

--- Async: Creating Sandbox ---
Sandbox created: sbx_def456

--- Async: Running Command ---
stdout: Hello from async Declaw sandbox!
exit_code: 0

--- Async: Cleaning Up ---
Sandbox killed.

==================================================
Done!
==================================================
```
