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

# Manage scripts

> Save a reusable bash script to a project, then run it or attach it to an automation.

A script is a named bash file saved to a project. You write it once and reuse it — run it by hand, or attach it to an [automation](https://docs.sazabi.com/guides/detect/automations.md) so it runs on a schedule. Scripts are managed with the Sazabi CLI.

Outcome: a saved, versioned script in your project you can attach to an automation. Time: a couple of minutes.

## What scripts are

Each script has a **name**, an optional **description**, and a **body** (the bash source). Names use letters, numbers, hyphens, and underscores (1-64 characters). Sazabi stores the body and a content hash, so you can see exactly what will run.

Because a script runs inside the project sandbox, it has access to the same CLIs and tooling the agent uses there. See [Set up the sandbox](https://docs.sazabi.com/guides/investigate/sandbox.md) for what the sandbox provides.

## Creating and editing

Create a script from inline content or a file:

```bash theme={"system"}
# From a file
sazabi scripts create deploy-check --file ./deploy-check.sh --description "Nightly deploy sanity check"

# From inline content
sazabi scripts create hello --content '#!/usr/bin/env bash
echo "hello from the sandbox"'
```

Update the body or description later. Pass the script's ID and current revision from `sazabi scripts get`, so Sazabi refuses the write if someone else changed the script first. Each successful update increases the revision, so run `sazabi scripts get` again before the next write:

```bash theme={"system"}
sazabi scripts get deploy-check
sazabi scripts update deploy-check --expected-script-id <id> --expected-revision <revision> --file ./deploy-check.sh
sazabi scripts update deploy-check --expected-script-id <id> --expected-revision <revision> --description "Updated helper"
```

List and inspect scripts:

```bash theme={"system"}
sazabi scripts list
sazabi scripts get deploy-check
```

Delete a script you no longer need, passing the same values from `sazabi scripts get`:

```bash theme={"system"}
sazabi scripts delete deploy-check --expected-script-id <id> --expected-revision <revision>
```

## Scripts and automations

A script becomes scheduled work when you attach it to an automation. The automation owns the schedule and timezone; the script owns the logic. The script's exit status is the run's result — exit `0` marks the run as succeeded, and any non-zero exit marks it as failed. A script that finishes its check and *finds* a problem should print what it found and still exit `0`; reserve non-zero for the script itself failing to run. See [Create automations](https://docs.sazabi.com/guides/detect/automations.md) for the full exit-status contract.

## Verify

Create a script, then read it back and confirm the stored body matches what you saved:

```bash theme={"system"}
sazabi scripts create verify-demo --content '#!/usr/bin/env bash
echo ok'
sazabi scripts get verify-demo
```

The `get` output should show the exact body you supplied. If the script is missing, confirm you selected the right project with `sazabi projects use`.

## Further reading

> [card] [Set up the sandbox](https://docs.sazabi.com/guides/investigate/sandbox.md)
>
> What the sandbox a script runs in provides.


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