| name | apply-nightshift |
| description | Apply patches/fixes from night-shift worker agents. Parses session reports, presents fixable issues for selection, creates git worktrees with applied patches, and commits for review. Triggers on "apply nightshift", "nightshift fixes", "apply patches", "night shift".
|
Apply Night Shift Fixes
Apply patches and fixes produced by the Night Shift autonomous worker agents to the Nx repo via git worktrees.
Inputs
The user may provide:
- A session date (e.g., "from Monday 2026-04-06") — looks up
~/projects/night-shift/sessions/session-YYYY-MM-DD.md
- A specific
/tmp/nightshift-work-XXXXX/ path — skip selection, apply directly
- Nothing — use the latest session file
Workflow
Mode A: Specific Patch Path Given
If the user points to a specific /tmp/nightshift-work-XXXXX/ directory:
- Read
reports/final-report.md to understand the fix
- Read
reports/confidence.json for confidence score
- Check if patches exist in
patches/
- Create a git worktree and branch, apply the patch, commit
- Invoke
plannotator-review pointed at the worktree branch so Jack can review in browser
- Report back — do NOT open a PR
Mode B: Session Review (Default)
Step 1: Find the Session
ls -t ~/projects/night-shift/sessions/session-*.md | head -1
cat ~/projects/night-shift/sessions/session-2026-04-08.md
Step 2: Parse and Present Fixed Issues
Read the session .md file. Extract all issues with Status: fixed. Present a table:
# Night Shift Session: 2026-04-09 (33 fixed / 53 total)
| # | Issue | Title | Confidence | Reports |
|---|-------|-------|------------|---------|
| 1 | [#32864](https://github.com/nrwl/nx/issues/32864) | Rspack Angular i18n Windows paths | 82/100 | `/tmp/nightshift-work-u5Nn6B/` |
| 2 | [NXC-4157](https://linear.app/nxdev/issue/NXC-4157) | Update @nx/rollup defaults | 95/100 | `/tmp/nightshift-work-RyN4Ea/` |
...
Include:
- Issue link (GitHub or Linear)
- Short title
- Confidence score
- Work directory path
- Peer review status if present (changes-requested, approved, etc.)
IMPORTANT: Skip issues with Status: error or Status: rejected. Only show Status: fixed.
Ask the user: "Which issues do you want to apply? (e.g., 1,3,5 or 'all')"
Step 3: Apply Selected Issues
For each selected issue:
- Read the report:
<work-dir>/reports/final-report.md
- Check for patches:
ls <work-dir>/patches/
- Determine naming:
- GitHub issues:
issue-NNNNN (e.g., issue-32864)
- Linear issues:
NXC-NNNN (e.g., NXC-4157)
- Specs/other: descriptive slug (e.g.,
e2e-perf-optimization)
- Check if worktree already exists:
git -C ~/projects/nx worktree list | grep <name>
If it exists, warn the user and skip unless they confirm overwrite.
- Create worktree:
cd ~/projects/nx
git fetch origin master
git worktree add ~/projects/nx-worktrees/<name> -b fix/<name> origin/master
- Apply the patch:
- Commit:
cd ~/projects/nx-worktrees/<name>
git add -A
git commit -m "fix(scope): brief description
## Current Behavior
<from report>
## Expected Behavior
<from report>
## Related Issue(s)
Fixes #NNNNN"
- NEVER co-author the commit — commit must come only from Jack
- Derive the commit scope from the package being changed (e.g.,
angular-rspack, nx, react)
- Use
fix for bug fixes, docs for documentation, chore for cleanup/TODOs
- Report status for each issue applied
Step 4: Update TODO.md
After all patches are applied, update ~/projects/dot-ai-config/dot_ai/TODO.md:
-
Add to Recent Tasks (item #1, bump others down, drop 11th):
1. **Night-shift community fixes batch** (YYYY-MM-DD)
- Summary: N worktrees created from session-YYYY-MM-DD night-shift run. All patches applied and committed.
- Session: `night-shift/sessions/session-YYYY-MM-DD.md`
-
Add a TODO checklist with 🤖 prefix, listing each applied issue with:
- Issue number + short title
- Confidence score and peer review status
- Worktree name (e.g.,
issue-32864)
- Original night-shift work dir with reports path (e.g.,
reports: /tmp/nightshift-work-XXXXX/reports/)
Format:
- [ ] 🤖 Review night-shift fixes from YYYY-MM-DD session (N applied, M fixed / T total)
- Session report: `/Users/jack/projects/night-shift/sessions/session-YYYY-MM-DD.md`
- Worktrees: `~/projects/nx-worktrees/issue-*` — review code, run tests, create PRs
- [ ] #NNNNN — short title (conf: NN, ✅ approved) `issue-NNNNN` | reports: `/tmp/nightshift-work-XXXXX/reports/`
- [ ] #NNNNN — short title (conf: NN, ⚠️ concerns) `issue-NNNNN` | reports: `/tmp/nightshift-work-XXXXX/reports/`
The reports: path is critical — it lets Jack quickly read final-report.md, theories.md, confidence.json, and peer-review.md when reviewing each fix.
Step 5: Summary
After all selected issues are applied, show:
## Applied Fixes
| Issue | Worktree | Branch | Reports | Status |
|-------|----------|--------|---------|--------|
| #32864 | ~/projects/nx-worktrees/issue-32864 | fix/issue-32864 | /tmp/nightshift-work-XXXXX/reports/ | Ready for review |
| NXC-4157 | ~/projects/nx-worktrees/NXC-4157 | fix/NXC-4157 | /tmp/nightshift-work-XXXXX/reports/ | Ready for review |
Remind the user:
cd ~/projects/nx-worktrees/<name> to review
- Read
<reports-dir>/final-report.md for root cause analysis and fix details
- Run
nx affected -t build-base,lint,test before pushing
- Do NOT open PRs automatically
Step 6: Open Plannotator for Browser Review
After the summary, open each applied worktree in Plannotator so Jack can review the diff
in the browser UI and leave comments / approvals / change requests.
For each applied worktree, invoke the plannotator-review skill pointed at that worktree's
branch. Plannotator needs to know which diff to show — pass the worktree path or branch so
it picks up the commit made in that worktree (not the current working directory's changes).
How to invoke:
Skill(skill: "plannotator-review", args: "<worktree-path-or-branch>")
- If applying a single worktree, invoke Plannotator once for that worktree.
- If applying multiple worktrees, invoke Plannotator once per worktree (sequentially — do
not parallelize skill invocations). Mention to Jack that a review tab will open for each
one, so he can tab through them.
- Do not produce an inline chat review summary — Plannotator is the review surface.
If a worktree's commit failed or the patch didn't apply cleanly, skip Plannotator for that
one and report the failure instead.
Important Notes
- The Nx repo is at
~/projects/nx
- Worktrees go in
~/projects/nx-worktrees/
- Night shift sessions are at
~/projects/night-shift/sessions/
- Work directories are at
/tmp/nightshift-work-XXXXX/
- Patches may have stale git hashes — use
git apply --3way or manual application as fallback
- Some issues have peer reviews at
<work-dir>/reports/peer-review.md — mention review concerns when presenting
- Always base worktrees on latest
origin/master
- Never push or open PRs unless explicitly asked