diff options
| author | Morgan Lunt <morganl@anthropic.com> | 2026-04-28 10:02:28 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-04-28 10:02:28 -0700 |
| commit | 38b5056c446aaf7895d5563591b94bc49e8e976e (patch) | |
| tree | c4d4861bd111f6becdd2fcc8d68c8e631b65ea6c /plugins/code-modernization/commands/modernize-extract-rules.md | |
| parent | 18113ade5c13cd90e669c650a58b1c815f0b158b (diff) | |
| parent | bdca23e8e46f8832d0030c05804ae207786ae37f (diff) | |
Merge pull request #1582 from anthropics/morganl/code-modernization-plugin
Add code-modernization plugin
Diffstat (limited to 'plugins/code-modernization/commands/modernize-extract-rules.md')
| -rw-r--r-- | plugins/code-modernization/commands/modernize-extract-rules.md | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/plugins/code-modernization/commands/modernize-extract-rules.md b/plugins/code-modernization/commands/modernize-extract-rules.md new file mode 100644 index 00000000..34e62472 --- /dev/null +++ b/plugins/code-modernization/commands/modernize-extract-rules.md @@ -0,0 +1,68 @@ +--- +description: Mine business logic from legacy code into testable, human-readable rule specifications +argument-hint: <system-dir> [module-pattern] +--- + +Extract the **business rules** embedded in `legacy/$1` into a structured, +testable specification — the institutional knowledge that's currently locked +in code and in the heads of engineers who are about to retire. + +Scope: if a module pattern was given (`$2`), focus there; otherwise cover the +entire system. Either way, prioritize calculation, validation, eligibility, +and state-transition logic over plumbing. + +## Method + +Spawn **three business-rules-extractor subagents in parallel**, each assigned +a different lens. If `$2` is non-empty, include "focusing on files matching +$2" in each prompt. + +1. **Calculations** — "Find every formula, rate, threshold, and computed value + in legacy/$1. For each: what does it compute, what are the inputs, what is + the exact formula/algorithm, where is it implemented (file:line), and what + edge cases does the code handle?" + +2. **Validations & eligibility** — "Find every business validation, eligibility + check, and guard condition in legacy/$1. For each: what is being checked, + what happens on pass/fail, where is it (file:line)?" + +3. **State & lifecycle** — "Find every status field, state machine, and + lifecycle transition in legacy/$1. For each entity: what states exist, + what triggers transitions, what side-effects fire?" + +## Synthesize + +Merge the three result sets. Deduplicate. For each distinct rule, write a +**Rule Card** in this exact format: + +``` +### RULE-NNN: <plain-English name> +**Category:** Calculation | Validation | Lifecycle | Policy +**Source:** `path/to/file.ext:line-line` +**Plain English:** One sentence a business analyst would recognize. +**Specification:** + Given <precondition> + When <trigger> + Then <outcome> + [And <additional outcome>] +**Parameters:** <constants, rates, thresholds with their current values> +**Edge cases handled:** <list> +**Confidence:** High | Medium | Low — <why> +``` + +Write all rule cards to `analysis/$1/BUSINESS_RULES.md` with: +- A summary table at top (ID, name, category, source, confidence) +- Rule cards grouped by category +- A final **"Rules requiring SME confirmation"** section listing every + Medium/Low confidence rule with the specific question a human needs to answer + +## Generate the DTO catalog + +As a companion, create `analysis/$1/DATA_OBJECTS.md` cataloging the core +data transfer objects / records / entities: name, fields with types, which +rules consume/produce them, source location. + +## Present + +Report: total rules found, breakdown by category, count needing SME review. +Suggest: `glow -p analysis/$1/BUSINESS_RULES.md` |
