Helps apply changes from the hmpps-template-typescript shared template to this repository. Use this skill when asked to: sync template changes, apply upstream template updates, check what template changes are available, or apply a specific template PR to this repo.
This skill helps you apply changes from the hmpps-template-typescript shared template to the current repository.
The template maintainers publish a changelog at https://raw.githubusercontent.com/ministryofjustice/hmpps-template-typescript/main/CHANGELOG.md. Each entry links to the GitHub PR that introduced the change — this skill fetches those diffs and applies them using git apply --3way.
Scripts for this skill are located at scripts/.
Before listing or applying changes, determine the target repository:
Use the current working directory from the environment context as the target repo path. Resolve the git root with:
git -C <cwd> rev-parse --show-toplevel
Use the output as REPO_PATH for all subsequent script calls.
Check whether the repo looks like it is based on hmpps-template-typescript by verifying that package.json exists in the repo root. If it doesn't exist, warn the user:
"This directory doesn't appear to be an hmpps-template-typescript-based project —
package.jsonwas not found. Template changes may not apply correctly. Do you want to continue anyway?"
If the user confirms, proceed. If the repo is clearly wrong (e.g. it's a plugin marketplace or documentation repo), stop and ask the user to navigate to the correct service repository first.
Run the bundled list-changes script and display its output directly to the user:
node scripts/list-changes.mjs
The output is a list ready to display - just present the list as provided. Each entry includes the date, title, PR number(s), PR URL(s), and a one-line description hint.
To show only a subset, use --limit and --from:
# Show first 20 entries
node scripts/list-changes.mjs --limit 20
# Show entries 21 onwards
node scripts/list-changes.mjs --from 21
Ask the user which change(s) they'd like to apply or inspect. They can specify by the PR number (e.g. "apply #679"), or by describing the change.
If the user asks to see more details about an entry before applying it, run the get-change-details script and display its output:
node scripts/get-change-details.mjs <pr-number>
For example:
node scripts/get-change-details.mjs 679
This outputs the PR title, URL, merge date, full description, and a list of all changed files with additions/deletions counts.
Once the user has selected a change, run the apply-change script with the PR number and the repo path resolved in Step 0:
node scripts/apply-change.mjs <pr-number> --repo <REPO_PATH>
For example, to apply PR #679:
node scripts/apply-change.mjs 679 --repo /path/to/repo
The script outputs JSON with these fields:
appliedFiles — files patched cleanlyconflictFiles — files that need manual conflict resolution (contain <<<<<<< markers)skippedFiles — files where the patch couldn't be applied at all (file missing or too diverged)skippedFileDetails — array of { filename, status } for each skipped file, where status is "added", "modified", "removed", or "renamed" as reported by GitHubrepoPath — the resolved path that was targetedsuccess — true if at least a partial apply succeededgitOutput — raw output from git (if any errors occurred)After running apply-change, summarise the result clearly:
If all files applied cleanly (conflictFiles and skippedFiles are empty):
git diff) and run the project's tests before committingchore: apply template change from hmpps-template-typescript PR #679If there are conflict files:
git add <file> before committingIf there are skipped files:
status from skippedFileDetailsstatus: "added" — the file doesn't exist in this repo yet. Fetch the file's content directly from the template using:
https://raw.githubusercontent.com/ministryofjustice/hmpps-template-typescript/main/<filename>
Then create it in the repo at the same path using the edit tool, and note any project-specific values (e.g. app names, URLs) that may need adjusting.status: "modified" or "renamed" — the file exists in the template but is missing or too diverged in this repo. Run get-change-details.mjs to understand what the change does, inspect the diff, and apply the relevant parts manually using the edit tool.status: "removed" — the template deleted this file. Check if the file exists in the repo and offer to delete it, but confirm with the user first as they may have intentionally kept it.git diff before committing.If success is false:
gitOutput to help diagnose the problemnpm run typecheck && npm run lint && npm run test.GITHUB_TOKEN environment variable to authenticate.