diff options
| author | Morgan Lunt <morganl@anthropic.com> | 2026-09-23 19:20:24 -0700 |
|---|---|---|
| committer | Morgan Lunt <morganl@anthropic.com> | 2026-09-24 17:50:20 -0700 |
| commit | 9b4e3c21f27766422e43259da71745b863684784 (patch) | |
| tree | f2f31eeb685997f58fe9022f2607240a683117a6 /plugins/code-modernization | |
| parent | cbba09effc7046cf649b78dc4b84e95cf1a64edd (diff) | |
code-modernization: preflight checks that legacy/ is protected from edits
The commands are written never to edit legacy/, but nothing checked
that anything enforced it. Preflight now has a Check 7 that reads,
without changing anything, the project's .claude/settings.json and
.claude/settings.local.json and the user's settings file, and looks for
an Edit deny rule that covers legacy/. The result is a row in
PREFLIGHT.md with the same status marks as the other checks: a green row
names the file and the rule, and a warning prints the settings snippet
to add. The check never edits a settings file and never suggests
loosening one.
The check also says plainly that a permission rule covers the file tools
and the shell commands the CLI recognizes, not a script that
opens the files itself, so a green row is not a guarantee. A read-only
mount, or a sandbox that blocks writes to legacy/, is. The README no
longer says the settings file enforces the invariant: the commands keep
to it by convention and the rule backs that up.
Diffstat (limited to 'plugins/code-modernization')
| -rw-r--r-- | plugins/code-modernization/README.md | 2 | ||||
| -rw-r--r-- | plugins/code-modernization/commands/modernize-preflight.md | 51 |
2 files changed, 51 insertions, 2 deletions
diff --git a/plugins/code-modernization/README.md b/plugins/code-modernization/README.md index 051aa51f..667ba809 100644 --- a/plugins/code-modernization/README.md +++ b/plugins/code-modernization/README.md @@ -85,7 +85,7 @@ Specialist subagents invoked by the commands (or directly): ## Recommended workspace setup -A `.claude/settings.json` in the project you're modernizing enforces the core invariant — never touch `legacy/`, freely edit `analysis/` and `modernized/`: +The commands never edit `legacy/`, by convention. A `.claude/settings.json` in the project you're modernizing backs that up with a deny rule for `legacy/` and allow rules for `analysis/` and `modernized/`; `/code-modernization:modernize-preflight` checks for the deny rule: ```json { diff --git a/plugins/code-modernization/commands/modernize-preflight.md b/plugins/code-modernization/commands/modernize-preflight.md index 0cc1832f..0fcc82e6 100644 --- a/plugins/code-modernization/commands/modernize-preflight.md +++ b/plugins/code-modernization/commands/modernize-preflight.md @@ -31,7 +31,7 @@ tool's Other). Do not print the questions in your reply, and do not answer them yourself. **While you wait, run only checks that do not need the answers.** None of -Checks 1–6 does (Check 6 verifies the scope boundary from the source +Checks 1–7 does (Check 6 verifies the scope boundary from the source *independently* — the human's answer says whether a crossing *matters*, not whether it exists), so run them while the pop-up is open. @@ -195,6 +195,55 @@ boundary crossing: If `$system` really is a standalone repository, one line saying so is the whole check — it is cheap when it does not apply. +## Check 7 — Is `legacy/` protected from edits? + +Every command here is written never to edit `legacy/`, but that is only a +convention until something enforces it. Look for a permission rule that does. +This check is **read-only**: never edit a settings file, and never suggest +loosening a permission. + +Read whichever of these exist: + +- the project's `.claude/settings.json` and `.claude/settings.local.json` +- the user settings: `~/.claude/settings.json`, or the `settings.json` in the + directory named by `CLAUDE_CONFIG_DIR` when that environment variable is set + +In each `permissions.deny` list, look for an `Edit` rule that covers +everything under `legacy/`: `Edit(legacy/**)`, `Edit(./legacy/**)`, +`Edit(**/legacy/**)`, an absolute `Edit(//…/legacy/**)`, `Edit(/legacy/**)` +(project files only — in user settings a leading `/` anchors at `~/.claude`), +or a broader `Edit` deny. A `Write(...)` rule does not count: file writes are +matched through the `Edit` rule. Report only which file holds the rule and the +rule itself — user settings can hold credentials, so quote nothing else from +them. + +The status is ✅ or ⚠️, never ❌, and this check changes no command's verdict: + +- **✅** — a matching deny rule exists. Name the file and the rule. If it is + broader than `legacy/` (a bare `Edit`), say that it also blocks + `analysis/` and `modernized/`, where the commands write. +- **⚠️** — none found, or none of the files exist or parse. Print this + snippet to add to the project's `.claude/settings.json` (merge the entry + into `permissions.deny` if that list is already there): + + ```json + { + "permissions": { + "deny": ["Edit(/legacy/**)"] + } + } + ``` + + Managed (organization) settings are not read here, so say that a rule set + there would not show up in this check. + +Say this plainly on either status, so a green row is not read as a guarantee: +a permission rule covers Claude's file tools and the shell commands Claude +Code recognizes (`sed`, `tee`, redirections such as `> file`), but not a +script or program that opens the files itself. The hard guarantee is +enforced by the operating system instead — a read-only mount of `legacy/`, +or a sandbox that does not let shell commands write there. + ## Report Write `analysis/$system/PREFLIGHT.md`. It **leads with the Answers section |
