Skip to content

Commit 458a4db

Browse files
authored
feat(review): inline IaC Fix: blocks for Critical/High/Medium findings (#134) (#137)
Every Critical/High/Medium finding in the report now carries a Fix: block — a minimal ready-to-copy remediation snippet: - Language-matched: emitted in the IaC dialect recorded during Step 2 discovery (CDK/CloudFormation/Terraform/SAM); AWS CLI fallback when the workload has no IaC - Evidence-grounded: uses the actual resource names from the finding's evidence, not placeholders - Report-only: never applied to the user's codebase, never a diff/patch (design principle: review and guidance, not code mutation); the JSON artifact's recommendation field stays prose-only - Reuses the named anti-pattern wrong/right pairs (#133) as fix skeletons Applied consistently to SKILL.md, SKILL-sequential.md, SKILL-devops-agent.md, the steering doc and its Kiro Power copy, and the claude-code/cursor/ antigravity adapter templates. New eval case 7 (Terraform workload) asserts language-matched, resource-grounded fix blocks; case 4 gains a CLI-fallback assertion.
1 parent c7c597a commit 458a4db

9 files changed

Lines changed: 103 additions & 17 deletions

File tree

adapters/antigravity/rules/aws-well-architected-framework-review.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ Structure:
117117
- Executive Summary (date, workload, criticality, lens, findings count, overall maturity 1-5)
118118
- Architecture Overview (PlantUML diagram)
119119
- Pillar Scorecard (table: pillar, score 1-5, key strength, key gap)
120-
- Critical and High Risk Findings (ID, pillar, title, evidence file:line, impact, recommendation, effort, AWS services)
121-
- Medium Risk Findings (condensed)
120+
- Critical and High Risk Findings (ID, pillar, title, evidence file:line, impact, recommendation, fix — ready-to-copy snippet in the workload's IaC dialect, AWS CLI when no IaC, report-only, effort, AWS services)
121+
- Medium Risk Findings (condensed, each with its fix snippet)
122122
- Low Risk Findings (summary table)
123123
- Cross-Pillar Trade-offs
124124
- Prioritized Remediation Plan (Quick Wins < 1 week, Foundation 1-4 weeks, Strategic 1-3 months)

adapters/claude-code/commands/aws-well-architected-framework-review.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,10 @@ Output a structured report:
158158
| Sustainability | {score} | {strength} | {gap} |
159159

160160
## Critical and High Risk Findings
161-
{For each: ID, pillar, title, description, evidence (file:line), impact assessment, recommendation, effort, AWS services}
161+
{For each: ID, pillar, title, description, evidence (file:line), impact assessment, recommendation, **Fix:** block — a minimal ready-to-copy snippet in the workload's IaC dialect (AWS CLI when no IaC), using the actual resource names from the evidence; shown in the report only, never applied — effort, AWS services}
162162

163163
## Medium Risk Findings
164-
{Same format, condensed}
164+
{Same format, condensed — each finding still carries its **Fix:** block}
165165

166166
## Low Risk Findings
167167
{Summary table: ID | Pillar | Title | Recommendation}

adapters/cursor/rules/aws-well-architected-framework-review.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ Structure:
117117
- Executive Summary (date, workload, criticality, lens, findings count, overall maturity 1-5)
118118
- Architecture Overview (PlantUML diagram)
119119
- Pillar Scorecard (table: pillar, score 1-5, key strength, key gap)
120-
- Critical and High Risk Findings (ID, pillar, title, evidence file:line, impact, recommendation, effort, AWS services)
121-
- Medium Risk Findings (condensed)
120+
- Critical and High Risk Findings (ID, pillar, title, evidence file:line, impact, recommendation, fix — ready-to-copy snippet in the workload's IaC dialect, AWS CLI when no IaC, report-only, effort, AWS services)
121+
- Medium Risk Findings (condensed, each with its fix snippet)
122122
- Low Risk Findings (summary table)
123123
- Cross-Pillar Trade-offs
124124
- Prioritized Remediation Plan (Quick Wins < 1 week, Foundation 1-4 weeks, Strategic 1-3 months)

powers/aws-well-architected-framework-review/steering/aws-well-architected-framework-review.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -436,10 +436,10 @@ Empirical measurement shows this section is where recall reaches the user. Skipp
436436
{After writing this table, count the rows and confirm the count matches the sum of subagent rows. If not, you dropped citations — go back and add them.}
437437

438438
## Critical and High Risk Findings
439-
{For each: ID, pillar, title, description, evidence (file:line), impact assessment, recommendation, effort, AWS services. This section EXPANDS on rows in the Full BP Ledger — it does NOT replace them.}
439+
{For each: ID, pillar, title, description, evidence (file:line), impact assessment, recommendation, **Fix:** block — a minimal ready-to-copy snippet in the workload's IaC dialect (AWS CLI when no IaC), using the actual resource names from the evidence; shown in the report only, never applied — effort, AWS services. This section EXPANDS on rows in the Full BP Ledger — it does NOT replace them.}
440440

441441
## Medium Risk Findings
442-
{Same format, condensed. Also references ledger rows.}
442+
{Same format, condensed — each finding still carries its **Fix:** block. Also references ledger rows.}
443443

444444
## Low Risk Findings
445445
{Summary table: ID | Pillar | Title | Recommendation. Also references ledger rows.}

skills/aws-well-architected-framework-review/SKILL-devops-agent.md

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,11 @@ For each infrastructure component, document:
110110
- Resilience configs (multi-AZ, backups, scaling)
111111
- Cost-relevant configs (instance types, capacity mode)
112112

113+
Record the workload's **primary IaC dialect** (CDK, CloudFormation, Terraform, or
114+
SAM) — Step 6 emits a per-finding **Fix:** block in this dialect. When the
115+
workload has no IaC (on-premises or legacy), fix blocks fall back to AWS CLI
116+
commands or explicit configuration guidance.
117+
113118
Create an architecture diagram in PlantUML showing major components, data flows,
114119
and trust boundaries.
115120

@@ -369,11 +374,11 @@ paraphrase. Target row count: 250-307.
369374
subagent rows. If not, you dropped citations — go back and add them.}
370375

371376
## Critical and High Risk Findings
372-
{For each: ID, pillar, title, description, evidence, impact, recommendation, effort, AWS services.
377+
{For each: ID, pillar, title, description, evidence, impact, recommendation, **Fix:** block (see "Fix blocks" below), effort, AWS services.
373378
This section EXPANDS on rows in the Full BP Ledger — it does NOT replace them.}
374379

375380
## Medium Risk Findings
376-
{Same format, condensed.}
381+
{Same format, condensed — each finding still carries its **Fix:** block.}
377382

378383
## Low Risk Findings
379384
{Summary table: ID | Pillar | Title | Recommendation}
@@ -411,6 +416,24 @@ subagent rows. If not, you dropped citations — go back and add them.}
411416
{Top 5 concrete actions from the "Do First" quadrant}
412417
```
413418

419+
### Fix blocks — ready-to-copy remediation snippets
420+
421+
Every 🔴 Critical/High and 🟡 Medium finding in the report MUST include a **Fix:**
422+
block — a minimal, ready-to-copy remediation snippet:
423+
424+
- **Language-matched.** Use the primary IaC dialect recorded in Step 2
425+
(CDK / CloudFormation / Terraform / SAM); fall back to AWS CLI commands or
426+
explicit configuration guidance when the workload has no IaC.
427+
- **Evidence-grounded.** Use the actual resource names and identifiers from the
428+
finding's evidence — not generic placeholders — whenever the source is available.
429+
- **Minimal.** Only the lines needed to close the gap; elide unchanged
430+
surrounding configuration with a comment.
431+
- **Report-only.** The fix appears in the report for the team to review and
432+
apply. Do NOT apply it to the workload's codebase and do NOT emit it as a
433+
diff/patch (repo design principle: review and guidance, not code mutation).
434+
- **Reuse anti-pattern examples.** When a finding matches a named anti-pattern
435+
from the pillar playbooks, start from that entry's Right example.
436+
414437
## Calibration Guidance
415438

416439
- A workload with multi-AZ, encryption, CI/CD with rollback, monitoring, and auto-scaling is MATURE — most findings should be improvements, not Critical

skills/aws-well-architected-framework-review/SKILL-sequential.md

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ For each infrastructure component, document:
5555
- Resilience configs (multi-AZ, backups, scaling)
5656
- Cost-relevant configs (instance types, capacity mode)
5757

58+
Record the workload's **primary IaC dialect** (CDK, CloudFormation, Terraform, or SAM) — Step 6 emits a per-finding **Fix:** block in this dialect. When the workload has no IaC, note that fix blocks will fall back to AWS CLI commands.
59+
5860
You MUST create an architecture diagram in PlantUML showing:
5961
- All major components and their relationships
6062
- Data flows and external dependencies
@@ -465,10 +467,10 @@ Empirical measurement shows this section is where recall reaches the user. Skipp
465467
{After writing this table, count the rows and confirm the count matches the sum of per-pillar rows. If not, you dropped citations — go back and add them.}
466468

467469
## Critical and High Risk Findings
468-
{For each: ID, pillar, title, description, evidence (file:line), impact assessment, recommendation, effort, AWS services. This section EXPANDS on rows in the Full BP Ledger — it does NOT replace them.}
470+
{For each: ID, pillar, title, description, evidence (file:line), impact assessment, recommendation, **Fix:** block (see "Fix blocks" below), effort, AWS services. This section EXPANDS on rows in the Full BP Ledger — it does NOT replace them.}
469471

470472
## Medium Risk Findings
471-
{Same format, condensed. Also references ledger rows.}
473+
{Same format, condensed — each finding still carries its **Fix:** block. Also references ledger rows.}
472474

473475
## Low Risk Findings
474476
{Summary table: ID | Pillar | Title | Recommendation. Also references ledger rows.}
@@ -539,6 +541,28 @@ For each solution in "Do First" and "Plan":
539541
{Top 5 concrete actions from the "Do First" quadrant — the team should start this week}
540542
```
541543

544+
### Fix blocks — ready-to-copy remediation snippets
545+
546+
Every 🔴 Critical/High and 🟡 Medium finding in the report MUST include a **Fix:** block — a minimal, ready-to-copy remediation snippet the user can apply themselves:
547+
548+
- **Language-matched.** Emit the snippet in the primary IaC dialect recorded in Step 2 (CDK / CloudFormation / Terraform / SAM). When the workload has no IaC (e.g., a verbal review), fall back to equivalent AWS CLI commands.
549+
- **Evidence-grounded.** Use the actual resource names and identifiers from the finding's evidence — not generic placeholders — whenever the source is available.
550+
- **Minimal.** Only the lines needed to close the gap; elide unchanged surrounding configuration with a comment.
551+
- **Report-only.** The fix appears in the report for the user to review and apply. Do NOT apply it to the user's codebase and do NOT emit it as a diff/patch (repo design principle: review and guidance, not code mutation). The JSON artifact's `recommendation` field (Step 6b) stays prose-only; fix blocks live in the markdown report.
552+
- **Reuse anti-pattern examples.** When a finding matches a named anti-pattern from the pillar playbooks, start from that entry's Right example.
553+
- **Scope.** Applies to full and pillar-scoped reports. Score mode and quick review stay snippet-free, and the Full BP Ledger table stays snippet-free — fixes belong in the findings sections.
554+
555+
Example (finding SEC08-BP02, Terraform workload, evidence `infra/rds.tf:12`):
556+
557+
**Fix:**
558+
```hcl
559+
# infra/rds.tf — aws_db_instance.orders (line 12)
560+
resource "aws_db_instance" "orders" {
561+
# ...existing configuration...
562+
storage_encrypted = true
563+
}
564+
```
565+
542566
## Step 6b: Emit structured output (`aws-well-architected-framework-review.json`)
543567

544568
After the markdown report, ALSO emit a machine-readable `aws-well-architected-framework-review.json` so the review can be

skills/aws-well-architected-framework-review/SKILL.md

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ For each infrastructure component, document:
4646
- Resilience configs (multi-AZ, backups, scaling)
4747
- Cost-relevant configs (instance types, capacity mode)
4848

49+
Record the workload's **primary IaC dialect** (CDK, CloudFormation, Terraform, or SAM) — Step 6 emits a per-finding **Fix:** block in this dialect. When the workload has no IaC, note that fix blocks will fall back to AWS CLI commands.
50+
4951
You MUST create an architecture diagram in PlantUML showing:
5052
- All major components and their relationships
5153
- Data flows and external dependencies
@@ -456,10 +458,10 @@ Empirical measurement shows this section is where recall reaches the user. Skipp
456458
{After writing this table, count the rows and confirm the count matches the sum of subagent rows. If not, you dropped citations — go back and add them.}
457459

458460
## Critical and High Risk Findings
459-
{For each: ID, pillar, title, description, evidence (file:line), impact assessment, recommendation, effort, AWS services. This section EXPANDS on rows in the Full BP Ledger — it does NOT replace them.}
461+
{For each: ID, pillar, title, description, evidence (file:line), impact assessment, recommendation, **Fix:** block (see "Fix blocks" below), effort, AWS services. This section EXPANDS on rows in the Full BP Ledger — it does NOT replace them.}
460462

461463
## Medium Risk Findings
462-
{Same format, condensed. Also references ledger rows.}
464+
{Same format, condensed — each finding still carries its **Fix:** block. Also references ledger rows.}
463465

464466
## Low Risk Findings
465467
{Summary table: ID | Pillar | Title | Recommendation. Also references ledger rows.}
@@ -530,6 +532,28 @@ For each solution in "Do First" and "Plan":
530532
{Top 5 concrete actions from the "Do First" quadrant — the team should start this week}
531533
```
532534

535+
### Fix blocks — ready-to-copy remediation snippets
536+
537+
Every 🔴 Critical/High and 🟡 Medium finding in the report MUST include a **Fix:** block — a minimal, ready-to-copy remediation snippet the user can apply themselves:
538+
539+
- **Language-matched.** Emit the snippet in the primary IaC dialect recorded in Step 2 (CDK / CloudFormation / Terraform / SAM). When the workload has no IaC (e.g., a verbal review), fall back to equivalent AWS CLI commands.
540+
- **Evidence-grounded.** Use the actual resource names and identifiers from the finding's evidence — not generic placeholders — whenever the source is available.
541+
- **Minimal.** Only the lines needed to close the gap; elide unchanged surrounding configuration with a comment.
542+
- **Report-only.** The fix appears in the report for the user to review and apply. Do NOT apply it to the user's codebase and do NOT emit it as a diff/patch (repo design principle: review and guidance, not code mutation). The JSON artifact's `recommendation` field (Step 6b) stays prose-only; fix blocks live in the markdown report.
543+
- **Reuse anti-pattern examples.** When a finding matches a named anti-pattern from the pillar playbooks, start from that entry's Right example.
544+
- **Scope.** Applies to full and pillar-scoped reports. Score mode and quick review stay snippet-free, and the Full BP Ledger table stays snippet-free — fixes belong in the findings sections.
545+
546+
Example (finding SEC08-BP02, Terraform workload, evidence `infra/rds.tf:12`):
547+
548+
**Fix:**
549+
```hcl
550+
# infra/rds.tf — aws_db_instance.orders (line 12)
551+
resource "aws_db_instance" "orders" {
552+
# ...existing configuration...
553+
storage_encrypted = true
554+
}
555+
```
556+
533557
## Step 6b: Emit structured output (`aws-well-architected-framework-review.json`)
534558

535559
After the markdown report, ALSO emit a machine-readable `aws-well-architected-framework-review.json` so the review can be

skills/aws-well-architected-framework-review/evals/evals.json

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@
7171
"BP IDs cited: SEC04 (detective controls/GuardDuty), SEC05 (network protection/WAF), REL10 (fault isolation/single-AZ RDS), and DLQ gap referenced as REL06 or REL07",
7272
"Risk assessment: no WAF = Medium, no GuardDuty = Medium, single-AZ RDS = High, no DLQ = High",
7373
"Eisenhower prioritization covers only the scoped findings",
74-
"Pillar scorecard shows only Security and Reliability scores (not all 6)"
74+
"Pillar scorecard shows only Security and Reliability scores (not all 6)",
75+
"High Risk findings each include a Fix: block with a concrete remediation snippet (AWS CLI or IaC, since only a verbal description was provided) referencing the named resources (e.g., the metadata RDS instance, the SQS queue)"
7576
]
7677
},
7778
{
@@ -105,6 +106,20 @@
105106
"Depth filter is respected — only Critical and High findings shown",
106107
"All 6 pillars receive a score even though findings are filtered"
107108
]
109+
},
110+
{
111+
"id": 7,
112+
"prompt": "Review the Security and Reliability pillars of this Terraform workload:\n\n```hcl\nresource \"aws_s3_bucket\" \"uploads\" {\n bucket = \"acme-uploads\"\n}\n\nresource \"aws_db_instance\" \"orders\" {\n engine = \"postgres\"\n instance_class = \"db.t3.medium\"\n backup_retention_period = 0\n}\n\nresource \"aws_iam_role_policy\" \"app\" {\n role = aws_iam_role.app.id\n policy = jsonencode({\n Version = \"2012-10-17\"\n Statement = [{ Effect = \"Allow\", Action = \"*\", Resource = \"*\" }]\n })\n}\n```",
113+
"expected_output": "A pillar-scoped Security + Reliability review whose High/Medium findings each include a ready-to-copy Fix: block written in Terraform (the workload's IaC dialect), referencing the actual resource names from the input.",
114+
"assertions": [
115+
"Every High Risk finding includes a Fix: block containing a syntactically plausible Terraform (HCL) snippet — not CloudFormation, CDK, or bare CLI",
116+
"Fix blocks reference the actual resource identifiers from the input (aws_s3_bucket.uploads / acme-uploads, aws_db_instance.orders, aws_iam_role_policy.app), not generic placeholders",
117+
"The wildcard IAM policy is flagged (SEC03) with a fix narrowing Action and Resource to least privilege",
118+
"The disabled backup retention is flagged (REL09) with a fix setting backup_retention_period to a value greater than 0",
119+
"The bucket's missing public-access block or missing encryption at rest is flagged (SEC08) with a corresponding Terraform fix resource",
120+
"Fix snippets are presented in the report only — the response does not claim to have modified or applied changes to the user's files",
121+
"The review stays scoped to Security and Reliability — no findings for the other four pillars"
122+
]
108123
}
109124
]
110125
}

steering/aws-well-architected-framework-review.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -629,10 +629,10 @@ Compile all analyses into a comprehensive report.
629629
| Sustainability | {score} | {strength} | {gap} |
630630

631631
## Critical and High Risk Findings
632-
{For each finding: ID, pillar, title, description, evidence (file:line), impact, recommendation, effort, AWS services}
632+
{For each finding: ID, pillar, title, description, evidence (file:line), impact, recommendation, **Fix:** block — a minimal ready-to-copy snippet in the workload's IaC dialect (AWS CLI when no IaC), using the actual resource names from the evidence; shown in the report only, never applied — effort, AWS services}
633633

634634
## Medium Risk Findings
635-
{Same format, condensed}
635+
{Same format, condensed — each finding still carries its **Fix:** block}
636636

637637
## Low Risk Findings
638638
{Summary table only}

0 commit comments

Comments
 (0)