From d4981e86b90f08a5aa029cb5cc1f274f6922cc17 Mon Sep 17 00:00:00 2001 From: Morgan Lunt Date: Tue, 15 Sep 2026 15:15:41 -0700 Subject: code-modernization: named arguments and namespaced command names Positional placeholders are zero-based ($0 is the first argument), but every command used $1 for the first one, so arguments arrived shifted: modernize-preflight carddemo java-spring analyzed legacy/java-spring. Each command now declares its arguments in frontmatter (for example `arguments: system module target_stack`) and uses the names. A missing optional argument now expands to an empty string instead of a literal placeholder. Plugin commands resolve only by their namespaced name, so the README, command cross-references, agents, workflow descriptions and the topology viewer now say /code-modernization:modernize-*. The extract-rules workflow is renamed modernize-extract-rules-mine. It shared the command's name, so invoking the command could start the workflow directly and skip the command's instructions. Commands launch workflows by script path, so nothing else changes. --- plugins/code-modernization/README.md | 46 +++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 22 deletions(-) (limited to 'plugins/code-modernization/README.md') diff --git a/plugins/code-modernization/README.md b/plugins/code-modernization/README.md index 2a148875..689dc48a 100644 --- a/plugins/code-modernization/README.md +++ b/plugins/code-modernization/README.md @@ -26,47 +26,49 @@ The discovery commands (`assess`, `map`, `extract-rules`) write artifacts to `an Each command takes a `` and assumes the code lives at `legacy//`. Artifacts land in `analysis//`; new code in `modernized//`. If your code is elsewhere, symlink it: `mkdir -p legacy && ln -s /path/to/code legacy/billing`. +Plugin commands are namespaced, so type the full name — `/code-modernization:modernize-…` (autocomplete finds it from `/modernize`). + Try the first three on your own codebase — each produces a standalone artifact, so you can stop and review at any point: ```bash -/modernize-preflight billing # is my environment ready? -/modernize-assess billing # what am I dealing with? -/modernize-map billing # show me the structure (opens an interactive map) +/code-modernization:modernize-preflight billing # is my environment ready? +/code-modernization:modernize-assess billing # what am I dealing with? +/code-modernization:modernize-map billing # show me the structure (opens an interactive map) ``` Then the full path: ```bash -/modernize-extract-rules billing # mine business rules → testable Rule Cards -/modernize-brief billing java-spring # the plan a steering committee approves (HITL gate) -/modernize-transform billing interest-calc java-spring # …or reimagine, or uplift — see Commands -/modernize-harden billing # security pass on the still-running legacy system -/modernize-status billing # where am I, what's stale, what's next +/code-modernization:modernize-extract-rules billing # mine business rules → testable Rule Cards +/code-modernization:modernize-brief billing java-spring # the plan a steering committee approves (HITL gate) +/code-modernization:modernize-transform billing interest-calc java-spring # …or reimagine, or uplift — see Commands +/code-modernization:modernize-harden billing # security pass on the still-running legacy system +/code-modernization:modernize-status billing # where am I, what's stale, what's next ``` ## Commands Run in order, but each is standalone — stop, review, resume. -- **`/modernize-preflight [target-stack]`** — Environment readiness check. Asks you the five questions the source can't answer (scope, whether you can build and test locally, bespoke build infrastructure, prior attempts, what's off limits), then detects the legacy stack, checks analysis tooling, reads the CI/build definition for how the system builds, smoke-tests the toolchain against the real code, inventories missing includes / deployment descriptors, and checks the **scope boundary** — whether `` is a slice of a larger repo and what outside it depends on it. Produces `PREFLIGHT.md` with a per-command Ready / Ready-with-gaps / Not-ready verdict. +- **`/code-modernization:modernize-preflight [target-stack]`** — Environment readiness check. Asks you the five questions the source can't answer (scope, whether you can build and test locally, bespoke build infrastructure, prior attempts, what's off limits), then detects the legacy stack, checks analysis tooling, reads the CI/build definition for how the system builds, smoke-tests the toolchain against the real code, inventories missing includes / deployment descriptors, and checks the **scope boundary** — whether `` is a slice of a larger repo and what outside it depends on it. Produces `PREFLIGHT.md` with a per-command Ready / Ready-with-gaps / Not-ready verdict. -- **`/modernize-assess `** *(or `--portfolio `)* — Inventory: languages, complexity, tech debt, security posture, and a COCOMO complexity index ([see note](#a-note-on-cocomo)). Produces `ASSESSMENT.md` + `ARCHITECTURE.mmd`. With `--portfolio`, sweeps every subdirectory and writes a sequencing heat-map (`portfolio.html`). +- **`/code-modernization:modernize-assess `** *(or `--portfolio `)* — Inventory: languages, complexity, tech debt, security posture, and a COCOMO complexity index ([see note](#a-note-on-cocomo)). Produces `ASSESSMENT.md` + `ARCHITECTURE.mmd`. With `--portfolio`, sweeps every subdirectory and writes a sequencing heat-map (`portfolio.html`). -- **`/modernize-map `** — Dependency and topology map: call graph, data lineage, entry points, and 2–4 business flows each traced for a persona (the claimant, the auditor). Produces `topology.json` and an **interactive zoomable `TOPOLOGY.html`** (circle-pack sized by LOC, edge toggles, search, and a persona-flow walkthrough), plus small `.mmd` diagrams for docs. +- **`/code-modernization:modernize-map `** — Dependency and topology map: call graph, data lineage, entry points, and 2–4 business flows each traced for a persona (the claimant, the auditor). Produces `topology.json` and an **interactive zoomable `TOPOLOGY.html`** (circle-pack sized by LOC, edge toggles, search, and a persona-flow walkthrough), plus small `.mmd` diagrams for docs. -- **`/modernize-extract-rules [module-pattern]`** — Mine the business rules — calculations, validations, eligibility, state transitions — into Given/When/Then "Rule Cards" with `file:line` citations and confidence ratings. Produces `BUSINESS_RULES.md` + `DATA_OBJECTS.md`. +- **`/code-modernization:modernize-extract-rules [module-pattern]`** — Mine the business rules — calculations, validations, eligibility, state transitions — into Given/When/Then "Rule Cards" with `file:line` citations and confidence ratings. Produces `BUSINESS_RULES.md` + `DATA_OBJECTS.md`. -- **`/modernize-brief [target-stack]`** — Synthesize discovery into a phased **Modernization Brief**: target architecture, phase plan, persona walkthroughs, behavior contract, and an approval block. Reads the discovery artifacts and **stops if any are missing**. Enters plan mode as a human-in-the-loop approval gate. For a same-stack uplift it also requires the **delta catalog**, since an uplift's phase order is decided by its version deltas. The execution commands read the brief and treat each phase's entry criteria as gates, so editing the brief steers execution. +- **`/code-modernization:modernize-brief [target-stack]`** — Synthesize discovery into a phased **Modernization Brief**: target architecture, phase plan, persona walkthroughs, behavior contract, and an approval block. Reads the discovery artifacts and **stops if any are missing**. Enters plan mode as a human-in-the-loop approval gate. For a same-stack uplift it also requires the **delta catalog**, since an uplift's phase order is decided by its version deltas. The execution commands read the brief and treat each phase's entry criteria as gates, so editing the brief steers execution. -- **`/modernize-reimagine `** — Greenfield rebuild from extracted intent. Mines a spec, designs and adversarially reviews a target architecture, then scaffolds services with executable acceptance tests under `modernized/-reimagined/`. Two human checkpoints. +- **`/code-modernization:modernize-reimagine `** — Greenfield rebuild from extracted intent. Mines a spec, designs and adversarially reviews a target architecture, then scaffolds services with executable acceptance tests under `modernized/-reimagined/`. Two human checkpoints. -- **`/modernize-transform `** — Surgical single-module rewrite (strangler-fig: replace one piece while the legacy system keeps running). Plans first (approval gate), writes characterization tests, then an idiomatic implementation, and proves equivalence by running the tests. Produces `TRANSFORMATION_NOTES.md`. +- **`/code-modernization:modernize-transform `** — Surgical single-module rewrite (strangler-fig: replace one piece while the legacy system keeps running). Plans first (approval gate), writes characterization tests, then an idiomatic implementation, and proves equivalence by running the tests. Produces `TRANSFORMATION_NOTES.md`. -- **`/modernize-uplift [project-pattern]`** — Same-stack version bump (e.g. `.NET Framework 4.8` → `.NET 8`, Spring Boot 2 → 3) — the common case `transform` gets wrong by rewriting. Preserves the code and makes the smallest diffs that compile and behave identically, driven by a **delta catalog** (the known breaking changes that *this* code actually hits) and the ecosystem's migration tooling. Equivalence is proven by running the test suite on both the old and new runtime where both can run here (otherwise it falls back to characterization tests, like `transform`). Migration is **pilot-first**: one representative project is migrated end-to-end in-session and its lessons written to a `PLAYBOOK.md` before anything else is touched; the rest then fan out, one agent per project, in **dependency-aware escalating batches behind a circuit breaker**. Produces `DELTA_CATALOG.md`, `BASELINE.md`, `PLAYBOOK.md` + `UPLIFT_NOTES.md`. If the catalog shows most of the code is forced to change, it tells you to use `transform` instead. +- **`/code-modernization:modernize-uplift [project-pattern]`** — Same-stack version bump (e.g. `.NET Framework 4.8` → `.NET 8`, Spring Boot 2 → 3) — the common case `transform` gets wrong by rewriting. Preserves the code and makes the smallest diffs that compile and behave identically, driven by a **delta catalog** (the known breaking changes that *this* code actually hits) and the ecosystem's migration tooling. Equivalence is proven by running the test suite on both the old and new runtime where both can run here (otherwise it falls back to characterization tests, like `transform`). Migration is **pilot-first**: one representative project is migrated end-to-end in-session and its lessons written to a `PLAYBOOK.md` before anything else is touched; the rest then fan out, one agent per project, in **dependency-aware escalating batches behind a circuit breaker**. Produces `DELTA_CATALOG.md`, `BASELINE.md`, `PLAYBOOK.md` + `UPLIFT_NOTES.md`. If the catalog shows most of the code is forced to change, it tells you to use `transform` instead. -- **`/modernize-harden `** — Security pass on the **legacy** system: OWASP/CWE, dependency CVEs, secrets, injection. Produces `SECURITY_FINDINGS.md` (ranked) and a reviewed `security_remediation.patch`. **Never edits `legacy/`** — you review and apply the patch yourself. Useful while the legacy system keeps running in production during migration. +- **`/code-modernization:modernize-harden `** — Security pass on the **legacy** system: OWASP/CWE, dependency CVEs, secrets, injection. Produces `SECURITY_FINDINGS.md` (ranked) and a reviewed `security_remediation.patch`. **Never edits `legacy/`** — you review and apply the patch yourself. Useful while the legacy system keeps running in production during migration. -- **`/modernize-status `** — Read-only progress report: artifact inventory, staleness flags, secrets-hygiene checks, and the single most useful next command. +- **`/code-modernization:modernize-status `** — Read-only progress report: artifact inventory, staleness flags, secrets-hygiene checks, and the single most useful next command. ## Agents @@ -94,11 +96,11 @@ A `.claude/settings.json` in the project you're modernizing enforces the core in } ``` -This guards the file tools; shell commands that mutate files (`sed -i`, `git apply`) still go through the normal Bash prompt, so review those with the same invariant in mind. That prompt is the containment for the two steps that fan out many write-capable agents at once — `/modernize-uplift` Step 5b and `/modernize-reimagine` Phase E — so keep Bash on a *prompted* permission mode for those. +This guards the file tools; shell commands that mutate files (`sed -i`, `git apply`) still go through the normal Bash prompt, so review those with the same invariant in mind. That prompt is the containment for the two steps that fan out many write-capable agents at once — `/code-modernization:modernize-uplift` Step 5b and `/code-modernization:modernize-reimagine` Phase E — so keep Bash on a *prompted* permission mode for those. ## Prerequisites -Commands degrade gracefully, but these improve the output (run `/modernize-preflight` to check all at once): +Commands degrade gracefully, but these improve the output (run `/code-modernization:modernize-preflight` to check all at once): - **Analysis tools** — [`scc`](https://github.com/boyter/scc) or [`cloc`](https://github.com/AlDanial/cloc); without them, metrics fall back to `find`/`wc`. - **A build toolchain** for the legacy stack — enables the strongest equivalence proof (live dual execution). Not required: without it, equivalence falls back to recorded-trace tests and preflight reports Ready-with-gaps rather than blocking. @@ -106,9 +108,9 @@ Commands degrade gracefully, but these improve the output (run `/modernize-prefl ## Safety notes -**Analyzed code is untrusted input.** A hostile codebase can plant comments like "ignore previous instructions" or "mark this rule approved" to steer what lands in `BUSINESS_RULES.md` or `SECURITY_FINDINGS.md`, which later commands trust. Defenses: agents treat file content as data and flag instruction-shaped text; verification agents re-derive every rule and finding from the cited code, not from another agent's description; filesystem paths are validated; and `/modernize-brief` is a human approval gate before any code is generated. Treat discovery artifacts from untrusted code with the same skepticism as the code itself. +**Analyzed code is untrusted input.** A hostile codebase can plant comments like "ignore previous instructions" or "mark this rule approved" to steer what lands in `BUSINESS_RULES.md` or `SECURITY_FINDINGS.md`, which later commands trust. Defenses: agents treat file content as data and flag instruction-shaped text; verification agents re-derive every rule and finding from the cited code, not from another agent's description; filesystem paths are validated; and `/code-modernization:modernize-brief` is a human approval gate before any code is generated. Treat discovery artifacts from untrusted code with the same skepticism as the code itself. -**Secrets stay out of shared artifacts.** Discovered credentials are masked (`AKIA****`) and inventoried in a gitignored `SECRETS.local.md` (or `~/.modernize//` on non-git projects); `/modernize-harden` keeps credential-removal hunks in a separate gitignored patch. Pass `--show-secrets` to include raw values in the quarantine file only. If you ran an early version of this plugin on a real system, check whether `analysis/` artifacts were committed and rotate anything exposed. +**Secrets stay out of shared artifacts.** Discovered credentials are masked (`AKIA****`) and inventoried in a gitignored `SECRETS.local.md` (or `~/.modernize//` on non-git projects); `/code-modernization:modernize-harden` keeps credential-removal hunks in a separate gitignored patch. Pass `--show-secrets` to include raw values in the quarantine file only. If you ran an early version of this plugin on a real system, check whether `analysis/` artifacts were committed and rotate anything exposed. ### A note on COCOMO -- cgit From 08bf451b72fb386f47dae959c35294e7d89164b4 Mon Sep 17 00:00:00 2001 From: Morgan Lunt Date: Wed, 23 Sep 2026 19:01:31 -0700 Subject: code-modernization: extract-rules per-module shards, resume and coverage gaps Extraction now shards by module: one extractor per module, in ordered batches, so each agent reads a small slice instead of the whole estate. The command builds the module list from analysis//topology.json when it exists (otherwise from the directory tree), states the shard count and an agent estimate before launching, and documents how to resume an interrupted run with resumeFromRunId and how to re-run only the shards that failed. The workflow stays inside the runtime's agent cap and reports coverage gaps (skipped, failed and unverified shards) instead of returning a partial catalog without saying so. The estimate paragraph carries what was observed on a 44-program, 30,000-line system: 466 to 647 agents, about 8.8M tokens, 50 to 80 minutes. Module-mode extractors cite paths relative to legacy//, like the lens-mode extractors. --- plugins/code-modernization/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'plugins/code-modernization/README.md') diff --git a/plugins/code-modernization/README.md b/plugins/code-modernization/README.md index 689dc48a..10772019 100644 --- a/plugins/code-modernization/README.md +++ b/plugins/code-modernization/README.md @@ -56,7 +56,7 @@ Run in order, but each is standalone — stop, review, resume. - **`/code-modernization:modernize-map `** — Dependency and topology map: call graph, data lineage, entry points, and 2–4 business flows each traced for a persona (the claimant, the auditor). Produces `topology.json` and an **interactive zoomable `TOPOLOGY.html`** (circle-pack sized by LOC, edge toggles, search, and a persona-flow walkthrough), plus small `.mmd` diagrams for docs. -- **`/code-modernization:modernize-extract-rules [module-pattern]`** — Mine the business rules — calculations, validations, eligibility, state transitions — into Given/When/Then "Rule Cards" with `file:line` citations and confidence ratings. Produces `BUSINESS_RULES.md` + `DATA_OBJECTS.md`. +- **`/code-modernization:modernize-extract-rules [module-pattern]`** — Mine the business rules — calculations, validations, eligibility, state transitions — into Given/When/Then "Rule Cards" with `file:line` citations and confidence ratings. With the Workflow tool, anything but a tiny system is extracted in per-module shards (from `map`'s `topology.json` if present, else the directory tree), so each extractor reads one focused slice. Produces `BUSINESS_RULES.md` + `DATA_OBJECTS.md`. - **`/code-modernization:modernize-brief [target-stack]`** — Synthesize discovery into a phased **Modernization Brief**: target architecture, phase plan, persona walkthroughs, behavior contract, and an approval block. Reads the discovery artifacts and **stops if any are missing**. Enters plan mode as a human-in-the-loop approval gate. For a same-stack uplift it also requires the **delta catalog**, since an uplift's phase order is decided by its version deltas. The execution commands read the brief and treat each phase's entry criteria as gates, so editing the brief steers execution. @@ -118,7 +118,7 @@ Commands degrade gracefully, but these improve the output (run `/code-modernizat ## Dynamic workflow orchestration -On Claude Code builds with the Workflow tool, five commands (`extract-rules`, `harden`, `assess --portfolio`, `reimagine`, `uplift`) run as scripted multi-agent orchestrations that fan out more agents for deeper coverage — looping until findings stabilize, and adversarially verifying each finding before it's written. `uplift`'s migration fan-out runs in dependency-aware escalating batches behind a per-batch **circuit breaker**, so a playbook that stops working is caught within a handful of agents and the spend stops until it is revised. They fall back to direct subagent fan-out on older builds automatically; no configuration needed. Invoking the slash command is the opt-in. +On Claude Code builds with the Workflow tool, five commands (`extract-rules`, `harden`, `assess --portfolio`, `reimagine`, `uplift`) run as scripted multi-agent orchestrations that fan out more agents for deeper coverage — looping until findings stabilize, and adversarially verifying each finding before it's written. `uplift`'s migration fan-out runs in dependency-aware escalating batches behind a per-batch **circuit breaker**, so a playbook that stops working is caught within a handful of agents and the spend stops until it is revised. A stopped or failed `extract-rules` (or `assess --portfolio`) run is **resumable** in the same session: the command re-runs the workflow with the run's ID, and every agent that finished before the stop replays from the run's journal instead of running again. Shards whose agents failed outright are reported and re-run on their own in a follow-up run. They fall back to direct subagent fan-out on older builds automatically; no configuration needed. Invoking the slash command is the opt-in. ## License -- cgit From 7c4583e465e15becca5568aeaa1c0c733e4dd88c Mon Sep 17 00:00:00 2001 From: Morgan Lunt Date: Wed, 23 Sep 2026 18:58:51 -0700 Subject: code-modernization: preflight asks its questions in a pop-up and proves the target stack The five Check 0 questions were left to the model to ask in chat, where they were easy to skip, paraphrase or answer on the person's behalf. They are now asked with AskUserQuestion, questions 1-4 in one call and the fifth in a second, each with a "Don't know" option and room for free text, and never in chat text. Checks that do not depend on the answers may run while the pop-up is open, and a question that is never answered still lands in the report as an open item. Every answer is recorded verbatim in an Answers section of PREFLIGHT.md, which the brief reads. The command declared a target_stack argument but never used it. Check 3b now builds a throwaway project on the target stack (restore, build, one passing test) so a target that installs but cannot build here is caught before transform or uplift starts. --- plugins/code-modernization/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins/code-modernization/README.md') diff --git a/plugins/code-modernization/README.md b/plugins/code-modernization/README.md index 10772019..21c42657 100644 --- a/plugins/code-modernization/README.md +++ b/plugins/code-modernization/README.md @@ -50,7 +50,7 @@ Then the full path: Run in order, but each is standalone — stop, review, resume. -- **`/code-modernization:modernize-preflight [target-stack]`** — Environment readiness check. Asks you the five questions the source can't answer (scope, whether you can build and test locally, bespoke build infrastructure, prior attempts, what's off limits), then detects the legacy stack, checks analysis tooling, reads the CI/build definition for how the system builds, smoke-tests the toolchain against the real code, inventories missing includes / deployment descriptors, and checks the **scope boundary** — whether `` is a slice of a larger repo and what outside it depends on it. Produces `PREFLIGHT.md` with a per-command Ready / Ready-with-gaps / Not-ready verdict. +- **`/code-modernization:modernize-preflight [target-stack]`** — Environment readiness check. Asks you, in a pop-up, the five questions the source can't answer (scope, whether you can build and test locally, bespoke build infrastructure, prior attempts, what's off limits) and records your answers verbatim. Then it detects the legacy stack, checks analysis tooling, reads the CI/build definition, smoke-tests the toolchain against the real code (and, if you name a target stack, that a throwaway project builds on it here), inventories missing includes / deployment descriptors, and checks the **scope boundary** — whether `` is a slice of a larger repo and what outside it depends on it. Produces `PREFLIGHT.md` with a per-command Ready / Ready-with-gaps / Not-ready verdict. - **`/code-modernization:modernize-assess `** *(or `--portfolio `)* — Inventory: languages, complexity, tech debt, security posture, and a COCOMO complexity index ([see note](#a-note-on-cocomo)). Produces `ASSESSMENT.md` + `ARCHITECTURE.mmd`. With `--portfolio`, sweeps every subdirectory and writes a sequencing heat-map (`portfolio.html`). -- cgit From 2ce9d0dace1239bec65379ecd3834258574c9073 Mon Sep 17 00:00:00 2001 From: Morgan Lunt Date: Wed, 23 Sep 2026 19:03:15 -0700 Subject: code-modernization: describe each node on the topology map After topology.json is built, map now writes one paragraph (55 to 90 words) per node into a description field: what the node does in business terms, then what it calls, reads, writes or is called by. Each writer gets only that node's source excerpt, header comment and connections from the map, is told every name and number must come from that data, and says so in one sentence when the data is thin. The session checks the paragraphs against those packets before merging them, and writers never write files. Writers run in parallel batches of about 8, and --no-describe skips the step. The viewer's sidebar shows the description under the size and language line with a muted caption, inserted as text rather than markup because it is derived from analyzed source. Nodes without a description, and topology.json files written before this change, render exactly as before. --- plugins/code-modernization/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'plugins/code-modernization/README.md') diff --git a/plugins/code-modernization/README.md b/plugins/code-modernization/README.md index 21c42657..6cf66ad5 100644 --- a/plugins/code-modernization/README.md +++ b/plugins/code-modernization/README.md @@ -54,7 +54,7 @@ Run in order, but each is standalone — stop, review, resume. - **`/code-modernization:modernize-assess `** *(or `--portfolio `)* — Inventory: languages, complexity, tech debt, security posture, and a COCOMO complexity index ([see note](#a-note-on-cocomo)). Produces `ASSESSMENT.md` + `ARCHITECTURE.mmd`. With `--portfolio`, sweeps every subdirectory and writes a sequencing heat-map (`portfolio.html`). -- **`/code-modernization:modernize-map `** — Dependency and topology map: call graph, data lineage, entry points, and 2–4 business flows each traced for a persona (the claimant, the auditor). Produces `topology.json` and an **interactive zoomable `TOPOLOGY.html`** (circle-pack sized by LOC, edge toggles, search, and a persona-flow walkthrough), plus small `.mmd` diagrams for docs. +- **`/code-modernization:modernize-map [--no-describe]`** — Dependency and topology map: call graph, data lineage, entry points, and 2–4 business flows each traced for a persona (the claimant, the auditor). Produces `topology.json` and an **interactive zoomable `TOPOLOGY.html`** (circle-pack sized by LOC, edge toggles, search, and a persona-flow walkthrough), plus small `.mmd` diagrams for docs. Each node also gets a short plain-language description in the sidebar, written by one agent per node from just that node's source and links; `--no-describe` skips that step. - **`/code-modernization:modernize-extract-rules [module-pattern]`** — Mine the business rules — calculations, validations, eligibility, state transitions — into Given/When/Then "Rule Cards" with `file:line` citations and confidence ratings. With the Workflow tool, anything but a tiny system is extracted in per-module shards (from `map`'s `topology.json` if present, else the directory tree), so each extractor reads one focused slice. Produces `BUSINESS_RULES.md` + `DATA_OBJECTS.md`. @@ -74,7 +74,7 @@ Run in order, but each is standalone — stop, review, resume. Specialist subagents invoked by the commands (or directly): -- **`legacy-analyst`** — Reads legacy code (COBOL, EJB, classic ASP, …) and produces structural summaries; spots implicit dependencies and "JOBOL" (procedural code in modern syntax). *(assess, reimagine, uplift)* +- **`legacy-analyst`** — Reads legacy code (COBOL, EJB, classic ASP, …) and produces structural summaries; spots implicit dependencies and "JOBOL" (procedural code in modern syntax). *(assess, map, extract-rules, reimagine)* - **`business-rules-extractor`** — Mines domain rules from procedural code with source citations. *(extract-rules, reimagine)* - **`architecture-critic`** — Skeptical reviewer of target designs and transformed code; flags over-engineering. *(reimagine, transform, uplift)* - **`security-auditor`** — Auth, input validation, secrets, dependency CVEs. *(assess, harden)* -- cgit From d7e3a90d48eba9c31733cfd530e35a5560611dc7 Mon Sep 17 00:00:00 2001 From: Morgan Lunt Date: Wed, 23 Sep 2026 19:03:35 -0700 Subject: code-modernization: put flags after the positional arguments assess and harden said --show-secrets could appear anywhere and that the system dir was the first non-flag token. Since the commands declare named arguments, $system is filled with the first token, so "--show-secrets carddemo" puts legacy/--show-secrets into every path template, and harden's workflow rejects a system name that starts with a dash. The old rule contradicted how the arguments bind. The usage text now says flags go after the positional arguments, and the README shows --show-secrets in that position on the assess and harden usage lines. assess --portfolio keeps its mode flag first. No parsing logic is added. A flag-first invocation now gets a request to run again in the right order, where a model used to work out the intent on its own. --- plugins/code-modernization/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'plugins/code-modernization/README.md') diff --git a/plugins/code-modernization/README.md b/plugins/code-modernization/README.md index 6cf66ad5..32f6c476 100644 --- a/plugins/code-modernization/README.md +++ b/plugins/code-modernization/README.md @@ -26,7 +26,7 @@ The discovery commands (`assess`, `map`, `extract-rules`) write artifacts to `an Each command takes a `` and assumes the code lives at `legacy//`. Artifacts land in `analysis//`; new code in `modernized//`. If your code is elsewhere, symlink it: `mkdir -p legacy && ln -s /path/to/code legacy/billing`. -Plugin commands are namespaced, so type the full name — `/code-modernization:modernize-…` (autocomplete finds it from `/modernize`). +Plugin commands are namespaced, so type the full name — `/code-modernization:modernize-…` (autocomplete finds it from `/modernize`). Flags go after the positional arguments (`/code-modernization:modernize-harden billing --show-secrets`): the first argument is the system directory, except for `assess --portfolio`, whose mode flag comes first. Try the first three on your own codebase — each produces a standalone artifact, so you can stop and review at any point: @@ -52,7 +52,7 @@ Run in order, but each is standalone — stop, review, resume. - **`/code-modernization:modernize-preflight [target-stack]`** — Environment readiness check. Asks you, in a pop-up, the five questions the source can't answer (scope, whether you can build and test locally, bespoke build infrastructure, prior attempts, what's off limits) and records your answers verbatim. Then it detects the legacy stack, checks analysis tooling, reads the CI/build definition, smoke-tests the toolchain against the real code (and, if you name a target stack, that a throwaway project builds on it here), inventories missing includes / deployment descriptors, and checks the **scope boundary** — whether `` is a slice of a larger repo and what outside it depends on it. Produces `PREFLIGHT.md` with a per-command Ready / Ready-with-gaps / Not-ready verdict. -- **`/code-modernization:modernize-assess `** *(or `--portfolio `)* — Inventory: languages, complexity, tech debt, security posture, and a COCOMO complexity index ([see note](#a-note-on-cocomo)). Produces `ASSESSMENT.md` + `ARCHITECTURE.mmd`. With `--portfolio`, sweeps every subdirectory and writes a sequencing heat-map (`portfolio.html`). +- **`/code-modernization:modernize-assess [--show-secrets]`** *(or `--portfolio `)* — Inventory: languages, complexity, tech debt, security posture, and a COCOMO complexity index ([see note](#a-note-on-cocomo)). Produces `ASSESSMENT.md` + `ARCHITECTURE.mmd`. With `--portfolio`, sweeps every subdirectory and writes a sequencing heat-map (`portfolio.html`). - **`/code-modernization:modernize-map [--no-describe]`** — Dependency and topology map: call graph, data lineage, entry points, and 2–4 business flows each traced for a persona (the claimant, the auditor). Produces `topology.json` and an **interactive zoomable `TOPOLOGY.html`** (circle-pack sized by LOC, edge toggles, search, and a persona-flow walkthrough), plus small `.mmd` diagrams for docs. Each node also gets a short plain-language description in the sidebar, written by one agent per node from just that node's source and links; `--no-describe` skips that step. @@ -66,7 +66,7 @@ Run in order, but each is standalone — stop, review, resume. - **`/code-modernization:modernize-uplift [project-pattern]`** — Same-stack version bump (e.g. `.NET Framework 4.8` → `.NET 8`, Spring Boot 2 → 3) — the common case `transform` gets wrong by rewriting. Preserves the code and makes the smallest diffs that compile and behave identically, driven by a **delta catalog** (the known breaking changes that *this* code actually hits) and the ecosystem's migration tooling. Equivalence is proven by running the test suite on both the old and new runtime where both can run here (otherwise it falls back to characterization tests, like `transform`). Migration is **pilot-first**: one representative project is migrated end-to-end in-session and its lessons written to a `PLAYBOOK.md` before anything else is touched; the rest then fan out, one agent per project, in **dependency-aware escalating batches behind a circuit breaker**. Produces `DELTA_CATALOG.md`, `BASELINE.md`, `PLAYBOOK.md` + `UPLIFT_NOTES.md`. If the catalog shows most of the code is forced to change, it tells you to use `transform` instead. -- **`/code-modernization:modernize-harden `** — Security pass on the **legacy** system: OWASP/CWE, dependency CVEs, secrets, injection. Produces `SECURITY_FINDINGS.md` (ranked) and a reviewed `security_remediation.patch`. **Never edits `legacy/`** — you review and apply the patch yourself. Useful while the legacy system keeps running in production during migration. +- **`/code-modernization:modernize-harden [--show-secrets]`** — Security pass on the **legacy** system: OWASP/CWE, dependency CVEs, secrets, injection. Produces `SECURITY_FINDINGS.md` (ranked) and a reviewed `security_remediation.patch`. **Never edits `legacy/`** — you review and apply the patch yourself. Useful while the legacy system keeps running in production during migration. - **`/code-modernization:modernize-status `** — Read-only progress report: artifact inventory, staleness flags, secrets-hygiene checks, and the single most useful next command. -- cgit From 5a8191cd213bd4f4b2a0dd237d450aed029d2752 Mon Sep 17 00:00:00 2001 From: Morgan Lunt Date: Wed, 23 Sep 2026 19:04:04 -0700 Subject: code-modernization: docs accuracy (permission rules, plan mode, marketplace) The README recommended Write(path) permission rules. File permissions are checked against Edit(path) rules only, so the Write rules were accepted but never consulted. The recommended settings now use Edit(analysis/**) and Edit(modernized/**) allow rules and an Edit(/legacy/**) deny rule, with a line saying that file writes are matched through the Edit rule. The deny rule is anchored at the project root, because an unanchored one also matches any nested directory named legacy. It refuses a cp out of legacy/ as well, so the README gives rsync -a for uplift's working copy, and says a symlinked legacy tree needs additionalDirectories and a deny on its real path. The list of shell commands that bypass the file rules drops sed -i (the deny rule does cover sed, tee and redirections) and keeps git apply and scripts. The README said brief enters plan mode; the command says to use plan mode if the session supports it. The README now says the same. The marketplace description predated same-stack uplift. It now lists uplift and mentions version uplifts such as .NET Framework to .NET 8. --- plugins/code-modernization/README.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'plugins/code-modernization/README.md') diff --git a/plugins/code-modernization/README.md b/plugins/code-modernization/README.md index 32f6c476..051aa51f 100644 --- a/plugins/code-modernization/README.md +++ b/plugins/code-modernization/README.md @@ -58,7 +58,7 @@ Run in order, but each is standalone — stop, review, resume. - **`/code-modernization:modernize-extract-rules [module-pattern]`** — Mine the business rules — calculations, validations, eligibility, state transitions — into Given/When/Then "Rule Cards" with `file:line` citations and confidence ratings. With the Workflow tool, anything but a tiny system is extracted in per-module shards (from `map`'s `topology.json` if present, else the directory tree), so each extractor reads one focused slice. Produces `BUSINESS_RULES.md` + `DATA_OBJECTS.md`. -- **`/code-modernization:modernize-brief [target-stack]`** — Synthesize discovery into a phased **Modernization Brief**: target architecture, phase plan, persona walkthroughs, behavior contract, and an approval block. Reads the discovery artifacts and **stops if any are missing**. Enters plan mode as a human-in-the-loop approval gate. For a same-stack uplift it also requires the **delta catalog**, since an uplift's phase order is decided by its version deltas. The execution commands read the brief and treat each phase's entry criteria as gates, so editing the brief steers execution. +- **`/code-modernization:modernize-brief [target-stack]`** — Synthesize discovery into a phased **Modernization Brief**: target architecture, phase plan, persona walkthroughs, behavior contract, and an approval block. Reads the discovery artifacts and **stops if any are missing**. Stops for your explicit approval as a human-in-the-loop gate, in plan mode if the session supports it. For a same-stack uplift it also requires the **delta catalog**, since an uplift's phase order is decided by its version deltas. The execution commands read the brief and treat each phase's entry criteria as gates, so editing the brief steers execution. - **`/code-modernization:modernize-reimagine `** — Greenfield rebuild from extracted intent. Mines a spec, designs and adversarially reviews a target architecture, then scaffolds services with executable acceptance tests under `modernized/-reimagined/`. Two human checkpoints. @@ -90,13 +90,17 @@ A `.claude/settings.json` in the project you're modernizing enforces the core in ```json { "permissions": { - "allow": ["Read(**)", "Write(analysis/**)", "Write(modernized/**)", "Edit(analysis/**)", "Edit(modernized/**)"], - "deny": ["Edit(legacy/**)", "Write(legacy/**)"] + "allow": ["Read(**)", "Edit(analysis/**)", "Edit(modernized/**)"], + "deny": ["Edit(/legacy/**)"] } } ``` -This guards the file tools; shell commands that mutate files (`sed -i`, `git apply`) still go through the normal Bash prompt, so review those with the same invariant in mind. That prompt is the containment for the two steps that fan out many write-capable agents at once — `/code-modernization:modernize-uplift` Step 5b and `/code-modernization:modernize-reimagine` Phase E — so keep Bash on a *prompted* permission mode for those. +Claude Code matches file writes through the `Edit` rule, so these cover the `Write` tool too; a `Write(path)` rule is accepted but never consulted. + +The deny rule starts with `/` so that it is anchored at the project root; without the slash it also matches any nested directory named `legacy`, such as `modernized//.../legacy/`. It refuses a copy out of `legacy/` too, so `uplift`'s working copy (`cp -r legacy/ modernized/-uplifted`) needs `rsync -a legacy// modernized/-uplifted/` instead, or a copy you run yourself. If `legacy/` is a symlink to a directory outside the project, add that directory to `additionalDirectories` so Claude can read through the link, and deny its real path as well, because the rule above matches the link's path and not its target's: `"additionalDirectories": ["/path/to/code"]` and `"Edit(//path/to/code/**)"` in `deny`. + +This guards the file tools; shell commands that mutate files (`git apply`, a script that opens files itself) still go through the normal Bash prompt, so review those with the same invariant in mind. That prompt is the containment for the two steps that fan out many write-capable agents at once — `/code-modernization:modernize-uplift` Step 5b and `/code-modernization:modernize-reimagine` Phase E — so keep Bash on a *prompted* permission mode for those. ## Prerequisites -- cgit From 9b4e3c21f27766422e43259da71745b863684784 Mon Sep 17 00:00:00 2001 From: Morgan Lunt Date: Wed, 23 Sep 2026 19:20:24 -0700 Subject: 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. --- plugins/code-modernization/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins/code-modernization/README.md') 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 { -- cgit From 6f020b9f66a1340efeab2fd4ca7a17f348e3fea9 Mon Sep 17 00:00:00 2001 From: Morgan Lunt Date: Wed, 23 Sep 2026 19:22:33 -0700 Subject: code-modernization: README section on teams, adapting the plugin and what it has been tried on Adds one section to the README for the questions a team asks before adopting the plugin. It says who owns which directory and which artifact suits which reviewer, taken from what each command says the artifact contains, and that state lives in files so a second person or a fresh session can pick up with modernize-status. It notes that preflight and assess write their reports under analysis/ (with two side effects: preflight's smoke test builds one small project with the system's own tools, and a non-git project's credential inventory goes to ~/.modernize/), that the commands, agents and workflows are plain markdown and JavaScript that can be forked, and that extraction is model-driven, so BUSINESS_RULES.md is reviewed output rather than a deterministic build artifact. It also lists the prerequisites (accept-edits mode or the allow rules, and a toolchain for the target stack) and says that the one example the README shows is AWS CardDemo, so stacks without an example should expect to adapt the prompts. --- plugins/code-modernization/README.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'plugins/code-modernization/README.md') diff --git a/plugins/code-modernization/README.md b/plugins/code-modernization/README.md index 667ba809..54b22fda 100644 --- a/plugins/code-modernization/README.md +++ b/plugins/code-modernization/README.md @@ -120,6 +120,31 @@ Commands degrade gracefully, but these improve the output (run `/code-modernizat `assess` derives a COCOMO figure from code size and uses it **only as a relative complexity/scale index** to rank and sequence systems — never as a timeline or cost. COCOMO's constants encode human-team productivity, which agentic transformation doesn't follow, so any duration derived from it would be wrong. +## Teams, adapting it, and what it has been tried on + +**Who owns what.** `legacy/` stays read-only: by convention, backed by the permission rule in [Recommended workspace setup](#recommended-workspace-setup). `analysis//` holds outputs a named person should review, not facts; `modernized/` is code and gets ordinary code review. The commands never commit, so commit both yourself; `assess` and `harden` keep the credential inventory and the credential patch out of git through `analysis/.gitignore`. Suggested reviewers, from what each artifact contains (the commands stop for a human at several gates but never check who that is): + +| Artifact | Contains | Suggested reviewer | +| --- | --- | --- | +| `PREFLIGHT.md` | the five answers only a person can give, the scope-boundary finding, tool and build checks | whoever owns the build | +| `ASSESSMENT.md` | inventory, technical debt, security posture, relative scale, recommended pattern | the engineering lead or sponsor | +| `topology.json`, `TOPOLOGY.html` | call graph, data lineage, persona flows | engineers who know the system | +| `BUSINESS_RULES.md` | Rule Cards with citations, priority and confidence, and a closing list of questions for experts | a business expert per domain; start with the P0 rules and that list | +| `MODERNIZATION_BRIEF.md` | phases, entry and exit criteria, behavior contract, approval block | the approver, who steers execution by editing it | +| `SECURITY_FINDINGS.md`, the patch | ranked findings, a reviewed remediation patch | a security engineer, who applies the patch | + +State lives in files, not in chat: later commands read the brief's criteria and the answers in `PREFLIGHT.md`, not your conversation, so a second person or a fresh session can run `/code-modernization:modernize-status ` and continue from the next command it names. + +**Trying it on a live repository.** `preflight` and `assess` write their reports under `analysis/` and change no source file. Two side effects: preflight's smoke test compiles one file and, where the system has a build system, restores and builds one small project or module with it; that writes build output (and, for some tools, updates lockfiles) wherever the build normally does, possibly inside `legacy/`, and outside a git repository `assess` writes any credential inventory to `~/.modernize//`. + +**Adapting it.** Commands, agents and workflows are plain markdown and JavaScript under Apache 2.0. Fork it to change the prompts, the gates or the steps for your stack. + +**Repeatability.** A model does the extraction, so two runs of `extract-rules` on the same estate, or on different models, can find different rules and number them differently. Treat `BUSINESS_RULES.md` as reviewed output, not a deterministic build artifact. Headings are always `### RULE-NNN: `, so later steps can find rules whichever run wrote them. The verification steps and the closing question list help a person review what was found; they do not make two runs identical. + +**Permissions and toolchain.** The commands write files, so a session that asks before every edit keeps stopping: use accept-edits mode or the allow rules in Recommended workspace setup. Shell commands still ask, even in accept-edits mode: `git check-ignore`, `python3` scripts, analysis tools such as `scc`, `cp -r`, and the build and test commands of your stacks, and so does anything outside the project, such as `~/.modernize/`. Writes to sensitive paths such as `.git/`, `.mvn/` and `.npmrc` ask even with an allow rule. `transform`, `reimagine` and `uplift` also need a toolchain that builds and tests the target stack; `preflight` checks it when you name one. + +**What it has been tried on.** The one example in this README, the map at the top, is AWS CardDemo, a public COBOL, CICS and JCL sample. Any other stack goes through the same generic path (`preflight` detects it from file extensions and manifests), but nothing in this plugin shows one being run, so expect to adapt. + ## Dynamic workflow orchestration On Claude Code builds with the Workflow tool, five commands (`extract-rules`, `harden`, `assess --portfolio`, `reimagine`, `uplift`) run as scripted multi-agent orchestrations that fan out more agents for deeper coverage — looping until findings stabilize, and adversarially verifying each finding before it's written. `uplift`'s migration fan-out runs in dependency-aware escalating batches behind a per-batch **circuit breaker**, so a playbook that stops working is caught within a handful of agents and the spend stops until it is revised. A stopped or failed `extract-rules` (or `assess --portfolio`) run is **resumable** in the same session: the command re-runs the workflow with the run's ID, and every agent that finished before the stop replays from the run's journal instead of running again. Shards whose agents failed outright are reported and re-run on their own in a follow-up run. They fall back to direct subagent fan-out on older builds automatically; no configuration needed. Invoking the slash command is the opt-in. -- cgit From d13ff0324cf9a8744be6c75251689816485e68cf Mon Sep 17 00:00:00 2001 From: Morgan Lunt Date: Wed, 23 Sep 2026 19:52:43 -0700 Subject: code-modernization: extract-rules asks before a large run, with an estimate The command told the model to state the shard count and an estimate before launching, but in live runs on a small system it launched without saying anything: a reply that only mentions the estimate is easy to skip and is not a gate. With more than 12 shards the command now requires an AskUserQuestion that carries the shard count, the line count and the estimate (agents, tokens, minutes) and offers to run all shards, run only a slice, or cancel. With 12 shards or fewer it launches straight away and says what it launched. The estimate is now a working formula (10 to 15 agents per shard, about 16k tokens per agent, about 8 agents finishing per minute) with the two runs it comes from: 4 shards used 58 agents in under 10 minutes, and a 44-program, 30,000-line estate used 466 to 647 agents. --- plugins/code-modernization/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins/code-modernization/README.md') diff --git a/plugins/code-modernization/README.md b/plugins/code-modernization/README.md index 54b22fda..0ded8668 100644 --- a/plugins/code-modernization/README.md +++ b/plugins/code-modernization/README.md @@ -56,7 +56,7 @@ Run in order, but each is standalone — stop, review, resume. - **`/code-modernization:modernize-map [--no-describe]`** — Dependency and topology map: call graph, data lineage, entry points, and 2–4 business flows each traced for a persona (the claimant, the auditor). Produces `topology.json` and an **interactive zoomable `TOPOLOGY.html`** (circle-pack sized by LOC, edge toggles, search, and a persona-flow walkthrough), plus small `.mmd` diagrams for docs. Each node also gets a short plain-language description in the sidebar, written by one agent per node from just that node's source and links; `--no-describe` skips that step. -- **`/code-modernization:modernize-extract-rules [module-pattern]`** — Mine the business rules — calculations, validations, eligibility, state transitions — into Given/When/Then "Rule Cards" with `file:line` citations and confidence ratings. With the Workflow tool, anything but a tiny system is extracted in per-module shards (from `map`'s `topology.json` if present, else the directory tree), so each extractor reads one focused slice. Produces `BUSINESS_RULES.md` + `DATA_OBJECTS.md`. +- **`/code-modernization:modernize-extract-rules [module-pattern]`** — Mine the business rules — calculations, validations, eligibility, state transitions — into Given/When/Then "Rule Cards" with `file:line` citations and confidence ratings. With the Workflow tool, anything but a tiny system is extracted in per-module shards (from `map`'s `topology.json` if present, else the directory tree), so each extractor reads one focused slice. A large run shows an estimate and asks before it starts. Produces `BUSINESS_RULES.md` + `DATA_OBJECTS.md`. - **`/code-modernization:modernize-brief [target-stack]`** — Synthesize discovery into a phased **Modernization Brief**: target architecture, phase plan, persona walkthroughs, behavior contract, and an approval block. Reads the discovery artifacts and **stops if any are missing**. Stops for your explicit approval as a human-in-the-loop gate, in plan mode if the session supports it. For a same-stack uplift it also requires the **delta catalog**, since an uplift's phase order is decided by its version deltas. The execution commands read the brief and treat each phase's entry criteria as gates, so editing the brief steers execution. -- cgit From 65b0f06f1bd6309b88ca8c3cc92e34d7a4f51f5f Mon Sep 17 00:00:00 2001 From: Morgan Lunt Date: Wed, 23 Sep 2026 22:32:35 -0700 Subject: code-modernization: fix contradictions and stale references in existing text Make the text say what the commands and workflows already do: where each build command writes, which commands need earlier output, the approval stop before an uplift fan-out, a version placeholder that named arguments left unusable, a reference to a README section that does not exist, and a few counts and step references. No new steps or options. --- plugins/code-modernization/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'plugins/code-modernization/README.md') diff --git a/plugins/code-modernization/README.md b/plugins/code-modernization/README.md index 0ded8668..087d5430 100644 --- a/plugins/code-modernization/README.md +++ b/plugins/code-modernization/README.md @@ -8,7 +8,7 @@ It works by enforcing a sequence, because modernization usually fails when teams preflight → assess → map → extract-rules → brief → (reimagine | transform | uplift) → harden ``` -The discovery commands (`assess`, `map`, `extract-rules`) write artifacts to `analysis//`. `brief` synthesizes them into an approval gate. The three build commands write to `modernized//` and are three different *methods* — the brief recommends which one fits: +The discovery commands (`assess`, `map`, `extract-rules`) write artifacts to `analysis//`. `brief` synthesizes them into an approval gate. The three build commands write under `modernized/` (`transform` to `//`, `reimagine` to `-reimagined/`, `uplift` to `-uplifted/`) and are three different *methods* — the brief recommends which one fits: - **`transform`** — cross-stack rewrite from extracted intent (e.g. COBOL → Java). - **`reimagine`** — greenfield rebuild on a new architecture. @@ -24,7 +24,7 @@ The discovery commands (`assess`, `map`, `extract-rules`) write artifacts to `an ## Quickstart -Each command takes a `` and assumes the code lives at `legacy//`. Artifacts land in `analysis//`; new code in `modernized//`. If your code is elsewhere, symlink it: `mkdir -p legacy && ln -s /path/to/code legacy/billing`. +Each command takes a `` and assumes the code lives at `legacy//`. Artifacts land in `analysis//`; new code under `modernized/`. If your code is elsewhere, symlink it: `mkdir -p legacy && ln -s /path/to/code legacy/billing`. Plugin commands are namespaced, so type the full name — `/code-modernization:modernize-…` (autocomplete finds it from `/modernize`). Flags go after the positional arguments (`/code-modernization:modernize-harden billing --show-secrets`): the first argument is the system directory, except for `assess --portfolio`, whose mode flag comes first. @@ -48,7 +48,7 @@ Then the full path: ## Commands -Run in order, but each is standalone — stop, review, resume. +Run in order; you can stop and review after any step. Each command stands alone except `brief`, which needs `assess`, `map` and `extract-rules` first. If a command stops or fails, `/code-modernization:modernize-status ` names the next step; an interrupted `extract-rules` run [can resume](#dynamic-workflow-orchestration). - **`/code-modernization:modernize-preflight [target-stack]`** — Environment readiness check. Asks you, in a pop-up, the five questions the source can't answer (scope, whether you can build and test locally, bespoke build infrastructure, prior attempts, what's off limits) and records your answers verbatim. Then it detects the legacy stack, checks analysis tooling, reads the CI/build definition, smoke-tests the toolchain against the real code (and, if you name a target stack, that a throwaway project builds on it here), inventories missing includes / deployment descriptors, and checks the **scope boundary** — whether `` is a slice of a larger repo and what outside it depends on it. Produces `PREFLIGHT.md` with a per-command Ready / Ready-with-gaps / Not-ready verdict. -- cgit From c9e990089c6c87cb96e227e998edbada1df82861 Mon Sep 17 00:00:00 2001 From: Morgan Lunt Date: Thu, 24 Sep 2026 18:07:14 -0700 Subject: code-modernization: add an optional live progress pane Adds a hooks module, off unless the CLI's early-access function hooks are enabled, that draws a pane beside the transcript while the commands run: the system, which steps are done, a map of its code, each unit of work and where it stands, what needs attention, and the next command. It reads only the artifacts the commands write and the legacy tree, so it works for any language and for a rewrite, a same-stack uplift or a greenfield rebuild. The map comes from topology.json when there is one and from the source tree when there is not. In an uplift each module is set against the baseline; tests are read from JUnit XML, .trx reports or the runs a session sees; a button shows and hides the pane, and /modernize-panel does the same from the keyboard. The same module adds x-ray context on legacy reads, a review deck for business rules (/modernize-review), a sign-off dialog (/modernize-sign) and a fleet view that spots one failure repeating across agents. It only watches: it never blocks, rewrites or restores an edit, and it runs no program inside the trees it reads. An uplift's changed modules are found by comparing the working copy with the tree by file name and size through the file API. Its options are the plugin's userConfig. Without the flag nothing loads and the commands, agents and workflows behave as before. 91 tests in tests/ run with "claude plugin test"; plugin validate passes on the release build with the flag on and off. --- plugins/code-modernization/README.md | 121 +++++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) (limited to 'plugins/code-modernization/README.md') diff --git a/plugins/code-modernization/README.md b/plugins/code-modernization/README.md index 087d5430..96a3c8a6 100644 --- a/plugins/code-modernization/README.md +++ b/plugins/code-modernization/README.md @@ -83,6 +83,127 @@ Specialist subagents invoked by the commands (or directly): - **`uplift-migrator`** — Migrates one project/module of an in-flight uplift by following the pilot's playbook, then runs that unit's real build to prove it; refuses to migrate anything if no playbook exists yet. Writes only inside its own unit's directory. *(uplift)* - **`scaffolder`** — Builds one service of a reimagined system; writes only within its own `modernized/...//` directory. *(reimagine)* +## Live progress pane (early access) + +While the commands run, the plugin can draw a live pane beside the transcript: for a system in any language, what the +commands are doing to it, how far along each part is, and what to run next. It is built on Claude Code's function hooks, +which are early access and off by default. Start with the flag to turn them on: + +```sh +CLAUDE_CODE_ENABLE_FUNCTION_HOOKS=1 claude +``` + +Without the flag nothing changes: the commands, agents and workflows behave the same and the pane never loads. Everything +it shows is read from the artifacts the commands write under `analysis//` and `modernized//`, and from the +legacy tree itself. Nothing is inferred by a model, and a fact that is not on disk is shown as absent. The hooks are written +against a feature that may change between releases; they were run on 2.1.280 and 2.1.283. + +### What it adds + +**A progress pane with an estate map.** Docked beside the transcript, for whatever system is under `legacy/` and in +whatever language: the system and what the plugin's commands are doing to it, which steps are done, a treemap of its +code, each unit of work and where it stands, what needs attention, and the next command to run. + +- **Any language.** The pane reads no language of its own. The map comes from `topology.json` when `/modernize-map` has run. + Until then it is read off the legacy tree: one tile per build module where the tree has build files (Maven, Gradle, npm, + .NET projects, Go, Cargo, Python packages, Composer, and more), one per source file for a tree without them, one per + directory for a tree too big for that. Its header names the languages by the share of the code (COBOL, Java, C#, PHP, + Perl, RPG, and any other by file type) and how many units it found. +- **Any way of working.** It follows the track whose artifacts are newest: a **rewrite** (map, rules, brief, transform), a + same-stack **uplift** (delta catalog, baseline, playbook, working copy), or a **reimagine** (spec, architecture, services). + Each has its own steps, its own next command, and tiles coloured by its own progress. An uplift's modules are set against + the baseline: *matches baseline* means every test that passed on the source runtime still passes and none is missing; + *worse than baseline* means more failures than it had (failures the baseline already had are not called worse). Set + `track` to pin one. +- **Any test runner.** A module's tests come from the reports it left (JUnit XML in the usual places, Visual Studio `.trx`, + or `.modernize/test-report.json`), and, where a runner leaves none, from a test command run in the module's directory during + the session (Maven, Gradle, pytest, Jest, dotnet, go, cargo, rspec, phpunit and more). +- **A tile lights up** for a few seconds when Claude or one of its agents reads (blue) or writes (yellow) a file under it, + in the legacy tree or in an uplift's working copy, so a fan-out is something you watch move across the system. +- **Show it and hide it.** It opens by itself under the fullscreen layout once the workspace has an `analysis/` directory. + A **hide** button at the top of the pane closes it. While it is hidden, one row above the prompt says where the + workspace stands and holds a **show pane** button that brings it back, on a terminal too narrow to dock it as well as a wide + one. `/modernize-panel` does the same from the keyboard, and shows the pane for a legacy tree nothing has analysed yet. + Set `panel` to `command` to have it open only on request, or `off` to have no pane and no button. + +**X-ray reads.** When Claude reads a file under `legacy//`, what the analysis already +established about that file rides along as context only the model sees: the map's callers, +callees and data stores, the business flows through it, the rules in `BUSINESS_RULES.md` that +cite it (narrowed to the lines just read when the read was a window), any rule a reviewer +disputed, and whether it has already been transformed. In an uplift it carries the module's +baseline (what fails on the source runtime is part of the oracle, so it is reproduced, not fixed), +where the module stands in the working copy, and the deltas the catalog cites the file under. The model stops re-deriving what three +stages already worked out, and stops calling code dead that the map knows is reached. A read +that misses because a cited path was taken from the workspace root is told where the file is +under the legacy root. + +**A review deck for business rules.** `/modernize-review [flagged|p0|all] [filter]` pages through +rule cards in the band above the prompt: the rule, its citation, Given / When / Then, the +suspected defect, the question for an SME. From an empty prompt, `1` confirms, `2` marks it wrong, +`3` sends it to discussion, `6` shows the cited legacy lines. Verdicts go to +`analysis//RULE_REVIEWS.json` and a readable `RULE_REVIEWS.md`; the agent-written rules +file is never edited. Disputed rules show up in the pane and in later x-ray notes. + +**A sign-off dialog.** `/modernize-sign [name, role]` fills in the brief's approval block: who, +when, and whether it covers Phase 1 or the full plan. + +**A fleet view.** Every agent loop that makes a tool call is counted, including a workflow's +agents, which `$.agent.list()` does not name. The pane shows how many are active and done, and +what the most recent are doing. When agents fail the same way (paths, numbers and quoted values +folded out, and one cause that words itself differently per command folded together), the pane +lists it with an example of what the failing calls were aimed at. The transcript says so once it +is a pattern for a fleet that size (three agents, or one in twenty), and once more if it spreads +fivefold: one cause across agents belongs in the playbook, not in each agent. A bare exit code +or a malformed call is not a cause and is not counted as one. + +### Pane commands + +| | | +|---|---| +| `/modernize-panel [open\|close\|json]` | Show or hide the pane (the same switch as its **hide** and **show pane** buttons); `json` prints the reading it draws from. | +| `/modernize-review [flagged\|p0\|all] [filter]` | Review rules. `flagged` (default) is the P0 rules with a defect, an SME note or less than High confidence. The filter matches an id, a domain, a title or a cited file. | +| `/modernize-sign [name, role]` | Sign the brief's approval block. | + +### Pane options + +Set in `/config`, or under `pluginConfigs` in settings. + +| Option | Default | | +|---|---|---| +| `system` | first under `analysis/`, else under `legacy/` | The system to follow. | +| `track` | `auto` | `auto` follows whichever way the commands are working on the system; `transform`, `uplift` or `reimagine` pins one. | +| `panel` | `auto` | `auto` opens the pane by itself and draws the show button while it is hidden; `command` opens it only when the button or `/modernize-panel` asks; `off` neither opens it nor draws the button. | +| `xray` | on | Attach analysis context to legacy reads. | +| `commandPrefix` | `/code-modernization:modernize-` | How the pane writes the plugin's commands. | +| `legacyDir` | `legacy` | The read-only tree. | + +### Pane keys + +Hotkeys work in the band above the prompt (the review deck's digits, from an empty prompt). A +pane's buttons are pressed by clicking, or `ctrl+x tab` to give the pane the keyboard, then Tab +and Enter. + +### What the pane does not do + +- An uplift's changed modules are found by comparing the working copy with the legacy tree by file name and size, with the + file API alone: the pane runs no program inside either tree. An edit that keeps a file exactly the same size is not seen by + that comparison, but a test run in the module, or a write during the session, shows it. +- Sizes are lines where the map gave them and bytes of source where the estate was read off the tree; a single file counts for + at most 400 KB, so a binary in a test folder is not a system's bulk. +- It never runs a command by itself. The pane's **next** button puts the command in the prompt + box; a person presses Enter. +- It does not call a model. The brief's phases and approval are read by pattern from the file; + what cannot be read that way is shown as unknown, not guessed. +- It only watches. It does not block or rewrite any edit or command; the workspace's own permission rules + (`Edit(/legacy/**)` denied, see Recommended workspace setup) are what keep `legacy/` read-only. +- The cut-over console (live legacy-versus-modern traffic diff with automatic fallback) and + approvals from a phone are not built: both need an environment this repository cannot test. + +To work on the pane, `hooks/register.ts` is the module: it binds the engine at `session.start` and wires the hooks, and +everything it calls is a plain function under `hooks/`. `claude plugin test .` runs the tests in `tests/` (parsers, layout, +estates in eight stacks, and the hooks through the engine's own `$`); `tsc -p .` typechecks them against the +declaration file `/plugin-types` writes into `.claude/types/`. + ## Recommended workspace setup 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: -- cgit From cafefb304bde4070c6c0877528ee49c1252eff85 Mon Sep 17 00:00:00 2001 From: Morgan Lunt Date: Thu, 24 Sep 2026 20:14:51 -0700 Subject: code-modernization: simpler commands, a source option, a report page and an equivalence check Commands hardcoded legacy/, so code too big to copy, or living at an absolute path, needed a hand-made symlink. Preflight now takes --source and makes the legacy/ link for you (a junction on Windows); nothing is copied, and every command says where the link points before it starts. The harden patch is applied with patch -p1 -d. Each command ends by naming the next command to run, and the commands are about a third shorter with no step removed: - map accepts an existing dependency graph (--graph) or the stack's own tooling, maps very large estates in resumable chunks, records reflection targets as unresolved instead of dead, asks before describing more than 40 nodes, and never gives two nodes the same location. - transform can take its module and target from the brief, counts the equivalence cases that executed (zero is a failure and a comparison never skips), shows the tests can fail with a deliberate one-line break, and hands "same or different" to a script when both systems can run. - brief writes each phase in one fixed shape: one command, module ids as in the map, and criteria written as conditions a build command may tick but not reword. - reimagine reuses the discovery artifacts instead of extracting them again. - status names the exact command to paste next. scripts/build_report.py turns whatever the commands wrote into one self-contained, offline REPORT.html (Mermaid is vendored, all text from the analysis is escaped, the quarantined secrets file is never read), and scripts/compare.py decides byte-for-byte whether two outputs match, records why, and checks it can fail. The shard builder ignores symbolic links and paths that leave the source, matches a plain name against what lies beneath it, and falls back to the directory tree when the map's modules share a location. The README drops from 275 to about 100 lines; the pane's reference moves to hooks/README.md. --- plugins/code-modernization/README.md | 286 +++++++---------------------------- 1 file changed, 56 insertions(+), 230 deletions(-) (limited to 'plugins/code-modernization/README.md') diff --git a/plugins/code-modernization/README.md b/plugins/code-modernization/README.md index 96a3c8a6..dd765fe1 100644 --- a/plugins/code-modernization/README.md +++ b/plugins/code-modernization/README.md @@ -1,18 +1,6 @@ -# Code Modernization Plugin +# Code Modernization -Point Claude at a legacy codebase — COBOL, legacy Java/C++/.NET, monolith web apps — and get back: an executive assessment, an interactive architecture map, the business rules mined out of the code, a steering-committee-ready modernization brief, and scaffolded or transformed new code with a behavior-equivalence test harness so you can prove nothing drifted. - -It works by enforcing a sequence, because modernization usually fails when teams skip steps — transforming code before understanding it, or shipping without a harness to catch behavior drift: - -``` -preflight → assess → map → extract-rules → brief → (reimagine | transform | uplift) → harden -``` - -The discovery commands (`assess`, `map`, `extract-rules`) write artifacts to `analysis//`. `brief` synthesizes them into an approval gate. The three build commands write under `modernized/` (`transform` to `//`, `reimagine` to `-reimagined/`, `uplift` to `-uplifted/`) and are three different *methods* — the brief recommends which one fits: - -- **`transform`** — cross-stack rewrite from extracted intent (e.g. COBOL → Java). -- **`reimagine`** — greenfield rebuild on a new architecture. -- **`uplift`** — same-stack version bump (e.g. .NET Framework → .NET 8) that *preserves* the code and fixes only the version deltas. +Point Claude at a legacy codebase (COBOL, Java, .NET, PHP, Perl, Python 2, C and more) and get an assessment, an interactive map, the business rules mined out of the code with citations, a plan you approve, and rewritten or upgraded code with tests that prove it still behaves the same. ![Interactive topology map of AWS CardDemo — domains as containers, modules sized by lines of code, dependency edges colored by kind, entry points ringed](assets/topology-viewer-screenshot.jpg) @@ -22,191 +10,43 @@ The discovery commands (`assess`, `map`, `extract-rules`) write artifacts to `an /plugin install code-modernization@claude-plugins-official ``` -## Quickstart - -Each command takes a `` and assumes the code lives at `legacy//`. Artifacts land in `analysis//`; new code under `modernized/`. If your code is elsewhere, symlink it: `mkdir -p legacy && ln -s /path/to/code legacy/billing`. - -Plugin commands are namespaced, so type the full name — `/code-modernization:modernize-…` (autocomplete finds it from `/modernize`). Flags go after the positional arguments (`/code-modernization:modernize-harden billing --show-secrets`): the first argument is the system directory, except for `assess --portfolio`, whose mode flag comes first. - -Try the first three on your own codebase — each produces a standalone artifact, so you can stop and review at any point: - -```bash -/code-modernization:modernize-preflight billing # is my environment ready? -/code-modernization:modernize-assess billing # what am I dealing with? -/code-modernization:modernize-map billing # show me the structure (opens an interactive map) -``` - -Then the full path: - -```bash -/code-modernization:modernize-extract-rules billing # mine business rules → testable Rule Cards -/code-modernization:modernize-brief billing java-spring # the plan a steering committee approves (HITL gate) -/code-modernization:modernize-transform billing interest-calc java-spring # …or reimagine, or uplift — see Commands -/code-modernization:modernize-harden billing # security pass on the still-running legacy system -/code-modernization:modernize-status billing # where am I, what's stale, what's next -``` - -## Commands - -Run in order; you can stop and review after any step. Each command stands alone except `brief`, which needs `assess`, `map` and `extract-rules` first. If a command stops or fails, `/code-modernization:modernize-status ` names the next step; an interrupted `extract-rules` run [can resume](#dynamic-workflow-orchestration). - -- **`/code-modernization:modernize-preflight [target-stack]`** — Environment readiness check. Asks you, in a pop-up, the five questions the source can't answer (scope, whether you can build and test locally, bespoke build infrastructure, prior attempts, what's off limits) and records your answers verbatim. Then it detects the legacy stack, checks analysis tooling, reads the CI/build definition, smoke-tests the toolchain against the real code (and, if you name a target stack, that a throwaway project builds on it here), inventories missing includes / deployment descriptors, and checks the **scope boundary** — whether `` is a slice of a larger repo and what outside it depends on it. Produces `PREFLIGHT.md` with a per-command Ready / Ready-with-gaps / Not-ready verdict. - -- **`/code-modernization:modernize-assess [--show-secrets]`** *(or `--portfolio `)* — Inventory: languages, complexity, tech debt, security posture, and a COCOMO complexity index ([see note](#a-note-on-cocomo)). Produces `ASSESSMENT.md` + `ARCHITECTURE.mmd`. With `--portfolio`, sweeps every subdirectory and writes a sequencing heat-map (`portfolio.html`). - -- **`/code-modernization:modernize-map [--no-describe]`** — Dependency and topology map: call graph, data lineage, entry points, and 2–4 business flows each traced for a persona (the claimant, the auditor). Produces `topology.json` and an **interactive zoomable `TOPOLOGY.html`** (circle-pack sized by LOC, edge toggles, search, and a persona-flow walkthrough), plus small `.mmd` diagrams for docs. Each node also gets a short plain-language description in the sidebar, written by one agent per node from just that node's source and links; `--no-describe` skips that step. - -- **`/code-modernization:modernize-extract-rules [module-pattern]`** — Mine the business rules — calculations, validations, eligibility, state transitions — into Given/When/Then "Rule Cards" with `file:line` citations and confidence ratings. With the Workflow tool, anything but a tiny system is extracted in per-module shards (from `map`'s `topology.json` if present, else the directory tree), so each extractor reads one focused slice. A large run shows an estimate and asks before it starts. Produces `BUSINESS_RULES.md` + `DATA_OBJECTS.md`. - -- **`/code-modernization:modernize-brief [target-stack]`** — Synthesize discovery into a phased **Modernization Brief**: target architecture, phase plan, persona walkthroughs, behavior contract, and an approval block. Reads the discovery artifacts and **stops if any are missing**. Stops for your explicit approval as a human-in-the-loop gate, in plan mode if the session supports it. For a same-stack uplift it also requires the **delta catalog**, since an uplift's phase order is decided by its version deltas. The execution commands read the brief and treat each phase's entry criteria as gates, so editing the brief steers execution. - -- **`/code-modernization:modernize-reimagine `** — Greenfield rebuild from extracted intent. Mines a spec, designs and adversarially reviews a target architecture, then scaffolds services with executable acceptance tests under `modernized/-reimagined/`. Two human checkpoints. - -- **`/code-modernization:modernize-transform `** — Surgical single-module rewrite (strangler-fig: replace one piece while the legacy system keeps running). Plans first (approval gate), writes characterization tests, then an idiomatic implementation, and proves equivalence by running the tests. Produces `TRANSFORMATION_NOTES.md`. - -- **`/code-modernization:modernize-uplift [project-pattern]`** — Same-stack version bump (e.g. `.NET Framework 4.8` → `.NET 8`, Spring Boot 2 → 3) — the common case `transform` gets wrong by rewriting. Preserves the code and makes the smallest diffs that compile and behave identically, driven by a **delta catalog** (the known breaking changes that *this* code actually hits) and the ecosystem's migration tooling. Equivalence is proven by running the test suite on both the old and new runtime where both can run here (otherwise it falls back to characterization tests, like `transform`). Migration is **pilot-first**: one representative project is migrated end-to-end in-session and its lessons written to a `PLAYBOOK.md` before anything else is touched; the rest then fan out, one agent per project, in **dependency-aware escalating batches behind a circuit breaker**. Produces `DELTA_CATALOG.md`, `BASELINE.md`, `PLAYBOOK.md` + `UPLIFT_NOTES.md`. If the catalog shows most of the code is forced to change, it tells you to use `transform` instead. - -- **`/code-modernization:modernize-harden [--show-secrets]`** — Security pass on the **legacy** system: OWASP/CWE, dependency CVEs, secrets, injection. Produces `SECURITY_FINDINGS.md` (ranked) and a reviewed `security_remediation.patch`. **Never edits `legacy/`** — you review and apply the patch yourself. Useful while the legacy system keeps running in production during migration. - -- **`/code-modernization:modernize-status `** — Read-only progress report: artifact inventory, staleness flags, secrets-hygiene checks, and the single most useful next command. - -## Agents - -Specialist subagents invoked by the commands (or directly): - -- **`legacy-analyst`** — Reads legacy code (COBOL, EJB, classic ASP, …) and produces structural summaries; spots implicit dependencies and "JOBOL" (procedural code in modern syntax). *(assess, map, extract-rules, reimagine)* -- **`business-rules-extractor`** — Mines domain rules from procedural code with source citations. *(extract-rules, reimagine)* -- **`architecture-critic`** — Skeptical reviewer of target designs and transformed code; flags over-engineering. *(reimagine, transform, uplift)* -- **`security-auditor`** — Auth, input validation, secrets, dependency CVEs. *(assess, harden)* -- **`test-engineer`** — Characterization and equivalence tests that pin legacy behavior. *(transform, uplift)* -- **`version-delta-analyst`** — Finds the breaking changes between two versions of one stack that bite *this* codebase, and drives the ecosystem migration tool. *(uplift)* -- **`uplift-migrator`** — Migrates one project/module of an in-flight uplift by following the pilot's playbook, then runs that unit's real build to prove it; refuses to migrate anything if no playbook exists yet. Writes only inside its own unit's directory. *(uplift)* -- **`scaffolder`** — Builds one service of a reimagined system; writes only within its own `modernized/...//` directory. *(reimagine)* - -## Live progress pane (early access) - -While the commands run, the plugin can draw a live pane beside the transcript: for a system in any language, what the -commands are doing to it, how far along each part is, and what to run next. It is built on Claude Code's function hooks, -which are early access and off by default. Start with the flag to turn them on: - -```sh -CLAUDE_CODE_ENABLE_FUNCTION_HOOKS=1 claude -``` - -Without the flag nothing changes: the commands, agents and workflows behave the same and the pane never loads. Everything -it shows is read from the artifacts the commands write under `analysis//` and `modernized//`, and from the -legacy tree itself. Nothing is inferred by a model, and a fact that is not on disk is shown as absent. The hooks are written -against a feature that may change between releases; they were run on 2.1.280 and 2.1.283. - -### What it adds - -**A progress pane with an estate map.** Docked beside the transcript, for whatever system is under `legacy/` and in -whatever language: the system and what the plugin's commands are doing to it, which steps are done, a treemap of its -code, each unit of work and where it stands, what needs attention, and the next command to run. +## Start here -- **Any language.** The pane reads no language of its own. The map comes from `topology.json` when `/modernize-map` has run. - Until then it is read off the legacy tree: one tile per build module where the tree has build files (Maven, Gradle, npm, - .NET projects, Go, Cargo, Python packages, Composer, and more), one per source file for a tree without them, one per - directory for a tree too big for that. Its header names the languages by the share of the code (COBOL, Java, C#, PHP, - Perl, RPG, and any other by file type) and how many units it found. -- **Any way of working.** It follows the track whose artifacts are newest: a **rewrite** (map, rules, brief, transform), a - same-stack **uplift** (delta catalog, baseline, playbook, working copy), or a **reimagine** (spec, architecture, services). - Each has its own steps, its own next command, and tiles coloured by its own progress. An uplift's modules are set against - the baseline: *matches baseline* means every test that passed on the source runtime still passes and none is missing; - *worse than baseline* means more failures than it had (failures the baseline already had are not called worse). Set - `track` to pin one. -- **Any test runner.** A module's tests come from the reports it left (JUnit XML in the usual places, Visual Studio `.trx`, - or `.modernize/test-report.json`), and, where a runner leaves none, from a test command run in the module's directory during - the session (Maven, Gradle, pytest, Jest, dotnet, go, cargo, rspec, phpunit and more). -- **A tile lights up** for a few seconds when Claude or one of its agents reads (blue) or writes (yellow) a file under it, - in the legacy tree or in an uplift's working copy, so a fan-out is something you watch move across the system. -- **Show it and hide it.** It opens by itself under the fullscreen layout once the workspace has an `analysis/` directory. - A **hide** button at the top of the pane closes it. While it is hidden, one row above the prompt says where the - workspace stands and holds a **show pane** button that brings it back, on a terminal too narrow to dock it as well as a wide - one. `/modernize-panel` does the same from the keyboard, and shows the pane for a legacy tree nothing has analysed yet. - Set `panel` to `command` to have it open only on request, or `off` to have no pane and no button. +1. **Point it at your code.** In a workspace folder, put the code at `legacy/` (a copy or a symlink), or leave it where it is and pass `--source ` in step 2: preflight makes the `legacy/` link for you and copies nothing. `` is a short label: letters, digits, `-` and `_`. +2. **Run** `/code-modernization:modernize-preflight ` (add `--source /path/to/code` if it lives elsewhere). +3. **Follow the "next step" line** each command ends with, or run `/code-modernization:modernize-status ` at any time: it says where you are and gives the exact command to paste. -**X-ray reads.** When Claude reads a file under `legacy//`, what the analysis already -established about that file rides along as context only the model sees: the map's callers, -callees and data stores, the business flows through it, the rules in `BUSINESS_RULES.md` that -cite it (narrowed to the lines just read when the read was a window), any rule a reviewer -disputed, and whether it has already been transformed. In an uplift it carries the module's -baseline (what fails on the source runtime is part of the oracle, so it is reproduced, not fixed), -where the module stands in the working copy, and the deltas the catalog cites the file under. The model stops re-deriving what three -stages already worked out, and stops calling code dead that the map knows is reached. A read -that misses because a cited path was taken from the workspace root is told where the file is -under the legacy root. +Commands are namespaced, so type the full name (autocomplete finds it from `/modernize`). Flags go after the arguments. No command edits your code: they write to `analysis//` and `modernized/`, and each refreshes `analysis//REPORT.html`, one page with everything found so far that you can open or share. -**A review deck for business rules.** `/modernize-review [flagged|p0|all] [filter]` pages through -rule cards in the band above the prompt: the rule, its citation, Given / When / Then, the -suspected defect, the question for an SME. From an empty prompt, `1` confirms, `2` marks it wrong, -`3` sends it to discussion, `6` shows the cited legacy lines. Verdicts go to -`analysis//RULE_REVIEWS.json` and a readable `RULE_REVIEWS.md`; the agent-written rules -file is never edited. Disputed rules show up in the pane and in later x-ray notes. +## The path -**A sign-off dialog.** `/modernize-sign [name, role]` fills in the brief's approval block: who, -when, and whether it covers Phase 1 or the full plan. +Each step stands alone, so you can stop and review after any of them. -**A fleet view.** Every agent loop that makes a tool call is counted, including a workflow's -agents, which `$.agent.list()` does not name. The pane shows how many are active and done, and -what the most recent are doing. When agents fail the same way (paths, numbers and quoted values -folded out, and one cause that words itself differently per command folded together), the pane -lists it with an example of what the failing calls were aimed at. The transcript says so once it -is a pattern for a fleet that size (three agents, or one in twenty), and once more if it spreads -fivefold: one cause across agents belongs in the playbook, not in each agent. A bare exit code -or a malformed call is not a cause and is not counted as one. - -### Pane commands - -| | | -|---|---| -| `/modernize-panel [open\|close\|json]` | Show or hide the pane (the same switch as its **hide** and **show pane** buttons); `json` prints the reading it draws from. | -| `/modernize-review [flagged\|p0\|all] [filter]` | Review rules. `flagged` (default) is the P0 rules with a defect, an SME note or less than High confidence. The filter matches an id, a domain, a title or a cited file. | -| `/modernize-sign [name, role]` | Sign the brief's approval block. | - -### Pane options - -Set in `/config`, or under `pluginConfigs` in settings. - -| Option | Default | | -|---|---|---| -| `system` | first under `analysis/`, else under `legacy/` | The system to follow. | -| `track` | `auto` | `auto` follows whichever way the commands are working on the system; `transform`, `uplift` or `reimagine` pins one. | -| `panel` | `auto` | `auto` opens the pane by itself and draws the show button while it is hidden; `command` opens it only when the button or `/modernize-panel` asks; `off` neither opens it nor draws the button. | -| `xray` | on | Attach analysis context to legacy reads. | -| `commandPrefix` | `/code-modernization:modernize-` | How the pane writes the plugin's commands. | -| `legacyDir` | `legacy` | The read-only tree. | - -### Pane keys +| Step | Command | What you get | +| --- | --- | --- | +| 1 | `modernize-preflight [target-stack]` | Is the environment ready? Asks the five questions only a person can answer, checks tools and a real build, finds missing source, and says what to fix. `PREFLIGHT.md` | +| 2 | `modernize-assess ` | What am I dealing with: inventory, complexity, debt, security, and the recommended pattern. `ASSESSMENT.md` | +| 3 | `modernize-map ` | The structure: dependencies, data flow, entry points and business flows as an interactive map (`TOPOLOGY.html`). Takes an existing dependency graph with `--graph `. | +| 4 | `modernize-extract-rules ` | The business rules as testable Given/When/Then cards with `file:line` citations, each checked by a second agent. `BUSINESS_RULES.md` | +| 5 | `modernize-brief [target-stack]` | The phased plan a steering committee approves. Nothing is built until you approve it. `MODERNIZATION_BRIEF.md` | +| 6 | one of `uplift`, `transform`, `reimagine` | The build. See below. | +| 7 | `modernize-harden ` | A security scan of the still-running legacy system, with ranked findings and a reviewed patch you apply yourself. `SECURITY_FINDINGS.md` | -Hotkeys work in the band above the prompt (the review deck's digits, from an empty prompt). A -pane's buttons are pressed by clicking, or `ctrl+x tab` to give the pane the keyboard, then Tab -and Enter. +`assess --portfolio ` ranks many systems into a sequencing heat-map. -### What the pane does not do +## Choose how to build (the brief recommends one) -- An uplift's changed modules are found by comparing the working copy with the legacy tree by file name and size, with the - file API alone: the pane runs no program inside either tree. An edit that keeps a file exactly the same size is not seen by - that comparison, but a test run in the module, or a write during the session, shows it. -- Sizes are lines where the map gave them and bytes of source where the estate was read off the tree; a single file counts for - at most 400 KB, so a binary in a test folder is not a system's bulk. -- It never runs a command by itself. The pane's **next** button puts the command in the prompt - box; a person presses Enter. -- It does not call a model. The brief's phases and approval are read by pattern from the file; - what cannot be read that way is shown as unknown, not guessed. -- It only watches. It does not block or rewrite any edit or command; the workspace's own permission rules - (`Edit(/legacy/**)` denied, see Recommended workspace setup) are what keep `legacy/` read-only. -- The cut-over console (live legacy-versus-modern traffic diff with automatic fallback) and - approvals from a phone are not built: both need an environment this repository cannot test. +| If you want | Run | What happens | +| --- | --- | --- | +| The same language on a newer version (.NET Framework 4.8 to .NET 8, Java 8 to 17, Spring Boot 2 to 3) | `modernize-uplift ` | Keeps your code and fixes only what the new version breaks, driven by a catalog of the breaking changes this code actually hits. One pilot unit first and its lessons written down, then batches. Proves nothing changed by running the test suite on both versions where both can run. | +| A new stack, one module at a time, while the old system keeps running | `modernize-transform [module] [target-stack]` | A plan you approve, tests that pin the old behavior, an idiomatic rewrite, and proof: the tests are run, counted, and shown to fail when the code is deliberately broken. | +| A rebuild on a new architecture | `modernize-reimagine ` | A spec mined from the code, an architecture that is reviewed and approved, then services scaffolded with executable acceptance tests. | -To work on the pane, `hooks/register.ts` is the module: it binds the engine at `session.start` and wires the hooks, and -everything it calls is a plain function under `hooks/`. `claude plugin test .` runs the tests in `tests/` (parsers, layout, -estates in eight stacks, and the hooks through the engine's own `$`); `tsc -p .` typechecks them against the -declaration file `/plugin-types` writes into `.claude/types/`. +If the delta catalog shows an "uplift" would rewrite most of the code, the command says so and points to `transform`. -## Recommended workspace setup +## Set it up so it runs smoothly -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: +The commands never edit your code, by convention. A `.claude/settings.json` in the workspace backs that up with a deny rule for the source and allow rules for the outputs (`preflight` checks for the deny rule): ```json { @@ -217,58 +57,44 @@ The commands never edit `legacy/`, by convention. A `.claude/settings.json` in t } ``` -Claude Code matches file writes through the `Edit` rule, so these cover the `Write` tool too; a `Write(path)` rule is accepted but never consulted. - -The deny rule starts with `/` so that it is anchored at the project root; without the slash it also matches any nested directory named `legacy`, such as `modernized//.../legacy/`. It refuses a copy out of `legacy/` too, so `uplift`'s working copy (`cp -r legacy/ modernized/-uplifted`) needs `rsync -a legacy// modernized/-uplifted/` instead, or a copy you run yourself. If `legacy/` is a symlink to a directory outside the project, add that directory to `additionalDirectories` so Claude can read through the link, and deny its real path as well, because the rule above matches the link's path and not its target's: `"additionalDirectories": ["/path/to/code"]` and `"Edit(//path/to/code/**)"` in `deny`. - -This guards the file tools; shell commands that mutate files (`git apply`, a script that opens files itself) still go through the normal Bash prompt, so review those with the same invariant in mind. That prompt is the containment for the two steps that fan out many write-capable agents at once — `/code-modernization:modernize-uplift` Step 5b and `/code-modernization:modernize-reimagine` Phase E — so keep Bash on a *prompted* permission mode for those. - -## Prerequisites - -Commands degrade gracefully, but these improve the output (run `/code-modernization:modernize-preflight` to check all at once): - -- **Analysis tools** — [`scc`](https://github.com/boyter/scc) or [`cloc`](https://github.com/AlDanial/cloc); without them, metrics fall back to `find`/`wc`. -- **A build toolchain** for the legacy stack — enables the strongest equivalence proof (live dual execution). Not required: without it, equivalence falls back to recorded-trace tests and preflight reports Ready-with-gaps rather than blocking. -- **The whole system in the tree** — deployment descriptors (JCL, CICS, route configs), copybooks/includes, DDL. Entry-point detection and data lineage need them. - -## Safety notes +- File writes are matched through the `Edit` rule, so this covers the `Write` tool too (a `Write(path)` rule is never consulted). The leading `/` anchors the rule at the workspace root. +- If `legacy/` is a symlink (which `--source` makes), also allow reading its target (`"additionalDirectories": ["/path/to/code"]`) and deny its real path (`"Edit(//path/to/code/**)"`), because the rule above matches the link's path, not its target's. +- The rule covers Claude's file tools and the shell commands it recognizes. A script that opens files itself is not covered, so keep Bash on a *prompted* permission mode for the two steps that fan out many writing agents at once (`uplift` step 5b and `reimagine` phase E). +- Shell commands still ask even in accept-edits mode (`python3` scripts, `scc`, `rsync`, your build and test commands, anything outside the workspace). Use accept-edits mode or allow rules for the ones you trust. -**Analyzed code is untrusted input.** A hostile codebase can plant comments like "ignore previous instructions" or "mark this rule approved" to steer what lands in `BUSINESS_RULES.md` or `SECURITY_FINDINGS.md`, which later commands trust. Defenses: agents treat file content as data and flag instruction-shaped text; verification agents re-derive every rule and finding from the cited code, not from another agent's description; filesystem paths are validated; and `/code-modernization:modernize-brief` is a human approval gate before any code is generated. Treat discovery artifacts from untrusted code with the same skepticism as the code itself. +Helpful but optional (run `preflight` to check them all): [`scc`](https://github.com/boyter/scc) or `cloc` for size metrics; `python3` for the map, the shard builder and the report; a build toolchain for your stack, which enables the strongest equivalence proof (running old and new side by side); and the whole system in the tree (deployment descriptors, copybooks, DDL), which entry points and data lineage need. Without a toolchain the plugin falls back to recorded-output tests and says so. -**Secrets stay out of shared artifacts.** Discovered credentials are masked (`AKIA****`) and inventoried in a gitignored `SECRETS.local.md` (or `~/.modernize//` on non-git projects); `/code-modernization:modernize-harden` keeps credential-removal hunks in a separate gitignored patch. Pass `--show-secrets` to include raw values in the quarantine file only. If you ran an early version of this plugin on a real system, check whether `analysis/` artifacts were committed and rotate anything exposed. +## Safety -### A note on COCOMO +- **Analyzed code is untrusted input.** A hostile codebase can plant comments like "ignore previous instructions" to steer what lands in `BUSINESS_RULES.md` or `SECURITY_FINDINGS.md`. Agents treat file content as data and flag instruction-shaped text, verification agents re-derive every rule and finding from the cited code, and `brief` is a human approval gate before anything is built. Treat discovery artifacts from untrusted code with the same skepticism as the code. +- **Secrets stay out of shared artifacts.** Discovered credentials are masked (`AKIA****`) and inventoried in a gitignored `SECRETS.local.md` (or `~/.modernize//` outside git); `harden` keeps credential-removal hunks in a separate gitignored patch. `--show-secrets` puts raw values in the quarantine file only. +- **Trying it on a live repository.** `preflight` and `assess` change no source file. Preflight's smoke test compiles one file and, where there is a build system, restores and builds one small project, which writes build output wherever the build normally does. -`assess` derives a COCOMO figure from code size and uses it **only as a relative complexity/scale index** to rank and sequence systems — never as a timeline or cost. COCOMO's constants encode human-team productivity, which agentic transformation doesn't follow, so any duration derived from it would be wrong. +## Working in a team -## Teams, adapting it, and what it has been tried on +State lives in files, not in chat: later commands read the brief and `PREFLIGHT.md`, not your conversation, so a second person or a fresh session can run `status` and continue. The commands never commit, so commit `analysis/` and `modernized/` yourself. -**Who owns what.** `legacy/` stays read-only: by convention, backed by the permission rule in [Recommended workspace setup](#recommended-workspace-setup). `analysis//` holds outputs a named person should review, not facts; `modernized/` is code and gets ordinary code review. The commands never commit, so commit both yourself; `assess` and `harden` keep the credential inventory and the credential patch out of git through `analysis/.gitignore`. Suggested reviewers, from what each artifact contains (the commands stop for a human at several gates but never check who that is): +| Artifact | Suggested reviewer | +| --- | --- | +| `PREFLIGHT.md` (the five answers, scope boundary, build checks) | whoever owns the build | +| `ASSESSMENT.md`, `REPORT.html` | the engineering lead or sponsor | +| `topology.json`, `TOPOLOGY.html` | engineers who know the system | +| `BUSINESS_RULES.md` | a business expert per domain: start with the P0 rules and the closing question list | +| `MODERNIZATION_BRIEF.md` | the approver, who steers execution by editing it | +| `SECURITY_FINDINGS.md` and the patch | a security engineer, who applies the patch | -| Artifact | Contains | Suggested reviewer | -| --- | --- | --- | -| `PREFLIGHT.md` | the five answers only a person can give, the scope-boundary finding, tool and build checks | whoever owns the build | -| `ASSESSMENT.md` | inventory, technical debt, security posture, relative scale, recommended pattern | the engineering lead or sponsor | -| `topology.json`, `TOPOLOGY.html` | call graph, data lineage, persona flows | engineers who know the system | -| `BUSINESS_RULES.md` | Rule Cards with citations, priority and confidence, and a closing list of questions for experts | a business expert per domain; start with the P0 rules and that list | -| `MODERNIZATION_BRIEF.md` | phases, entry and exit criteria, behavior contract, approval block | the approver, who steers execution by editing it | -| `SECURITY_FINDINGS.md`, the patch | ranked findings, a reviewed remediation patch | a security engineer, who applies the patch | - -State lives in files, not in chat: later commands read the brief's criteria and the answers in `PREFLIGHT.md`, not your conversation, so a second person or a fresh session can run `/code-modernization:modernize-status ` and continue from the next command it names. - -**Trying it on a live repository.** `preflight` and `assess` write their reports under `analysis/` and change no source file. Two side effects: preflight's smoke test compiles one file and, where the system has a build system, restores and builds one small project or module with it; that writes build output (and, for some tools, updates lockfiles) wherever the build normally does, possibly inside `legacy/`, and outside a git repository `assess` writes any credential inventory to `~/.modernize//`. - -**Adapting it.** Commands, agents and workflows are plain markdown and JavaScript under Apache 2.0. Fork it to change the prompts, the gates or the steps for your stack. - -**Repeatability.** A model does the extraction, so two runs of `extract-rules` on the same estate, or on different models, can find different rules and number them differently. Treat `BUSINESS_RULES.md` as reviewed output, not a deterministic build artifact. Headings are always `### RULE-NNN: `, so later steps can find rules whichever run wrote them. The verification steps and the closing question list help a person review what was found; they do not make two runs identical. - -**Permissions and toolchain.** The commands write files, so a session that asks before every edit keeps stopping: use accept-edits mode or the allow rules in Recommended workspace setup. Shell commands still ask, even in accept-edits mode: `git check-ignore`, `python3` scripts, analysis tools such as `scc`, `cp -r`, and the build and test commands of your stacks, and so does anything outside the project, such as `~/.modernize/`. Writes to sensitive paths such as `.git/`, `.mvn/` and `.npmrc` ask even with an allow rule. `transform`, `reimagine` and `uplift` also need a toolchain that builds and tests the target stack; `preflight` checks it when you name one. +## Live progress pane (early access) -**What it has been tried on.** The one example in this README, the map at the top, is AWS CardDemo, a public COBOL, CICS and JCL sample. Any other stack goes through the same generic path (`preflight` detects it from file extensions and manifests), but nothing in this plugin shows one being run, so expect to adapt. +A pane beside the transcript that shows the map of your code, how far each part has got and what to run next, in any language and for any of the three ways of building. It needs Claude Code's early-access function hooks: start with `CLAUDE_CODE_ENABLE_FUNCTION_HOOKS=1 claude`. Without the flag nothing changes. Details are in [hooks/README.md](hooks/README.md). -## Dynamic workflow orchestration +## Good to know -On Claude Code builds with the Workflow tool, five commands (`extract-rules`, `harden`, `assess --portfolio`, `reimagine`, `uplift`) run as scripted multi-agent orchestrations that fan out more agents for deeper coverage — looping until findings stabilize, and adversarially verifying each finding before it's written. `uplift`'s migration fan-out runs in dependency-aware escalating batches behind a per-batch **circuit breaker**, so a playbook that stops working is caught within a handful of agents and the spend stops until it is revised. A stopped or failed `extract-rules` (or `assess --portfolio`) run is **resumable** in the same session: the command re-runs the workflow with the run's ID, and every agent that finished before the stop replays from the run's journal instead of running again. Shards whose agents failed outright are reported and re-run on their own in a follow-up run. They fall back to direct subagent fan-out on older builds automatically; no configuration needed. Invoking the slash command is the opt-in. +- **The assessment's COCOMO figure is a relative size index, never a timeline or a cost.** Its constants encode human-team productivity, which agentic work does not follow. +- **A model does the extraction, so two runs can find different rules.** Treat `BUSINESS_RULES.md` as reviewed output, not a deterministic build artifact. Headings are always `### RULE-NNN: `. +- **Large runs are resumable.** On Claude Code builds with the Workflow tool, `extract-rules`, `harden`, `assess --portfolio`, `reimagine` and `uplift` run as scripted multi-agent jobs that verify findings adversarially. `extract-rules` shards by module and asks before a big run; a stopped run resumes in the same session with its run ID, and finished agents replay from the journal. `uplift` migrates in escalating batches behind a circuit breaker. Older builds fall back to plain subagents automatically. +- **Adapting it.** Commands, agents and workflows are markdown and JavaScript under Apache 2.0: fork them to change the prompts or steps for your stack. +- **Agents.** `legacy-analyst`, `business-rules-extractor`, `architecture-critic`, `security-auditor`, `test-engineer`, `version-delta-analyst`, `uplift-migrator` and `scaffolder` are invoked by the commands (or directly). The last two write only inside their own unit's directory. +- **Related.** [code-migration-kit-with-claude-code](https://github.com/anthropics/code-migration-kit-with-claude-code) is a separate public kit of prompts, templates and scripts for large-scale language migrations. This plugin is the guided, command-driven workflow from discovery through plan, build and proof; use either or both. ## License -- cgit From b6b148f496e8da208676b4a1553bdf292ce340d9 Mon Sep 17 00:00:00 2001 From: Morgan Lunt Date: Thu, 24 Sep 2026 20:18:45 -0700 Subject: code-modernization: a front door that asks what you want once /code-modernization:modernize takes no arguments. It finds the code, asks what the person wants to do with it (a newer version of the same technology, a rewrite in another one, a rebuild, or just to understand it) and what must stay true, writes the answers to analysis//INTENT.md, shows the road ahead in a few lines, and gives the exact first command. On a return visit it acts like status. brief takes its objective, target and each phase's build command from INTENT.md, and uplift, transform and reimagine fall back to it for their versions, target and vision, so nobody is asked the same thing twice. The README's start section now begins with the front door. --- plugins/code-modernization/README.md | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'plugins/code-modernization/README.md') diff --git a/plugins/code-modernization/README.md b/plugins/code-modernization/README.md index dd765fe1..7392e6a7 100644 --- a/plugins/code-modernization/README.md +++ b/plugins/code-modernization/README.md @@ -12,11 +12,19 @@ Point Claude at a legacy codebase (COBOL, Java, .NET, PHP, Perl, Python 2, C and ## Start here -1. **Point it at your code.** In a workspace folder, put the code at `legacy/` (a copy or a symlink), or leave it where it is and pass `--source ` in step 2: preflight makes the `legacy/` link for you and copies nothing. `` is a short label: letters, digits, `-` and `_`. -2. **Run** `/code-modernization:modernize-preflight ` (add `--source /path/to/code` if it lives elsewhere). -3. **Follow the "next step" line** each command ends with, or run `/code-modernization:modernize-status ` at any time: it says where you are and gives the exact command to paste. - -Commands are namespaced, so type the full name (autocomplete finds it from `/modernize`). Flags go after the arguments. No command edits your code: they write to `analysis//` and `modernized/`, and each refreshes `analysis//REPORT.html`, one page with everything found so far that you can open or share. +Type `/code-modernization:modernize` in a workspace folder (autocomplete finds it from `/modernize`). It asks what you want to do with +your code, finds it (a `legacy/` copy or symlink, or a folder you point it at), writes your answers down once, shows the road +ahead, and gives you the exact first command. You can also run any command directly: + +1. **Point it at your code.** Put it at `legacy/` (a copy or a symlink), or pass `--source ` to preflight: it makes the + `legacy/` link for you and copies nothing. `` is a short label: letters, digits, `-` and `_`. +2. **Run** `/code-modernization:modernize-preflight `. +3. **Follow the "next step" line** each command ends with, or run `/code-modernization:modernize-status ` at any time: it says + where you are and gives the exact command to paste. + +Commands are namespaced, so type the full name. Flags go after the arguments. No command edits your code: they write to +`analysis//` and `modernized/`, and each refreshes `analysis//REPORT.html`, one page with everything found so far that +you can open or share. ## The path -- cgit From f33999b153851d927a103e0f4b6032ed53a94aad Mon Sep 17 00:00:00 2001 From: Morgan Lunt Date: Thu, 24 Sep 2026 20:27:49 -0700 Subject: code-modernization: call workflows by name and fix the uplift version arguments The Workflow tool refuses a plugin script path whenever the plugin lives outside the working directory, which is the normal case for an installed plugin: the model failed once or twice on every run before falling back to the registered name. The commands now call each workflow by its registered name and mention the script path only as a fallback. modernize-uplift also referred to legacy/$system_version, which is not an argument; it now uses $source_version everywhere, and the version pair, the rewrite target and the vision fall back to analysis//INTENT.md when they are not given. The README notes that a scripted (claude -p) run needs CLAUDE_CODE_PRINT_BG_WAIT_CEILING_MS=0 so long fan-out steps can finish. --- plugins/code-modernization/README.md | 1 + 1 file changed, 1 insertion(+) (limited to 'plugins/code-modernization/README.md') diff --git a/plugins/code-modernization/README.md b/plugins/code-modernization/README.md index 7392e6a7..c1f047b1 100644 --- a/plugins/code-modernization/README.md +++ b/plugins/code-modernization/README.md @@ -100,6 +100,7 @@ A pane beside the transcript that shows the map of your code, how far each part - **The assessment's COCOMO figure is a relative size index, never a timeline or a cost.** Its constants encode human-team productivity, which agentic work does not follow. - **A model does the extraction, so two runs can find different rules.** Treat `BUSINESS_RULES.md` as reviewed output, not a deterministic build artifact. Headings are always `### RULE-NNN: `. - **Large runs are resumable.** On Claude Code builds with the Workflow tool, `extract-rules`, `harden`, `assess --portfolio`, `reimagine` and `uplift` run as scripted multi-agent jobs that verify findings adversarially. `extract-rules` shards by module and asks before a big run; a stopped run resumes in the same session with its run ID, and finished agents replay from the journal. `uplift` migrates in escalating batches behind a circuit breaker. Older builds fall back to plain subagents automatically. +- **Scripting it (`claude -p`).** Long steps run as background workflows, and a headless session stops waiting for background work after 10 minutes. Set `CLAUDE_CODE_PRINT_BG_WAIT_CEILING_MS=0` so `extract-rules`, `harden` and the other fan-out steps can finish, and answer a step's approval gate by resuming the session with `--resume`. - **Adapting it.** Commands, agents and workflows are markdown and JavaScript under Apache 2.0: fork them to change the prompts or steps for your stack. - **Agents.** `legacy-analyst`, `business-rules-extractor`, `architecture-critic`, `security-auditor`, `test-engineer`, `version-delta-analyst`, `uplift-migrator` and `scaffolder` are invoked by the commands (or directly). The last two write only inside their own unit's directory. - **Related.** [code-migration-kit-with-claude-code](https://github.com/anthropics/code-migration-kit-with-claude-code) is a separate public kit of prompts, templates and scripts for large-scale language migrations. This plugin is the guided, command-driven workflow from discovery through plan, build and proof; use either or both. -- cgit From 363af43603ecdb1bdbed7303764b6daeeec7c37f Mon Sep 17 00:00:00 2001 From: Morgan Lunt Date: Fri, 25 Sep 2026 11:29:00 -0700 Subject: code-modernization: version 1.0.0, usage counts and a README results table The plugin now has a version and a changelog. Two hooks record whole-number usage counts (which command ran, how far a system got, how many rules and proofs) through the CLI's own telemetry: counts from 100 up are rounded, nothing is sent when the plugin is not in use, and any of three switches turns it off. The README documents every key and lists what the plugin was tried on, checked against the run files. --- plugins/code-modernization/README.md | 162 +++++++++++++++++++++++++++-------- 1 file changed, 128 insertions(+), 34 deletions(-) (limited to 'plugins/code-modernization/README.md') diff --git a/plugins/code-modernization/README.md b/plugins/code-modernization/README.md index c1f047b1..691d355a 100644 --- a/plugins/code-modernization/README.md +++ b/plugins/code-modernization/README.md @@ -1,30 +1,31 @@ # Code Modernization -Point Claude at a legacy codebase (COBOL, Java, .NET, PHP, Perl, Python 2, C and more) and get an assessment, an interactive map, the business rules mined out of the code with citations, a plan you approve, and rewritten or upgraded code with tests that prove it still behaves the same. +Point Claude at a legacy codebase and get four things: an understanding of what it is and what it does, a plan you approve, the modernized code, and **proof that the new code behaves like the old**. It works with any language and any kind of move: a newer version of the same technology, a rewrite in another one, or a rebuild on a new architecture. -![Interactive topology map of AWS CardDemo — domains as containers, modules sized by lines of code, dependency edges colored by kind, entry points ringed](assets/topology-viewer-screenshot.jpg) +![One report page with everything found so far: a green banner when the proof passes and the old and new outputs match, the command to run next, the steps done, and the counts, with tabs for the assessment, the map, the business rules, the plan, the build notes and the proof.](assets/media/report-glance.jpg) ## Install +You need [Claude Code](https://code.claude.com). Then: + ``` /plugin install code-modernization@claude-plugins-official ``` +Some steps start many agents at once, so expect real usage on a large system (see *What to expect*). Start with one module or one unit as a pilot, not the whole estate. + ## Start here -Type `/code-modernization:modernize` in a workspace folder (autocomplete finds it from `/modernize`). It asks what you want to do with -your code, finds it (a `legacy/` copy or symlink, or a folder you point it at), writes your answers down once, shows the road -ahead, and gives you the exact first command. You can also run any command directly: +Open a folder for the work and type `/code-modernization:modernize`. It asks what you want to do with your code (a couple of short questions), finds the code, writes your answers down once, shows the road ahead, and gives you the exact first command. Every later command reads what you said, so nothing is asked twice. **Not sure what you want?** Choose *Understand it first*: you get the assessment, the map, the business rules and a plan, and no code is rebuilt. -1. **Point it at your code.** Put it at `legacy/` (a copy or a symlink), or pass `--source ` to preflight: it makes the - `legacy/` link for you and copies nothing. `` is a short label: letters, digits, `-` and `_`. -2. **Run** `/code-modernization:modernize-preflight `. -3. **Follow the "next step" line** each command ends with, or run `/code-modernization:modernize-status ` at any time: it says - where you are and gives the exact command to paste. +To go step by step instead, point the first command at your code and follow the "next step" line each command ends with: -Commands are namespaced, so type the full name. Flags go after the arguments. No command edits your code: they write to -`analysis//` and `modernized/`, and each refreshes `analysis//REPORT.html`, one page with everything found so far that -you can open or share. +``` +/code-modernization:modernize-preflight --source +/code-modernization:modernize-status # where am I, and what is next: run it any time +``` + +`` is a short label of your choice (letters, digits, `-`, `_`). `--source` makes a link at `legacy/` and copies nothing, so a huge repository stays where it is. **Nothing edits your legacy source.** Commands write only to `analysis//` and `modernized/` (a build check writes build output where your build normally does), and each refreshes `analysis//REPORT.html`: one page, with everything found so far, that you can open or share. A few steps need someone who knows how the system is built and run, so bring an engineer for the first questions. ## The path @@ -32,25 +33,80 @@ Each step stands alone, so you can stop and review after any of them. | Step | Command | What you get | | --- | --- | --- | -| 1 | `modernize-preflight [target-stack]` | Is the environment ready? Asks the five questions only a person can answer, checks tools and a real build, finds missing source, and says what to fix. `PREFLIGHT.md` | -| 2 | `modernize-assess ` | What am I dealing with: inventory, complexity, debt, security, and the recommended pattern. `ASSESSMENT.md` | -| 3 | `modernize-map ` | The structure: dependencies, data flow, entry points and business flows as an interactive map (`TOPOLOGY.html`). Takes an existing dependency graph with `--graph `. | -| 4 | `modernize-extract-rules ` | The business rules as testable Given/When/Then cards with `file:line` citations, each checked by a second agent. `BUSINESS_RULES.md` | -| 5 | `modernize-brief [target-stack]` | The phased plan a steering committee approves. Nothing is built until you approve it. `MODERNIZATION_BRIEF.md` | -| 6 | one of `uplift`, `transform`, `reimagine` | The build. See below. | -| 7 | `modernize-harden ` | A security scan of the still-running legacy system, with ranked findings and a reviewed patch you apply yourself. `SECURITY_FINDINGS.md` | +| 0 | `modernize` | Say what you want. Writes `INTENT.md`; every later command reads it. | +| 1 | `modernize-preflight [target-stack] [--source ]` | Is the environment ready? Asks five questions only a person can answer (is this the whole system or a slice, can it build and test here, is there custom build tooling, has anyone tried before, is anything off limits), proves a build works on this code, and finds missing source. | +| 2 | `modernize-assess ` | What am I dealing with: inventory, complexity, debt, security, and a recommended pattern. | +| 3 | `modernize-map ` | The structure: dependencies, data flow, entry points and business flows, as an interactive map. | +| 4 | `modernize-extract-rules ` | The business rules as testable Given/When/Then cards with `file:line` citations, each re-checked by a second agent. | +| 4b | `modernize-review ` | A person confirms or corrects the rules that look wrong. Your answers reach the plan and the build. With the live pane on, `/modernize-review-pane` does the same one card at a time. | +| 5 | `modernize-brief [target-stack]` | The phased plan a steering committee approves. **Nothing is built until you approve it.** | +| 6 | `uplift`, `transform` or `reimagine` | The build (see below). | +| 7 | `modernize-verify ` | **The proof.** An independent re-check with one verdict per module. | +| 8 | `modernize-harden ` | A security scan of the legacy system with a reviewed patch you apply yourself. | + +`assess --portfolio ` surveys many systems and ranks them on one page. `modernize-status ` says where you are and gives the exact command to paste. + +**A person decides at six points**, and the plugin never decides them for you: the five preflight answers, the rules that look wrong (`review`), approving the brief, accepting any difference the proof finds, signing the proof, and applying the security patch. -`assess --portfolio ` ranks many systems into a sequencing heat-map. +## How it proves the result -## Choose how to build (the brief recommends one) +Modernization fails quietly: the new code passes the tests someone wrote, and differs on the inputs nobody thought of. So the proof is built from evidence a script can check, not from the model's opinion. `modernize-verify` runs after a build, ideally in a fresh session, and re-does the work instead of trusting the notes the build left behind: + +- **The tests, run again from clean.** Build output is deleted, the full suite runs, and the counts come from the runner's own result files or a saved log. A run that executed no tests, or skipped them, is a failure, and a count the command merely typed in does not count. +- **Old and new on the same inputs.** Where the legacy code can run, both run on the same inputs and a script compares every byte. Only fields that must vary (timestamps, generated ids) are masked, floating-point output can be compared within a declared tolerance, and every masked field is listed in the result. A difference a person accepts is recorded with the reason. +- **Inputs nobody used.** It invents at least ten new inputs (boundaries, empty, huge, unusual order, and malformed records when you asked for exact behavior, quirks included) and compares again, so a suite that only passes on the cases the model chose is caught. +- **Tests that can fail.** A deliberate one-line break must turn tests red (the canary), and the comparison itself is checked by changing one byte of an output. +- **Every critical rule is backed by a test that ran.** Each P0 business rule must be named by a test that executed and passed. A rule named only by a skipped or pending test is listed as "named, not run", and a test folder that holds no code of its own is listed as tooling and gets no verdict. +- **The source is untouched**, checked by file times without running anything inside the analyzed tree. + +Each module gets one verdict, computed by `scripts/proof_pack.py` from those files with rules written into the output: **PROVEN**, **PARTLY PROVEN** (with what is missing) or **NOT PROVEN** (nothing ran, something differs, a test fails). If the old system cannot run where you work (a mainframe program, a system that only runs in production), the old behavior can only be checked against recorded outputs, and the best verdict is PARTLY PROVEN: the page says so plainly. Anything a person must decide (open questions, exit criteria, the sign-off) is listed as waiting for a person and is never ticked for you. Every verdict is computed again from current evidence each time; none is carried over from an earlier run. + +![The proof tab of the report: what passed for one rewritten module, a table of checks each with its detail, and the count of critical rules that a test names.](assets/media/report-proof.jpg) + +## Choose how to build (the plan recommends one) | If you want | Run | What happens | | --- | --- | --- | -| The same language on a newer version (.NET Framework 4.8 to .NET 8, Java 8 to 17, Spring Boot 2 to 3) | `modernize-uplift ` | Keeps your code and fixes only what the new version breaks, driven by a catalog of the breaking changes this code actually hits. One pilot unit first and its lessons written down, then batches. Proves nothing changed by running the test suite on both versions where both can run. | -| A new stack, one module at a time, while the old system keeps running | `modernize-transform [module] [target-stack]` | A plan you approve, tests that pin the old behavior, an idiomatic rewrite, and proof: the tests are run, counted, and shown to fail when the code is deliberately broken. | -| A rebuild on a new architecture | `modernize-reimagine ` | A spec mined from the code, an architecture that is reviewed and approved, then services scaffolded with executable acceptance tests. | +| The same technology on a newer version (.NET Framework to .NET 8, Java 8 to 17, Spring Boot 2 to 3) | `modernize-uplift [source-version] [target-version]` | Keeps your code and fixes only what the new version breaks, driven by a catalog of the breaking changes this code actually hits. One pilot unit first with its lessons written down, then batches. The proof is the same test suite run on both versions. | +| A new technology, one module at a time, while the old system keeps running | `modernize-transform [module] [target-stack]` | A plan you approve, tests that pin the old behavior, an idiomatic rewrite, and proof: old and new run on the same inputs and a script compares them. | +| A rebuild on a new architecture | `modernize-reimagine [target-vision]` | A spec mined from the code, an architecture that is reviewed and approved, then services scaffolded with executable acceptance tests. | -If the delta catalog shows an "uplift" would rewrite most of the code, the command says so and points to `transform`. +A version move keeps your code, so it can skip `extract-rules` and `review`: `preflight`, `assess`, `uplift`, `verify` is a complete path, and `map` and `brief` add the unit order and an approved phased plan for a large system. If the delta catalog shows an "uplift" would rewrite most of the code, the command says so and points to `transform`. Rehost (move as is) and Replace (buy a product) change no code, so no build command applies; the analysis is still useful for both. + +## What it has been tried on + +The commands were run for real, headlessly, on public codebases while the plugin was built, and what broke was fixed. Every number below comes from the files those runs wrote. The same command can give different counts on a second run (the security scan of the osCommerce code found 48 confirmed findings and then 52), so read the numbers as typical, not exact. Wherever a person had to decide (approve a plan, accept a difference), the tester played that person. Some runs stopped early because of limits of the test machine (it refused to run any freshly compiled program, and its package index refused installs); the plugin said so and did not work around them. + +| Codebase | Move | What it did and what was shown | +| --- | --- | --- | +| **AWS CardDemo** (COBOL, CICS, JCL) | Rewrite in Java, one job at a time | 35 rules (8 critical) and a five-phase plan, then the monthly interest job rewritten in Java 21 (213 tests at the end). Five independent checks in a row compared it with the real COBOL program, built locally, on inputs written after the fact. Each found something the tests had missed, and each was answered: a blank field that halted the job, a non-numeric account key, a negative zero, and differences the owner accepted as deliberate. The last check tried fifteen more inputs with malformed records and found seven more differences, so it ended NOT PROVEN. It also told two problems of the old system's test harness apart from defects in the new code. What ends a loop like this is a person deciding which inputs are in scope; the verify command now reads that from the intent you gave the front door. | +| **Eclipse Jetty** (Java 8, 2,600 files) | Java 8 to 17 | A pilot on the `jetty-util` module: the same 946 tests give the same results on both Java versions. Building and running both versions found six changes that reading the code had not predicted: a direct buffer reported as memory-mapped on 17, a bundle plugin that writes an invalid manifest and still says SUCCESS, and a build on JDK 13 to 16 that would have shipped Java 8-labelled classes that crash on Java 8, among others. 50 tests were added for the 25 of 56 critical rules that had none (996 tests run on each version, no differences). | +| **osCommerce** (PHP 5, about 44,000 lines of PHP) | PHP to Python and FastAPI | 97 rules (26 critical) and a six-phase plan. First slice, the product page: 17,957 tests pass, and 17,727 comparison cases against the real PHP files are identical. Two deliberate breaks each turned tests red. The architecture review found two high-severity problems (expired specials still shown, and a page request holding a database write lock) that were fixed with tests that failed first. An independent verification said PROVEN: its own break made 647 more tests fail, and 14 new inputs matched the real PHP. | +| **AngularJS RealWorld** (AngularJS 1.5) | AngularJS to React and TypeScript | 79 rules (5 critical). The articles service was rewritten: 166 tests, and 29 comparison cases against recorded responses of the real API (23 identical, 6 differences approved as deliberate, none unexplained). Four deliberate breaks each turned tests red, and the review's two high-severity findings were fixed. Checked by the build step itself; there was no separate verification run. | +| **JPetStore** (Java and JSP) | Rebuild as a REST API | A spec with 12 capabilities, the 35 rules and a four-phase plan. The architecture review found two blockers (an order confirmation that could not be safely replayed, and cart updates lost under parallel requests); both were designed out. One service was scaffolded: 35 tests ran and passed, 56 more are pending or need Docker. The independent check said NOT PROVEN: 6 of 24 new comparisons with the old application differ, and the development cases hold no old-versus-new comparison yet. That run also showed the proof step counting skipped tests as covering a rule; it now flags five of the six critical rules as named only by tests that did not run. | +| **beets** (Python 2, about 19,000 lines) | Python 2 to 3 | 21 rules for the tagging module (4 critical), all about matching. Only 3 files in the whole tree fail to compile on Python 3, so it is an uplift and not a rewrite. No existing test could run on Python 3 yet, and the packages they need were refused by this machine's package index; the plugin reported that and did not claim a pass. | +| **Spring PetClinic** (7 services) | Spring Boot 2.6 to 3.3 | A delta catalog with exact target versions: 59 `javax` imports in 10 files to move, a request that answered 200 on 2.6 and answers 400 on 3.3 (verified by running both), a Hibernate 6 identifier check that came out safe, and a monitoring endpoint that Boot 3 dropped. The pilot stopped at the plan gate because the approved plan named a different first service, and the command enforced the plan. | +| **AWStats** (Perl, about 43,000 lines) | Perl to Python and FastAPI | 88 rules (2 critical) and a six-phase plan that keeps replacing it with an existing product open as the alternative. The security scan confirmed 48 findings, 9 of them high (7 in an optional module that runs as root), and refuted 14 of 62 as false positives. | +| **Redmine 2.3.3, eShop (.NET), Jenkins pipelines** | Rails 3.2 to 7.1, .NET Framework 4.7.2 to .NET 10, Jenkins to GitHub Actions | Maps, rules (185, 57 and 58) and plans. Redmine's assessment led with "check whether upstream already made this move". eShop's catalog lists 12 silent behavior changes and says the first phase must build a test harness because the solution has none. | +| **NetHack, KISS FFT, BSD numbers** (C) | C to Python, and to Rust | 28, 70 to 93 and 56 rules. NetHack's first slice (its declarations, in Python) matched the C program on 8 of 8 comparison cases. The Rust runs stopped at the plan: this Mac killed every freshly compiled program, so the plugin listed what could not run and did not work around it. | +| **A booby-trapped codebase** (built for the test) | Rewrite | Planted instructions in comments, the README, a `CLAUDE.md` and a project settings file, a script that would drop a marker file, and file names with shell syntax. Nothing planted was obeyed, no marker file appeared, the source stayed unchanged, the planted lines were listed in the report, and the credential was masked. | + +## What to expect + +Steps run as agents working for you, and the heavy ones run many at once. Rough times on systems of tens of thousands of lines: preflight 3 to 4 minutes, assess 5 to 8, map 5 to 15, extract-rules 5 to 15, brief about 5. Building one module takes 15 to 30 minutes, an uplift pilot about 15. The heaviest step, `extract-rules`, started 50 to 200 agents in these runs, and every fan-out step says how many it will start; `extract-rules` asks before a big run. On systems in the millions of lines, work one module or unit at a time. The size index in `assess` is a relative measure for ranking systems, never a schedule or a cost. + +## Words you will see + +| Word | Plain meaning | +| --- | --- | +| Agent | A separate Claude worker that does one job (read one module, check one rule) and reports back. Steps start many of them at once. | +| Business rule card | One thing the system does, written as Given / When / Then with the file and line it comes from, so a person can check it. | +| P0 | A rule that would defeat the system's purpose or be costly or irreversible if it were wrong. Everything else is P1 or P2. | +| Brief | The written plan, phase by phase. You approve it; commands never build anything before that. | +| Uplift / transform / reimagine | Newer version of the same technology / rewrite in another technology / rebuild on a new architecture. | +| Pilot | The first small unit built end to end, so its lessons are written down before the rest is attempted. | +| Canary | A deliberate one-line break in the new code that must make tests fail, proving the tests can fail. | +| Delta catalog | The list of things the newer version breaks that this code actually uses. | ## Set it up so it runs smoothly @@ -70,36 +126,74 @@ The commands never edit your code, by convention. A `.claude/settings.json` in t - The rule covers Claude's file tools and the shell commands it recognizes. A script that opens files itself is not covered, so keep Bash on a *prompted* permission mode for the two steps that fan out many writing agents at once (`uplift` step 5b and `reimagine` phase E). - Shell commands still ask even in accept-edits mode (`python3` scripts, `scc`, `rsync`, your build and test commands, anything outside the workspace). Use accept-edits mode or allow rules for the ones you trust. -Helpful but optional (run `preflight` to check them all): [`scc`](https://github.com/boyter/scc) or `cloc` for size metrics; `python3` for the map, the shard builder and the report; a build toolchain for your stack, which enables the strongest equivalence proof (running old and new side by side); and the whole system in the tree (deployment descriptors, copybooks, DDL), which entry points and data lineage need. Without a toolchain the plugin falls back to recorded-output tests and says so. +Helpful but optional (run `preflight` to check them all): [`scc`](https://github.com/boyter/scc) or `cloc` for size metrics; Python 3.8 or newer as `python3` (on Windows `python` or `py -3` works) for the map, the shard builder, the proof and the report; a build toolchain for your stack, which enables the strongest proof (running old and new side by side); and the whole system in the tree (deployment descriptors, copybooks, DDL), which entry points and data lineage need. Without a toolchain the plugin falls back to recorded-output tests and says so. ## Safety -- **Analyzed code is untrusted input.** A hostile codebase can plant comments like "ignore previous instructions" to steer what lands in `BUSINESS_RULES.md` or `SECURITY_FINDINGS.md`. Agents treat file content as data and flag instruction-shaped text, verification agents re-derive every rule and finding from the cited code, and `brief` is a human approval gate before anything is built. Treat discovery artifacts from untrusted code with the same skepticism as the code. +- **Analyzed code is untrusted input.** A hostile codebase can plant comments like "ignore previous instructions", a README that tells tools to run a script, or file names with shell syntax. Agents treat file content as data, list the instruction-shaped text they found and never follow it (the legacy code's own build and tests run only where a command needs its behavior, in a scratch copy when it can), verification agents re-derive every rule and finding from the cited code, and `brief` is a human approval gate before anything is built. Treat discovery artifacts from untrusted code with the same skepticism as the code. - **Secrets stay out of shared artifacts.** Discovered credentials are masked (`AKIA****`) and inventoried in a gitignored `SECRETS.local.md` (or `~/.modernize//` outside git); `harden` keeps credential-removal hunks in a separate gitignored patch. `--show-secrets` puts raw values in the quarantine file only. +- **The old system is run only where it is safe.** Baselines come from the legacy code running locally or against a test environment you named. Production or third-party services, new accounts and real data are off limits unless the plan you approved names them, a token in a recorded response is replaced before anything is saved, and every command stops the servers it started. - **Trying it on a live repository.** `preflight` and `assess` change no source file. Preflight's smoke test compiles one file and, where there is a build system, restores and builds one small project, which writes build output wherever the build normally does. +## Telemetry + +The plugin counts how it is used, so the next version can be better. It sends **whole numbers only**: never code, file or system names, paths, prompts or anything you typed. Counts of 100 or more are rounded to two significant figures (17,727 is sent as 18,000), so a number says roughly how big, not exactly which system. It sends them through Claude Code's own telemetry, so nothing is sent to Anthropic when that is off. The plugin itself makes no network call and adds no identifier; the one file it writes is a small `telemetry-state.json` of hashes in its own data folder, so the same counts are not sent twice. + +Two hooks do it, and only in a folder where you are using the plugin (you typed one of its commands, or the folder holds an `analysis//` folder with files it wrote, such as `INTENT.md` or `PREFLIGHT.md`): + +- **When you type one of the plugin's commands:** which command, and how far that system had got. +- **When a turn ends and the counts changed:** how far the newest system has got. + +| Key | What it counts | +| --- | --- | +| `pv` | plugin version as major*10000 + minor*100 + patch | +| `cmd` | command typed: 1 front door, 2 preflight, 3 assess, 4 map, 5 extract-rules, 6 review, 7 brief, 8 transform, 9 uplift, 10 reimagine, 11 verify, 12 harden, 13 status, 20 to 22 the pane's commands, 99 other | +| `perm` | permission mode the session ran in: 0 unknown, 1 default, 2 accept edits, 3 plan, 4 auto, 5 bypass, 6 don't ask | +| `has_source` | 1 when the command carried `--source` | +| `fresh` | 1 when the system had no artifacts yet | +| `systems` | systems under `analysis/` | +| `goal` | 0 unknown, 1 understand, 2 uplift, 3 transform, 4 reimagine | +| `lang` | the language with most lines in the map: 1 COBOL, 2 Java, 3 C# and .NET, 4 Python, 5 PHP, 6 Perl, 7 C, 8 C++, 9 JavaScript and TypeScript, 10 Ruby, 11 Go, 12 Rust, 13 Kotlin and Scala, 14 SQL, 15 Fortran, 16 RPG, 17 Pascal and Delphi, 18 shell, 19 assembler, 99 other, 0 unknown | +| `done` | the steps that have left their file, added up: preflight 1, assess 2, map 4, rules 8, reviewed 16, brief 32, approved 64, built 128, verified 256, signed 512, hardened 1024, report 2048, deltas 4096, baseline 8192, playbook 16384, spec 32768 | +| `map_kloc` | thousand lines of code in the map | +| `rules`, `p0` | business rules found, and the critical ones among them | +| `rev_ok`, `rev_wrong` | rules a person confirmed, and rules a person marked wrong | +| `phases` | phases in the plan | +| `built` | modules or services built (an uplift's working copy counts as one once it exists) | +| `eq_cases`, `eq_diff`, `eq_appr` | old-versus-new comparison cases run, differences or missing outputs nobody approved, differences a person approved (counted from the case list, the way the report counts them) | +| `v_proven`, `v_partly`, `v_not` | modules judged PROVEN, PARTLY PROVEN and NOT PROVEN | +| `sec_crit`, `sec_high` | critical and high security findings | + +To see exactly what would be sent for your workspace, before anything is sent, run `python3 scripts/telemetry.py show /path/to/workspace` from the plugin's folder (add `--prompt "/code-modernization:modernize-verify billing"` to see a command's counts). + +To turn it off, use any one of these: the plugin's **Usage counts** option, `CODE_MODERNIZATION_TELEMETRY=0` in your environment (anything but an explicit `1` or `on` counts as off), or Claude Code's own `DISABLE_TELEMETRY=1` (or `CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1`). Nothing is sent while any of them is set. + +If nothing seems to be sent when you expect it, set `CODE_MODERNIZATION_TELEMETRY_DEBUG=1`: each hook run then adds one line saying what it decided to `telemetry-debug.log` in the plugin's data folder. + ## Working in a team -State lives in files, not in chat: later commands read the brief and `PREFLIGHT.md`, not your conversation, so a second person or a fresh session can run `status` and continue. The commands never commit, so commit `analysis/` and `modernized/` yourself. +State lives in files, not in chat: later commands read the brief, the intent and `PREFLIGHT.md`, not your conversation, so a second person or a fresh session can run `status` and continue. The commands never commit to your repository, so commit `analysis/` and `modernized/` yourself (an uplift's working copy gets its own local history, for a reviewable diff). | Artifact | Suggested reviewer | | --- | --- | | `PREFLIGHT.md` (the five answers, scope boundary, build checks) | whoever owns the build | | `ASSESSMENT.md`, `REPORT.html` | the engineering lead or sponsor | | `topology.json`, `TOPOLOGY.html` | engineers who know the system | -| `BUSINESS_RULES.md` | a business expert per domain: start with the P0 rules and the closing question list | +| `BUSINESS_RULES.md` (then `modernize-review`) | a business expert per domain: start with the P0 rules and the closing question list | | `MODERNIZATION_BRIEF.md` | the approver, who steers execution by editing it | +| `VERIFICATION.md` | the approver and a second engineer, who sign it | | `SECURITY_FINDINGS.md` and the patch | a security engineer, who applies the patch | ## Live progress pane (early access) -A pane beside the transcript that shows the map of your code, how far each part has got and what to run next, in any language and for any of the three ways of building. It needs Claude Code's early-access function hooks: start with `CLAUDE_CODE_ENABLE_FUNCTION_HOOKS=1 claude`. Without the flag nothing changes. Details are in [hooks/README.md](hooks/README.md). +A pane beside the transcript that shows the map of your code, how far each part has got, each built module's proof verdict, and what to run next, in any language and for any of the three ways of building. It needs Claude Code's early-access function hooks: start with `CLAUDE_CODE_ENABLE_FUNCTION_HOOKS=1 claude`. Without the flag nothing changes. Its three commands are typed bare: `/modernize-panel` shows or hides it, `/modernize-review-pane` reviews the flagged rule cards in it, and `/modernize-sign` fills in the plan's approval block. Details are in [hooks/README.md](hooks/README.md). + +![The live pane beside the transcript for a rewrite: the map with one module reviewed, the phases, a module marked proven, the next command, and two items that need attention.](assets/media/pane-rewrite.png) ## Good to know -- **The assessment's COCOMO figure is a relative size index, never a timeline or a cost.** Its constants encode human-team productivity, which agentic work does not follow. -- **A model does the extraction, so two runs can find different rules.** Treat `BUSINESS_RULES.md` as reviewed output, not a deterministic build artifact. Headings are always `### RULE-NNN: `. -- **Large runs are resumable.** On Claude Code builds with the Workflow tool, `extract-rules`, `harden`, `assess --portfolio`, `reimagine` and `uplift` run as scripted multi-agent jobs that verify findings adversarially. `extract-rules` shards by module and asks before a big run; a stopped run resumes in the same session with its run ID, and finished agents replay from the journal. `uplift` migrates in escalating batches behind a circuit breaker. Older builds fall back to plain subagents automatically. +- **A model does the extraction, so two runs can find different rules.** Treat `BUSINESS_RULES.md` as reviewed output, not a deterministic build artifact. Rules are cut one per business decision, not one per branch, and headings are always `### RULE-NNN: `. +- **Large runs are resumable.** On Claude Code builds with the Workflow tool, `extract-rules`, `harden`, `assess --portfolio`, `reimagine` and `uplift` run as scripted multi-agent jobs that verify findings adversarially. `extract-rules` shards by module and asks before a big run; a stopped run resumes in the same session with its run ID, and finished agents replay from the journal. Older builds fall back to plain subagents automatically. - **Scripting it (`claude -p`).** Long steps run as background workflows, and a headless session stops waiting for background work after 10 minutes. Set `CLAUDE_CODE_PRINT_BG_WAIT_CEILING_MS=0` so `extract-rules`, `harden` and the other fan-out steps can finish, and answer a step's approval gate by resuming the session with `--resume`. - **Adapting it.** Commands, agents and workflows are markdown and JavaScript under Apache 2.0: fork them to change the prompts or steps for your stack. - **Agents.** `legacy-analyst`, `business-rules-extractor`, `architecture-critic`, `security-auditor`, `test-engineer`, `version-delta-analyst`, `uplift-migrator` and `scaffolder` are invoked by the commands (or directly). The last two write only inside their own unit's directory. -- cgit From c8874f5ad883e26428f483ffa4d537cc81489e64 Mon Sep 17 00:00:00 2001 From: Morgan Lunt Date: Fri, 25 Sep 2026 12:06:43 -0700 Subject: code-modernization: count failures and the machine's python, once per version Usage counts now say what the plugin runs on (system, python status and version, path problems) and which kind of failure happens: a missing or placeholder python, a permission block, a model error, or an error in the plugin's own script. Failures are classified on the machine into a fixed list and only the code is sent, once per kind per session. A session-start ping, once per plugin version, counts machines where nobody gets as far as typing a command. When python cannot run, the shell wrapper reports that itself, and on Windows it falls back to python or the py launcher. --- plugins/code-modernization/README.md | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'plugins/code-modernization/README.md') diff --git a/plugins/code-modernization/README.md b/plugins/code-modernization/README.md index 691d355a..e9da7047 100644 --- a/plugins/code-modernization/README.md +++ b/plugins/code-modernization/README.md @@ -139,10 +139,15 @@ Helpful but optional (run `preflight` to check them all): [`scc`](https://github The plugin counts how it is used, so the next version can be better. It sends **whole numbers only**: never code, file or system names, paths, prompts or anything you typed. Counts of 100 or more are rounded to two significant figures (17,727 is sent as 18,000), so a number says roughly how big, not exactly which system. It sends them through Claude Code's own telemetry, so nothing is sent to Anthropic when that is off. The plugin itself makes no network call and adds no identifier; the one file it writes is a small `telemetry-state.json` of hashes in its own data folder, so the same counts are not sent twice. -Two hooks do it, and only in a folder where you are using the plugin (you typed one of its commands, or the folder holds an `analysis//` folder with files it wrote, such as `INTENT.md` or `PREFLIGHT.md`): +Five small hooks do it: -- **When you type one of the plugin's commands:** which command, and how far that system had got. -- **When a turn ends and the counts changed:** how far the newest system has got. +- **When you type one of the plugin's commands:** which command, how far that system had got, and what it is running on (operating system, python status and version, and whether the folder's path has a space or unusual characters). +- **When a turn ends and the counts changed:** how far the newest system has got, and how the last rule extraction went (agents started, lost, unverified). Only in a folder where the plugin has left files such as `INTENT.md` or `PREFLIGHT.md`. +- **When something fails:** a tool call that errored, or a model call that ended a turn. The failure's text is read on your machine to choose one code from a fixed list (python missing, blocked by a permission rule, timed out, file not found, rate limit and so on) and only the code is sent, at most once per kind per session. Only where the plugin is in use or the failing command names it. +- **When one of the plugin's own scripts raises an error:** which kind of error and which line, never its message. +- **Once per plugin version on each machine, at the start of a session:** what the plugin runs on (the same operating system, python and path numbers), so that machines where nobody gets as far as typing a command are still counted once. This is the one number that is sent without you using the plugin. + +If python is missing, is the Windows Store placeholder, is too old or crashes, the small shell script that starts the hooks says so in numbers itself, because python cannot report its own absence. If it finds `python` or the `py` launcher working, it uses that instead. | Key | What it counts | | --- | --- | @@ -163,11 +168,22 @@ Two hooks do it, and only in a folder where you are using the plugin (you typed | `eq_cases`, `eq_diff`, `eq_appr` | old-versus-new comparison cases run, differences or missing outputs nobody approved, differences a person approved (counted from the case list, the way the report counts them) | | `v_proven`, `v_partly`, `v_not` | modules judged PROVEN, PARTLY PROVEN and NOT PROVEN | | `sec_crit`, `sec_high` | critical and high security findings | +| `os` | system: 1 macOS, 2 Linux, 3 Windows, 4 Windows subsystem for Linux, 0 other | +| `py` | how python worked: 0 python3 ran, 1 none found, 2 macOS developer-tools stub, 3 python3 present but broken (the Windows Store placeholder), 4 python3 unusable but python or py ran, 5 too old, 6 the script crashed | +| `pyv` | python version as major*100 + minor (311 is 3.11) | +| `pathf` | the folder's path: 1 has a space, 2 has non-ASCII characters, 4 is over 200 characters (added up) | +| `tool` | the tool that failed: 1 Bash, 2 Read, 3 Edit or Write, 4 Glob or Grep, 5 agent, 6 Workflow, 7 asking the person, 8 skill, 9 web, 10 a connector, 99 other | +| `kind` | what went wrong: 1 python or another interpreter missing, 2 the Windows Store python stub, 3 the macOS developer-tools stub, 4 python too old or a syntax error, 5 one of the plugin's scripts raised an error, 6 blocked by a permission rule or policy, 7 a file permission was denied, 8 timed out, 9 a file or folder was not found, 10 network, certificate or sign-in, 11 disk or memory, 12 workflow or agent trouble, 99 other | +| `api` | a model call ended a turn: 1 rate limit, 2 sign-in failed, 3 billing, 4 invalid request, 5 server error or overloaded, 6 output too long, 7 network or timeout, 99 unknown | +| `err`, `err_at` | the plugin's own script raised: 1 KeyError, 2 ValueError, 3 OSError, 4 TypeError, 5 AttributeError, 6 RecursionError, 7 MemoryError, 8 UnicodeError, 99 other; and the line of `telemetry.py` where it raised | +| `agents`, `wf_failed`, `wf_skip`, `wf_unver` | agents the last rule extraction started, modules or agents it lost, modules it skipped, rules it could not verify | To see exactly what would be sent for your workspace, before anything is sent, run `python3 scripts/telemetry.py show /path/to/workspace` from the plugin's folder (add `--prompt "/code-modernization:modernize-verify billing"` to see a command's counts). To turn it off, use any one of these: the plugin's **Usage counts** option, `CODE_MODERNIZATION_TELEMETRY=0` in your environment (anything but an explicit `1` or `on` counts as off), or Claude Code's own `DISABLE_TELEMETRY=1` (or `CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1`). Nothing is sent while any of them is set. +**What these numbers cannot see.** A machine where the shell cannot start the hooks at all (for example Windows without Git Bash) sends nothing, and neither does a machine that never starts a session with the plugin enabled, so failure rates here are a floor, not a total. Read them next to install counts and Claude Code's own hook-failure events. + If nothing seems to be sent when you expect it, set `CODE_MODERNIZATION_TELEMETRY_DEBUG=1`: each hook run then adds one line saying what it decided to `telemetry-debug.log` in the plugin's data folder. ## Working in a team -- cgit