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. Import the pipeline
Section titled “1. Import the pipeline”-
Go to Pipelines → New pipeline.
-
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.\""}]} -
In the editor, open Pipeline settings → Workspace and set Local repository to your clone. Adjust
testCommandunder Variables. -
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}}.0counts 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.
2. Add the schedule trigger
Section titled “2. Add the schedule trigger”- Triggers → Add trigger → Schedule.
- Name:
Nightly deps. Runs pipeline: Nightly maintenance. - Cron expression:
0 3 * * 1-5(03:00 Monday–Friday, local time). - 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}}. - Click Validate, then Save trigger.
Other schedules: 30 2 * * * (every night), 0 6 * * 1 (Monday mornings), @weekdays (09:00 on weekdays). See Schedule.
3. Make sure it can run at night
Section titled “3. Make sure it can run at night”- 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 pushandghmust work without prompts (see Linear guide → step 2).
4. Get told about it
Section titled “4. Get told about it”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.
Test it now
Section titled “Test it now”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-….
Ideas for other nightly jobs
Section titled “Ideas for other nightly jobs”- 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
TODOcomment 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 withcurl. (Notification channels carry run status, not step output.)