# Schedule a nightly coding agent prompt with Crew

> Schedule a nightly coding agent prompt with a Crew automation, fire it from a webhook, and chain steps into a workflow the agents engine keeps across restarts.

- Canonical URL: https://getedith.pro/docs/agents/tutorials/schedule-a-nightly-agent-prompt
- Updated: 2026-12-03

By the end of this tutorial, a coding agent will review your repository every night at 22:00 without you starting it, you will know how to fire the same prompt from a webhook, and you will have a two-step workflow that keeps its place across restarts. You need Crew running on a Mac in the Edith beta, and an agent CLI such as Claude Code or Codex. See [Get Crew](https://getedith.pro/docs/agents/crew/get-crew).

> **Beta:** Crew is a beta extension and can change between releases.

## Know who runs the schedule

The agents engine owns schedules, not the Edith window. They keep firing after Edith quits, and with background sessions on, the engine starts again at login. Background sessions are on by default. Edith must be turned on in **System Settings > General > Login Items**.

To check them from a terminal, run `ed crew background`, and `ed crew background on` if they are off. See [Background sessions](https://getedith.pro/docs/agents/crew/background).

## Add the project and start a thread

Schedules run in a project, a folder the engine tracks.

1. On the Crew page, switch to **Threads**.
2. Press **Add project** in the Threads sidebar and choose the repository folder, such as `~/code/app`.
3. Press **New thread** (⌘N), pick the agent, such as Claude Code, and send a first message, such as "Read the README and wait for instructions".

The automation you add next belongs to this thread and uses its agent and settings.

## Create the nightly automation

1. Open the thread and press ⌥⌘B to show its details panel.
2. Under **Automations**, press **+** (**New automation for this thread**).
3. Give it a name, such as `Nightly review`.
4. In **Prompt to send**, write what the agent receives each time: "Review today's commits and list anything risky".
5. Under **When**, choose **Daily** and set the time to 22:00. **Weekdays** skips weekends, **Weekly** runs on one day, **Every** repeats every few minutes and **Once** runs at one date and time.
6. Under **Thread**, choose **New thread each run** so every night's review is its own thread. **Same thread** keeps adding to this one, and **Same thread, fresh session** uses this thread with a fresh agent session.
7. Leave **Enabled** on and press **Create automation**.

A review only reads code. For a job that edits files overnight, start the thread in a new worktree, with **Where the agent works** (⌘⇧X) set to **New worktree**, so each run never touches the branch you have open.

### From the terminal

The same schedule, created on the project:

```terminal
$ ed crew projects add ~/code/app --provider claude
$ ed crew schedules add "Nightly review" --prompt "Review today's commits and list anything risky" --at 22:00 --project ~/code/app
```

`--at` is a local time of day. Add `--weekdays 1,2,3,4,5` to skip weekends; days run from 0 (Sunday) to 6. Use exactly one trigger: `--every`, `--at`, `--once` or `--webhook`. `--provider`, `--model`, `--effort`, `--permissions`, `--worktree <ref>` and `--thread-mode` set how each run works. See [`ed crew schedules`](https://getedith.pro/docs/agents/crew/cli/schedules).

## Test it now

Do not wait until 22:00 to find a typo in the prompt. In the automation's row under **Automations**, press **Run now**. It sends the prompt now without changing the next run. The row shows how the last run went, and the new thread appears in the Threads sidebar.

### From the terminal

```terminal
$ ed crew schedules ls
$ ed crew schedules run sch_01
$ ed crew thread read th_01 --limit 400
```

## Change, pause or remove it

Each automation row has buttons for **Pause** (then **Resume**), **Edit** and **Delete**. Deleting stops the automation; threads it already ran keep their history.

### From the terminal

```terminal
$ ed crew schedules update sch_01 --at 23:30
$ ed crew schedules disable sch_01
$ ed crew schedules enable sch_01
$ ed crew schedules rm sch_01
```

`update` changes only what you pass, and a new trigger replaces the old one.

## Trigger it from a webhook instead

A webhook schedule runs when its path is called, for example by your Git host when an issue opens. Webhook schedules are set up from a terminal:

```terminal
$ ed crew schedules add Issues --prompt "Triage {{body.issue.title}}" --webhook --signature-header X-Hub-Signature-256 --signature-prefix sha256= --secret-file ~/.hook-secret --filter body.action=opened
$ ed crew schedules show sch_02
```

The prompt can use `{{body.<path>}}` and `{{headers.<name>}}` from the delivery. `show` prints the webhook path. The path holds the hook's secret token, so give it only to the sender. `--secret-file` reads the signing secret from a file; never pass it on the command line.

Check what arrived, and replace the path if it leaked:

```terminal
$ ed crew schedules deliveries sch_02
$ ed crew schedules rotate sch_02
```

## Chain steps into a workflow

A schedule sends one prompt. For several steps in a row, write a workflow. The engine keeps each run across restarts, so a run that is waiting is still waiting after a reboot. Here is one, with your own folder in `cwd`:

```json
{
  "name": "nightly-fix",
  "description": "Fix flaky tests at night, then report",
  "triggers": [{ "type": "daily", "time_of_day": "02:00" }],
  "steps": [
    {
      "type": "send",
      "name": "fix",
      "provider": "codex",
      "cwd": "/Users/me/code/app",
      "text": "Find and fix the flaky tests"
    },
    {
      "type": "wait_turn",
      "name": "fixed",
      "thread": "{{steps.fix.thread_id}}"
    },
    {
      "type": "send",
      "name": "report",
      "thread": "{{steps.fix.thread_id}}",
      "text": "Summarize what you changed and what still fails"
    }
  ]
}
```

A `send` step without a `thread` starts a new thread and reports its `thread_id`, which later steps use. The `daily` trigger starts a run at that time. `every` with `every_ms`, and `webhook` with a `name`, also work.

To add it:

1. In the Threads sidebar, press the **Workflows** button.
2. Press **New workflow**, replace the template with the JSON above, and press **Save**.
3. To try one run by hand, select the workflow and press **Run**, or right-click it and choose **Run…**. In the sheet, press **Run** again.

The Workflows page lists each run with its steps and their state. Runs that wait for you are marked **Needs you**; open one to answer it. A run pauses when an agent step fails and retries on its own; open the run and press **Resume** to retry now, or **Cancel run** to stop it.

### From the terminal

Save the JSON as `nightly-fix.json`, then register it, check the next start, and try one run:

```terminal
$ ed crew workflows register nightly-fix.json
$ ed crew workflows hooks nightly-fix
$ ed crew workflows start nightly-fix --key test-1
$ ed crew workflows ls
$ ed crew workflows show run_01
```

Starting again with the same `--key` returns the same run instead of a second one. `ed crew workflows resume run_01` retries a paused run now, and `cancel` stops it.

## Next steps

- [Keep agents running overnight](https://getedith.pro/docs/agents/tutorials/keep-agents-running-overnight)
- [Review an agent plan in a thread](https://getedith.pro/docs/agents/tutorials/review-an-agent-plan-in-a-thread)
- [Schedules](https://getedith.pro/docs/agents/crew/schedules) and [Workflows](https://getedith.pro/docs/agents/crew/workflows)
- [`ed crew schedules`](https://getedith.pro/docs/agents/crew/cli/schedules) and [`ed crew workflows`](https://getedith.pro/docs/agents/crew/cli/workflows)

## Get Edith

Edith is a native Mac app for macOS 14 or later on Apple silicon with 100+ extensions, the `ed` command line and an MCP server. $35 once for one Mac, plus $7 for each additional Mac, with no subscription and a 30-day refund.

- [Buy Edith](https://getedith.pro/pricing): $35 once for one Mac, plus $7 for each additional Mac
- [Download Edith](https://getedith.pro/download): the installer, or Homebrew
