> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.ada.cx/llms.txt.

# code-tools

Read, change, and test the [Code tools](/docs/automation/tools/code-tools) of your AI Agent. A Code tool runs a short Python snippet to transform data during a conversation. The alias is `code-actions`.

## Commands

| Command                                   | What it does                                                                               |
| ----------------------------------------- | ------------------------------------------------------------------------------------------ |
| `code-tools list`                         | Lists Code tools, one page at a time.                                                      |
| `code-tools get <id>`                     | Shows one Code tool and its source. `--source-out` writes the source to a file.            |
| `code-tools create`                       | Creates a Code tool from a Python file.                                                    |
| `code-tools update <id>`                  | Changes a Code tool, or turns it on or off. Fields that you do not give keep their values. |
| `code-tools delete <id>`                  | Deletes a Code tool.                                                                       |
| `code-tools test <id>`                    | Runs a Code tool one time with test inputs. The run saves nothing.                         |
| `code-tools allowed-domains add <domain>` | Lets the `fetch()` of a Code tool reach a domain.                                          |
| `code-tools allowed-domains list`         | Lists the allowed domains.                                                                 |
| `code-tools allowed-domains remove <id>`  | Removes an allowed domain.                                                                 |

## Examples

Create a Code tool with one input that reads a variable and one input that the AI Agent gives:

```bash
adacli acme code-tools create --file filter_items.py --name "Filter items" \
  --description "Keep the order items over a price threshold" \
  --inputs '[{"name":"order_response","type":"dict","variable_id":"<variable-id>"},{"name":"threshold","type":"number"}]' \
  --outputs '[{"name":"Total","key":"total"}]'
```

Edit the source of a Code tool. Write the source to a file, change it, then send it back:

```bash
adacli acme code-tools get <code-tool-id> --source-out filter_items.py
adacli acme code-tools update <code-tool-id> --file filter_items.py
```

Run a Code tool with test inputs:

```bash
adacli acme code-tools test <code-tool-id> --inputs '{"order_response":{"items":[{"price":12}]},"threshold":5}'
```

Let Code tools call an API:

```bash
adacli acme code-tools allowed-domains add https://api.example.com
```

## Details

* `create` needs `--file`, `--name`, and `--description`. The API refuses source over 64 KB and a name that another tool uses.
* `update --inputs` and `update --outputs` replace the full list.
* In an output, `variable_id` is the 24-character ID of a variable, not its name. `key` is a JMESPath expression into the result.
* `test` runs like a live call. `fetch()` sends real requests, and secrets resolve.
* `test` needs the Owner or Admin role. The API allows 10 test runs each minute. A failed run gives a non-zero exit code.
* An allowed domain is a scheme and a host, with an optional port. A leading `*.` allows one level of subdomain. An `https://` domain does not allow `http://` requests.
* Do not put a secret in the source. Use an [environment variable](/docs/automation/tools/code-tools/inputs-outputs-and-environment) for each secret.

For every option of a command, run it with `--help`, for example `adacli acme code-tools create --help`.

## Related commands

* [`api-tools`](/adacli/commands/api-tools): get the data that a Code tool transforms.
* [`variables`](/adacli/commands/variables): get the variable IDs for inputs and outputs.
* [`playbooks`](/adacli/commands/playbooks): run a Code tool from a Playbook step.

---

Have any questions? Contact your Ada team, or email us at [](mailto:help@ada.cx?subject=Help%20Docs%20inquiry).