summaryrefslogtreecommitdiff
path: root/plugins/code-modernization
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/code-modernization')
-rw-r--r--plugins/code-modernization/README.md1
-rw-r--r--plugins/code-modernization/commands/modernize-assess.md4
-rw-r--r--plugins/code-modernization/commands/modernize-extract-rules.md8
-rw-r--r--plugins/code-modernization/commands/modernize-harden.md6
-rw-r--r--plugins/code-modernization/commands/modernize-reimagine.md4
-rw-r--r--plugins/code-modernization/commands/modernize-transform.md7
-rw-r--r--plugins/code-modernization/commands/modernize-uplift.md25
7 files changed, 36 insertions, 19 deletions
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: <name>`.
- **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.
diff --git a/plugins/code-modernization/commands/modernize-assess.md b/plugins/code-modernization/commands/modernize-assess.md
index dec2eb23..a9b6b752 100644
--- a/plugins/code-modernization/commands/modernize-assess.md
+++ b/plugins/code-modernization/commands/modernize-assess.md
@@ -23,9 +23,11 @@ list the subdirectories first (`ls -d <parent-dir>/*/ | xargs -n1 basename`; the
script has no filesystem access), tell the user the count (30 systems means 30
agents), then run one survey agent per system:
+Call it by name (the plugin registers it). If the tool does not know the name, pass `scriptPath: "${CLAUDE_PLUGIN_ROOT}/workflows/portfolio-assess.js"` instead:
+
```
Workflow({
- scriptPath: "${CLAUDE_PLUGIN_ROOT}/workflows/portfolio-assess.js",
+ name: "code-modernization:modernize-portfolio-assess",
args: { parentDir: "<parent-dir>", systems: ["<sub1>", "<sub2>", ...] }
})
```
diff --git a/plugins/code-modernization/commands/modernize-extract-rules.md b/plugins/code-modernization/commands/modernize-extract-rules.md
index 7c405d57..e1a79740 100644
--- a/plugins/code-modernization/commands/modernize-extract-rules.md
+++ b/plugins/code-modernization/commands/modernize-extract-rules.md
@@ -50,9 +50,11 @@ A run is capped at 1000 agents: for more than about 70 shards, launch parts of a
one `Workflow` call after another, and merge the results (concatenate rules, de-duplicate
by `source` + name) before rendering once.
+Call it by name (the plugin registers it). If the tool does not know the name, pass `scriptPath: "${CLAUDE_PLUGIN_ROOT}/workflows/extract-rules.js"` instead:
+
```
Workflow({
- scriptPath: "${CLAUDE_PLUGIN_ROOT}/workflows/extract-rules.js",
+ name: "code-modernization:modernize-extract-rules-mine",
args: {
system: "$system",
modules: <contents of analysis/$system/extract-rules.modules.json>, // omit in lens mode
@@ -70,7 +72,7 @@ resume. Show the workflow's per-batch log lines as they arrive.
- **Stopped or failed** (`status: failed`, `TaskStop`, an interrupted session) so no result
came back: if the error names the args, fix them and relaunch; otherwise **resume, never
restart, and never fall back to Method B**: completed agents are journaled. Stop a run that
- is somehow still going, then re-invoke with the **identical** `scriptPath` and `args` (re-read
+ is somehow still going, then re-invoke with the **identical** workflow `name` and `args` (re-read
the modules file; cut it the same way if split) plus `resumeFromRunId: "<Run ID>"`. Finished
agents replay instantly. After `parallel[i] failed` lines the resume re-runs from that
batch onward, still far cheaper than starting over. If resume is impossible, read
@@ -79,7 +81,7 @@ resume. Show the workflow's per-batch log lines as they arrive.
- **Completed with failures** (`<failures>` lists dead agents): **do not resume** (a failed
agent makes the journal replay everything after it). Use the result: `rerunModules` holds
every shard with a gap, re-passable. Render what was confirmed, then offer one follow-up
- invocation (same `scriptPath`, `args.modules` = `rerunModules`, no `resumeFromRunId`) and
+ invocation (same workflow `name`, `args.modules` = `rerunModules`, no `resumeFromRunId`) and
fold its result in.
### 4. Render
diff --git a/plugins/code-modernization/commands/modernize-harden.md b/plugins/code-modernization/commands/modernize-harden.md
index bab2716c..6267391a 100644
--- a/plugins/code-modernization/commands/modernize-harden.md
+++ b/plugins/code-modernization/commands/modernize-harden.md
@@ -35,9 +35,11 @@ commentary.
formula, 5 + N + M**: 5 finders, N refuters (one per distinct finding), M second judges (one per finding
still Critical or High after refutation); N and M are known only once the finders return.
+Call it by name (the plugin registers it). If the tool does not know the name, pass `scriptPath: "${CLAUDE_PLUGIN_ROOT}/workflows/harden-scan.js"` instead:
+
```
Workflow({
- scriptPath: "${CLAUDE_PLUGIN_ROOT}/workflows/harden-scan.js",
+ name: "code-modernization:modernize-harden-scan",
args: { system: "$system" }
})
```
@@ -121,7 +123,7 @@ Only when the user takes the offer. Call the workflow again with just the gaps,
```
Workflow({
- scriptPath: "${CLAUDE_PLUGIN_ROOT}/workflows/harden-scan.js",
+ name: "code-modernization:modernize-harden-scan",
args: { system: "$system", classes: <deadFinders>, findings: <unverified> }
})
```
diff --git a/plugins/code-modernization/commands/modernize-reimagine.md b/plugins/code-modernization/commands/modernize-reimagine.md
index f06970c9..7fa08883 100644
--- a/plugins/code-modernization/commands/modernize-reimagine.md
+++ b/plugins/code-modernization/commands/modernize-reimagine.md
@@ -63,9 +63,11 @@ available). The approval authorizes the build-out.
**With the Workflow tool,** scaffold **every** service in the approved architecture (no cap; the runtime
queues agents). Tell the user the service count, then:
+Call it by name (the plugin registers it). If the tool does not know the name, pass `scriptPath: "${CLAUDE_PLUGIN_ROOT}/workflows/reimagine-scaffold.js"` instead:
+
```
Workflow({
- scriptPath: "${CLAUDE_PLUGIN_ROOT}/workflows/reimagine-scaffold.js",
+ name: "code-modernization:modernize-reimagine-scaffold",
args: { system: "$system", services: [
{ name: "<service-name>", responsibilities: "<one line from the architecture>" }, ...
] }
diff --git a/plugins/code-modernization/commands/modernize-transform.md b/plugins/code-modernization/commands/modernize-transform.md
index 2ef8b946..06ea4537 100644
--- a/plugins/code-modernization/commands/modernize-transform.md
+++ b/plugins/code-modernization/commands/modernize-transform.md
@@ -11,7 +11,7 @@ equivalence. This is one vertical slice of the strangler fig; output goes to
The code is `legacy/$system`, often a symlink to where it really lives: say where it points (`readlink legacy/$system`) in one line before you start. Run every subagent in the foreground and wait for its result: never end your turn while one is still running. **If `$module` or `$target_stack` is empty**, read
`analysis/$system/MODERNIZATION_BRIEF.md`: take the target stack it names, and the first module of
the earliest phase whose `Command:` is `transform` that has no
-`modernized/$system/<module>/TRANSFORMATION_NOTES.md` yet. Say which you picked.
+`modernized/$system/<module>/TRANSFORMATION_NOTES.md` yet (with no brief, the target in `INTENT.md`). Say which you picked.
## Step 0 — Toolchain, then the plan (human gate)
@@ -42,7 +42,8 @@ prove equivalence, and anything ambiguous that needs a human decision now.
Spawn the **test-engineer** subagent: "Write characterization tests for module $module of legacy/$system.
Read the source, identify every observable behavior and encode each as a test with concrete input and
expected output derived from the legacy logic. Target framework: <right for $target_stack>. Write to
-`modernized/$system/$module/src/test/`. These tests define 'done'. Follow your secret-handling rules:
+`modernized/$system/$module/src/test/`. These tests define 'done'. Name the `RULE-NNN` id(s) each test pins
+(from `analysis/$system/BUSINESS_RULES.md`) in its name or a one-line comment, so the trace can find it. Follow your secret-handling rules:
no credential from legacy code becomes a fixture; use fake same-shape values and read anything live
from environment variables." Show the user the test file and get a yes before going on.
@@ -85,6 +86,8 @@ unreachable branches) and why; the canary result and the executed-case count; fo
dependent module. Show one representative behavior side by side
(`diff -y --width=160 <(sed -n '<lines>p' <legacy file>) <target file>`). Never pick a credential-bearing
range, and mask any credential-like literal in the notes: they live in `modernized/` and get committed.
+This is your own evidence: `/code-modernization:modernize-verify $system $module` is the independent re-check
+(it re-runs the tests and the comparison, tries new inputs, and gives one verdict).
## Step 5 — Architecture review
diff --git a/plugins/code-modernization/commands/modernize-uplift.md b/plugins/code-modernization/commands/modernize-uplift.md
index 2e976a4a..a3d67cce 100644
--- a/plugins/code-modernization/commands/modernize-uplift.md
+++ b/plugins/code-modernization/commands/modernize-uplift.md
@@ -1,10 +1,10 @@
---
description: Same-stack version uplift (e.g. .NET Framework 4.8 to .NET 8, Java 8 to 17) — keep the code, fix the version deltas, prove nothing changed
-argument-hint: <system> <source-version> <target-version> [project-pattern]
+argument-hint: <system> [source-version] [target-version] [project-pattern]
arguments: system source_version target_version project_pattern
---
-Uplift `$system` from **legacy/$system_version** to **$target_version**: same stack, newer version.
+Uplift `$system` from **$source_version** to **$target_version**: same stack, newer version.
The code is `legacy/$system`, often a symlink to where it really lives: say where it points (`readlink legacy/$system`) in one line before you start. Run every subagent in the foreground and wait for its result: never end your turn while one is still running.
This is **not** `transform`, which extracts intent and rewrites idiomatically. Here the code is good
@@ -22,7 +22,8 @@ recorded outputs on the target only. That is fine, but label it honestly (Step 0
## Step 0 — Toolchain and version pinning (fail fast)
-1. **Pin the version pair exactly.** If either version is vague (".NET" with no number), stop and ask.
+1. **Pin the version pair exactly.** If the versions were not given, take them from `analysis/$system/INTENT.md` or the
+ brief. If either version is missing or vague (".NET" with no number), stop and ask.
2. **Target runtime, required.** Verify it builds and tests (`dotnet --version` and a `dotnet test`
smoke; `mvn` or `gradle`; `python3 -V` and `pytest`).
3. **Source runtime, the baseline oracle.** Verify the *old* version also runs here. If it does not
@@ -87,7 +88,7 @@ pair; the working-copy plan; which ecosystem tool you will drive and whether it
project order with the overrides above; the harness plan and **whether a true dual run is possible or
it is target-only** (.NET: one test project multi-targeted, the `net48` leg needs Windows; Java: a
double JDK build; Python: separate interpreter environments); how equivalence is proven (**the baseline
-on legacy/$system_version is the oracle and $target_version must reproduce it**, or characterization tests
+on $source_version is the oracle and $target_version must reproduce it**, or characterization tests
against recorded outputs); anything ambiguous.
## Step 3 — Delta catalog (the driver artifact)
@@ -98,11 +99,13 @@ brief may have just built it); regenerate only if missing or stale.
**Preferred, with the Workflow tool** (this invocation authorizes it):
+Call it by name (the plugin registers it); if the tool does not know the name, pass `scriptPath: "${CLAUDE_PLUGIN_ROOT}/workflows/uplift-deltas.js"` instead:
+
```
Workflow({
- scriptPath: "${CLAUDE_PLUGIN_ROOT}/workflows/uplift-deltas.js",
+ name: "code-modernization:modernize-uplift-deltas",
args: { system: "$system",
- source: "legacy/$system_version", target: "$target_version", projectPattern: "$project_pattern" }
+ source: "$source_version", target: "$target_version", projectPattern: "$project_pattern" }
})
```
@@ -114,7 +117,7 @@ first. The finders are read-only: **you** write `DELTA_CATALOG.md`. Surface `inj
`upliftVsRewriteSignal` (see the end of this file).
**Fallback:** spawn the **version-delta-analyst** agent: "Build the delta catalog for uplifting legacy/$system
-from legacy/$system_version to $target_version. Run the ecosystem migration tool in report mode, intersect its
+from $source_version to $target_version. Run the ecosystem migration tool in report mode, intersect its
findings and the known breaking changes with what this code uses, cover all four categories, cite
file:line, flag silent-behavioral deltas as test-before-touch, never under-report dependency deltas."
@@ -128,7 +131,7 @@ Either way rank by blast radius and mark each delta **Mechanical** (a codemod ca
trivial real type and assert on it under both targets; if that will not go green on both, fix the
harness now, not mid-migration. If the source leg cannot run here (Step 0.3), prove the target leg and
mark it target-only.
-2. **Baseline is the oracle, and it goes in a file.** Run the existing suite on **legacy/$system_version** and
+2. **Baseline is the oracle, and it goes in a file.** Run the existing suite on **`legacy/$system`** (the $source_version code) and
write the per-test table to **`analysis/$system/BASELINE.md`**, including the tests legacy fails: you
are proving *no behavior changed*, not *all tests pass*. If the source runtime cannot run here, write
the single line `target-only: <why>` instead. Step 5 does not start until the file exists.
@@ -178,10 +181,12 @@ Only after the pilot and playbook are approved. With a handful of units left, re
in dependency order, in-session. For many units **the playbook is the prompt**: brief agents from what the
pilot proved about this codebase, not from general knowledge. With the Workflow tool:
+Call it by name (the plugin registers it); if the tool does not know the name, pass `scriptPath: "${CLAUDE_PLUGIN_ROOT}/workflows/uplift-migrate.js"` instead:
+
```
Workflow({
- scriptPath: "${CLAUDE_PLUGIN_ROOT}/workflows/uplift-migrate.js",
- args: { system: "$system", source: "legacy/$system_version", target: "$target_version",
+ name: "code-modernization:modernize-uplift-migrate",
+ args: { system: "$system", source: "$source_version", target: "$target_version",
units: [ { name: "<unit>", path: "<dir relative to modernized/$system-uplifted/>",
deps: ["<sibling unit this one depends on>", ...] }, ... ] }
})