Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .claude/commands/plan-issue.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ Read these two files first, before any other file. Where these instructions star
Clone into a scratch folder outside the repository, `$scratch = Join-Path ([IO.Path]::GetTempPath()) "template-update-$([guid]::NewGuid().ToString('N').Substring(0, 8))"`, and delete it before you reply.

1. **Research.** Clone the template from its address, `_src_path` read as `.template/Get-TemplateUpdate.ps1` reads it: `gh:<path>` is `https://github.com/<path>`, the old `https://github.com/polewskm/project-template`, with or without `.git`, is `https://github.com/NCodeGroup/project-template.git`, and a local path that isn't a folder on this PC, such as the clone of the template the project was created from on another PC, is `https://github.com/NCodeGroup/project-template.git`: `git clone --quiet --no-checkout -- <that address> $scratch\template`. The target is the version the request names, or else the newest tag, as `Update-Project.ps1` picks it: `git -C $scratch\template tag --list --sort=-version:refname | Where-Object { $_ -match '^v?\d+(\.\d+){0,3}$' } | Select-Object -First 1`. When the target is the project's version and the request changes no answer, the project is up to date: stop and say so. Read `git -C $scratch\template show <tag>:CHANGELOG.md`, every section after the project's version up to and including the target, and list each change that reaches a project: commands added, renamed or removed, changed rules and conventions, files added, moved or removed, new answers, and anything the notes say a project must do.
2. **Trial run.** Clone the project and branch from the commit the plan starts from: `git clone --quiet -- (git rev-parse --show-toplevel) $scratch\project`, then `git -C $scratch\project switch --quiet -c template-trial (git rev-parse HEAD)`. The clone's `origin/HEAD` names the branch checked out where it was cloned from, such as a plan worktree's `worktree-<name>`, and `Update-Project.ps1` records the branch `origin/HEAD` names as the `default_branch` answer when the answers have none (the template's ADR-0060). So point it where the project's own `origin/HEAD` points, which the update step reads: `$default = "$(git symbolic-ref --quiet --short refs/remotes/origin/HEAD 2>$null)".Trim() -replace '^origin/', ''`, then `if ($default) { git -C $scratch\project symbolic-ref refs/remotes/origin/HEAD "refs/remotes/origin/$default" } else { git -C $scratch\project remote set-head origin --delete }`. Run the clone's update script with the target, adding `-Data @{ <answer> = <value> }` for the answers the request changes: `& $scratch\project\.template\Update-Project.ps1 -Ref <tag> -NoCommit -TemplateClone $scratch\template *>&1 | Tee-Object $scratch\trial.txt`. Run it with `&`, not `pwsh -File`, which can't pass `-Data`. `-TemplateClone` has it read the clone from step 1 instead of cloning `_src_path` itself, which an older update script can't do when `_src_path` names a folder that isn't on this PC; the target's script, which the update hands over to, then moves `_src_path` to the clone's address, and the trial's output says so. From its output, record each file under `Template <from> -> <to>:` with its kind, each conflict, the files under `Local edits discarded` and `Restored`, and each project-owned file the template changed, with its diff. Then, in the clone, run the project's `build_command` and each check its `AGENTS.md` names, such as a lint or customization check, and record each failure.
2. **Trial run.** Clone the project and branch from the commit the plan starts from: `git clone --quiet -- (git rev-parse --show-toplevel) $scratch\project`, then `git -C $scratch\project switch --quiet -c template-trial (git rev-parse HEAD)`. The clone's `origin/HEAD` names the branch checked out where it was cloned from, such as a plan worktree's `worktree-<name>`, and `Update-Project.ps1` records the branch `origin/HEAD` names as the `default_branch` answer when the answers have none (the template's ADR-0060). So point it where the project's own `origin/HEAD` points, which the update step reads: `$default = "$(git symbolic-ref --quiet --short refs/remotes/origin/HEAD 2>$null)".Trim() -replace '^origin/', ''`, then `if ($default) { git -C $scratch\project symbolic-ref refs/remotes/origin/HEAD "refs/remotes/origin/$default" } else { git -C $scratch\project remote set-head origin --delete }`. Its `origin` is the project's folder too, where the update finds no GitHub repository. The update step reads the project's own `origin`, and in a GitHub project prints notes written for that repository, such as the last one, which names `tools/Set-RepositoryBaseline.ps1 -Repo <owner>/<name>`, and reads its visibility from GitHub. So point the clone's `origin` at the project's own as well: `$origin = "$(git remote get-url origin 2>$null)".Trim()`, then `if ($origin) { git -C $scratch\project remote set-url origin $origin }`. Run the clone's update script with the target, adding `-Data @{ <answer> = <value> }` for the answers the request changes: `& $scratch\project\.template\Update-Project.ps1 -Ref <tag> -NoCommit -TemplateClone $scratch\template *>&1 | Tee-Object $scratch\trial.txt`. Run it with `&`, not `pwsh -File`, which can't pass `-Data`. `-TemplateClone` has it read the clone from step 1 instead of cloning `_src_path` itself, which an older update script can't do when `_src_path` names a folder that isn't on this PC; the target's script, which the update hands over to, then moves `_src_path` to the clone's address, and the trial's output says so. From its output, record each file under `Template <from> -> <to>:` with its kind, each conflict, the files under `Local edits discarded` and `Restored`, and each project-owned file the template changed, with its diff. Then, in the clone, run the project's `build_command` and each check its `AGENTS.md` names, such as a lint or customization check, and record each failure.
3. **Project files that describe the old template.** The template owns each file it renders, except those its `copier.yml` lists under `_skip_if_exists`, which are the project's, and `_merged_files`, which updates merge. A merged or template-owned file that the project's `project_owned_files` answer in `.copier-answers.yml` names is the project's too: updates leave it alone, and the trial shows the template's change to it with the project-owned files. List the files it renders with `git -C $scratch\template ls-tree -r --name-only <tag> -- template/`, named as `Update-Project.ps1` names them: without `template/`, without each Jinja tag and without a `.jinja` suffix. Every other tracked file is the project's own, and so is each `_skip_if_exists` file. For each change from step 1, search the project's own files, such as `AGENTS.md`, `README.md`, `CONTRIBUTING.md`, `CHANGELOG.md`, ADRs, `.claude/rules/`, project instruction files and the project's own scripts, such as a `build/*.ps1` wrapper that runs a check a template script now runs (a command in it that runs the check, such as `dotnet csharpier check .`, not a comment, comment-based help or a string that only names the check), for text or code that still describes or repeats the old behavior, and plan its exact replacement. Leave text that records history, such as a past changelog entry, as it is. For each project-owned file the trial showed a template change for, decide which of its hunks the project takes, and plan them the same way. Also search the project's own tooling, meaning its scripts, generators, checks and CI, hook and release helpers but not the product's code or its stack's toolchain, for a language that ADR-0021 in the target's `docs/decisions/project-template/` doesn't list, such as a `*.py` script, a `requirements.txt` or `pyproject.toml` that serves only tooling, or a CI step that runs `pip`, `uv` or `python` for it. Leave a Python program the project runs as it is, such as Copier or pre-commit, and add no step that ports a tool: list each one under `## Follow-ups` as a port to the first language ADR-0021 lists that fits, naming its files.
4. **Steps.** Order the plan's steps this way:
1. The update, titled `Update from project-template <tag>`. Its Change runs `& .\.template\Update-Project.ps1 -Ref <tag> -NoCommit`, with the trial's `-Data`, and quotes the output the trial printed. When step 1 read `_src_path` as another address, the Change first clones the template from that address into a scratch folder outside the repository, `git clone --quiet --no-checkout -- <that address> <scratch folder>`, adds `-TemplateClone <scratch folder>` to the update, as the trial did, and deletes that folder afterwards. Any difference from the trial, such as another file, a conflict the trial didn't have, or a failure, is an escalation: the executor stops, marks the step `[?]` and quotes the difference. When the trial had a conflict, the Change gives each conflicting file's resolved lines and runs `git add <file>` for it. Its Files line lists every file the trial listed, plus `.copier-answers.yml`, which the listing leaves out. A folder whose files the template owns may be listed as `<folder>/`, and this step may list more than three files. `-NoCommit` stages the update instead of committing it, so the step is committed like any other, and the `git status` check before that commit catches any file the trial didn't predict. The update has already staged its changes, deletions included, also when it stops on a conflict, and `git add <path>` fails for a file already staged as deleted (`pathspec did not match`). So the Files line marks each file the trial staged as deleted with `(deleted)`, and the Change ends with: `Commit note: stage with git add -- <the Files not marked (deleted)>; a (deleted) file is already staged, so never run git add on it.` An older target's script that stops on a conflict leaves its deletions unstaged instead, shown as ` D` by `git -C $scratch\project status --porcelain` after the trial: leave such a file unmarked, so the note's `git add` stages its deletion. Its Done-when checks the result, not the output: `if ((Select-String -LiteralPath .copier-answers.yml -Pattern '^_commit: <tag>$' -Quiet) -and -not (git diff --name-only --diff-filter=U) -and -not (git grep -lE '^(<<<<<<<|>>>>>>>) ')) { exit 0 } else { exit 1 }`.
Expand All @@ -207,7 +207,7 @@ Clone into a scratch folder outside the repository, `$scratch = Join-Path ([IO.P
4. When the trial printed `README.md doesn't follow the .NET library layout yet`, one step titled `Bring README.md to the .NET library layout`, after the project-file steps. Its Change runs `./.template/Test-Readme.ps1 -Fix`, which puts the template's header block at the top of a README that has none, the `## Project` block right below a `## Project` heading that has none and the package header block at the top of each package readme that has none, then deletes the old title, description and badge lines the header block replaces, quoting each, keeps the library's own badges, such as a coverage badge, in a centred `<p align="center">` paragraph right below the header block, deletes the `## Project` links the block repeats, keeping the project's own below it, deletes each package readme's old title and the badges its block repeats, keeping the package's own badges on a line right below the block, writes a package readme the trial names as missing, with what the package is for, `## Installation` and an example, and adds or moves `## Installation`, `## Quick start`, `## Usage` and `## Project` into that order, naming for each section the README's own text it takes, so no line of the project's is lost (the template's ADR-0055 and ADR-0061). When a gap is the blank `repository` answer, the update step's `-Data` gets `repository = '<Owner/Name>'`, the project's GitHub repository. Its Done-when runs `$o = @(./.template/Test-Readme.ps1); if (-not $? -or $LASTEXITCODE -or ($o -match '^(Warning: |::warning::)')) { exit 1 } else { exit 0 }`, which also fails on a gap the check only warns about, under GitHub Actions too.
5. The gate, last: the gate `AGENTS.md` names, or else `build_command` and then `test_command`.

When the trial adds `.github/workflows/codeql.yml`, its output says so, with the commands written for `<owner>/<name>`, since the trial's clone has a folder as its origin: the plan writes them for this project's own GitHub repository. The plan's Review checklist then starts with a step for the person, done before the update's pull request can pass, since GitHub refuses the workflow's results while CodeQL's default setup is on and an executor never calls `gh`: list the default setup's languages with `gh api repos/<owner>/<name>/code-scanning/default-setup --jq .languages`, turn the default setup off with `gh api -X PATCH repos/<owner>/<name>/code-scanning/default-setup -f state=not-configured`, and re-run the pull request's failed Analyze jobs. No step of the plan runs either command.
When the trial adds `.github/workflows/codeql.yml`, its output says so, with the commands written for this project's own GitHub repository, which the trial's clone has as its `origin`. The plan's Review checklist then starts with a step for the person, done before the update's pull request can pass, since GitHub refuses the workflow's results while CodeQL's default setup is on and an executor never calls `gh`: list the default setup's languages with `gh api repos/<owner>/<name>/code-scanning/default-setup --jq .languages`, turn the default setup off with `gh api -X PATCH repos/<owner>/<name>/code-scanning/default-setup -f state=not-configured`, and re-run the pull request's failed Analyze jobs. No step of the plan runs either command.

A Done-when that runs a build, a check or the tests tests its exit code, never a line of its output: with stdout and stderr combined, build output can print after the pass line. Use `<command>; if (-not $? -or $LASTEXITCODE) { exit 1 } else { exit 0 }`.
5. **Template gaps.** A trial result the release notes don't explain, a check that fails because of the template, or a workaround the project needs is a gap in the template. File each one yourself, from this session, as an issue in the template's repository, the one `_src_path` names: `gh issue create --repo <owner/repo> --title <title> --body-file <file>`. A gap whose fix waits on other work, such as a template change not merged yet, is a dependent issue: file it as Dependent Issues below says. Every gap issue names this project's repository in the Repositories callout that section describes, since its fix is checked here. Give each issue's URL in your reply and name it under Decisions. Also add this decision: when a step escalates because the update differs from the trial, the orchestrating session files the gap the same way, and the executor never calls `gh`. In the Review checklist, list what can be checked only after the plan's branch is merged, such as a new command or a changed `plan-executor` subagent, which a session loads only when it starts.
Expand Down
Loading
Loading