Skip to content

Nightly maintenance

This guide sets up a pipeline that runs at 03:00 on weekdays, has an agent update your dependencies, runs the tests (sending failures back to the agent), and opens a pull request only if there are new commits. You wake up to a PR, or to nothing if everything was already current.

  1. Go to Pipelines → New pipeline.

  2. Paste this into Or import a pipeline JSON and click Import:

    {
    "jimothyPipeline": 1,
    "name": "Nightly maintenance",
    "description": "Update dependencies, fix breakage, open a PR if anything changed.",
    "icon": "workflow",
    "color": "#34d399",
    "repo": {
    "mode": "worktree",
    "localPath": "",
    "baseBranch": "main",
    "branchTemplate": "chore/{{issue.key | slug}}"
    },
    "concurrency": 1,
    "variables": { "testCommand": "npm test" },
    "steps": [
    {
    "id": "update",
    "name": "Update dependencies",
    "type": "agent",
    "harnessId": "claude-code",
    "model": "sonnet",
    "dependsOn": [],
    "timeoutMinutes": 45,
    "prompt": "{{issue.title}}\n\n{{issue.description}}\n\nUpdate this project's dependencies to their latest compatible versions (stay within the current major version unless the upgrade is trivial). Run the test suite. Fix anything the updates break. Commit each logical change with a message starting with \"chore(deps):\". If nothing needs updating, make no commits.\n{{#if steps.test.output}}\nThe test suite failed after your last attempt. Fix it:\n{{steps.test.output | truncate:4000}}\n{{/if}}"
    },
    {
    "id": "test",
    "name": "Run tests",
    "type": "shell",
    "dependsOn": ["update"],
    "command": "{{vars.testCommand | raw}}",
    "timeoutMinutes": 20,
    "loopBackTo": "update",
    "maxLoops": 2
    },
    {
    "id": "commits",
    "name": "Count new commits",
    "type": "shell",
    "dependsOn": ["test"],
    "command": "git rev-list --count \"origin/$FACTORY_BASE_BRANCH..HEAD\""
    },
    {
    "id": "pr",
    "name": "Open pull request",
    "type": "shell",
    "dependsOn": ["commits"],
    "runIf": "{{steps.commits.output}}",
    "timeoutMinutes": 5,
    "command": "git push -u origin HEAD && gh pr create --base {{run.baseBranch}} --head {{run.branch}} --title \"chore(deps): nightly dependency updates\" --body \"Automated by Jimothy run #$FACTORY_RUN_NUMBER.\""
    }
    ]
    }
  3. In the editor, open Pipeline settings → Workspace and set Local repository to your clone. Adjust testCommand under Variables.

  4. Save.

How it works:

  • Update dependencies is a Claude Code step. On a feedback loop it sees the failing test output through {{steps.test.output}}.
  • Run tests loops back to the update step up to twice.
  • Count new commits prints how many commits the branch has on top of origin/main. Its output is a number.
  • Open pull request has Run only if {{steps.commits.output}}. 0 counts as false, so when nothing changed the step is skipped (with Condition not met) and the run still succeeds.
  • The branch template chore/{{issue.key | slug}} gives each night its own branch, e.g. chore/sched-202609290100, because schedule issue keys include the firing time.
  • Max concurrent runs is 1, so a slow night can’t overlap with the next.
  1. Triggers → Add trigger → Schedule.
  2. Name: Nightly deps. Runs pipeline: Nightly maintenance.
  3. Cron expression: 0 3 * * 1-5 (03:00 Monday–Friday, local time).
  4. Task title: Nightly maintenance. Task description: anything extra for the agent, e.g. Skip @types packages. Never upgrade react beyond 19.x. — it reaches the prompt as {{issue.description}}.
  5. Click Validate, then Save trigger.

Other schedules: 30 2 * * * (every night), 0 6 * * 1 (Monday mornings), @weekdays (09:00 on weekdays). See Schedule.

  • Jimothy must be running. Closing the window leaves it in the tray; Quit stops schedules.
  • The computer must be awake at 03:00. Missed firings are not caught up. On macOS you can schedule a wake a few minutes earlier with sudo pmset repeat wakeorpoweron MTWRF 02:55:00, or pick a time you’re usually online.
  • git push and gh must work without prompts (see Linear guide → step 2).

Add a notification channel for Run succeeded and Run failed limited to the Nightly maintenance pipeline (Notifications → Add channel → Slack, pick the pipeline under Pipelines). The success message includes the PR link when one was opened.

You don’t need to wait for 03:00: click Run in the pipeline editor, enter a title like Nightly maintenance (manual test) and start it. Manual runs behave the same; their issue key is TASK-<n> instead of SCHED-….

  • Flaky test hunt: run the suite five times in a shell step, feed failures to an agent that proposes fixes.
  • TODO sweeper: an agent that picks one TODO comment and resolves it, with an approval step before the PR.
  • Weekly report: a shell step that gathers git log --since=1.week, a Claude API step that summarizes {{steps.log.output}}, and a final shell step that posts the summary to a Slack incoming webhook with curl. (Notification channels carry run status, not step output.)