SKILL.md
SKILL.mdBrowse 2 files
2,058 tokens
7,796 bytes
Token encoding: o200k_base
Snapshot 646e806
1---2name: update-cnw-templates3description: Update the CNW (create-nx-workspace) template repos (nrwl/empty-template, nrwl/react-template, etc.) to a target nx version via nx migrate, verify each repo, and open a PR per repo. Clones repos it needs - assumes no local checkout. Use when asked to "update the CNW templates", "migrate the templates to nx X", "bump the template repos", or given a version like "update templates to 23.2.0".4allowed-tools: Bash, Read, Write, Edit, Grep, Glob, WebFetch5---6 7# Update CNW Templates8 9Bump every CNW template repo to one target nx version, verify it still builds and10still scaffolds, then open a draft PR per repo. Each template is an independent11GitHub repo under `nrwl/`; `create-nx-workspace --template nrwl/<repo>` clones its12`main` to scaffold a user's workspace. Each repo has a `ci.yml` that lints, tests,13builds, typechecks, and e2es it on PRs - but the consumer path (scaffolding from `main`14via `--template`) isn't covered there, and a force-push to `main` skips PR CI entirely15(how the react template broke). So verify before you ship.16 17This skill makes **no assumption that the repos are checked out locally.** It clones18what it needs. Anyone on the team can run it from a fresh machine.19 20## Input21 22- **Target nx version** - e.g. `23.2.0`. If omitted, use latest stable: `npm view nx@latest version`. Verify it exists: `npm view nx@<version> version`.23- **Repos** - one, several, or (default) all live templates. Names may be given with or without the `-template` suffix.24- **Work dir** - where clones land. Default `./tmp/cnw-templates/` (gitignored). Reuse an existing clone if one is already there and clean.25 26## The template repos27 28All live under `nrwl/<name>-template`, push target branch `main`. `--template` accepts29the full `nrwl/<repo>` form for all of them. Four templates also have a bare shorthand.30 31| Template | `--template` value | Shorthand |32| --------------- | ------------------------------- | --------- |33| empty | `nrwl/empty-template` | `empty` |34| typescript | `nrwl/typescript-template` | `ts` |35| react | `nrwl/react-template` | `react` |36| angular | `nrwl/angular-template` | `angular` |37| react-mfe | `nrwl/react-mfe-template` | - |38| nextjs | `nrwl/nextjs-template` | - |39| nestjs | `nrwl/nestjs-template` | - |40| express-api | `nrwl/express-api-template` | - |41| astro-starlight | `nrwl/astro-starlight-template` | - |42| remotion | `nrwl/remotion-template` | - |43| tanstack-start | `nrwl/tanstack-start-template` | - |44| tanstack-ai | `nrwl/tanstack-ai-template` | - |45 46Before continuing, check that all the templates are live. A repo is live if47`GET https://api.github.com/repos/nrwl/<name>-template/commits/main` returns 200 (a sha).48If you hit 404 report it.49 50This table may change, and the user will tell you which repos to use (defaults to all in the table).51 52## Procedure53 54### 1. Resolve version + repo set55 56```bash57npm view nx@<version> version # confirm target exists58# for each requested repo, confirm it's live:59curl -s -o /dev/null -w "%{http_code}" https://api.github.com/repos/nrwl/<name>-template/commits/main60```61 62### 1a. If in a Polygraph session, add the templates to it63 64If this skill runs inside a Polygraph session (the startup banner names a session ID),65add every target template repo to the session so their per-repo PRs link together under66one session. The repos are exact `owner/repo` refs, so add them directly - no discovery:67 68```69add_repo(sessionId: "<session-id>", repoIds: ["nrwl/empty-template", "nrwl/react-template", ...])70```71 72Add only the live repos you're actually touching. After `add_repo`, the PRs you open in73step 5 join the session automatically - the link is the session, not any cross-reference74in the PR bodies. If there's no session, skip this and proceed normally.75 76### 2. Clone (or reuse) each repo77 78All template repos are npm (`package-lock.json`). Clone over SSH; the working tree must79be clean before you touch it.80 81```bash82mkdir -p tmp/cnw-templates && cd tmp/cnw-templates83git clone git@github.com:nrwl/<name>-template.git # or reuse an existing clean clone84cd <name>-template85git checkout main86git status --porcelain # MUST be empty; if dirty, skip this repo and report87git fetch origin main && git reset --hard origin/main # make sure we start from latest origin88grep '"nx"' package.json # record current version89```90 91### 3. Migrate92 93Use `CI=true` to skip prompts.94 95```bash96CI=true npm install # node_modules at current version97CI=true npx nx migrate <target-version> # updates package.json, writes migrations.json98CI=true npm install # apply the dep bump99if [ -f migrations.json ]; then100 CI=true npx nx migrate --run-migrations101 rm -f migrations.json102fi103```104 105### 4. Verify106 107```bash108NX_NO_CLOUD=true NX_DAEMON=false CI=true npx nx run-many -t build test lint typecheck --skip-nx-cache109NX_NO_CLOUD=true NX_DAEMON=false CI=true npx nx run-many -t e2e # where the repo defines it110```111 112If any target fails, **revert that repo (`git checkout .`) and report** - never open a red PR.113 114### 5. Commit + PR (per repo)115 116Every template's `main` is a single "Initial commit" (verified across all 12 repos), so117keep the branch to **one commit** (amend, don't stack) and squash-merge the PR.118 119```bash120cd tmp/cnw-templates/<name>-template121git checkout -b update-nx-<target-version>122git add -A123git commit -m "chore(deps): update to nx <target-version>" # never mention AI/Claude124git push -u origin update-nx-<target-version>125# open a draft PR to main via the GitHub API (token from env/1Password, never hardcode):126curl -s -X POST -H "Authorization: Bearer $GH_TOKEN" -H "Accept: application/vnd.github+json" \127 "https://api.github.com/repos/nrwl/<name>-template/pulls" \128 -d '{"title":"chore(deps): update to nx <target-version>","head":"update-nx-<target-version>","base":"main","draft":true,"body":"<per-repo summary: old->new nx, migrations run>"}'129```130 131PR body: old -> new nx version, which migrations ran, and the verification result. For a132not-yet-created repo (404 in step 1), skip the push - report it as "not created".133 134### 6. Sanity check after the PRs land - run-all-templates.sh135 136`run-all-templates.sh` (bundled next to this file) runs `create-nx-workspace --template137nrwl/<repo>` for every template and reports pass/fail. It scaffolds from each repo's138**`main`**, so run it as a **follow-up once the template PRs are merged** (or after you139push to `main`) - a real end-to-end check that every template still scaffolds for users.140It can't see an unpushed branch, so it's a post-merge step, not a pre-merge gate.141 142```bash143# all templates:144CNW_VERSION=<target-version> ./run-all-templates.sh145# a subset:146CNW_VERSION=<target-version> ONLY="empty-template react-template" ./run-all-templates.sh147```148 149### 7. Report150 151One table across all repos:152 153```154| Template | Previous | Updated | Files | Status |155| --------------- | -------- | ------- | ----- | -------------- |156| empty-template | 23.1.0 | 23.2.0 | 2 | PR #NN (draft) |157| nuxt-template | 23.1.0 | - | - | not created |158```159 160Be ready to explain any change - which migration produced it and why.161 162## Notes163 164- **Always `CI=true`** for nx/npm commands so nothing blocks on a prompt.165- **Never push without confirmation.** Open PRs as **drafts**; the owner reviews and marks ready.166- Patch bumps are usually just `package.json` + lockfile (no `migrations.json`). Minor/major can rewrite source - review the non-dep diff before committing.167 Discovery context
Discovered by repository scan. No exact path reference found in the snapshot’s root AGENTS.md.