---
title: "Code Triggers"
description: "Run Cody against your repo on a schedule or on demand, with project memory carried across runs"
canonical: "https://docs.ainative.studio/docs/cody-cli/code-triggers"
last-updated: "2026-10-26T19:08:16.785Z"
---

# Code Triggers

Source: https://docs.ainative.studio/docs/cody-cli/code-triggers

> Run Cody against your repo on a schedule or on demand, with project memory carried across runs

# Code Triggers

Code triggers let you configure a prompt that runs against a repository
— on a schedule, or manually — without keeping a local CLI session open.
Each run spins up a real agent that executes your prompt against the
repo and branch you specify.

## Creating a trigger

```bash
curl -X POST https://api.ainative.studio/v1/code/triggers \
  -H "Authorization: Bearer $AINATIVE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "nightly-dependency-check",
    "schedule": "manual",
    "prompt": "Check for outdated dependencies and open a PR if any are more than one major version behind.",
    "repo": "your-org/your-repo",
    "branch": "main",
    "github_token": "ghp_..."
  }'
```

| Field | Required | Description |
|---|---|---|
| `name` | Yes | A label for the trigger |
| `schedule` | Yes | Cron expression, or `"manual"` for on-demand only |
| `prompt` | Yes | The task to run against the repo |
| `repo` | Yes | `org/repo` |
| `branch` | Yes | Branch to target |
| `github_token` | Yes, to run | A token with access to `repo` — used to read files and open a PR. **Required for a run to actually execute** — a trigger without one will fail with a clear error rather than silently doing nothing. Write-only: never returned by any response. |
| `use_memory` | No, default `true` | See Project memory below |

## Running a trigger

```bash
curl -X POST https://api.ainative.studio/v1/code/triggers/<id>/run \
  -H "Authorization: Bearer $AINATIVE_API_KEY"
```

Runs bill to your own account — a trigger only ever executes with your
own GitHub token and on your own usage.

## Project memory

By default (`use_memory: true`), each run automatically:

- **Recalls** relevant context from your project's memory before
  starting — the same automatic project memory described in
  [Memory](/docs/cody-cli/memory), scoped to the trigger's `repo`.
- **Stores a summary** of what the run did after it finishes.

This means a scheduled trigger and your local Cody CLI sessions on the
same repo build up and draw from the same project memory over time. Set
`use_memory: false` on a trigger if you'd rather it run without any
memory context.

## Listing and deleting

```bash
# List
curl https://api.ainative.studio/v1/code/triggers \
  -H "Authorization: Bearer $AINATIVE_API_KEY"

# Delete
curl -X DELETE https://api.ainative.studio/v1/code/triggers/<id> \
  -H "Authorization: Bearer $AINATIVE_API_KEY"
```
