← Moody's CreditCONTENT HISTORY

Update to Moody's Credit

Snapshot Nov 3, 2026 · 18:24 UTC · version 3.0.1

Collection source: downloaded plugin package. These snapshots do not have a confirmed matching collection source. Differences in file lists alone do not establish changes to the package.

WHAT CHANGED

Payment or plan references changed

Full description — Now says: Helps credit analysts and investors see how a company compares with its closest peers. It resolves the target and up to three peers, then compares their...

Observed in published text. Live prices and checkout terms have not been verified by this change.

Save Moody's Credit and check future changes in Following.

Up to 3 plugins free · no card required.

All fields and original values.

Full description

Before

Sep 30, 2026 · 22:55 UTC

Produce a Peer Analysis HTML report for a target company and its credit peers using Moody's GenAI MCP tools. Use this skill whenever the user asks to compare a company against its peers, run a peer analysis, do a credit peer comparison, ...

After

Nov 3, 2026 · 18:24 UTC

Helps credit analysts and investors see how a company compares with its closest peers. It resolves the target and up to three peers, then compares their credit ratings and rating drivers, key financial and credit metrics, probability of ...

Skill instructions

Before

Sep 30, 2026 · 22:55 UTC

Produce a Peer Analysis HTML report for a target company and its credit peers using Moody's GenAI MCP tools. Use this skill whenever the user asks to compare a company against its peers, run a peer analysis, do a credit peer comparis...

After

Nov 3, 2026 · 18:24 UTC

Helps credit analysts and investors see how a company compares with its closest peers. It resolves the target and up to three peers, then compares their credit ratings and rating drivers, key financial and credit metrics, probability of ...

Supporting files

Before

Sep 30, 2026 · 22:55 UTC

[{"relative_path":"__MACOSX/._SKILL.md","size_in_bytes":163},{"relative_path":"__MACOSX/._assets","size_in_bytes":163},{"relative_path":"__MACOSX/._evals","size_in_bytes":163},{"relative_path":"__MACOSX/._references","size_in_bytes":163}...

After

Nov 3, 2026 · 18:24 UTC

[{"relative_path":"agents/openai.yaml","size_in_bytes":573},{"relative_path":"assets/icon.png","size_in_bytes":1753},{"relative_path":"assets/template.html","size_in_bytes":24588},{"relative_path":"evals/evals.json","size_in_bytes":3506}]

Compare saved observations

Download comparison JSON

SKILL.md text changes

− removed · + added

--- before
+++ after
@@ -1,110 +1,111 @@
 ---
 name: peer-analysis
 description: >
-  Produce a Peer Analysis HTML report for a target company and its credit peers using Moody's
-  GenAI MCP tools. Use this skill whenever the user asks to compare a company against its peers,
-  run a peer analysis, do a credit peer comparison, generate a peer group report, or analyze
-  relative credit positioning. Trigger even if they just name a company and mention "peers",
-  "peer comparison", "credit comparison", "peer group", or "relative value".
+  Helps credit analysts and investors see how a company compares with its closest peers. It resolves the target and up to three peers, then compares their credit ratings and rating drivers, key financial and credit metrics, probability of default and ESG profiles, and concludes on the target's relative credit positioning. Peers can be chosen by the user or discovered automatically.
 ---
 
 # Peer Analysis Skill
 
 Generates a professional HTML report (styled like a Moody's peer analysis PDF) for a target
-company and up to 3 credit peers. Data is pulled from multiple `Moodys MCP server` MCP tools and
-consolidated into a single HTML artifact covering peers comparison, ratings chart, and ESG.
+company and up to 3 credit peers. Data is pulled from multiple Moody's MCP tools and
+consolidated into a single HTML artifact covering peers comparison, ratings chart, PD, and ESG.
 
-The workflow is **single-artifact delivery**: gather all data, then write the entire filled
-HTML document to a single `.html` file in `/mnt/user-data/outputs/` and actively render it to
-the user with **both** `present_files` and `visualize:show_widget`. The rendered HTML artifact
-is the deliverable — writing the file without rendering it is a failed run.
+The workflow is **single-artifact file delivery**: gather all data, fill the complete HTML
+document, write it to disk as a standalone `.html` file, and present it to the user for
+download. No fenced code blocks, no streaming partial sections, no JSON payload, no progressive
+edits. The downloaded file is the sole deliverable.
 
 > ## ⚠️ CRITICAL — NON-NEGOTIABLE OUTPUT CONTRACT
 >
-> **The LLM MUST deliver the final report as a single standalone HTML artifact file that it
-> then actively renders on screen.** Creating the file is only half the job — a file that is
-> written but never surfaced is a failed run, and is the single most common failure mode for
-> this skill. Specifically:
+> **The LLM MUST write the final report to disk and present it as a downloadable file.**
+> This is the only acceptable form of delivery for this skill. Specifically:
 >
-> - The LLM **MUST** write the **complete, standalone HTML document** (`<!doctype html>` →
->   `</html>`), with every section from the streaming protocol populated inline, to a single
->   `.html` file in `/mnt/user-data/outputs/` using the `create_file` tool.
-> - The LLM **MUST** then render that file with **both** display tools — `present_files`
->   **and** `visualize:show_widget` — before ending its turn. Firing both renderers is what
->   guarantees the report always appears even if one tool is unavailable.
-> - The LLM **MUST NOT** end its turn after `create_file` without having called the display tools.
-> - The LLM **MUST NOT** emit the report inline as a fenced ` ```html ` code block, as prose,
->   Markdown, JSON, attachments, or links. The rendered HTML artifact itself is the answer.
-> - The LLM **MUST NOT** split the report across multiple files, multiple messages, partial
->   snippets, or summaries.
-> - If data gathering fails partially, still produce the single HTML artifact file with the
->   best-available content and `"--"` placeholders for missing cells — never skip the artifact
->   or the render step.
+> - The LLM **MUST** write the complete, standalone HTML document (`<!doctype html>` → `</html>`)
+>   to `/mnt/user-data/outputs/{target_company_slug}_peer_analysis.html` and then call
+>   `present_files` to surface it to the user.
+> - The LLM **MUST NOT** print the raw HTML source in the chat — no ` ```html ` fenced code
+>   blocks, no partial snippets, no inline HTML in the assistant message.
+> - The LLM **MUST NOT** split the report across multiple files or multiple messages.
+> - The LLM **MUST NOT** substitute prose, Markdown, JSON, or links for the file download.
+> - The delivered file **MUST NOT** contain any unfilled `{{ placeholder }}` token.
+> - If data gathering fails partially, still write and deliver the file with best-available
+>   content and `Not available` / `—` placeholders (as specified per section below) for missing
+>   cells — never skip the file delivery.
 >
 > Treat any other output shape as a hard failure of the skill.
 
-## Required MCP server
+## Parameters
+
+| Pattern | Type | Required | Notes |
+|---|---|---|---|
+| Company Name | Company | Yes | The target company. The user may also name the peers they want compared; if they do, use those peers. If they do not, peers are discovered automatically in Step 2. |
 
-`Moodys MCP server` — tools used: `findEntity`, `getEntityPeers`, `getEntityRatings`,
-`getCreditOpinion`, `getEntityFinancials_v2` (sections: Profile, Summary, RatingOutlook, FactorsLeadingToUpgrade,
-FactorsLeadingToDowngrade, CreditStrengths, CreditChallenges, ESGConsiderations,
-KeyIndicatorsTable, ScorecardTable, ESGConsiderations), `getEntitySectorOutlook`
+## Required MCP server
 
-If any of the tools required for a section do not exist, inform the user: One or more tools required for this section are not available under your current subscription. Unlock more of the expert insights, data, and analytics you trust. Get Link:https://www.moodys.com/web/en/us/capabilities/gen-ai/ai-ready-data.html with us to learn more. 
+`moodys_mcp` — tools used: `findEntity`, `getEntityPeers`, `getEntityProfile`, `getEntityRatings`,
+`getCreditOpinion` (sections: Summary, FactorsLeadingToUpgrade, FactorsLeadingToDowngrade,
+CreditStrengths, CreditChallenges, KeyIndicatorsTable, RatingFactors), `getEntityScorecardV2`,
+`getEntityFinancials_v2`, `getEntityEsg`, `getEntityProbabilityOfDefault`
+
+If any of the tools required for a section are not available under the current subscription,
+inform the user: "One or more tools required for this section are not available under your
+current subscription. Unlock more of the expert insights, data, and analytics you trust. Get
+Link:https://www.moodys.com/web/en/us/capabilities/gen-ai/ai-ready-data.html with us to learn
+more."
 
 ## Bundled files
 
-- `assets/template.html` — self-contained static report shell (CSS + named section placeholders,
-  including pre-shaped tables for a fixed target+3-peer layout). No embedded data, no inline
-  script. Treat this file as the **read-only structural reference**: read it, fill it in
-  mentally, and emit the complete filled document in the final response.
-
-## Shared chrome & citations
-
-Before emitting, read [`references/shared-template.md`](references/shared-template.md) (page
-chrome: cover, TOC, section block, sources-section wrapper, footer, outlook-badge, design
-tokens) and [`references/shared-citations.md`](references/shared-citations.md) (citation
-numbering, hyperlinking, source data shape, markup snippets). Both are **authoritative** — do
-not invent, duplicate, or restyle anything they already define. The canonical CSS is already
-inlined in `assets/template.html` between the `/* BEGIN/END shared-template-css */` and
-`/* BEGIN/END shared-citations-css */` markers; never re-copy it at emit time.
-
-The rest of this section is the skill-specific binding.
-
-This skill uses the **`cover-multi`** variant. Skill-specific override retained above the
-marker region: `**.page { max-width: 1050px }**` (PA reports are wider than the 900px canonical
-default to fit the multi-column scorecard / key-indicators tables). Skill-specific CSS that
-stays local: `.sub-heading`, all PA-specific table classes (`.pa-table`, `.credit-drivers-table`,
-`.ki-table`, `.sc-table`), and the chart helpers (`.chart-container`, `.chart-title`,
-`.chart-legend`, `.chart-legend-item`, `.chart-legend-swatch`). All outlook-badge usage in this
-skill must use the canonical pastel variants (`stable` / `positive` / `negative` / `review` /
-`na`) defined by the shared skill — no solid-fill or inline-color overrides. PA flags the target
-entity on the cover with `class="company-chip target"`; the chip wrappers themselves come from
-the shared cover-multi snippet.
-
-The prefix used for the end-of-document container in this skill is `pa`, so the container id
-is `#pa-sources`. Optional per-section recap blocks live in `#pa-cite-peers`,
-`#pa-cite-ratings`, and `#pa-cite-esg`. Internal MCP tool names (e.g. `getCreditOpinion`)
-are NEVER rendered inside `.source-meta`.
+- `assets/template.html` — self-contained report shell (all CSS inline, no external dependencies)
+  with `{{ placeholder }}` tokens for every value that varies per run, including pre-shaped tables
+  for a fixed target + 3-peer layout. Treat this file as the **structural reference**: read it
+  once, replace every `{{ token }}` with its value (token map below), and emit the complete
+  filled document. Keep its `<head>`/CSS, section order, table skeletons, row labels and CSS
+  class names exactly as shipped.
+- `evals/evals.json` — test prompts and assertions for this skill.
+
+---
+
+## CRITICAL: Decide how to respond before doing anything
+
+**Check the conversation history before doing anything else.**
+
+**If a report has already been generated in this conversation:**
+- **Follow-on question** → read the relevant section of the delivered `.html` file and answer
+  directly. Do NOT re-run the data gathering.
+- **Regeneration request** (e.g. "regenerate", "update", "redo") → ask: "Would you like me to
+  regenerate the full report, or just a specific section?" and wait before doing anything.
+
+**If no report has been generated yet** → run the full workflow below.
 
 ---
 
 ## Step 1 — Resolve the target company
 
-Call `findEntity` with the company name provided by the user. Store the canonical entity name
-and entity ID.
+Call `findEntity` **once** with the company name provided by the user (and, if the user named
+their own peers, include those peer names in the same request — `findEntity` is called once per
+request, not once per company). Keep the canonical entity name and `entityId` for each company.
 
 If the user provides only one company name, that is the **target company**. The peers will be
 discovered automatically in Step 2.
 
+**Canonical names, not raw record titles.** Resolve each company to the name a reader would
+recognize and use that name everywhere in the report (cover, tables, charts, prose).
+
+If a tool errors, treat the error as the result, retry once, and continue with what you have.
+
 ---
 
 ## Step 2 — Discover and resolve peers
 
-Call `getEntityPeers` for the target company. Select the top 3 peers returned.
+If the user did not name peers, call `getEntityPeers` for the target with `maxPeersPerEntity: 3`
+and take the peers returned (analyst-defined peers first).
+
+You now have a set of up to **4 companies** (1 target + up to 3 peers). The records returned by
+`getEntityPeers` already carry entity IDs; only call `findEntity` again for a peer that arrives
+without one, and fold all such names into a single call. Never rebuild an ID from a company name.
 
-You now have a set of up to **4 companies** (1 target + up to 3 peers). For each peer, call
-`findEntity` to resolve its canonical entity name and ID.
+If fewer than 3 peers are returned, proceed with however many were found — never invent a peer to
+fill the set.
 
 ---
 
@@ -112,48 +113,79 @@
 
 Read `assets/template.html` (relative to this skill directory) once. Keep its exact structure —
 CSS, `<head>`, section order, table skeletons (including all pre-shaped 4-company columns/rows),
-row labels, and element IDs — as the scaffold for the final artifact. Do **not** copy it to the
-workspace and do **not** open it.
+row labels, and class names — as the scaffold for the final artifact. Only the `{{ token }}`
+placeholders are replaced.
 
 ---
 
 ## Step 4 — Gather all data in parallel
 
 For every company in the set (target + up to 3 peers), fire **all of the following in a single
-parallel batch** (one message, many tool calls):
+parallel batch** (one message, many tool calls) — do not wait for one tool's results before
+requesting the next. Use the `entityId` values from Steps 1–2 exactly as resolved.
 
-### Credit Opinion data (per company)
-
-Call `getCreditOpinion`,`getEntityFinancials_v2` requesting these sections, about the key Indicators table this should be populated with most recent fiscal year available (e.g. 2025 FY) on `getEntityFinancials_v2`. Not LTM allowed:
+**`getEntityProfile`** — one call with all companies in `entities`. Use the legal name,
+headquarters/registered address, business description, NAICS/NACE classification and employee
+count for the Peers table.
+
+**`getCreditOpinion`** — one call with all companies in `entities`, `sections`:
+`Summary`, `FactorsLeadingToUpgrade`, `FactorsLeadingToDowngrade`, `CreditStrengths`,
+`CreditChallenges`, `KeyIndicatorsTable`, `RatingFactors`. Leave `publishDate` at its default
+(latest opinion).
 
 | Section parameter | Purpose |
 |---|---|
-| `Profile` | Company description for the Peers Table |
+| `Summary` | Key segments/brands and scale for the Peers Table description; forward values for the Scorecard |
 | `FactorsLeadingToUpgrade` | Upgrade factors for Credit Drivers |
 | `FactorsLeadingToDowngrade` | Downgrade factors for Credit Drivers |
 | `CreditStrengths` | Credit strengths for Credit Drivers |
 | `CreditChallenges` | Credit challenges for Credit Drivers |
-| `KeyIndicatorsTable` | Financial metrics for Key Indicators table |
-| `ScorecardTable` | Scorecard data |
-| `ESGConsiderations` | ESG narrative containing the CIS classification and E/S/G scores for the ESG Table & Heatmap |
-
-### Ratings (per company)
-
-Call `getEntityRatings` — retrieve the current long-term rating, rating class, rating date,
-outlook, and historical ratings (need at least the last 5 rating actions for the Ratings Chart).
+| `KeyIndicatorsTable` | Moody's-adjusted and projected metrics (Scorecard fallback / Forward column) |
+| `RatingFactors` | Scorecard factor values and forward values (Scorecard fallback) |
 
-### ESG (per company)
+**`getEntityScorecardV2`** — one call per company (the tool takes a single `entityId`), retrieval
+mode (no `methodology`, no `overrides`). This is the structured source for the Moody's scorecard
+factor values and the methodology used. It works for unrated entities too.
+
+**`getEntityFinancials_v2`** — one call with all companies in `entities`, `filterCriteria`:
+`{ "excludeInterimData": true, "sections": ["key_indicators", "income_statement", "cash_flow_statement", "balance_sheet"] }`.
+
+> **CRITICAL — `getEntityFinancials_v2` is the authoritative source for all quantitative data.**
+> Do NOT rely solely on the Key Indicators or Scorecard exhibits embedded in `getCreditOpinion` —
+> those may reference an older period. After fetching financials, identify each entity's latest
+> year with a non-null Revenue value and use that year exclusively for the Key Indicators charts,
+> the Scorecard "Current" column, and the Revenue chart. **LTM figures are not permitted.**
+> Convert all monetary values to USD billions for display (request `currencies: ["USD"]` and
+> `scale: "billions"` if the entity's reporting currency differs).
+
+**`getEntityRatings`** — one call with all companies in `entities` and `years: 10` — retrieve the
+current long-term rating, rating class, rating date, outlook, and at least the last 5 historical
+rating actions (needed for the Ratings Chart).
+
+> **`getEntityRatings` is the single, exclusive source of truth for every Moody's rating symbol
+> that appears anywhere in the final document** — Rating Cards, the Ratings Chart, the
+> Scorecard's "Actual rating" row, and the PD table's "Moody's Rating" column. Never derive,
+> infer, or back into a rating symbol from a scorecard-indicated outcome, a notching assumption,
+> or a credit opinion's narrative prose (which can mention a rating in passing that is stale or
+> inconsistent). If `getEntityRatings` and any other source disagree, `getEntityRatings` wins.
+> Never alter, round, or relabel a rating symbol to make a chart look cleaner — if a rating
+> needs repositioning on an axis, adjust the axis, never the symbol.
+
+**`getEntityEsg`** — one call with all companies in `entities` — overall CIS classification plus
+E, S, G issuer profile sub-scores (IPS), and the analyst comments.
+
+**`getEntityProbabilityOfDefault`** — one call with target + every resolved peer in `entities` —
+retrieve current 1-year PD (%), 5-year cumulative PD (%), and PD-implied rating. The history
+window can stay at its default; only current values are shown. **If the call returns an error or
+empty data, retry once** before treating PD as unavailable — the tool is prone to transient
+failures and a second attempt frequently succeeds.
+
+If any tool errors or returns nothing for a company, treat the error text as the result, retry
+that call once, and then mark the affected cells `Not available` / `—` as specified below —
+never fill them from memory.
 
-Source ESG from the `ESGConsiderations` section of `getCreditOpinion` (requested in the Credit
-Opinion call above). This section is narrative text, but Moody's states the overall CIS
-classification and the E, S, and G issuer-profile scores within it (e.g. "CIS-3", "E-4", "S-3",
-"G-2"). Extract those codes verbatim for the ESG Table & Heatmap. If a given score is not stated
-in the narrative, follow the `na` / `--` conventions in the report spec rather than inventing one.
-
-### Sector outlook (once per sector)
-
-Call `getEntitySectorOutlook` for the target company's sector. Reuse for peers in the same
-sector.
+Compute quantitative values (ratios, margins, averages, medians) silently; do not narrate the
+arithmetic — write only the final numbers into the output.
 
 Hold all results in context for Step 5 synthesis.
 
@@ -161,129 +193,630 @@
 
 ## Step 5 — Synthesize + emit the complete artifact
 
-After data is gathered, write the **entire filled `template.html` document** — with every
-element from the streaming protocol populated in place — to a single `.html` file in
-`/mnt/user-data/outputs/`, then render it. The full required delivery sequence (`create_file`
-→ `present_files` → `visualize:show_widget` → one short sentence) is specified in the
-**Step 6 — Output and presentation** section below; follow it exactly.
-
-The HTML file **must**:
-
-- Be written in a single `create_file` call (no progressive `StrReplace` edits, no multi-file
-  split).
-- Contain a complete, standalone HTML document (doctype → `</html>`) that renders without
-  external dependencies.
-- Preserve the template's `<head>` (CSS, fonts), section order, table skeletons, row labels, and
-  element IDs exactly. Only the empty targets defined below are populated.
+After data is gathered, replace every `{{ token }}` in the template (token map below) and write
+the complete document to disk, then present it to the user (see Step 6 for the file-naming and
+delivery contract).
+
+The assembled document **must**:
+
+- Be a complete, standalone HTML document (doctype → `</html>`) that renders without external
+  dependencies.
+- Preserve the template's `<head>` (CSS), section order, table skeletons, row labels and class
+  names exactly. Only the `{{ token }}` placeholders are replaced.
+- Contain no leftover `{{ ... }}` token. Tokens for unused peer slots are replaced with an empty
+  string.
 
 Write in professional financial/credit analysis language. Always reference specific companies by
-name. The target company is **always the first column / first row** in every table. Render order
-of content inside the file follows the page top-to-bottom so the artifact is human-readable
-as well as browser-renderable: cover/header fields first, then Peers Comparison sub-sections
-(1–6), Ratings Chart, ESG, and citations/sources last.
-
-Attribute substantive claims with numbered citation references. The exact inline markup, the
-URL-less fallback, and the rule that `n` matches the row position of the source inside
-`#pa-sources` are defined in [references/shared-citations.md](references/shared-citations.md).
-
-### Cover / header fields (write first)
-
-- `#pa-report-date` — e.g. `April 20, 2026` (plain text)
-- `#pa-footer-date` — same value (plain text)
-- `#pa-target-company` — canonical name of the target (plain text)
-- `#pa-peer-count` — integer count of peers resolved in Step 2 (plain text)
-- `#pa-company-chips` — `<span class="company-chip target">Target</span>` followed by one
-  `<span class="company-chip">Peer</span>` per peer (space-separated; target first)
-- `#pa-cover-img-right`, `#pa-cover-img-bottom` — optional. If you have image URLs or data URIs
-  to use, set the `src` attributes **and** add the `has-cover-image` class to the corresponding
-  container (`<div class="cover-top has-cover-image">` and/or `<div class="cover-bottom has-cover-image">`).
-  If you do not have images, leave the template as-is — the empty image strips will collapse
-  automatically and the cover will render as a clean navy block with the accent bar.
-
-### Report body — sections, streaming protocol & charts
-
-Before emitting, read [`references/report-spec.md`](references/report-spec.md) for the
-authoritative body-authoring spec: the Section 1 sub-sections (Peers Table, Peers Rating,
-Credit Drivers, Key Indicators, Scorecards, Conclusion), Section 2 (Ratings Chart + analysis),
-Section 3 (ESG Table + analysis), where the optional `#pa-cite-*` recaps and the
-`#pa-sources` rows go, the **streaming protocol** (element → content mapping), the reference
-HTML snippets, the Ratings-Chart SVG template (constants, rating→value map, coordinate
-formulae), and the class-selection rules and conventions. **The spec also carries three
-Amendments that override this base layout — apply them.** Populate every `#pa-*` target
-exactly as specified there.
-
----
+name. The target company is **always the first column / first row** in every table and
+comparison. Pass HTML values as-is (valid markup, no scratch arithmetic, no HTML comments left
+in the final value).
 
-## Step 6 — Output and presentation (required final steps)
+### Placeholder map
 
-> ## ⚠️ CRITICAL — THE SKILL IS NOT COMPLETE UNTIL THE REPORT IS VISIBLY RENDERED
+| Placeholder token(s) | Content type |
+|---|---|
+| `report_date` (used on the cover and in the footer) | Plain text, `Month D, YYYY`, today's date |
+| `target_company` | Plain text (canonical target name) |
+| `peer_count` | Plain text integer — count of peers actually resolved |
+| `company_chips_html` | `<span class="company-chip target">` for the target, then one `<span class="company-chip">` per resolved peer |
+| `peers_table_html` | `<tr>` rows (company name + description) with inline citations |
+| `rating_cards_html` | One `.rating-card` per company (target first) |
+| `cd_col_1` … `cd_col_4` | Plain text (company names; empty string for unresolved peer slots) |
+| `cd_r{1..4}_c{1..4}` | Prose cell content (short `<p>` or plain text) with inline citations |
+| `ki_charts_html` | `ki-fy-header` + five `.peer-bar-chart-outer` panels |
+| `fi_charts_html` | Single `.peer-bar-chart-outer` panel (Revenue) |
+| `sc_col_1` … `sc_col_4` | Plain text (company names; each spans 2 sub-columns) |
+| `sc_col_{1..4}_curr`, `sc_col_{1..4}_fwd` | Plain text sub-header labels (`FY{YYYY}` / `Forward`) |
+| `sc_r{1..6}_c{1..4}_curr`, `…_fwd` | Plain text scorecard cell values |
+| `conclusion_html` | Three `<p>` paragraphs |
+| `section2_suffix` (TOC label and Section 2 heading) | `" & Probability of Default"` or empty string |
+| `ratings_chart_html` | Single `<div class="chart-container">…<svg>…</svg>…</div>` block |
+| `pd_panel_html` | PD banner + bar chart + table, or the `.pd-unavailable` note |
+| `ratings_analysis_html` | One `<p>` paragraph |
+| `esg_heatmap_html` | `table.esg-heatmap` + `.esg-legend` |
+| `esg_analysis_html` | Two `<p>` paragraphs |
+
+If fewer than 3 peers are returned, leave unused column/row slots empty. Do not collapse or
+remove cells — the pre-shaped tables simply keep those cells blank.
+
+### Cover / header fields
+
+- `report_date` — e.g. `October 22, 2026` (plain text; the example is illustrative only)
+- `target_company` — canonical name of the target (plain text)
+- `peer_count` — integer count of peers resolved in Steps 1–2 (plain text)
+- `company_chips_html` — target first (with the `target` class), then one chip per resolved peer;
+  omit chips for unresolved peer slots, do not pad to 3
+
+```html
+<span class="company-chip target">Target Co</span>
+<span class="company-chip">Peer One</span>
+<span class="company-chip">Peer Two</span>
+<span class="company-chip">Peer Three</span>
+```
+
+The cover image strips in the template are intentionally empty; leave them as shipped.
+
+### Section 1 — Peers Comparison Table & Analysis
+
+**1) Peers Table** → `peers_table_html`
+
+Write one `<tr>` per company (target first, then peers in order): company name + a substantive
+description paragraph built from `getEntityProfile` (business description, headquarters,
+employees) and the credit opinion `Summary` (key segments/brands, scale). Include the latest
+fiscal-year revenue from the financials. Cite claims.
+
+```html
+<tr>
+  <td class="company-name">Target Co</td>
+  <td>Headquartered in Dearborn, Michigan, Target Co is a global automaker with FY2025 revenue of
+  approximately $180B, anchored by its F-Series, SUV, and Pro commercial businesses.</td>
+</tr>
+```
+
+**2) Rating Summary** → `rating_cards_html`
+
+Emit exactly one `.rating-card` per company (target first, extra class `target-card`). Use only
+the current (most recent) long-term issuer or senior unsecured rating and current outlook —
+never loop over historical entries. Prefer Long-Term Issuer Rating; if absent, Senior Unsecured.
+The rating cards are the sole representation of peer ratings in Section 1 (there is no separate
+peers-rating table).
+
+- `.rc-company` — abbreviated company name (≤ 25 chars; truncate with "…" if longer)
+- `.rc-rating` — Moody's rating symbol (e.g. `Baa2`), copied from `getEntityRatings`
+- `.rc-class` — rating class + most-recent rating date (e.g. `Senior Unsecured / 2024-05-09`)
+- `.outlook-badge` — canonical pastel classes only: `stable`, `positive`, `negative`, `review`, `na`
+
+```html
+<div class="rating-card target-card">
+  <div class="rc-company">Target Co</div>
+  <div class="rc-rating">Baa2</div>
+  <div class="rc-class">Senior Unsecured / 2024-05-09</div>
+  <span class="outlook-badge stable">Stable</span>
+</div>
+```
+
+**3) Credit Drivers** → `cd_col_1`..`cd_col_4` and `cd_r{1-4}_c{1-4}` (4 rows × 4 company columns)
+
+Write the 4 company header cells (`cd_col_1` = target, `cd_col_2`..`cd_col_4` = peers in order;
+empty strings for peer slots beyond what was resolved) and the 16 body cells:
+
+- Row 1 (Upgrade factors) — from `FactorsLeadingToUpgrade`
+- Row 2 (Downgrade factors) — from `FactorsLeadingToDowngrade`
+- Row 3 (Credit strengths, qualitative) — from `CreditStrengths`
+- Row 4 (Credit challenges, qualitative) — from `CreditChallenges`
+
+Each cell is a substantive paragraph with specific quantitative thresholds where available.
+Quantitative metrics are covered by the Key Indicators bar charts — the table has only 4 rows;
+do not add a 5th row. If a credit opinion section is missing for a company, write
+`Not available` rather than leaving the cell blank.
+
+**4) Key Indicators — Peer Bar Charts** → `ki_charts_html` and `fi_charts_html`
+
+Emit five `.peer-bar-chart-outer` panels as `ki_charts_html`, and a single Revenue panel as
+`fi_charts_html` (it follows immediately with no separate sub-heading — the template already
+handles this). The bar charts are the sole representation of key-indicator data. All panels use
+the same markup so they look identical; the CSS classes in the template supply all colours, fonts
+and sizing — add no inline colours except as stated below.
+
+| Chart | Metric | Unit | Source | Note |
+|-------|--------|------|--------|------|
+| 1 | FCF Margin % | `%` | (OCF − \|Capex\|) / Revenue, from `getEntityFinancials_v2` | Higher = better |
+| 2 | Debt / EBITDA | `x` | `getEntityFinancials_v2` Key Indicators | Lower = better |
+| 3 | EBITDA Margin % | `%` | EBITDA / Revenue, from `getEntityFinancials_v2` | Higher = better |
+| 4 | EBITA / Interest | `x` | `getEntityFinancials_v2` Key Indicators | Higher = better |
+| 5 | RCF / Net Debt | `%` | `getEntityFinancials_v2` Key Indicators | Higher = better |
+
+Per KI panel:
+- Start the `ki_charts_html` block with one `<div class="ki-fy-header">`, e.g.
+  `KEY INDICATORS — FY2025 | Company vs. Peers`; if entities have mixed fiscal years write
+  `KEY INDICATORS — Most Recent FY | Company vs. Peers`.
+- Inside each panel: `.pbc-title` (metric name in caps), `.pbc-subtitle` (unit + fiscal year, e.g.
+  `FY2025, % of revenue`), then a `<div class="pbc-legend">` with four swatches via a CSS variable:
+  `<span style="--sw:#0066cc">Target</span><span style="--sw:#6f9fd3">Peers</span><span
+  style="--sw:#2e7d32">Peer average</span><span style="--sw:#d9680f">Peer median (line)</span>`.
+- One bar row per company: target first, then peers sorted by descending value, then the
+  average row last. Target bar `subj-pos` (or `subj-neg` if negative); peer bars `peer-pos` /
+  `peer-neg`; average `avg-bar` — the class goes on the `.pbc-fill` element.
+- Append the fiscal year to each company's `pbc-name` in parentheses, e.g. `Target Co (FY2025)`,
+  using the FY identified via `getEntityFinancials_v2` for that entity; put the full name in `title`.
+- Every row shows its numeric value in `.pbc-val` (class `pos`/`neg` for company rows, `avg-val`
+  for the average). Format: ratios to 1 decimal with `x` (e.g. `2.4x`), percentages to 1 decimal.
+- Median marker: `.pbc-median-line` with a `.pbc-median-tip` reading `Median {value}`, placed in
+  the **target row's track only** (not repeated on every row, to avoid clutter).
+- A closing `.pbc-note` line: peer median, peer average (n = number of peers), company value, gap.
+- **Bar width, positive-only charts:** `maxAbs` = max absolute value across company, peers and
+  average; `width = (value / maxAbs * 88).toFixed(1) + '%'`, `left:0`; median
+  `left = (median / maxAbs * 88).toFixed(1) + '%'`.
+- **Charts that can go negative (FCF margin; any other with a negative value):** add class
+  `zero-axis` to every `.pbc-track` in that panel; zero sits at 44%. Positive bars:
+  `left:44%; width=(v/maxAbs*44)%`. Negative bars: `left=(44-|v|/maxAbs*44)%;
+  width=(|v|/maxAbs*44)%`. Median `left = (44 + median/maxAbs*44)%`.
+- Compute peer average and median across resolved peers only (exclude the target). Omit the bar
+  row for a company whose value is missing and say so in the `.pbc-note`.
+
+```html
+<div class="ki-fy-header">KEY INDICATORS — FY2025 | Company vs. Peers</div>
+<div class="peer-bar-chart-outer">
+  <div class="pbc-title">Debt / EBITDA</div>
+  <div class="pbc-subtitle">FY2025, multiple (x) — lower is stronger</div>
+  <div class="pbc-legend"><span style="--sw:#0066cc">Target</span><span style="--sw:#6f9fd3">Peers</span><span style="--sw:#2e7d32">Peer average</span><span style="--sw:#d9680f">Peer median (line)</span></div>
+  <div class="pbc-rows">
+    <div class="pbc-row">
+      <div class="pbc-name subject" title="Target Co">Target Co (FY2025)</div>
+      <div class="pbc-track">
+        <div class="pbc-median-line" style="left:52.3%"><div class="pbc-median-tip">Median 2.1x</div></div>
+        <div class="pbc-fill subj-pos" style="left:0;width:61.0%"></div>
+      </div>
+      <div class="pbc-val pos">2.4x</div>
+    </div>
+    <!-- one row per resolved peer (sorted descending), then the average row last -->
+    <div class="pbc-row" style="margin-top:4px;padding-top:8px;border-top:1px dashed #cbd5e1">
+      <div class="pbc-name average">Peer average</div>
+      <div class="pbc-track"><div class="pbc-fill avg-bar" style="left:0;width:50.7%"></div></div>
+      <div class="pbc-val avg-val">2.0x</div>
+    </div>
+  </div>
+  <div class="pbc-note">Peer median 2.1x | Peer avg 2.0x (n=3). Company: 2.4x. Gap vs. median: +0.3x.</div>
+</div>
+<!-- repeat for FCF Margin %, EBITDA Margin %, EBITA/Interest, RCF/Net Debt (HTML comments are
+     shown here for illustration only — do not leave them in the final value) -->
+```
+
+**Revenue chart** (`fi_charts_html`; same panel markup, same FY header convention, no separate
+sub-heading, unit USD billions, values formatted `$12.3B`). Always include a Peer average row
+(peer mean, excluding the target) when at least one peer resolved. `maxRevenue` = max across all
+rows including the average and the median. **Include the peer-median line exactly like every Key
+Indicators chart**: a `.pbc-median-line` with a `.pbc-median-tip` reading `Median $X.XB` in the
+target row's track at `left = (median / maxRevenue * 88)%`, the `Peer median (line)` legend entry
+(`style="--sw:#d9680f"`), and the median in the closing `.pbc-note`. Target bar `subj-pos`, peer
+bars `peer-pos`, average `avg-bar`, each class on the `.pbc-fill` element. If a revenue value is
+missing show `N/A` and omit the bar. Do not add a Debt/EBITDA chart here — it is already in the
+KI charts.
+
+**5) Scorecards** → `sc_col_*` and `sc_r{1-6}_c{1-4}_{curr|fwd}` (6 rows × 4 companies × Current/Forward)
+
+Write the 4 top-level company headers (`sc_col_1`..`sc_col_4`, target first) and the 8 sub-header
+labels (`sc_col_{1-4}_curr`, `sc_col_{1-4}_fwd`).
+
+> **FY LABEL SYNCHRONY — STRICTLY ENFORCED (Sections 4 and 5):**
+> The label in `sc_col_{n}_curr` for a company MUST be identical to the FY label appended to
+> that company's bars in the Key Indicators charts — the most recent non-null full fiscal year
+> from `getEntityFinancials_v2` (with `excludeInterimData: true`), labelled `FY{YYYY}` (e.g.
+> `FY2025`). **Never use "LTM", "TTM", "Current", or any label other than the specific
+> `FY{YYYY}` form.** Each entity's label is set independently (e.g. a June year-end company
+> keeps its own FY). `sc_col_{n}_fwd` is simply `Forward`. All numbers in Section 4 and the
+> Scorecard Current cells must come from the same `FY{YYYY}` period. If entities have different
+> most-recent FYs, the KI header reads `KEY INDICATORS — Most Recent FY | Company vs. Peers`.
+> Check this synchrony before writing the file; mismatched labels are a hard failure.
+
+> **`~` (tilde) prefix rule — STRICT:** `~` (e.g. `~2.5x`) means approximately estimated /
+> forecast and must ONLY appear in **Forward** (`_fwd`) cells, never in **Current** (`_curr`)
+> cells. Current cells contain actual reported or Moody's-adjusted figures; use the precise
+> value as-is (e.g. `2.3x`, `14.8%`).
+
+> **Distorted EBITDA years.** If the most recent FY has a non-cash charge (e.g. goodwill
+> impairment) that makes Debt/EBITDA not meaningful, still use that year as the reference; show
+> the reported figure with a `†` marker (e.g. `N/M†`) and use the Moody's-adjusted ratio from the
+> credit opinion's Key Indicators exhibit or the scorecard factor value for the leverage cell
+> instead.
+
+Write the 48 body cells for the 6 rows:
+- Row 1 — Scale: Revenue/Sales (USD bn)
+- Row 2 — Profitability: EBIT(A) margin
+- Row 3 — Leverage: Debt/EBITDA
+- Row 4 — Cash flow: RCF/Net debt
+- Row 5 — Coverage: EBIT(A)/Interest
+- Row 6 — Actual rating — from `getEntityRatings`, verbatim. The Current cell is the rating
+  symbol; the Forward cell is the current outlook (e.g. `Stable`). If `getEntityRatings` returns
+  no current Long-Term Rating or an obviously stale one, show what it returned with its date and
+  do not substitute a rating from credit-opinion prose. There is no "Scorecard-indicated
+  outcome" row.
+
+Rows 1–5 — **every resolved company's cells must show a value, never blank and never a bare
+"N/A" when any source has the number.** Fill in this order and stop at the first source that has it:
+1. **Current:** the Moody's-adjusted ratio for the latest fiscal year from `getEntityFinancials_v2`
+   (`reportingBasis: "adjusted"` when needed), then the same metric from `getEntityScorecardV2`
+   (`factors`/subfactor values), then the credit opinion `KeyIndicatorsTable` / `RatingFactors`
+   column for that FY. Compute margins/ratios yourself from reported statement lines if no
+   adjusted figure exists, and mark them `(rep.)`.
+2. **Forward:** the first projected column (or projected range) in the credit opinion
+   `KeyIndicatorsTable`; else the forward values quoted in `RatingFactors` / `Summary`; else the
+   forward scorecard value from `getEntityScorecardV2`. Format projections with a leading `~`.
+3. If an entity's latest opinion is older than 12 months or a forward column is genuinely absent,
+   re-call `getCreditOpinion` for that entity with a `publishDate` range covering the last 3 years
+   (`mode: "range"`, `from` and `to` both set) and use the newest opinion that has a projection,
+   adding `(as of {Mon YYYY})` to the cell.
+4. Only if every source above is exhausted, write `—` (an em dash). Never write "N/A", leave a
+   cell blank, or invent a projection; the template's footnote explains the dash.
+
+If fewer than 3 peers resolved, leave the unused column cells empty — do not collapse the table.
+
+**6) Conclusion** → `conclusion_html`
+
+Write this last, from the findings you have already produced for the financials, ratings, ESG and
+PD sections — differentiate the target among its peers; do not re-derive data. Three `<p>`
+paragraphs, oriented around the target company's differentiation:
+
+- Paragraph 1: how the target differentiates positively vs. weaker peers on quantitative
+  metrics (leverage, coverage, cash flow) — cite specific ratios.
+- Paragraph 2: business risk profile comparison — where the target is more concentrated or less
+  diversified vs. stable peers, referencing upgrade/downgrade triggers.
+- Paragraph 3: practical positioning — frame the target's "path to stand out" by linking back to
+  the upgrade/downgrade framework and key risk factors.
+
+At most one citation per sentence. Cite only records you actually received from a tool result;
+never add a generic "Moody's Ratings result" source.
+
+### Section 2 — Ratings Chart (± Probability of Default)
+
+> **SECTION 2 TITLE RULE — STRICTLY ENFORCED:**
+> The template reads `Section 2. Ratings Chart{{ section2_suffix }}` in both the TOC label and
+> the section heading. Set `section2_suffix` to:
+> - `" & Probability of Default"` if PD data is available (a real banner + chart + table is
+>   written into the PD panel)
+> - `""` (empty string) if PD data is unavailable after the retry
 >
-> Writing the file is **not** delivery. After you write the HTML you **must** actively render
-> it with every display tool available, in order, before you say anything else. Do not end
-> your turn until the rendered report is on screen.
-
-Follow this exact sequence. Do not skip a step, reorder, or substitute alternatives:
-
-1. **Write the HTML file in a single call.** Call `create_file` to write the entire standalone
-   HTML document (`<!doctype html>` → `</html>`) to
-   `/mnt/user-data/outputs/{target_company_slug}_peer_analysis.html` in **one** call.
-   `{target_company_slug}` is the target's canonical name lowercased with spaces and special
-   characters replaced by underscores (e.g. `apple_inc_peer_analysis.html`). No progressive
-   edits, no multi-file split.
-2. **Present the file.** Immediately call `present_files` on that exact path to surface the
-   artifact to the user.
-3. **Show the widget.** Immediately call `visualize:show_widget` on the same file to render the
-   report visually. Call this even if `present_files` already succeeded — firing both renderers
-   is what guarantees the report always appears.
-4. **Confirm in one short sentence.** Only after the renderers return, add a single brief
-   sentence in chat (e.g. `Peer Analysis for {Target Company} — the report is available above as
-   a self-contained HTML artifact.`). Nothing more.
-
-If a display tool call fails or is unavailable, immediately try the other one rather than
-stopping. Never end your turn at step 1, and never paste the HTML into chat or suggest shell
-commands.
+> Keep this consistent with what the PD panel actually contains — never append
+> "& Probability of Default" if the panel only has the unavailable placeholder.
+
+Section 2 order: Ratings Chart → PD panel → Ratings analysis.
+
+**Chart** → `ratings_chart_html`
+
+Emit a single `<div class="chart-container">…<svg>…</svg>…</div>` block, built the same way
+every run — this is the only chart spec, do not improvise. It plots the last 5 rating actions per
+company as a line chart, most-recent point highlighted, x-axis labelled with actual rating dates.
+
+**Fixed constants (always use these exact numbers):**
+- `viewBox="0 0 780 440"`, plot area `x: 90→740` (650px wide), `y: 50→350` (300px tall); the SVG
+  has `width="100%"` and no fixed height so it scales with the page.
+- `maxPts` = the largest number of rating actions any company has, capped at 5
+- Palette (target first, colour-blind-safe and legible on white): `#0066cc`, `#d9680f`, `#1a7a4a`,
+  `#7c3aed`. Give each peer line a distinct dash pattern (`stroke-dasharray="6 4"` on peers) only
+  if two lines overlap; the target line is always solid and drawn last (on top).
+- `xPos(i) = 90 + (i / (maxPts - 1)) * 650` (if `maxPts` is 1, centre at x=415)
+
+**Rating → numeric value** (higher = better), index 0 = `C` (value 1) … index 20 = `Aaa`
+(value 21):
+`["C","Ca","Caa3","Caa2","Caa1","B3","B2","B1","Ba3","Ba2","Ba1","Baa3","Baa2","Baa1","A3","A2","A1","Aa3","Aa2","Aa1","Aaa"]`
+
+**Y-axis range:** `minV = clamp(min(all values) - 1, 1, 21)`, `maxV = clamp(max(all values) + 1,
+1, 21)` (if equal, `maxV = minV + 1`). One gridline + label per whole-number tier from `minV` to
+`maxV`. `yPos(v) = 50 + 300 - ((v - minV) / (maxV - minV)) * 300`.
+
+**Drawing rules:**
+- Gridlines `stroke="#e5e7eb"`; y-axis tier labels `font-size="12" fill="#475569"
+  text-anchor="end"` at `x="82"`, vertically centred on the gridline (`y = yPos + 4`). Rotated
+  y-axis title "Moody's rating" (`font-size="11" fill="#64748b"`, `transform="rotate(-90 20 200)"`
+  at `x="20" y="200"`).
+- X-axis baseline `stroke="#334155" stroke-width="1.5"` at `y="350"`; date labels (`MMM YYYY`)
+  `font-size="11" fill="#475569" text-anchor="middle"` at `y="372"`; x-axis title "Rating action
+  date (oldest to most recent)" `font-size="11" fill="#64748b"` centred at `x="415" y="410"`.
+- Lines: `stroke-width="2.5" stroke-linejoin="round" stroke-linecap="round"`.
+- Regular points: `<circle r="5">` in company colour with a white 1.5px stroke. Most-recent point
+  (rightmost): `<circle r="8">` in company colour with a white `<circle r="4" fill="white"/>`
+  stacked on top, plus `<title>{company} · {rating symbol} · {date}</title>`.
+- Value labels beside each point: rating symbol, `font-size="11" font-weight="700"`, company
+  colour, with a white halo (`paint-order="stroke" stroke="#fff" stroke-width="3"`). Place the
+  target's labels above (`dy="-12"`) and each peer's below (`dy="20"`) so overlapping series stay
+  readable. If two points in the same series sit within 40px of each other horizontally, label
+  only the leftmost; always label the most recent point.
+- Legend below the SVG (`.chart-legend`) with each company's current rating in parens, e.g.
+  `Target Co (Baa1)`, target first.
+- Clean markup only: no scratch arithmetic, no HTML comments left in the final value.
+
+```html
+<div class="chart-container">
+  <div class="chart-title">Moody's Long-Term Rating History — Last 5 Actions</div>
+  <div class="chart-subtitle">Higher on the axis = stronger credit quality; most recent action marked with a ringed point</div>
+  <svg viewBox="0 0 780 440" width="100%" preserveAspectRatio="xMidYMid meet">
+    <line x1="90" y1="50" x2="740" y2="50" stroke="#e5e7eb" stroke-width="1"/>
+    <text x="82" y="54" text-anchor="end" font-size="12" fill="#475569">Baa1</text>
+    <!-- one gridline + label per tier from minV to maxV -->
+    <line x1="90" y1="350" x2="740" y2="350" stroke="#334155" stroke-width="1.5"/>
+    <text x="90" y="372" text-anchor="middle" font-size="11" fill="#475569">Jan 2021</text>
+    <!-- one date label per x position, then the axis titles -->
+    <path d="M90,202 L252,202 L415,148 L577,148 L740,148" fill="none" stroke="#0066cc"
+          stroke-width="2.5" stroke-linejoin="round" stroke-linecap="round"/>
+    <circle cx="90" cy="202" r="5" fill="#0066cc" stroke="#fff" stroke-width="1.5"/>
+    <text x="90" y="190" text-anchor="middle" font-size="11" font-weight="700" fill="#0066cc" paint-order="stroke" stroke="#fff" stroke-width="3">Baa2</text>
+    <circle cx="740" cy="148" r="8" fill="#0066cc"/>
+    <circle cx="740" cy="148" r="4" fill="white"/>
+    <title>Target Co · Baa1 · Mar 2025</title>
+    <!-- repeat path + circles for each peer with palette[1..3] -->
+  </svg>
+  <div class="chart-legend">
+    <div class="chart-legend-item"><span class="chart-legend-swatch" style="background:#0066cc"></span>Target Co (Baa1)</div>
+    <!-- one legend item per company -->
+  </div>
+  <div class="chart-source">Source: Moody's Long-Term Ratings</div>
+</div>
+```
+
+For companies with fewer than 5 historical ratings, either repeat the oldest available value to
+fill trailing points, or reduce `maxPts` to the largest available count and drop the
+corresponding x-axis labels. Compute coordinates once, silently — do not leave scratch arithmetic
+or alternative options as HTML comments in the output (the comments in the snippet above are
+illustrative only).
+
+**PD panel** → `pd_panel_html`
+
+Always write something into the PD panel — it is never silently empty.
+
+Compute the peer average (1-year PD, 5-year cumulative PD) as the arithmetic mean across resolved
+peers only (exclude the target). Map the average PD to a PD-implied rating the same way as for
+individual companies. Always label the implied rating "PD-implied rating", never as a Moody's
+rating.
+
+Determine the PD signal:
+- `red` — target 1-year PD is >2× peer average
+- `amber` — target 1-year PD is 1.25–2× peer average
+- `green` — target 1-year PD is ≤1.25× peer average
+
+**If PD is still unavailable after the retry**, set `pd_panel_html` to:
+
+```html
+<div class="pd-unavailable">Probability of Default data was unavailable for this run.</div>
+```
+
+and set `section2_suffix` to an empty string.
+
+**When PD data is available**, write, in this order:
+
+1. **Signal banner** (`.pd-banner`, modifier matches the signal): `PD Signal: {SIGNAL} —
+   {Target}'s 1-year PD ({x}%) is {n}× the peer average ({y}%), {range description}.` followed by
+   one sentence of context. No emoji or icon characters — the colour modifier carries the signal.
+
+2. **1-year PD bar chart** (immediately after the banner, before the table): one
+   `.peer-bar-chart-outer` panel reusing the Key Indicators bar markup exactly. Use only the
+   template's existing classes (`pbc-title`, `pbc-subtitle`, `pbc-legend`, `pbc-rows`, `pbc-row`,
+   `pbc-name`, `pbc-track`, `pbc-fill`, `pbc-val`, `pbc-note`, plus `pbc-scale-note`, `pbc-axis`,
+   `grid`) — never invent new class names or inline swatch styles.
+   - `.pbc-title` "1-Year Probability of Default"; `.pbc-subtitle` "Moody's EDF, % — lower is
+     stronger".
+   - `.pbc-legend`: `<span style="--sw:#0066cc">Target</span><span style="--sw:#6f9fd3">Peers</span><span
+     style="--sw:#2e7d32">Peer average</span>` (same markup as the Key Indicators legend, no median
+     entry).
+   - **Log scale (required).** PDs across a peer set routinely differ by 50x or more, so a linear
+     scale makes the investment-grade peers' bars invisible slivers. Size every bar on a
+     logarithmic scale: `lo = 10^floor(log10(min value))`, `hi = 10^ceil(log10(max value))` (across
+     all rows including the average),
+     `width = (6 + 82 * (log10(v) - log10(lo)) / (log10(hi) - log10(lo))).toFixed(1) + '%'` — so
+     the smallest bar is still at least 6% wide and the largest at most 88%. Add class `grid` to
+     every `.pbc-track` (it draws quarter-way gridlines), and directly under the rows add a
+     `<div class="pbc-axis"><span class="pbc-axis-spacer"></span><span class="pbc-axis-ticks"><span>{lo}%</span>
+     <span>{mid1}%</span><span>{mid2}%</span><span>{hi}%</span></span><span class="pbc-axis-end"></span></div>`
+     whose tick labels are the PD values at 0, 1/3, 2/3 and 100% of the log range (format with up
+     to 3 significant figures). Then `<div class="pbc-scale-note">Logarithmic scale — bar length
+     is not proportional to PD.</div>` right under the subtitle.
+   - **The colour class goes on the `.pbc-fill` element itself** (never only on the row), exactly
+     as in the Key Indicators charts: `<div class="pbc-track grid"><div class="pbc-fill subj-pos"
+     style="left:0;width:50.9%"></div></div>` for the target, `pbc-fill peer-pos` for peers,
+     `pbc-fill avg-bar` for the average. A fill with no colour class and no width renders as an
+     empty track, so every row must have both.
+   - Rows: target first (`subj-pos`), peers sorted by descending PD (`peer-pos`), then a
+     dashed-border `Peer average` row (`avg-bar`). `.pbc-name` carries the company's short name;
+     `.pbc-val` shows the 1-year PD with 3 significant figures and a `%` sign (e.g. `0.0084%`),
+     class `pos` on the target's value. Do not show a median line.
+   - `.pbc-note`: one sentence stating the target's PD as a multiple of the peer average and
+     which peer is highest/lowest.
+
+3. **Table** (`.pd-table`) — columns: Company | 1-Year PD (%) | 5-Year Cumulative PD (%) |
+   PD-Implied Rating | Moody's Rating. Target row first (`.pd-row-target`, name tagged
+   `<span class="pd-target-tag">(TARGET)</span>`), then peers, then a final `.pd-row-avg` row
+   labelled `Peer Average (ex-{Target})` (Moody's Rating column shows `—` for the average row).
+   The Moody's Rating column is copied verbatim from `getEntityRatings`; never re-derive it from
+   PD data or any other source.
+
+```html
+<div class="pd-banner amber">
+  <div><strong>PD Signal: AMBER</strong> — Target Co's 1-year PD (0.0234%) is 1.87× the peer
+  average (0.0125%), within the 1.25–2.0× amber range. Elevated relative to peers but consistent
+  with a strong investment-grade entity carrying elevated near-term capex.</div>
+</div>
+<!-- 1-year PD bar chart panel here -->
+<div class="chart-source">PD-implied ratings are model-implied and are not Moody's ratings.</div>
+<table class="pd-table">
+  <thead>
+    <tr><th>Company</th><th>1-Year PD (%)</th><th>5-Year Cumulative PD (%)</th><th>PD-Implied Rating</th><th>Moody's Rating</th></tr>
+  </thead>
+  <tbody>
+    <tr class="pd-row-target">
+      <td class="company-name">Target Co <span class="pd-target-tag">(TARGET)</span></td>
+      <td>0.0234%</td><td>0.4009%</td><td>Aa1</td><td>A1</td>
+    </tr>
+    <tr><td class="company-name">Peer A</td><td>0.0176%</td><td>0.2807%</td><td>Aaa</td><td>Aa2</td></tr>
+    <!-- one row per resolved peer -->
+    <tr class="pd-row-avg">
+      <td>Peer Average (ex-Target Co)</td><td>0.0125%</td><td>0.2222%</td><td>Aaa</td><td>—</td>
+    </tr>
+  </tbody>
+</table>
+```
+
+**Analysis** → `ratings_analysis_html`
+
+One `<p>` paragraph on rating trajectories — which companies show improvement, deterioration, or
+stability, and what that implies for relative credit positioning.
+
+### Section 3 — ESG Heatmap & Analysis
+
+**ESG heatmap** → `esg_heatmap_html`
+
+A colour-coded HTML table — the only ESG data table (there is no separate plain ESG table).
+Five columns: company name, Overall (CIS-*), Environmental (E-*), Social (S-*), Governance (G-*).
+Label scores precisely: CIS = Credit Impact Score, E/S/G = Issuer Profile Scores. Apply a CSS
+class to each score `<td>` based on numeric severity (lower = better): `esg-s1` (green, minimal
+risk) … `esg-s5` (red, very high risk) — parse the numeric suffix from the score string (e.g.
+`CIS-3` → 3). If a company returns no ESG data, or a score is `N/A` or missing, show `N/A` and
+omit the colour class.
+
+```html
+<table class="esg-heatmap">
+  <thead>
+    <tr><th>Company</th><th>CIS (Overall)</th><th>E Score</th><th>S Score</th><th>G Score</th></tr>
+  </thead>
+  <tbody>
+    <tr>
+      <td>Target Co</td>
+      <td class="esg-s3">CIS-3</td><td class="esg-s4">E-4</td><td class="esg-s3">S-3</td><td class="esg-s2">G-2</td>
+    </tr>
+    <!-- one row per company, target first, same order as all other tables -->
+  </tbody>
+</table>
+<div class="esg-legend">
+  <span><i style="background:#bbf7d0"></i>1 Positive / minimal</span>
+  <span><i style="background:#d9f99d"></i>2 Low</span>
+  <span><i style="background:#fde68a"></i>3 Moderate</span>
+  <span><i style="background:#fdba74"></i>4 High</span>
+  <span><i style="background:#fca5a5"></i>5 Very high</span>
+</div>
+```
+
+Always include the legend after the table. Wrap nothing else around it; the `esg-heatmap` class
+(already styled in the template) supplies fixed column widths, cell spacing and colours. Use the
+company's short name in the first cell (full name in `title`).
+
+**Analysis** → `esg_analysis_html`
+
+Two `<p>` paragraphs:
+- Paragraph 1: compare ESG profiles across the peer set — which companies share similar
+  profiles and what drives the overall classification.
+- Paragraph 2: highlight the key differentiator (typically Governance) and explain which company
+  stands out as weaker/stronger and why.
+
+### Citations & Sources
+
+The report carries **one consolidated, de-duplicated, continuously numbered Sources list** at the
+very end, covering Sections 1–3 (there are no per-section citation recaps). Attribute
+substantive claims inline with numbered references:
+
+- **Inline reference:** `<a class="cite-ref" href="{source URL}" target="_blank">[n]</a>`
+  immediately after the claim (the `cite-ref` class is styled in the template). If the tool
+  result gives no URL for the source, use `<span class="cite-ref">[n]</span>` instead.
+- **Numbering:** assign `n` in order of first appearance across the finished document
+  (top-to-bottom: Section 1 → 3), one number per distinct source; reuse the same `n` whenever
+  the same source is cited again.
+- **Sources list:** fill the template's `#sources-footer` container (the template comment says it
+  is platform-filled; in this skill you fill it yourself) with one list matching the inline
+  numbers:
+  ```html
+  <aside class="citations"><ol>
+    <li>{Document or record title} — Moody's, {date}</li>
+    <!-- one <li> per source, in [1], [2], … order -->
+  </ol></aside>
+  ```
+  Internal MCP tool names (e.g. `getCreditOpinion`) are NEVER rendered in the Sources list.
+- **Citation hygiene** (keep the list tidy):
+  - Cite each source once per paragraph or table row rather than after every figure; in the
+    Scorecard cite once per company column (on its Current cell) instead of on every cell.
+  - Cite the credit opinion document for qualitative statements and the financials record for
+    ratios.
+  - Cite each company's rating record once per rating card and once in the ratings analysis
+    paragraph — not on chart points, labels or legend items (the chart carries one uncited
+    "Source" line instead).
+  - Cite each company's ESG record once in the analysis paragraphs; do not cite individual
+    heatmap cells.
+  - Cite each company's PD record once, in the banner sentence; do not cite chart bars or table
+    cells, and do not cite rating records there.
+  - Never cite a record you did not receive from a tool result in this run. If you cannot cite a
+    fact precisely, leave it uncited — an uncited sentence is fine; a fake citation is not.
+  - Never cite a "no data found" statement unless a tool result actually returned a record
+    marked as no data for that lookup.
+
+### Class-selection rules
+
+**`.outlook-badge`** modifier (inside rating cards):
+
+- `stable` — outlook is "Stable"
+- `positive` — outlook is "Positive"
+- `negative` — outlook is "Negative"
+- `review` — outlook contains "Review" (e.g., "Rating Under Review")
+- `na` — outlook is missing or unknown
+
+**`.company-chip.target`** applies only to the target (first) chip. Remaining chips use plain
+`.company-chip`.
+
+### Conventions
+
+- Use `<p>` for paragraphs, `<ul><li>` for bullets, `<strong class="subsection-title">…</strong>`
+  for bold subheaders inside prose containers.
+- Do NOT include overall section titles inside the filled values — the template already has them.
+- `rating` values: use Moody's rating symbol (e.g. `Aaa`, `Aa1`, `Baa2`, `Ba1`). If not found,
+  use `N/A`.
+- `outlook` values: `Stable`, `Positive`, `Negative`, `Rating Under Review`, or `N/A`.
+- Charts use the template's own CSS classes and inline SVG (no external chart library); colours,
+  fonts and sizing come from the template so all panels look identical. No emoji or icon glyphs
+  in any generated content.
 
 ---
 
+## Guardrails (apply across the whole workflow)
+
+- **Never fabricate** rating values, outlooks, dates, financial figures, or rationale text. Every
+  rating traces back to `getEntityRatings`; every financial figure to `getEntityFinancials_v2`,
+  `getEntityScorecardV2` or the credit opinion's exhibits.
+- **The target company always appears first** — first column/row in every table and comparison.
+- If fewer than 3 peers are resolved, leave the unused column/row slots empty — do not pad with
+  invented peers, and do not collapse or restructure the pre-shaped tables.
+- If a Credit Opinion section is missing for a company, write `Not available` rather than
+  leaving the cell blank.
+- Rating consistency across sections is structural, not a final-pass check: every section that
+  shows a company's current rating takes it from the same `getEntityRatings` result, so one
+  ground-truth source feeds the Rating Cards, Ratings Chart, Scorecard "Actual rating" row and PD
+  table.
+
 ## Tips
 
 - Run ALL data-gathering tool calls in a single parallel batch (one message, many tool calls).
-- Deliver the report as **one** `.html` file in `/mnt/user-data/outputs/`, then render it with
-  **both** `present_files` and `visualize:show_widget` (see Step 6). Never paste it as a fenced
-  ` ```html ` code block, never split across files or messages, and never stop at file creation.
-- The target company always appears as the first column / first row in every table and
-  comparison.
+- Write the final HTML to disk as a single `.html` file and deliver it via `present_files` — do
+  not print the HTML source in the chat, do not split across multiple files.
 - The conclusion must orient around the target company — how it differentiates from its peers.
-- If fewer than 3 peers are returned, leave the unused column/row IDs empty. The pre-shaped
-  tables keep those cells blank — do not attempt to collapse or restructure the table.
-- If `getCreditOpinion` does not return a particular section, write `Not available` in the
-  corresponding cell rather than leaving it blank.
-- `getEntitySectorOutlook` typically applies to all companies in the same sector — call once
-  and reuse.
-- Emit the ratings-chart SVG directly into `#pa-ratings-chart` — the template no longer builds
-  the chart at render time. Pick the `.outlook-badge` class yourself using the rules above.
-- For companies with fewer than 5 historical ratings, either repeat the oldest available rating
-  value to fill the trailing points, or reduce `maxPts` in the chart formula to the largest
-  available count (and drop the corresponding `Rating k` x-axis labels).
-- Inline citations follow the shared citations skill — read
-  [references/shared-citations.md](references/shared-citations.md) before authoring any `[n]`
-  reference or the Citations block.
+- Before writing the file, check: no `{{ ... }}` token left; FY labels in the KI charts match the
+  Scorecard sub-headers; the Section 2 title matches the PD panel; the Scorecard has exactly 6
+  body rows; the Actual rating row matches the Rating Cards for every company; the Sources list
+  numbers match the inline references.
 
 ---
 
-## Amendments (in `references/report-spec.md`)
+## Step 6 — Save and deliver the report as a downloadable file
+
+After assembling the complete HTML string, **write it to disk as a standalone `.html` file** and
+make it available for the user to download. Do **not** print the raw HTML in the chat.
+
+### File naming
+
+Use the pattern: `{target_company_slug}_peer_analysis.html`
+
+Where `{target_company_slug}` is the target company's canonical name lowercased, spaces and
+special characters replaced with underscores (e.g. `apple_inc_peer_analysis.html`).
 
-Three amendments in [`references/report-spec.md`](references/report-spec.md) override the base
-report layout and **must be applied**:
+### Delivery
 
-1. **Most recent fiscal year** — always populate Key Indicators and Scorecards from each
-   entity's most recent FY-end `getEntityFinancials_v2` data (with the distorted-EBITDA `†`
-   handling), not whatever year the credit opinion cites.
-2. **Visual Enhancements** — rating summary cards (`#pa-rating-cards`), financial comparison
-   bar charts (`#pa-fi-charts`), and the ESG score heatmap (`#pa-esg-heatmap`).
-3. **Section layout / ratings-chart / ESG overrides** — emit rating cards instead of the
-   `<tbody id="pa-peers-rating">` table, the enhanced ratings chart, and the ESG heatmap
-   instead of the `<tbody id="pa-esg-table">` table.
+After writing the file, use whatever file-presentation capability is available in the current
+environment to surface the file to the user so they can open or download it. Do not describe
+the tool being used — just invoke it. Then add one short confirmation sentence, for example:
+`The peer analysis report for [Target Company] is ready to download above.`
 
-See the spec for the full rules, reference snippets, the updated element-ID mapping, and the
-exact list of base elements to omit.
+Do **not** print the HTML source in the chat. Do **not** emit a fenced ` ```html ` code block.
+The saved file is the sole deliverable.
Full technical diff · 3 changed fields

changed /description

BEFORE
"Produce a Peer Analysis HTML report for a target company and its credit peers using Moody's GenAI MCP tools. Use this skill whenever the user asks to compare a company against its peers, run a peer analysis, do a credit peer comparison, generate a peer group report, or analyze relative credit positioning. Trigger even if they just name a company and mention \"peers\", \"peer comparison\", \"credit comparison\", \"peer group\", or \"relative value\"."
AFTER
"Helps credit analysts and investors see how a company compares with its closest peers. It resolves the target and up to three peers, then compares their credit ratings and rating drivers, key financial and credit metrics, probability of default and ESG profiles, and concludes on the target's relative credit positioning. Peers can be chosen by the user or discovered automatically.\n"

changed /included_files

BEFORE
[
  {
    "relative_path": "__MACOSX/._SKILL.md",
    "size_in_bytes": 163
  },
  {
    "relative_path": "__MACOSX/._assets",
    "size_in_bytes": 163
  },
  {
    "relative_path": "__MACOSX/._evals",
    "size_in_bytes": 163
  },
  {
    "relative_path": "__MACOSX/._references",
    "size_in_bytes": 163
  },
  {
    "relative_path": "__MACOSX/assets/._template.html",
    "size_in_bytes": 163
  },
  {
    "relative_path": "__MACOSX/evals/._evals.json",
    "size_in_bytes": 163
  },
  {
    "relative_path": "__MACOSX/references/._report-spec.md",
    "size_in_bytes": 163
  },
  {
    "relative_path": "__MACOSX/references/._shared-citations.md",
    "size_in_bytes": 163
  },
  {
    "relative_path": "__MACOSX/references/._shared-template.md",
    "size_in_bytes": 163
  },
  {
    "relative_path": "assets/template.html",
    "size_in_bytes": 23871
  },
  {
    "relative_path": "evals/evals.json",
    "size_in_bytes": 4149
  },
  {
    "relative_path": "references/report-spec.md",
    "size_in_bytes": 32726
  },
  {
    "relative_path": "references/shared-citations.md",
    "size_in_bytes": 5814
  },
  {
    "relative_path": "references/shared-template.md",
    "size_in_bytes": 8111
  }
]
AFTER
[
  {
    "relative_path": "agents/openai.yaml",
    "size_in_bytes": 573
  },
  {
    "relative_path": "assets/icon.png",
    "size_in_bytes": 1753
  },
  {
    "relative_path": "assets/template.html",
    "size_in_bytes": 24588
  },
  {
    "relative_path": "evals/evals.json",
    "size_in_bytes": 3506
  }
]

changed /skill_md_contents

BEFORE
"---\nname: peer-analysis\ndescription: >\n  Produce a Peer Analysis HTML report for a target company and its credit peers using Moody's\n  GenAI MCP tools. Use this skill whenever the user asks to compare a company against its peers,\n  run a peer analysis, do a credit peer comparison, generate a peer group report, or analyze\n  relative credit positioning. Trigger even if they just name a company and mention \"peers\",\n  \"peer comparison\", \"credit comparison\", \"peer group\", or \"relative value\".\n---\n\n# Peer Analysis Skill\n\nGenerates a professional HTML report (styled like a Moody's peer analysis PDF) for a target\ncompany and up to 3 credit peers. Data is pulled from multiple `Moodys MCP server` MCP tools and\nconsolidated into a single HTML artifact covering peers comparison, ratings chart, and ESG.\n\nThe workflow is **single-artifact delivery**: gather all data, then write the entire filled\nHTML document to a single `.html` file in `/mnt/user-data/outputs/` and actively render it to\nthe user with **both** `present_files` and `visualize:show_widget`. The rendered HTML artifact\nis the deliverable — writing the file without rendering it is a failed run.\n\n> ## ⚠️ CRITICAL — NON-NEGOTIABLE OUTPUT CONTRACT\n>\n> **The LLM MUST deliver the final report as a single standalone HTML artifact file that it\n> then actively renders on screen.** Creating the file is only half the job — a file that is\n> written but never surfaced is a failed run, and is the single most common failure mode for\n> this skill. Specifically:\n>\n> - The LLM **MUST** write the **complete, standalone HTML document** (`<!doctype html>` →\n>   `</html>`), with every section from the streaming protocol populated inline, to a single\n>   `.html` file in `/mnt/user-data/outputs/` using the `create_file` tool.\n> - The LLM **MUST** then render that file with **both** display tools — `present_files`\n>   **and** `visualize:show_widget` — before ending its turn. Firing both renderers is what\n>   guarantees the report always appears even if one tool is unavailable.\n> - The LLM **MUST NOT** end its turn after `create_file` without having called the display tools.\n> - The LLM **MUST NOT** emit the report inline as a fenced ` ```html ` code block, as prose,\n>   Markdown, JSON, attachments, or links. The rendered HTML artifact itself is the answer.\n> - The LLM **MUST NOT** split the report across multiple files, multiple messages, partial\n>   snippets, or summaries.\n> - If data gathering fails partially, still produce the single HTML artifact file with the\n>   best-available content and `\"--\"` placeholders for missing cells — never skip the artifact\n>   or the render step.\n>\n> Treat any other output shape as a hard failure of the skill.\n\n## Required MCP server\n\n`Moodys MCP server` — tools used: `findEntity`, `getEntityPeers`, `getEntityRatings`,\n`getCreditOpinion`, `getEntityFinancials_v2` (sections: Profile, Summary, RatingOutlook, FactorsLeadingToUpgrade,\nFactorsLeadingToDowngrade, CreditStrengths, CreditChallenges, ESGConsiderations,\nKeyIndicatorsTable, ScorecardTable, ESGConsiderations), `getEntitySectorOutlook`\n\nIf any of the tools required for a section do not exist, inform the user: One or more tools required for this section are not available under your current subscription. Unlock more of the expert insights, data, and analytics you trust. Get Link:https://www.moodys.com/web/en/us/capabilities/gen-ai/ai-ready-data.html with us to learn more. \n\n## Bundled files\n\n- `assets/template.html` — self-contained static report shell (CSS + named section placeholders,\n  including pre-shaped tables for a fixed target+3-peer layout). No embedded data, no inline\n  script. Treat this file as the **read-only structural reference**: read it, fill it in\n  mentally, and emit the complete filled document in the final response.\n\n## Shared chrome & citations\n\nBefore emitting, read [`references/shared-template.md`](references/shared-template.md) (page\nchrome: cover, TOC, section block, sources-section wrapper, footer, outlook-badge, design\ntokens) and [`references/shared-citations.md`](references/shared-citations.md) (citation\nnumbering, hyperlinking, source data shape, markup snippets). Both are **authoritative** — do\nnot invent, duplicate, or restyle anything they already define. The canonical CSS is already\ninlined in `assets/template.html` between the `/* BEGIN/END shared-template-css */` and\n`/* BEGIN/END shared-citations-css */` markers; never re-copy it at emit time.\n\nThe rest of this section is the skill-specific binding.\n\nThis skill uses the **`cover-multi`** variant. Skill-specific override retained above the\nmarker region: `**.page { max-width: 1050px }**` (PA reports are wider than the 900px canonical\ndefault to fit the multi-column scorecard / key-indicators tables). Skill-specific CSS that\nstays local: `.sub-heading`, all PA-specific table classes (`.pa-table`, `.credit-drivers-table`,\n`.ki-table`, `.sc-table`), and the chart helpers (`.chart-container`, `.chart-title`,\n`.chart-legend`, `.chart-legend-item`, `.chart-legend-swatch`). All outlook-badge usage in this\nskill must use the canonical pastel variants (`stable` / `positive` / `negative` / `review` /\n`na`) defined by the shared skill — no solid-fill or inline-color overrides. PA flags the target\nentity on the cover with `class=\"company-chip target\"`; the chip wrappers themselves come from\nthe shared cover-multi snippet.\n\nThe prefix used for the end-of-document container in this skill is `pa`, so the container id\nis `#pa-sources`. Optional per-section recap blocks live in `#pa-cite-peers`,\n`#pa-cite-ratings`, and `#pa-cite-esg`. Internal MCP tool names (e.g. `getCreditOpinion`)\nare NEVER rendered inside `.source-meta`.\n\n---\n\n## Step 1 — Resolve the target company\n\nCall `findEntity` with the company name provided by the user. Store the canonical entity name\nand entity ID.\n\nIf the user provides only one company name, that is the **target company**. The peers will be\ndiscovered automatically in Step 2.\n\n---\n\n## Step 2 — Discover and resolve peers\n\nCall `getEntityPeers` for the target company. Select the top 3 peers returned.\n\nYou now have a set of up to **4 companies** (1 target + up to 3 peers). For each peer, call\n`findEntity` to resolve its canonical entity name and ID.\n\n---\n\n## Step 3 — Read the template\n\nRead `assets/template.html` (relative to this skill directory) once. Keep its exact structure —\nCSS, `<head>`, section order, table skeletons (including all pre-shaped 4-company columns/rows),\nrow labels, and element IDs — as the scaffold for the final artifact. Do **not** copy it to the\nworkspace and do **not** open it.\n\n---\n\n## Step 4 — Gather all data in parallel\n\nFor every company in the set (target + up to 3 peers), fire **all of the following in a single\nparallel batch** (one message, many tool calls):\n\n### Credit Opinion data (per company)\n\nCall `getCreditOpinion`,`getEntityFinancials_v2` requesting these sections, about the key Indicators table this should be populated with most recent fiscal year available (e.g. 2025 FY) on `getEntityFinancials_v2`. Not LTM allowed:\n\n| Section parameter | Purpose |\n|---|---|\n| `Profile` | Company description for the Peers Table |\n| `FactorsLeadingToUpgrade` | Upgrade factors for Credit Drivers |\n| `FactorsLeadingToDowngrade` | Downgrade factors for Credit Drivers |\n| `CreditStrengths` | Credit strengths for Credit Drivers |\n| `CreditChallenges` | Credit challenges for Credit Drivers |\n| `KeyIndicatorsTable` | Financial metrics for Key Indicators table |\n| `ScorecardTable` | Scorecard data |\n| `ESGConsiderations` | ESG narrative containing the CIS classification and E/S/G scores for the ESG Table & Heatmap |\n\n### Ratings (per company)\n\nCall `getEntityRatings` — retrieve the current long-term rating, rating class, rating date,\noutlook, and historical ratings (need at least the last 5 rating actions for the Ratings Chart).\n\n### ESG (per company)\n\nSource ESG from the `ESGConsiderations` section of `getCreditOpinion` (requested in the Credit\nOpinion call above). This section is narrative text, but Moody's states the overall CIS\nclassification and the E, S, and G issuer-profile scores within it (e.g. \"CIS-3\", \"E-4\", \"S-3\",\n\"G-2\"). Extract those codes verbatim for the ESG Table & Heatmap. If a given score is not stated\nin the narrative, follow the `na` / `--` conventions in the report spec rather than inventing one.\n\n### Sector outlook (once per sector)\n\nCall `getEntitySectorOutlook` for the target company's sector. Reuse for peers in the same\nsector.\n\nHold all results in context for Step 5 synthesis.\n\n---\n\n## Step 5 — Synthesize + emit the complete artifact\n\nAfter data is gathered, write the **entire filled `template.html` document** — with every\nelement from the streaming protocol populated in place — to a single `.html` file in\n`/mnt/user-data/outputs/`, then render it. The full required delivery sequence (`create_file`\n→ `present_files` → `visualize:show_widget` → one short sentence) is specified in the\n**Step 6 — Output and presentation** section below; follow it exactly.\n\nThe HTML file **must**:\n\n- Be written in a single `create_file` call (no progressive `StrReplace` edits, no multi-file\n  split).\n- Contain a complete, standalone HTML document (doctype → `</html>`) that renders without\n  external dependencies.\n- Preserve the template's `<head>` (CSS, fonts), section order, table skeletons, row labels, and\n  element IDs exactly. Only the empty targets defined below are populated.\n\nWrite in professional financial/credit analysis language. Always reference specific companies by\nname. The target company is **always the first column / first row** in every table. Render order\nof content inside the file follows the page top-to-bottom so the artifact is human-readable\nas well as browser-renderable: cover/header fields first, then Peers Comparison sub-sections\n(1–6), Ratings Chart, ESG, and citations/sources last.\n\nAttribute substantive claims with numbered citation references. The exact inline markup, the\nURL-less fallback, and the rule that `n` matches the row position of the source inside\n`#pa-sources` are defined in [references/shared-citations.md](references/shared-citations.md).\n\n### Cover / header fields (write first)\n\n- `#pa-report-date` — e.g. `April 20, 2026` (plain text)\n- `#pa-footer-date` — same value (plain text)\n- `#pa-target-company` — canonical name of the target (plain text)\n- `#pa-peer-count` — integer count of peers resolved in Step 2 (plain text)\n- `#pa-company-chips` — `<span class=\"company-chip target\">Target</span>` followed by one\n  `<span class=\"company-chip\">Peer</span>` per peer (space-separated; target first)\n- `#pa-cover-img-right`, `#pa-cover-img-bottom` — optional. If you have image URLs or data URIs\n  to use, set the `src` attributes **and** add the `has-cover-image` class to the corresponding\n  container (`<div class=\"cover-top has-cover-image\">` and/or `<div class=\"cover-bottom has-cover-image\">`).\n  If you do not have images, leave the template as-is — the empty image strips will collapse\n  automatically and the cover will render as a clean navy block with the accent bar.\n\n### Report body — sections, streaming protocol & charts\n\nBefore emitting, read [`references/report-spec.md`](references/report-spec.md) for the\nauthoritative body-authoring spec: the Section 1 sub-sections (Peers Table, Peers Rating,\nCredit Drivers, Key Indicators, Scorecards, Conclusion), Section 2 (Ratings Chart + analysis),\nSection 3 (ESG Table + analysis), where the optional `#pa-cite-*` recaps and the\n`#pa-sources` rows go, the **streaming protocol** (element → content mapping), the reference\nHTML snippets, the Ratings-Chart SVG template (constants, rating→value map, coordinate\nformulae), and the class-selection rules and conventions. **The spec also carries three\nAmendments that override this base layout — apply them.** Populate every `#pa-*` target\nexactly as specified there.\n\n---\n\n## Step 6 — Output and presentation (required final steps)\n\n> ## ⚠️ CRITICAL — THE SKILL IS NOT COMPLETE UNTIL THE REPORT IS VISIBLY RENDERED\n>\n> Writing the file is **not** delivery. After you write the HTML you **must** actively render\n> it with every display tool available, in order, before you say anything else. Do not end\n> your turn until the rendered report is on screen.\n\nFollow this exact sequence. Do not skip a step, reorder, or substitute alternatives:\n\n1. **Write the HTML file in a single call.** Call `create_file` to write the entire standalone\n   HTML document (`<!doctype html>` → `</html>`) to\n   `/mnt/user-data/outputs/{target_company_slug}_peer_analysis.html` in **one** call.\n   `{target_company_slug}` is the target's canonical name lowercased with spaces and special\n   characters replaced by underscores (e.g. `apple_inc_peer_analysis.html`). No progressive\n   edits, no multi-file split.\n2. **Present the file.** Immediately call `present_files` on that exact path to surface the\n   artifact to the user.\n3. **Show the widget.** Immediately call `visualize:show_widget` on the same file to render the\n   report visually. Call this even if `present_files` already succeeded — firing both renderers\n   is what guarantees the report always appears.\n4. **Confirm in one short sentence.** Only after the renderers return, add a single brief\n   sentence in chat (e.g. `Peer Analysis for {Target Company} — the report is available above as\n   a self-contained HTML artifact.`). Nothing more.\n\nIf a display tool call fails or is unavailable, immediately try the other one rather than\nstopping. Never end your turn at step 1, and never paste the HTML into chat or suggest shell\ncommands.\n\n---\n\n## Tips\n\n- Run ALL data-gathering tool calls in a single parallel batch (one message, many tool calls).\n- Deliver the report as **one** `.html` file in `/mnt/user-data/outputs/`, then render it with\n  **both** `present_files` and `visualize:show_widget` (see Step 6). Never paste it as a fenced\n  ` ```html ` code block, never split across files or messages, and never stop at file creation.\n- The target company always appears as the first column / first row in every table and\n  comparison.\n- The conclusion must orient around the target company — how it differentiates from its peers.\n- If fewer than 3 peers are returned, leave the unused column/row IDs empty. The pre-shaped\n  tables keep those cells blank — do not attempt to collapse or restructure the table.\n- If `getCreditOpinion` does not return a particular section, write `Not available` in the\n  corresponding cell rather than leaving it blank.\n- `getEntitySectorOutlook` typically applies to all companies in the same sector — call once\n  and reuse.\n- Emit the ratings-chart SVG directly into `#pa-ratings-chart` — the template no longer builds\n  the chart at render time. Pick the `.outlook-badge` class yourself using the rules above.\n- For companies with fewer than 5 historical ratings, either repeat the oldest available rating\n  value to fill the trailing points, or reduce `maxPts` in the chart formula to the largest\n  available count (and drop the corresponding `Rating k` x-axis labels).\n- Inline citations follow the shared citations skill — read\n  [references/shared-citations.md](references/shared-citations.md) before authoring any `[n]`\n  reference or the Citations block.\n\n---\n\n## Amendments (in `references/report-spec.md`)\n\nThree amendments in [`references/report-spec.md`](references/report-spec.md) override the base\nreport layout and **must be applied**:\n\n1. **Most recent fiscal year** — always populate Key Indicators and Scorecards from each\n   entity's most recent FY-end `getEntityFinancials_v2` data (with the distorted-EBITDA `†`\n   handling), not whatever year the credit opinion cites.\n2. **Visual Enhancements** — rating summary cards (`#pa-rating-cards`), financial comparison\n   bar charts (`#pa-fi-charts`), and the ESG score heatmap (`#pa-esg-heatmap`).\n3. **Section layout / ratings-chart / ESG overrides** — emit rating cards instead of the\n   `<tbody id=\"pa-peers-rating\">` table, the enhanced ratings chart, and the ESG heatmap\n   instead of the `<tbody id=\"pa-esg-table\">` table.\n\nSee the spec for the full rules, reference snippets, the updated element-ID mapping, and the\nexact list of base elements to omit.\n"
AFTER
"---\nname: peer-analysis\ndescription: >\n  Helps credit analysts and investors see how a company compares with its closest peers. It resolves the target and up to three peers, then compares their credit ratings and rating drivers, key financial and credit metrics, probability of default and ESG profiles, and concludes on the target's relative credit positioning. Peers can be chosen by the user or discovered automatically.\n---\n\n# Peer Analysis Skill\n\nGenerates a professional HTML report (styled like a Moody's peer analysis PDF) for a target\ncompany and up to 3 credit peers. Data is pulled from multiple Moody's MCP tools and\nconsolidated into a single HTML artifact covering peers comparison, ratings chart, PD, and ESG.\n\nThe workflow is **single-artifact file delivery**: gather all data, fill the complete HTML\ndocument, write it to disk as a standalone `.html` file, and present it to the user for\ndownload. No fenced code blocks, no streaming partial sections, no JSON payload, no progressive\nedits. The downloaded file is the sole deliverable.\n\n> ## ⚠️ CRITICAL — NON-NEGOTIABLE OUTPUT CONTRACT\n>\n> **The LLM MUST write the final report to disk and present it as a downloadable file.**\n> This is the only acceptable form of delivery for this skill. Specifically:\n>\n> - The LLM **MUST** write the complete, standalone HTML document (`<!doctype html>` → `</html>`)\n>   to `/mnt/user-data/outputs/{target_company_slug}_peer_analysis.html` and then call\n>   `present_files` to surface it to the user.\n> - The LLM **MUST NOT** print the raw HTML source in the chat — no ` ```html ` fenced code\n>   blocks, no partial snippets, no inline HTML in the assistant message.\n> - The LLM **MUST NOT** split the report across multiple files or multiple messages.\n> - The LLM **MUST NOT** substitute prose, Markdown, JSON, or links for the file download.\n> - The delivered file **MUST NOT** contain any unfilled `{{ placeholder }}` token.\n> - If data gathering fails partially, still write and deliver the file with best-available\n>   content and `Not available` / `—` placeholders (as specified per section below) for missing\n>   cells — never skip the file delivery.\n>\n> Treat any other output shape as a hard failure of the skill.\n\n## Parameters\n\n| Pattern | Type | Required | Notes |\n|---|---|---|---|\n| Company Name | Company | Yes | The target company. The user may also name the peers they want compared; if they do, use those peers. If they do not, peers are discovered automatically in Step 2. |\n\n## Required MCP server\n\n`moodys_mcp` — tools used: `findEntity`, `getEntityPeers`, `getEntityProfile`, `getEntityRatings`,\n`getCreditOpinion` (sections: Summary, FactorsLeadingToUpgrade, FactorsLeadingToDowngrade,\nCreditStrengths, CreditChallenges, KeyIndicatorsTable, RatingFactors), `getEntityScorecardV2`,\n`getEntityFinancials_v2`, `getEntityEsg`, `getEntityProbabilityOfDefault`\n\nIf any of the tools required for a section are not available under the current subscription,\ninform the user: \"One or more tools required for this section are not available under your\ncurrent subscription. Unlock more of the expert insights, data, and analytics you trust. Get\nLink:https://www.moodys.com/web/en/us/capabilities/gen-ai/ai-ready-data.html with us to learn\nmore.\"\n\n## Bundled files\n\n- `assets/template.html` — self-contained report shell (all CSS inline, no external dependencies)\n  with `{{ placeholder }}` tokens for every value that varies per run, including pre-shaped tables\n  for a fixed target + 3-peer layout. Treat this file as the **structural reference**: read it\n  once, replace every `{{ token }}` with its value (token map below), and emit the complete\n  filled document. Keep its `<head>`/CSS, section order, table skeletons, row labels and CSS\n  class names exactly as shipped.\n- `evals/evals.json` — test prompts and assertions for this skill.\n\n---\n\n## CRITICAL: Decide how to respond before doing anything\n\n**Check the conversation history before doing anything else.**\n\n**If a report has already been generated in this conversation:**\n- **Follow-on question** → read the relevant section of the delivered `.html` file and answer\n  directly. Do NOT re-run the data gathering.\n- **Regeneration request** (e.g. \"regenerate\", \"update\", \"redo\") → ask: \"Would you like me to\n  regenerate the full report, or just a specific section?\" and wait before doing anything.\n\n**If no report has been generated yet** → run the full workflow below.\n\n---\n\n## Step 1 — Resolve the target company\n\nCall `findEntity` **once** with the company name provided by the user (and, if the user named\ntheir own peers, include those peer names in the same request — `findEntity` is called once per\nrequest, not once per company). Keep the canonical entity name and `entityId` for each company.\n\nIf the user provides only one company name, that is the **target company**. The peers will be\ndiscovered automatically in Step 2.\n\n**Canonical names, not raw record titles.** Resolve each company to the name a reader would\nrecognize and use that name everywhere in the report (cover, tables, charts, prose).\n\nIf a tool errors, treat the error as the result, retry once, and continue with what you have.\n\n---\n\n## Step 2 — Discover and resolve peers\n\nIf the user did not name peers, call `getEntityPeers` for the target with `maxPeersPerEntity: 3`\nand take the peers returned (analyst-defined peers first).\n\nYou now have a set of up to **4 companies** (1 target + up to 3 peers). The records returned by\n`getEntityPeers` already carry entity IDs; only call `findEntity` again for a peer that arrives\nwithout one, and fold all such names into a single call. Never rebuild an ID from a company name.\n\nIf fewer than 3 peers are returned, proceed with however many were found — never invent a peer to\nfill the set.\n\n---\n\n## Step 3 — Read the template\n\nRead `assets/template.html` (relative to this skill directory) once. Keep its exact structure —\nCSS, `<head>`, section order, table skeletons (including all pre-shaped 4-company columns/rows),\nrow labels, and class names — as the scaffold for the final artifact. Only the `{{ token }}`\nplaceholders are replaced.\n\n---\n\n## Step 4 — Gather all data in parallel\n\nFor every company in the set (target + up to 3 peers), fire **all of the following in a single\nparallel batch** (one message, many tool calls) — do not wait for one tool's results before\nrequesting the next. Use the `entityId` values from Steps 1–2 exactly as resolved.\n\n**`getEntityProfile`** — one call with all companies in `entities`. Use the legal name,\nheadquarters/registered address, business description, NAICS/NACE classification and employee\ncount for the Peers table.\n\n**`getCreditOpinion`** — one call with all companies in `entities`, `sections`:\n`Summary`, `FactorsLeadingToUpgrade`, `FactorsLeadingToDowngrade`, `CreditStrengths`,\n`CreditChallenges`, `KeyIndicatorsTable`, `RatingFactors`. Leave `publishDate` at its default\n(latest opinion).\n\n| Section parameter | Purpose |\n|---|---|\n| `Summary` | Key segments/brands and scale for the Peers Table description; forward values for the Scorecard |\n| `FactorsLeadingToUpgrade` | Upgrade factors for Credit Drivers |\n| `FactorsLeadingToDowngrade` | Downgrade factors for Credit Drivers |\n| `CreditStrengths` | Credit strengths for Credit Drivers |\n| `CreditChallenges` | Credit challenges for Credit Drivers |\n| `KeyIndicatorsTable` | Moody's-adjusted and projected metrics (Scorecard fallback / Forward column) |\n| `RatingFactors` | Scorecard factor values and forward values (Scorecard fallback) |\n\n**`getEntityScorecardV2`** — one call per company (the tool takes a single `entityId`), retrieval\nmode (no `methodology`, no `overrides`). This is the structured source for the Moody's scorecard\nfactor values and the methodology used. It works for unrated entities too.\n\n**`getEntityFinancials_v2`** — one call with all companies in `entities`, `filterCriteria`:\n`{ \"excludeInterimData\": true, \"sections\": [\"key_indicators\", \"income_statement\", \"cash_flow_statement\", \"balance_sheet\"] }`.\n\n> **CRITICAL — `getEntityFinancials_v2` is the authoritative source for all quantitative data.**\n> Do NOT rely solely on the Key Indicators or Scorecard exhibits embedded in `getCreditOpinion` —\n> those may reference an older period. After fetching financials, identify each entity's latest\n> year with a non-null Revenue value and use that year exclusively for the Key Indicators charts,\n> the Scorecard \"Current\" column, and the Revenue chart. **LTM figures are not permitted.**\n> Convert all monetary values to USD billions for display (request `currencies: [\"USD\"]` and\n> `scale: \"billions\"` if the entity's reporting currency differs).\n\n**`getEntityRatings`** — one call with all companies in `entities` and `years: 10` — retrieve the\ncurrent long-term rating, rating class, rating date, outlook, and at least the last 5 historical\nrating actions (needed for the Ratings Chart).\n\n> **`getEntityRatings` is the single, exclusive source of truth for every Moody's rating symbol\n> that appears anywhere in the final document** — Rating Cards, the Ratings Chart, the\n> Scorecard's \"Actual rating\" row, and the PD table's \"Moody's Rating\" column. Never derive,\n> infer, or back into a rating symbol from a scorecard-indicated outcome, a notching assumption,\n> or a credit opinion's narrative prose (which can mention a rating in passing that is stale or\n> inconsistent). If `getEntityRatings` and any other source disagree, `getEntityRatings` wins.\n> Never alter, round, or relabel a rating symbol to make a chart look cleaner — if a rating\n> needs repositioning on an axis, adjust the axis, never the symbol.\n\n**`getEntityEsg`** — one call with all companies in `entities` — overall CIS classification plus\nE, S, G issuer profile sub-scores (IPS), and the analyst comments.\n\n**`getEntityProbabilityOfDefault`** — one call with target + every resolved peer in `entities` —\nretrieve current 1-year PD (%), 5-year cumulative PD (%), and PD-implied rating. The history\nwindow can stay at its default; only current values are shown. **If the call returns an error or\nempty data, retry once** before treating PD as unavailable — the tool is prone to transient\nfailures and a second attempt frequently succeeds.\n\nIf any tool errors or returns nothing for a company, treat the error text as the result, retry\nthat call once, and then mark the affected cells `Not available` / `—` as specified below —\nnever fill them from memory.\n\nCompute quantitative values (ratios, margins, averages, medians) silently; do not narrate the\narithmetic — write only the final numbers into the output.\n\nHold all results in context for Step 5 synthesis.\n\n---\n\n## Step 5 — Synthesize + emit the complete artifact\n\nAfter data is gathered, replace every `{{ token }}` in the template (token map below) and write\nthe complete document to disk, then present it to the user (see Step 6 for the file-naming and\ndelivery contract).\n\nThe assembled document **must**:\n\n- Be a complete, standalone HTML document (doctype → `</html>`) that renders without external\n  dependencies.\n- Preserve the template's `<head>` (CSS), section order, table skeletons, row labels and class\n  names exactly. Only the `{{ token }}` placeholders are replaced.\n- Contain no leftover `{{ ... }}` token. Tokens for unused peer slots are replaced with an empty\n  string.\n\nWrite in professional financial/credit analysis language. Always reference specific companies by\nname. The target company is **always the first column / first row** in every table and\ncomparison. Pass HTML values as-is (valid markup, no scratch arithmetic, no HTML comments left\nin the final value).\n\n### Placeholder map\n\n| Placeholder token(s) | Content type |\n|---|---|\n| `report_date` (used on the cover and in the footer) | Plain text, `Month D, YYYY`, today's date |\n| `target_company` | Plain text (canonical target name) |\n| `peer_count` | Plain text integer — count of peers actually resolved |\n| `company_chips_html` | `<span class=\"company-chip target\">` for the target, then one `<span class=\"company-chip\">` per resolved peer |\n| `peers_table_html` | `<tr>` rows (company name + description) with inline citations |\n| `rating_cards_html` | One `.rating-card` per company (target first) |\n| `cd_col_1` … `cd_col_4` | Plain text (company names; empty string for unresolved peer slots) |\n| `cd_r{1..4}_c{1..4}` | Prose cell content (short `<p>` or plain text) with inline citations |\n| `ki_charts_html` | `ki-fy-header` + five `.peer-bar-chart-outer` panels |\n| `fi_charts_html` | Single `.peer-bar-chart-outer` panel (Revenue) |\n| `sc_col_1` … `sc_col_4` | Plain text (company names; each spans 2 sub-columns) |\n| `sc_col_{1..4}_curr`, `sc_col_{1..4}_fwd` | Plain text sub-header labels (`FY{YYYY}` / `Forward`) |\n| `sc_r{1..6}_c{1..4}_curr`, `…_fwd` | Plain text scorecard cell values |\n| `conclusion_html` | Three `<p>` paragraphs |\n| `section2_suffix` (TOC label and Section 2 heading) | `\" & Probability of Default\"` or empty string |\n| `ratings_chart_html` | Single `<div class=\"chart-container\">…<svg>…</svg>…</div>` block |\n| `pd_panel_html` | PD banner + bar chart + table, or the `.pd-unavailable` note |\n| `ratings_analysis_html` | One `<p>` paragraph |\n| `esg_heatmap_html` | `table.esg-heatmap` + `.esg-legend` |\n| `esg_analysis_html` | Two `<p>` paragraphs |\n\nIf fewer than 3 peers are returned, leave unused column/row slots empty. Do not collapse or\nremove cells — the pre-shaped tables simply keep those cells blank.\n\n### Cover / header fields\n\n- `report_date` — e.g. `October 22, 2026` (plain text; the example is illustrative only)\n- `target_company` — canonical name of the target (plain text)\n- `peer_count` — integer count of peers resolved in Steps 1–2 (plain text)\n- `company_chips_html` — target first (with the `target` class), then one chip per resolved peer;\n  omit chips for unresolved peer slots, do not pad to 3\n\n```html\n<span class=\"company-chip target\">Target Co</span>\n<span class=\"company-chip\">Peer One</span>\n<span class=\"company-chip\">Peer Two</span>\n<span class=\"company-chip\">Peer Three</span>\n```\n\nThe cover image strips in the template are intentionally empty; leave them as shipped.\n\n### Section 1 — Peers Comparison Table & Analysis\n\n**1) Peers Table** → `peers_table_html`\n\nWrite one `<tr>` per company (target first, then peers in order): company name + a substantive\ndescription paragraph built from `getEntityProfile` (business description, headquarters,\nemployees) and the credit opinion `Summary` (key segments/brands, scale). Include the latest\nfiscal-year revenue from the financials. Cite claims.\n\n```html\n<tr>\n  <td class=\"company-name\">Target Co</td>\n  <td>Headquartered in Dearborn, Michigan, Target Co is a global automaker with FY2025 revenue of\n  approximately $180B, anchored by its F-Series, SUV, and Pro commercial businesses.</td>\n</tr>\n```\n\n**2) Rating Summary** → `rating_cards_html`\n\nEmit exactly one `.rating-card` per company (target first, extra class `target-card`). Use only\nthe current (most recent) long-term issuer or senior unsecured rating and current outlook —\nnever loop over historical entries. Prefer Long-Term Issuer Rating; if absent, Senior Unsecured.\nThe rating cards are the sole representation of peer ratings in Section 1 (there is no separate\npeers-rating table).\n\n- `.rc-company` — abbreviated company name (≤ 25 chars; truncate with \"…\" if longer)\n- `.rc-rating` — Moody's rating symbol (e.g. `Baa2`), copied from `getEntityRatings`\n- `.rc-class` — rating class + most-recent rating date (e.g. `Senior Unsecured / 2024-05-09`)\n- `.outlook-badge` — canonical pastel classes only: `stable`, `positive`, `negative`, `review`, `na`\n\n```html\n<div class=\"rating-card target-card\">\n  <div class=\"rc-company\">Target Co</div>\n  <div class=\"rc-rating\">Baa2</div>\n  <div class=\"rc-class\">Senior Unsecured / 2024-05-09</div>\n  <span class=\"outlook-badge stable\">Stable</span>\n</div>\n```\n\n**3) Credit Drivers** → `cd_col_1`..`cd_col_4` and `cd_r{1-4}_c{1-4}` (4 rows × 4 company columns)\n\nWrite the 4 company header cells (`cd_col_1` = target, `cd_col_2`..`cd_col_4` = peers in order;\nempty strings for peer slots beyond what was resolved) and the 16 body cells:\n\n- Row 1 (Upgrade factors) — from `FactorsLeadingToUpgrade`\n- Row 2 (Downgrade factors) — from `FactorsLeadingToDowngrade`\n- Row 3 (Credit strengths, qualitative) — from `CreditStrengths`\n- Row 4 (Credit challenges, qualitative) — from `CreditChallenges`\n\nEach cell is a substantive paragraph with specific quantitative thresholds where available.\nQuantitative metrics are covered by the Key Indicators bar charts — the table has only 4 rows;\ndo not add a 5th row. If a credit opinion section is missing for a company, write\n`Not available` rather than leaving the cell blank.\n\n**4) Key Indicators — Peer Bar Charts** → `ki_charts_html` and `fi_charts_html`\n\nEmit five `.peer-bar-chart-outer` panels as `ki_charts_html`, and a single Revenue panel as\n`fi_charts_html` (it follows immediately with no separate sub-heading — the template already\nhandles this). The bar charts are the sole representation of key-indicator data. All panels use\nthe same markup so they look identical; the CSS classes in the template supply all colours, fonts\nand sizing — add no inline colours except as stated below.\n\n| Chart | Metric | Unit | Source | Note |\n|-------|--------|------|--------|------|\n| 1 | FCF Margin % | `%` | (OCF − \\|Capex\\|) / Revenue, from `getEntityFinancials_v2` | Higher = better |\n| 2 | Debt / EBITDA | `x` | `getEntityFinancials_v2` Key Indicators | Lower = better |\n| 3 | EBITDA Margin % | `%` | EBITDA / Revenue, from `getEntityFinancials_v2` | Higher = better |\n| 4 | EBITA / Interest | `x` | `getEntityFinancials_v2` Key Indicators | Higher = better |\n| 5 | RCF / Net Debt | `%` | `getEntityFinancials_v2` Key Indicators | Higher = better |\n\nPer KI panel:\n- Start the `ki_charts_html` block with one `<div class=\"ki-fy-header\">`, e.g.\n  `KEY INDICATORS — FY2025 | Company vs. Peers`; if entities have mixed fiscal years write\n  `KEY INDICATORS — Most Recent FY | Company vs. Peers`.\n- Inside each panel: `.pbc-title` (metric name in caps), `.pbc-subtitle` (unit + fiscal year, e.g.\n  `FY2025, % of revenue`), then a `<div class=\"pbc-legend\">` with four swatches via a CSS variable:\n  `<span style=\"--sw:#0066cc\">Target</span><span style=\"--sw:#6f9fd3\">Peers</span><span\n  style=\"--sw:#2e7d32\">Peer average</span><span style=\"--sw:#d9680f\">Peer median (line)</span>`.\n- One bar row per company: target first, then peers sorted by descending value, then the\n  average row last. Target bar `subj-pos` (or `subj-neg` if negative); peer bars `peer-pos` /\n  `peer-neg`; average `avg-bar` — the class goes on the `.pbc-fill` element.\n- Append the fiscal year to each company's `pbc-name` in parentheses, e.g. `Target Co (FY2025)`,\n  using the FY identified via `getEntityFinancials_v2` for that entity; put the full name in `title`.\n- Every row shows its numeric value in `.pbc-val` (class `pos`/`neg` for company rows, `avg-val`\n  for the average). Format: ratios to 1 decimal with `x` (e.g. `2.4x`), percentages to 1 decimal.\n- Median marker: `.pbc-median-line` with a `.pbc-median-tip` reading `Median {value}`, placed in\n  the **target row's track only** (not repeated on every row, to avoid clutter).\n- A closing `.pbc-note` line: peer median, peer average (n = number of peers), company value, gap.\n- **Bar width, positive-only charts:** `maxAbs` = max absolute value across company, peers and\n  average; `width = (value / maxAbs * 88).toFixed(1) + '%'`, `left:0`; median\n  `left = (median / maxAbs * 88).toFixed(1) + '%'`.\n- **Charts that can go negative (FCF margin; any other with a negative value):** add class\n  `zero-axis` to every `.pbc-track` in that panel; zero sits at 44%. Positive bars:\n  `left:44%; width=(v/maxAbs*44)%`. Negative bars: `left=(44-|v|/maxAbs*44)%;\n  width=(|v|/maxAbs*44)%`. Median `left = (44 + median/maxAbs*44)%`.\n- Compute peer average and median across resolved peers only (exclude the target). Omit the bar\n  row for a company whose value is missing and say so in the `.pbc-note`.\n\n```html\n<div class=\"ki-fy-header\">KEY INDICATORS — FY2025 | Company vs. Peers</div>\n<div class=\"peer-bar-chart-outer\">\n  <div class=\"pbc-title\">Debt / EBITDA</div>\n  <div class=\"pbc-subtitle\">FY2025, multiple (x) — lower is stronger</div>\n  <div class=\"pbc-legend\"><span style=\"--sw:#0066cc\">Target</span><span style=\"--sw:#6f9fd3\">Peers</span><span style=\"--sw:#2e7d32\">Peer average</span><span style=\"--sw:#d9680f\">Peer median (line)</span></div>\n  <div class=\"pbc-rows\">\n    <div class=\"pbc-row\">\n      <div class=\"pbc-name subject\" title=\"Target Co\">Target Co (FY2025)</div>\n      <div class=\"pbc-track\">\n        <div class=\"pbc-median-line\" style=\"left:52.3%\"><div class=\"pbc-median-tip\">Median 2.1x</div></div>\n        <div class=\"pbc-fill subj-pos\" style=\"left:0;width:61.0%\"></div>\n      </div>\n      <div class=\"pbc-val pos\">2.4x</div>\n    </div>\n    <!-- one row per resolved peer (sorted descending), then the average row last -->\n    <div class=\"pbc-row\" style=\"margin-top:4px;padding-top:8px;border-top:1px dashed #cbd5e1\">\n      <div class=\"pbc-name average\">Peer average</div>\n      <div class=\"pbc-track\"><div class=\"pbc-fill avg-bar\" style=\"left:0;width:50.7%\"></div></div>\n      <div class=\"pbc-val avg-val\">2.0x</div>\n    </div>\n  </div>\n  <div class=\"pbc-note\">Peer median 2.1x | Peer avg 2.0x (n=3). Company: 2.4x. Gap vs. median: +0.3x.</div>\n</div>\n<!-- repeat for FCF Margin %, EBITDA Margin %, EBITA/Interest, RCF/Net Debt (HTML comments are\n     shown here for illustration only — do not leave them in the final value) -->\n```\n\n**Revenue chart** (`fi_charts_html`; same panel markup, same FY header convention, no separate\nsub-heading, unit USD billions, values formatted `$12.3B`). Always include a Peer average row\n(peer mean, excluding the target) when at least one peer resolved. `maxRevenue` = max across all\nrows including the average and the median. **Include the peer-median line exactly like every Key\nIndicators chart**: a `.pbc-median-line` with a `.pbc-median-tip` reading `Median $X.XB` in the\ntarget row's track at `left = (median / maxRevenue * 88)%`, the `Peer median (line)` legend entry\n(`style=\"--sw:#d9680f\"`), and the median in the closing `.pbc-note`. Target bar `subj-pos`, peer\nbars `peer-pos`, average `avg-bar`, each class on the `.pbc-fill` element. If a revenue value is\nmissing show `N/A` and omit the bar. Do not add a Debt/EBITDA chart here — it is already in the\nKI charts.\n\n**5) Scorecards** → `sc_col_*` and `sc_r{1-6}_c{1-4}_{curr|fwd}` (6 rows × 4 companies × Current/Forward)\n\nWrite the 4 top-level company headers (`sc_col_1`..`sc_col_4`, target first) and the 8 sub-header\nlabels (`sc_col_{1-4}_curr`, `sc_col_{1-4}_fwd`).\n\n> **FY LABEL SYNCHRONY — STRICTLY ENFORCED (Sections 4 and 5):**\n> The label in `sc_col_{n}_curr` for a company MUST be identical to the FY label appended to\n> that company's bars in the Key Indicators charts — the most recent non-null full fiscal year\n> from `getEntityFinancials_v2` (with `excludeInterimData: true`), labelled `FY{YYYY}` (e.g.\n> `FY2025`). **Never use \"LTM\", \"TTM\", \"Current\", or any label other than the specific\n> `FY{YYYY}` form.** Each entity's label is set independently (e.g. a June year-end company\n> keeps its own FY). `sc_col_{n}_fwd` is simply `Forward`. All numbers in Section 4 and the\n> Scorecard Current cells must come from the same `FY{YYYY}` period. If entities have different\n> most-recent FYs, the KI header reads `KEY INDICATORS — Most Recent FY | Company vs. Peers`.\n> Check this synchrony before writing the file; mismatched labels are a hard failure.\n\n> **`~` (tilde) prefix rule — STRICT:** `~` (e.g. `~2.5x`) means approximately estimated /\n> forecast and must ONLY appear in **Forward** (`_fwd`) cells, never in **Current** (`_curr`)\n> cells. Current cells contain actual reported or Moody's-adjusted figures; use the precise\n> value as-is (e.g. `2.3x`, `14.8%`).\n\n> **Distorted EBITDA years.** If the most recent FY has a non-cash charge (e.g. goodwill\n> impairment) that makes Debt/EBITDA not meaningful, still use that year as the reference; show\n> the reported figure with a `†` marker (e.g. `N/M†`) and use the Moody's-adjusted ratio from the\n> credit opinion's Key Indicators exhibit or the scorecard factor value for the leverage cell\n> instead.\n\nWrite the 48 body cells for the 6 rows:\n- Row 1 — Scale: Revenue/Sales (USD bn)\n- Row 2 — Profitability: EBIT(A) margin\n- Row 3 — Leverage: Debt/EBITDA\n- Row 4 — Cash flow: RCF/Net debt\n- Row 5 — Coverage: EBIT(A)/Interest\n- Row 6 — Actual rating — from `getEntityRatings`, verbatim. The Current cell is the rating\n  symbol; the Forward cell is the current outlook (e.g. `Stable`). If `getEntityRatings` returns\n  no current Long-Term Rating or an obviously stale one, show what it returned with its date and\n  do not substitute a rating from credit-opinion prose. There is no \"Scorecard-indicated\n  outcome\" row.\n\nRows 1–5 — **every resolved company's cells must show a value, never blank and never a bare\n\"N/A\" when any source has the number.** Fill in this order and stop at the first source that has it:\n1. **Current:** the Moody's-adjusted ratio for the latest fiscal year from `getEntityFinancials_v2`\n   (`reportingBasis: \"adjusted\"` when needed), then the same metric from `getEntityScorecardV2`\n   (`factors`/subfactor values), then the credit opinion `KeyIndicatorsTable` / `RatingFactors`\n   column for that FY. Compute margins/ratios yourself from reported statement lines if no\n   adjusted figure exists, and mark them `(rep.)`.\n2. **Forward:** the first projected column (or projected range) in the credit opinion\n   `KeyIndicatorsTable`; else the forward values quoted in `RatingFactors` / `Summary`; else the\n   forward scorecard value from `getEntityScorecardV2`. Format projections with a leading `~`.\n3. If an entity's latest opinion is older than 12 months or a forward column is genuinely absent,\n   re-call `getCreditOpinion` for that entity with a `publishDate` range covering the last 3 years\n   (`mode: \"range\"`, `from` and `to` both set) and use the newest opinion that has a projection,\n   adding `(as of {Mon YYYY})` to the cell.\n4. Only if every source above is exhausted, write `—` (an em dash). Never write \"N/A\", leave a\n   cell blank, or invent a projection; the template's footnote explains the dash.\n\nIf fewer than 3 peers resolved, leave the unused column cells empty — do not collapse the table.\n\n**6) Conclusion** → `conclusion_html`\n\nWrite this last, from the findings you have already produced for the financials, ratings, ESG and\nPD sections — differentiate the target among its peers; do not re-derive data. Three `<p>`\nparagraphs, oriented around the target company's differentiation:\n\n- Paragraph 1: how the target differentiates positively vs. weaker peers on quantitative\n  metrics (leverage, coverage, cash flow) — cite specific ratios.\n- Paragraph 2: business risk profile comparison — where the target is more concentrated or less\n  diversified vs. stable peers, referencing upgrade/downgrade triggers.\n- Paragraph 3: practical positioning — frame the target's \"path to stand out\" by linking back to\n  the upgrade/downgrade framework and key risk factors.\n\nAt most one citation per sentence. Cite only records you actually received from a tool result;\nnever add a generic \"Moody's Ratings result\" source.\n\n### Section 2 — Ratings Chart (± Probability of Default)\n\n> **SECTION 2 TITLE RULE — STRICTLY ENFORCED:**\n> The template reads `Section 2. Ratings Chart{{ section2_suffix }}` in both the TOC label and\n> the section heading. Set `section2_suffix` to:\n> - `\" & Probability of Default\"` if PD data is available (a real banner + chart + table is\n>   written into the PD panel)\n> - `\"\"` (empty string) if PD data is unavailable after the retry\n>\n> Keep this consistent with what the PD panel actually contains — never append\n> \"& Probability of Default\" if the panel only has the unavailable placeholder.\n\nSection 2 order: Ratings Chart → PD panel → Ratings analysis.\n\n**Chart** → `ratings_chart_html`\n\nEmit a single `<div class=\"chart-container\">…<svg>…</svg>…</div>` block, built the same way\nevery run — this is the only chart spec, do not improvise. It plots the last 5 rating actions per\ncompany as a line chart, most-recent point highlighted, x-axis labelled with actual rating dates.\n\n**Fixed constants (always use these exact numbers):**\n- `viewBox=\"0 0 780 440\"`, plot area `x: 90→740` (650px wide), `y: 50→350` (300px tall); the SVG\n  has `width=\"100%\"` and no fixed height so it scales with the page.\n- `maxPts` = the largest number of rating actions any company has, capped at 5\n- Palette (target first, colour-blind-safe and legible on white): `#0066cc`, `#d9680f`, `#1a7a4a`,\n  `#7c3aed`. Give each peer line a distinct dash pattern (`stroke-dasharray=\"6 4\"` on peers) only\n  if two lines overlap; the target line is always solid and drawn last (on top).\n- `xPos(i) = 90 + (i / (maxPts - 1)) * 650` (if `maxPts` is 1, centre at x=415)\n\n**Rating → numeric value** (higher = better), index 0 = `C` (value 1) … index 20 = `Aaa`\n(value 21):\n`[\"C\",\"Ca\",\"Caa3\",\"Caa2\",\"Caa1\",\"B3\",\"B2\",\"B1\",\"Ba3\",\"Ba2\",\"Ba1\",\"Baa3\",\"Baa2\",\"Baa1\",\"A3\",\"A2\",\"A1\",\"Aa3\",\"Aa2\",\"Aa1\",\"Aaa\"]`\n\n**Y-axis range:** `minV = clamp(min(all values) - 1, 1, 21)`, `maxV = clamp(max(all values) + 1,\n1, 21)` (if equal, `maxV = minV + 1`). One gridline + label per whole-number tier from `minV` to\n`maxV`. `yPos(v) = 50 + 300 - ((v - minV) / (maxV - minV)) * 300`.\n\n**Drawing rules:**\n- Gridlines `stroke=\"#e5e7eb\"`; y-axis tier labels `font-size=\"12\" fill=\"#475569\"\n  text-anchor=\"end\"` at `x=\"82\"`, vertically centred on the gridline (`y = yPos + 4`). Rotated\n  y-axis title \"Moody's rating\" (`font-size=\"11\" fill=\"#64748b\"`, `transform=\"rotate(-90 20 200)\"`\n  at `x=\"20\" y=\"200\"`).\n- X-axis baseline `stroke=\"#334155\" stroke-width=\"1.5\"` at `y=\"350\"`; date labels (`MMM YYYY`)\n  `font-size=\"11\" fill=\"#475569\" text-anchor=\"middle\"` at `y=\"372\"`; x-axis title \"Rating action\n  date (oldest to most recent)\" `font-size=\"11\" fill=\"#64748b\"` centred at `x=\"415\" y=\"410\"`.\n- Lines: `stroke-width=\"2.5\" stroke-linejoin=\"round\" stroke-linecap=\"round\"`.\n- Regular points: `<circle r=\"5\">` in company colour with a white 1.5px stroke. Most-recent point\n  (rightmost): `<circle r=\"8\">` in company colour with a white `<circle r=\"4\" fill=\"white\"/>`\n  stacked on top, plus `<title>{company} · {rating symbol} · {date}</title>`.\n- Value labels beside each point: rating symbol, `font-size=\"11\" font-weight=\"700\"`, company\n  colour, with a white halo (`paint-order=\"stroke\" stroke=\"#fff\" stroke-width=\"3\"`). Place the\n  target's labels above (`dy=\"-12\"`) and each peer's below (`dy=\"20\"`) so overlapping series stay\n  readable. If two points in the same series sit within 40px of each other horizontally, label\n  only the leftmost; always label the most recent point.\n- Legend below the SVG (`.chart-legend`) with each company's current rating in parens, e.g.\n  `Target Co (Baa1)`, target first.\n- Clean markup only: no scratch arithmetic, no HTML comments left in the final value.\n\n```html\n<div class=\"chart-container\">\n  <div class=\"chart-title\">Moody's Long-Term Rating History — Last 5 Actions</div>\n  <div class=\"chart-subtitle\">Higher on the axis = stronger credit quality; most recent action marked with a ringed point</div>\n  <svg viewBox=\"0 0 780 440\" width=\"100%\" preserveAspectRatio=\"xMidYMid meet\">\n    <line x1=\"90\" y1=\"50\" x2=\"740\" y2=\"50\" stroke=\"#e5e7eb\" stroke-width=\"1\"/>\n    <text x=\"82\" y=\"54\" text-anchor=\"end\" font-size=\"12\" fill=\"#475569\">Baa1</text>\n    <!-- one gridline + label per tier from minV to maxV -->\n    <line x1=\"90\" y1=\"350\" x2=\"740\" y2=\"350\" stroke=\"#334155\" stroke-width=\"1.5\"/>\n    <text x=\"90\" y=\"372\" text-anchor=\"middle\" font-size=\"11\" fill=\"#475569\">Jan 2021</text>\n    <!-- one date label per x position, then the axis titles -->\n    <path d=\"M90,202 L252,202 L415,148 L577,148 L740,148\" fill=\"none\" stroke=\"#0066cc\"\n          stroke-width=\"2.5\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/>\n    <circle cx=\"90\" cy=\"202\" r=\"5\" fill=\"#0066cc\" stroke=\"#fff\" stroke-width=\"1.5\"/>\n    <text x=\"90\" y=\"190\" text-anchor=\"middle\" font-size=\"11\" font-weight=\"700\" fill=\"#0066cc\" paint-order=\"stroke\" stroke=\"#fff\" stroke-width=\"3\">Baa2</text>\n    <circle cx=\"740\" cy=\"148\" r=\"8\" fill=\"#0066cc\"/>\n    <circle cx=\"740\" cy=\"148\" r=\"4\" fill=\"white\"/>\n    <title>Target Co · Baa1 · Mar 2025</title>\n    <!-- repeat path + circles for each peer with palette[1..3] -->\n  </svg>\n  <div class=\"chart-legend\">\n    <div class=\"chart-legend-item\"><span class=\"chart-legend-swatch\" style=\"background:#0066cc\"></span>Target Co (Baa1)</div>\n    <!-- one legend item per company -->\n  </div>\n  <div class=\"chart-source\">Source: Moody's Long-Term Ratings</div>\n</div>\n```\n\nFor companies with fewer than 5 historical ratings, either repeat the oldest available value to\nfill trailing points, or reduce `maxPts` to the largest available count and drop the\ncorresponding x-axis labels. Compute coordinates once, silently — do not leave scratch arithmetic\nor alternative options as HTML comments in the output (the comments in the snippet above are\nillustrative only).\n\n**PD panel** → `pd_panel_html`\n\nAlways write something into the PD panel — it is never silently empty.\n\nCompute the peer average (1-year PD, 5-year cumulative PD) as the arithmetic mean across resolved\npeers only (exclude the target). Map the average PD to a PD-implied rating the same way as for\nindividual companies. Always label the implied rating \"PD-implied rating\", never as a Moody's\nrating.\n\nDetermine the PD signal:\n- `red` — target 1-year PD is >2× peer average\n- `amber` — target 1-year PD is 1.25–2× peer average\n- `green` — target 1-year PD is ≤1.25× peer average\n\n**If PD is still unavailable after the retry**, set `pd_panel_html` to:\n\n```html\n<div class=\"pd-unavailable\">Probability of Default data was unavailable for this run.</div>\n```\n\nand set `section2_suffix` to an empty string.\n\n**When PD data is available**, write, in this order:\n\n1. **Signal banner** (`.pd-banner`, modifier matches the signal): `PD Signal: {SIGNAL} —\n   {Target}'s 1-year PD ({x}%) is {n}× the peer average ({y}%), {range description}.` followed by\n   one sentence of context. No emoji or icon characters — the colour modifier carries the signal.\n\n2. **1-year PD bar chart** (immediately after the banner, before the table): one\n   `.peer-bar-chart-outer` panel reusing the Key Indicators bar markup exactly. Use only the\n   template's existing classes (`pbc-title`, `pbc-subtitle`, `pbc-legend`, `pbc-rows`, `pbc-row`,\n   `pbc-name`, `pbc-track`, `pbc-fill`, `pbc-val`, `pbc-note`, plus `pbc-scale-note`, `pbc-axis`,\n   `grid`) — never invent new class names or inline swatch styles.\n   - `.pbc-title` \"1-Year Probability of Default\"; `.pbc-subtitle` \"Moody's EDF, % — lower is\n     stronger\".\n   - `.pbc-legend`: `<span style=\"--sw:#0066cc\">Target</span><span style=\"--sw:#6f9fd3\">Peers</span><span\n     style=\"--sw:#2e7d32\">Peer average</span>` (same markup as the Key Indicators legend, no median\n     entry).\n   - **Log scale (required).** PDs across a peer set routinely differ by 50x or more, so a linear\n     scale makes the investment-grade peers' bars invisible slivers. Size every bar on a\n     logarithmic scale: `lo = 10^floor(log10(min value))`, `hi = 10^ceil(log10(max value))` (across\n     all rows including the average),\n     `width = (6 + 82 * (log10(v) - log10(lo)) / (log10(hi) - log10(lo))).toFixed(1) + '%'` — so\n     the smallest bar is still at least 6% wide and the largest at most 88%. Add class `grid` to\n     every `.pbc-track` (it draws quarter-way gridlines), and directly under the rows add a\n     `<div class=\"pbc-axis\"><span class=\"pbc-axis-spacer\"></span><span class=\"pbc-axis-ticks\"><span>{lo}%</span>\n     <span>{mid1}%</span><span>{mid2}%</span><span>{hi}%</span></span><span class=\"pbc-axis-end\"></span></div>`\n     whose tick labels are the PD values at 0, 1/3, 2/3 and 100% of the log range (format with up\n     to 3 significant figures). Then `<div class=\"pbc-scale-note\">Logarithmic scale — bar length\n     is not proportional to PD.</div>` right under the subtitle.\n   - **The colour class goes on the `.pbc-fill` element itself** (never only on the row), exactly\n     as in the Key Indicators charts: `<div class=\"pbc-track grid\"><div class=\"pbc-fill subj-pos\"\n     style=\"left:0;width:50.9%\"></div></div>` for the target, `pbc-fill peer-pos` for peers,\n     `pbc-fill avg-bar` for the average. A fill with no colour class and no width renders as an\n     empty track, so every row must have both.\n   - Rows: target first (`subj-pos`), peers sorted by descending PD (`peer-pos`), then a\n     dashed-border `Peer average` row (`avg-bar`). `.pbc-name` carries the company's short name;\n     `.pbc-val` shows the 1-year PD with 3 significant figures and a `%` sign (e.g. `0.0084%`),\n     class `pos` on the target's value. Do not show a median line.\n   - `.pbc-note`: one sentence stating the target's PD as a multiple of the peer average and\n     which peer is highest/lowest.\n\n3. **Table** (`.pd-table`) — columns: Company | 1-Year PD (%) | 5-Year Cumulative PD (%) |\n   PD-Implied Rating | Moody's Rating. Target row first (`.pd-row-target`, name tagged\n   `<span class=\"pd-target-tag\">(TARGET)</span>`), then peers, then a final `.pd-row-avg` row\n   labelled `Peer Average (ex-{Target})` (Moody's Rating column shows `—` for the average row).\n   The Moody's Rating column is copied verbatim from `getEntityRatings`; never re-derive it from\n   PD data or any other source.\n\n```html\n<div class=\"pd-banner amber\">\n  <div><strong>PD Signal: AMBER</strong> — Target Co's 1-year PD (0.0234%) is 1.87× the peer\n  average (0.0125%), within the 1.25–2.0× amber range. Elevated relative to peers but consistent\n  with a strong investment-grade entity carrying elevated near-term capex.</div>\n</div>\n<!-- 1-year PD bar chart panel here -->\n<div class=\"chart-source\">PD-implied ratings are model-implied and are not Moody's ratings.</div>\n<table class=\"pd-table\">\n  <thead>\n    <tr><th>Company</th><th>1-Year PD (%)</th><th>5-Year Cumulative PD (%)</th><th>PD-Implied Rating</th><th>Moody's Rating</th></tr>\n  </thead>\n  <tbody>\n    <tr class=\"pd-row-target\">\n      <td class=\"company-name\">Target Co <span class=\"pd-target-tag\">(TARGET)</span></td>\n      <td>0.0234%</td><td>0.4009%</td><td>Aa1</td><td>A1</td>\n    </tr>\n    <tr><td class=\"company-name\">Peer A</td><td>0.0176%</td><td>0.2807%</td><td>Aaa</td><td>Aa2</td></tr>\n    <!-- one row per resolved peer -->\n    <tr class=\"pd-row-avg\">\n      <td>Peer Average (ex-Target Co)</td><td>0.0125%</td><td>0.2222%</td><td>Aaa</td><td>—</td>\n    </tr>\n  </tbody>\n</table>\n```\n\n**Analysis** → `ratings_analysis_html`\n\nOne `<p>` paragraph on rating trajectories — which companies show improvement, deterioration, or\nstability, and what that implies for relative credit positioning.\n\n### Section 3 — ESG Heatmap & Analysis\n\n**ESG heatmap** → `esg_heatmap_html`\n\nA colour-coded HTML table — the only ESG data table (there is no separate plain ESG table).\nFive columns: company name, Overall (CIS-*), Environmental (E-*), Social (S-*), Governance (G-*).\nLabel scores precisely: CIS = Credit Impact Score, E/S/G = Issuer Profile Scores. Apply a CSS\nclass to each score `<td>` based on numeric severity (lower = better): `esg-s1` (green, minimal\nrisk) … `esg-s5` (red, very high risk) — parse the numeric suffix from the score string (e.g.\n`CIS-3` → 3). If a company returns no ESG data, or a score is `N/A` or missing, show `N/A` and\nomit the colour class.\n\n```html\n<table class=\"esg-heatmap\">\n  <thead>\n    <tr><th>Company</th><th>CIS (Overall)</th><th>E Score</th><th>S Score</th><th>G Score</th></tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td>Target Co</td>\n      <td class=\"esg-s3\">CIS-3</td><td class=\"esg-s4\">E-4</td><td class=\"esg-s3\">S-3</td><td class=\"esg-s2\">G-2</td>\n    </tr>\n    <!-- one row per company, target first, same order as all other tables -->\n  </tbody>\n</table>\n<div class=\"esg-legend\">\n  <span><i style=\"background:#bbf7d0\"></i>1 Positive / minimal</span>\n  <span><i style=\"background:#d9f99d\"></i>2 Low</span>\n  <span><i style=\"background:#fde68a\"></i>3 Moderate</span>\n  <span><i style=\"background:#fdba74\"></i>4 High</span>\n  <span><i style=\"background:#fca5a5\"></i>5 Very high</span>\n</div>\n```\n\nAlways include the legend after the table. Wrap nothing else around it; the `esg-heatmap` class\n(already styled in the template) supplies fixed column widths, cell spacing and colours. Use the\ncompany's short name in the first cell (full name in `title`).\n\n**Analysis** → `esg_analysis_html`\n\nTwo `<p>` paragraphs:\n- Paragraph 1: compare ESG profiles across the peer set — which companies share similar\n  profiles and what drives the overall classification.\n- Paragraph 2: highlight the key differentiator (typically Governance) and explain which company\n  stands out as weaker/stronger and why.\n\n### Citations & Sources\n\nThe report carries **one consolidated, de-duplicated, continuously numbered Sources list** at the\nvery end, covering Sections 1–3 (there are no per-section citation recaps). Attribute\nsubstantive claims inline with numbered references:\n\n- **Inline reference:** `<a class=\"cite-ref\" href=\"{source URL}\" target=\"_blank\">[n]</a>`\n  immediately after the claim (the `cite-ref` class is styled in the template). If the tool\n  result gives no URL for the source, use `<span class=\"cite-ref\">[n]</span>` instead.\n- **Numbering:** assign `n` in order of first appearance across the finished document\n  (top-to-bottom: Section 1 → 3), one number per distinct source; reuse the same `n` whenever\n  the same source is cited again.\n- **Sources list:** fill the template's `#sources-footer` container (the template comment says it\n  is platform-filled; in this skill you fill it yourself) with one list matching the inline\n  numbers:\n  ```html\n  <aside class=\"citations\"><ol>\n    <li>{Document or record title} — Moody's, {date}</li>\n    <!-- one <li> per source, in [1], [2], … order -->\n  </ol></aside>\n  ```\n  Internal MCP tool names (e.g. `getCreditOpinion`) are NEVER rendered in the Sources list.\n- **Citation hygiene** (keep the list tidy):\n  - Cite each source once per paragraph or table row rather than after every figure; in the\n    Scorecard cite once per company column (on its Current cell) instead of on every cell.\n  - Cite the credit opinion document for qualitative statements and the financials record for\n    ratios.\n  - Cite each company's rating record once per rating card and once in the ratings analysis\n    paragraph — not on chart points, labels or legend items (the chart carries one uncited\n    \"Source\" line instead).\n  - Cite each company's ESG record once in the analysis paragraphs; do not cite individual\n    heatmap cells.\n  - Cite each company's PD record once, in the banner sentence; do not cite chart bars or table\n    cells, and do not cite rating records there.\n  - Never cite a record you did not receive from a tool result in this run. If you cannot cite a\n    fact precisely, leave it uncited — an uncited sentence is fine; a fake citation is not.\n  - Never cite a \"no data found\" statement unless a tool result actually returned a record\n    marked as no data for that lookup.\n\n### Class-selection rules\n\n**`.outlook-badge`** modifier (inside rating cards):\n\n- `stable` — outlook is \"Stable\"\n- `positive` — outlook is \"Positive\"\n- `negative` — outlook is \"Negative\"\n- `review` — outlook contains \"Review\" (e.g., \"Rating Under Review\")\n- `na` — outlook is missing or unknown\n\n**`.company-chip.target`** applies only to the target (first) chip. Remaining chips use plain\n`.company-chip`.\n\n### Conventions\n\n- Use `<p>` for paragraphs, `<ul><li>` for bullets, `<strong class=\"subsection-title\">…</strong>`\n  for bold subheaders inside prose containers.\n- Do NOT include overall section titles inside the filled values — the template already has them.\n- `rating` values: use Moody's rating symbol (e.g. `Aaa`, `Aa1`, `Baa2`, `Ba1`). If not found,\n  use `N/A`.\n- `outlook` values: `Stable`, `Positive`, `Negative`, `Rating Under Review`, or `N/A`.\n- Charts use the template's own CSS classes and inline SVG (no external chart library); colours,\n  fonts and sizing come from the template so all panels look identical. No emoji or icon glyphs\n  in any generated content.\n\n---\n\n## Guardrails (apply across the whole workflow)\n\n- **Never fabricate** rating values, outlooks, dates, financial figures, or rationale text. Every\n  rating traces back to `getEntityRatings`; every financial figure to `getEntityFinancials_v2`,\n  `getEntityScorecardV2` or the credit opinion's exhibits.\n- **The target company always appears first** — first column/row in every table and comparison.\n- If fewer than 3 peers are resolved, leave the unused column/row slots empty — do not pad with\n  invented peers, and do not collapse or restructure the pre-shaped tables.\n- If a Credit Opinion section is missing for a company, write `Not available` rather than\n  leaving the cell blank.\n- Rating consistency across sections is structural, not a final-pass check: every section that\n  shows a company's current rating takes it from the same `getEntityRatings` result, so one\n  ground-truth source feeds the Rating Cards, Ratings Chart, Scorecard \"Actual rating\" row and PD\n  table.\n\n## Tips\n\n- Run ALL data-gathering tool calls in a single parallel batch (one message, many tool calls).\n- Write the final HTML to disk as a single `.html` file and deliver it via `present_files` — do\n  not print the HTML source in the chat, do not split across multiple files.\n- The conclusion must orient around the target company — how it differentiates from its peers.\n- Before writing the file, check: no `{{ ... }}` token left; FY labels in the KI charts match the\n  Scorecard sub-headers; the Section 2 title matches the PD panel; the Scorecard has exactly 6\n  body rows; the Actual rating row matches the Rating Cards for every company; the Sources list\n  numbers match the inline references.\n\n---\n\n## Step 6 — Save and deliver the report as a downloadable file\n\nAfter assembling the complete HTML string, **write it to disk as a standalone `.html` file** and\nmake it available for the user to download. Do **not** print the raw HTML in the chat.\n\n### File naming\n\nUse the pattern: `{target_company_slug}_peer_analysis.html`\n\nWhere `{target_company_slug}` is the target company's canonical name lowercased, spaces and\nspecial characters replaced with underscores (e.g. `apple_inc_peer_analysis.html`).\n\n### Delivery\n\nAfter writing the file, use whatever file-presentation capability is available in the current\nenvironment to surface the file to the user so they can open or download it. Do not describe\nthe tool being used — just invoke it. Then add one short confirmation sentence, for example:\n`The peer analysis report for [Target Company] is ready to download above.`\n\nDo **not** print the HTML source in the chat. Do **not** emit a fenced ` ```html ` code block.\nThe saved file is the sole deliverable.\n"
Full snapshot data
{
  "description": "Helps credit analysts and investors see how a company compares with its closest peers. It resolves the target and up to three peers, then compares their credit ratings and rating drivers, key financial and credit metrics, probability of default and ESG profiles, and concludes on the target's relative credit positioning. Peers can be chosen by the user or discovered automatically.\n",
  "included_files": [
    {
      "relative_path": "agents/openai.yaml",
      "size_in_bytes": 573
    },
    {
      "relative_path": "assets/icon.png",
      "size_in_bytes": 1753
    },
    {
      "relative_path": "assets/template.html",
      "size_in_bytes": 24588
    },
    {
      "relative_path": "evals/evals.json",
      "size_in_bytes": 3506
    }
  ],
  "name": "peer-analysis",
  "skill_md_contents": "---\nname: peer-analysis\ndescription: >\n  Helps credit analysts and investors see how a company compares with its closest peers. It resolves the target and up to three peers, then compares their credit ratings and rating drivers, key financial and credit metrics, probability of default and ESG profiles, and concludes on the target's relative credit positioning. Peers can be chosen by the user or discovered automatically.\n---\n\n# Peer Analysis Skill\n\nGenerates a professional HTML report (styled like a Moody's peer analysis PDF) for a target\ncompany and up to 3 credit peers. Data is pulled from multiple Moody's MCP tools and\nconsolidated into a single HTML artifact covering peers comparison, ratings chart, PD, and ESG.\n\nThe workflow is **single-artifact file delivery**: gather all data, fill the complete HTML\ndocument, write it to disk as a standalone `.html` file, and present it to the user for\ndownload. No fenced code blocks, no streaming partial sections, no JSON payload, no progressive\nedits. The downloaded file is the sole deliverable.\n\n> ## ⚠️ CRITICAL — NON-NEGOTIABLE OUTPUT CONTRACT\n>\n> **The LLM MUST write the final report to disk and present it as a downloadable file.**\n> This is the only acceptable form of delivery for this skill. Specifically:\n>\n> - The LLM **MUST** write the complete, standalone HTML document (`<!doctype html>` → `</html>`)\n>   to `/mnt/user-data/outputs/{target_company_slug}_peer_analysis.html` and then call\n>   `present_files` to surface it to the user.\n> - The LLM **MUST NOT** print the raw HTML source in the chat — no ` ```html ` fenced code\n>   blocks, no partial snippets, no inline HTML in the assistant message.\n> - The LLM **MUST NOT** split the report across multiple files or multiple messages.\n> - The LLM **MUST NOT** substitute prose, Markdown, JSON, or links for the file download.\n> - The delivered file **MUST NOT** contain any unfilled `{{ placeholder }}` token.\n> - If data gathering fails partially, still write and deliver the file with best-available\n>   content and `Not available` / `—` placeholders (as specified per section below) for missing\n>   cells — never skip the file delivery.\n>\n> Treat any other output shape as a hard failure of the skill.\n\n## Parameters\n\n| Pattern | Type | Required | Notes |\n|---|---|---|---|\n| Company Name | Company | Yes | The target company. The user may also name the peers they want compared; if they do, use those peers. If they do not, peers are discovered automatically in Step 2. |\n\n## Required MCP server\n\n`moodys_mcp` — tools used: `findEntity`, `getEntityPeers`, `getEntityProfile`, `getEntityRatings`,\n`getCreditOpinion` (sections: Summary, FactorsLeadingToUpgrade, FactorsLeadingToDowngrade,\nCreditStrengths, CreditChallenges, KeyIndicatorsTable, RatingFactors), `getEntityScorecardV2`,\n`getEntityFinancials_v2`, `getEntityEsg`, `getEntityProbabilityOfDefault`\n\nIf any of the tools required for a section are not available under the current subscription,\ninform the user: \"One or more tools required for this section are not available under your\ncurrent subscription. Unlock more of the expert insights, data, and analytics you trust. Get\nLink:https://www.moodys.com/web/en/us/capabilities/gen-ai/ai-ready-data.html with us to learn\nmore.\"\n\n## Bundled files\n\n- `assets/template.html` — self-contained report shell (all CSS inline, no external dependencies)\n  with `{{ placeholder }}` tokens for every value that varies per run, including pre-shaped tables\n  for a fixed target + 3-peer layout. Treat this file as the **structural reference**: read it\n  once, replace every `{{ token }}` with its value (token map below), and emit the complete\n  filled document. Keep its `<head>`/CSS, section order, table skeletons, row labels and CSS\n  class names exactly as shipped.\n- `evals/evals.json` — test prompts and assertions for this skill.\n\n---\n\n## CRITICAL: Decide how to respond before doing anything\n\n**Check the conversation history before doing anything else.**\n\n**If a report has already been generated in this conversation:**\n- **Follow-on question** → read the relevant section of the delivered `.html` file and answer\n  directly. Do NOT re-run the data gathering.\n- **Regeneration request** (e.g. \"regenerate\", \"update\", \"redo\") → ask: \"Would you like me to\n  regenerate the full report, or just a specific section?\" and wait before doing anything.\n\n**If no report has been generated yet** → run the full workflow below.\n\n---\n\n## Step 1 — Resolve the target company\n\nCall `findEntity` **once** with the company name provided by the user (and, if the user named\ntheir own peers, include those peer names in the same request — `findEntity` is called once per\nrequest, not once per company). Keep the canonical entity name and `entityId` for each company.\n\nIf the user provides only one company name, that is the **target company**. The peers will be\ndiscovered automatically in Step 2.\n\n**Canonical names, not raw record titles.** Resolve each company to the name a reader would\nrecognize and use that name everywhere in the report (cover, tables, charts, prose).\n\nIf a tool errors, treat the error as the result, retry once, and continue with what you have.\n\n---\n\n## Step 2 — Discover and resolve peers\n\nIf the user did not name peers, call `getEntityPeers` for the target with `maxPeersPerEntity: 3`\nand take the peers returned (analyst-defined peers first).\n\nYou now have a set of up to **4 companies** (1 target + up to 3 peers). The records returned by\n`getEntityPeers` already carry entity IDs; only call `findEntity` again for a peer that arrives\nwithout one, and fold all such names into a single call. Never rebuild an ID from a company name.\n\nIf fewer than 3 peers are returned, proceed with however many were found — never invent a peer to\nfill the set.\n\n---\n\n## Step 3 — Read the template\n\nRead `assets/template.html` (relative to this skill directory) once. Keep its exact structure —\nCSS, `<head>`, section order, table skeletons (including all pre-shaped 4-company columns/rows),\nrow labels, and class names — as the scaffold for the final artifact. Only the `{{ token }}`\nplaceholders are replaced.\n\n---\n\n## Step 4 — Gather all data in parallel\n\nFor every company in the set (target + up to 3 peers), fire **all of the following in a single\nparallel batch** (one message, many tool calls) — do not wait for one tool's results before\nrequesting the next. Use the `entityId` values from Steps 1–2 exactly as resolved.\n\n**`getEntityProfile`** — one call with all companies in `entities`. Use the legal name,\nheadquarters/registered address, business description, NAICS/NACE classification and employee\ncount for the Peers table.\n\n**`getCreditOpinion`** — one call with all companies in `entities`, `sections`:\n`Summary`, `FactorsLeadingToUpgrade`, `FactorsLeadingToDowngrade`, `CreditStrengths`,\n`CreditChallenges`, `KeyIndicatorsTable`, `RatingFactors`. Leave `publishDate` at its default\n(latest opinion).\n\n| Section parameter | Purpose |\n|---|---|\n| `Summary` | Key segments/brands and scale for the Peers Table description; forward values for the Scorecard |\n| `FactorsLeadingToUpgrade` | Upgrade factors for Credit Drivers |\n| `FactorsLeadingToDowngrade` | Downgrade factors for Credit Drivers |\n| `CreditStrengths` | Credit strengths for Credit Drivers |\n| `CreditChallenges` | Credit challenges for Credit Drivers |\n| `KeyIndicatorsTable` | Moody's-adjusted and projected metrics (Scorecard fallback / Forward column) |\n| `RatingFactors` | Scorecard factor values and forward values (Scorecard fallback) |\n\n**`getEntityScorecardV2`** — one call per company (the tool takes a single `entityId`), retrieval\nmode (no `methodology`, no `overrides`). This is the structured source for the Moody's scorecard\nfactor values and the methodology used. It works for unrated entities too.\n\n**`getEntityFinancials_v2`** — one call with all companies in `entities`, `filterCriteria`:\n`{ \"excludeInterimData\": true, \"sections\": [\"key_indicators\", \"income_statement\", \"cash_flow_statement\", \"balance_sheet\"] }`.\n\n> **CRITICAL — `getEntityFinancials_v2` is the authoritative source for all quantitative data.**\n> Do NOT rely solely on the Key Indicators or Scorecard exhibits embedded in `getCreditOpinion` —\n> those may reference an older period. After fetching financials, identify each entity's latest\n> year with a non-null Revenue value and use that year exclusively for the Key Indicators charts,\n> the Scorecard \"Current\" column, and the Revenue chart. **LTM figures are not permitted.**\n> Convert all monetary values to USD billions for display (request `currencies: [\"USD\"]` and\n> `scale: \"billions\"` if the entity's reporting currency differs).\n\n**`getEntityRatings`** — one call with all companies in `entities` and `years: 10` — retrieve the\ncurrent long-term rating, rating class, rating date, outlook, and at least the last 5 historical\nrating actions (needed for the Ratings Chart).\n\n> **`getEntityRatings` is the single, exclusive source of truth for every Moody's rating symbol\n> that appears anywhere in the final document** — Rating Cards, the Ratings Chart, the\n> Scorecard's \"Actual rating\" row, and the PD table's \"Moody's Rating\" column. Never derive,\n> infer, or back into a rating symbol from a scorecard-indicated outcome, a notching assumption,\n> or a credit opinion's narrative prose (which can mention a rating in passing that is stale or\n> inconsistent). If `getEntityRatings` and any other source disagree, `getEntityRatings` wins.\n> Never alter, round, or relabel a rating symbol to make a chart look cleaner — if a rating\n> needs repositioning on an axis, adjust the axis, never the symbol.\n\n**`getEntityEsg`** — one call with all companies in `entities` — overall CIS classification plus\nE, S, G issuer profile sub-scores (IPS), and the analyst comments.\n\n**`getEntityProbabilityOfDefault`** — one call with target + every resolved peer in `entities` —\nretrieve current 1-year PD (%), 5-year cumulative PD (%), and PD-implied rating. The history\nwindow can stay at its default; only current values are shown. **If the call returns an error or\nempty data, retry once** before treating PD as unavailable — the tool is prone to transient\nfailures and a second attempt frequently succeeds.\n\nIf any tool errors or returns nothing for a company, treat the error text as the result, retry\nthat call once, and then mark the affected cells `Not available` / `—` as specified below —\nnever fill them from memory.\n\nCompute quantitative values (ratios, margins, averages, medians) silently; do not narrate the\narithmetic — write only the final numbers into the output.\n\nHold all results in context for Step 5 synthesis.\n\n---\n\n## Step 5 — Synthesize + emit the complete artifact\n\nAfter data is gathered, replace every `{{ token }}` in the template (token map below) and write\nthe complete document to disk, then present it to the user (see Step 6 for the file-naming and\ndelivery contract).\n\nThe assembled document **must**:\n\n- Be a complete, standalone HTML document (doctype → `</html>`) that renders without external\n  dependencies.\n- Preserve the template's `<head>` (CSS), section order, table skeletons, row labels and class\n  names exactly. Only the `{{ token }}` placeholders are replaced.\n- Contain no leftover `{{ ... }}` token. Tokens for unused peer slots are replaced with an empty\n  string.\n\nWrite in professional financial/credit analysis language. Always reference specific companies by\nname. The target company is **always the first column / first row** in every table and\ncomparison. Pass HTML values as-is (valid markup, no scratch arithmetic, no HTML comments left\nin the final value).\n\n### Placeholder map\n\n| Placeholder token(s) | Content type |\n|---|---|\n| `report_date` (used on the cover and in the footer) | Plain text, `Month D, YYYY`, today's date |\n| `target_company` | Plain text (canonical target name) |\n| `peer_count` | Plain text integer — count of peers actually resolved |\n| `company_chips_html` | `<span class=\"company-chip target\">` for the target, then one `<span class=\"company-chip\">` per resolved peer |\n| `peers_table_html` | `<tr>` rows (company name + description) with inline citations |\n| `rating_cards_html` | One `.rating-card` per company (target first) |\n| `cd_col_1` … `cd_col_4` | Plain text (company names; empty string for unresolved peer slots) |\n| `cd_r{1..4}_c{1..4}` | Prose cell content (short `<p>` or plain text) with inline citations |\n| `ki_charts_html` | `ki-fy-header` + five `.peer-bar-chart-outer` panels |\n| `fi_charts_html` | Single `.peer-bar-chart-outer` panel (Revenue) |\n| `sc_col_1` … `sc_col_4` | Plain text (company names; each spans 2 sub-columns) |\n| `sc_col_{1..4}_curr`, `sc_col_{1..4}_fwd` | Plain text sub-header labels (`FY{YYYY}` / `Forward`) |\n| `sc_r{1..6}_c{1..4}_curr`, `…_fwd` | Plain text scorecard cell values |\n| `conclusion_html` | Three `<p>` paragraphs |\n| `section2_suffix` (TOC label and Section 2 heading) | `\" & Probability of Default\"` or empty string |\n| `ratings_chart_html` | Single `<div class=\"chart-container\">…<svg>…</svg>…</div>` block |\n| `pd_panel_html` | PD banner + bar chart + table, or the `.pd-unavailable` note |\n| `ratings_analysis_html` | One `<p>` paragraph |\n| `esg_heatmap_html` | `table.esg-heatmap` + `.esg-legend` |\n| `esg_analysis_html` | Two `<p>` paragraphs |\n\nIf fewer than 3 peers are returned, leave unused column/row slots empty. Do not collapse or\nremove cells — the pre-shaped tables simply keep those cells blank.\n\n### Cover / header fields\n\n- `report_date` — e.g. `October 22, 2026` (plain text; the example is illustrative only)\n- `target_company` — canonical name of the target (plain text)\n- `peer_count` — integer count of peers resolved in Steps 1–2 (plain text)\n- `company_chips_html` — target first (with the `target` class), then one chip per resolved peer;\n  omit chips for unresolved peer slots, do not pad to 3\n\n```html\n<span class=\"company-chip target\">Target Co</span>\n<span class=\"company-chip\">Peer One</span>\n<span class=\"company-chip\">Peer Two</span>\n<span class=\"company-chip\">Peer Three</span>\n```\n\nThe cover image strips in the template are intentionally empty; leave them as shipped.\n\n### Section 1 — Peers Comparison Table & Analysis\n\n**1) Peers Table** → `peers_table_html`\n\nWrite one `<tr>` per company (target first, then peers in order): company name + a substantive\ndescription paragraph built from `getEntityProfile` (business description, headquarters,\nemployees) and the credit opinion `Summary` (key segments/brands, scale). Include the latest\nfiscal-year revenue from the financials. Cite claims.\n\n```html\n<tr>\n  <td class=\"company-name\">Target Co</td>\n  <td>Headquartered in Dearborn, Michigan, Target Co is a global automaker with FY2025 revenue of\n  approximately $180B, anchored by its F-Series, SUV, and Pro commercial businesses.</td>\n</tr>\n```\n\n**2) Rating Summary** → `rating_cards_html`\n\nEmit exactly one `.rating-card` per company (target first, extra class `target-card`). Use only\nthe current (most recent) long-term issuer or senior unsecured rating and current outlook —\nnever loop over historical entries. Prefer Long-Term Issuer Rating; if absent, Senior Unsecured.\nThe rating cards are the sole representation of peer ratings in Section 1 (there is no separate\npeers-rating table).\n\n- `.rc-company` — abbreviated company name (≤ 25 chars; truncate with \"…\" if longer)\n- `.rc-rating` — Moody's rating symbol (e.g. `Baa2`), copied from `getEntityRatings`\n- `.rc-class` — rating class + most-recent rating date (e.g. `Senior Unsecured / 2024-05-09`)\n- `.outlook-badge` — canonical pastel classes only: `stable`, `positive`, `negative`, `review`, `na`\n\n```html\n<div class=\"rating-card target-card\">\n  <div class=\"rc-company\">Target Co</div>\n  <div class=\"rc-rating\">Baa2</div>\n  <div class=\"rc-class\">Senior Unsecured / 2024-05-09</div>\n  <span class=\"outlook-badge stable\">Stable</span>\n</div>\n```\n\n**3) Credit Drivers** → `cd_col_1`..`cd_col_4` and `cd_r{1-4}_c{1-4}` (4 rows × 4 company columns)\n\nWrite the 4 company header cells (`cd_col_1` = target, `cd_col_2`..`cd_col_4` = peers in order;\nempty strings for peer slots beyond what was resolved) and the 16 body cells:\n\n- Row 1 (Upgrade factors) — from `FactorsLeadingToUpgrade`\n- Row 2 (Downgrade factors) — from `FactorsLeadingToDowngrade`\n- Row 3 (Credit strengths, qualitative) — from `CreditStrengths`\n- Row 4 (Credit challenges, qualitative) — from `CreditChallenges`\n\nEach cell is a substantive paragraph with specific quantitative thresholds where available.\nQuantitative metrics are covered by the Key Indicators bar charts — the table has only 4 rows;\ndo not add a 5th row. If a credit opinion section is missing for a company, write\n`Not available` rather than leaving the cell blank.\n\n**4) Key Indicators — Peer Bar Charts** → `ki_charts_html` and `fi_charts_html`\n\nEmit five `.peer-bar-chart-outer` panels as `ki_charts_html`, and a single Revenue panel as\n`fi_charts_html` (it follows immediately with no separate sub-heading — the template already\nhandles this). The bar charts are the sole representation of key-indicator data. All panels use\nthe same markup so they look identical; the CSS classes in the template supply all colours, fonts\nand sizing — add no inline colours except as stated below.\n\n| Chart | Metric | Unit | Source | Note |\n|-------|--------|------|--------|------|\n| 1 | FCF Margin % | `%` | (OCF − \\|Capex\\|) / Revenue, from `getEntityFinancials_v2` | Higher = better |\n| 2 | Debt / EBITDA | `x` | `getEntityFinancials_v2` Key Indicators | Lower = better |\n| 3 | EBITDA Margin % | `%` | EBITDA / Revenue, from `getEntityFinancials_v2` | Higher = better |\n| 4 | EBITA / Interest | `x` | `getEntityFinancials_v2` Key Indicators | Higher = better |\n| 5 | RCF / Net Debt | `%` | `getEntityFinancials_v2` Key Indicators | Higher = better |\n\nPer KI panel:\n- Start the `ki_charts_html` block with one `<div class=\"ki-fy-header\">`, e.g.\n  `KEY INDICATORS — FY2025 | Company vs. Peers`; if entities have mixed fiscal years write\n  `KEY INDICATORS — Most Recent FY | Company vs. Peers`.\n- Inside each panel: `.pbc-title` (metric name in caps), `.pbc-subtitle` (unit + fiscal year, e.g.\n  `FY2025, % of revenue`), then a `<div class=\"pbc-legend\">` with four swatches via a CSS variable:\n  `<span style=\"--sw:#0066cc\">Target</span><span style=\"--sw:#6f9fd3\">Peers</span><span\n  style=\"--sw:#2e7d32\">Peer average</span><span style=\"--sw:#d9680f\">Peer median (line)</span>`.\n- One bar row per company: target first, then peers sorted by descending value, then the\n  average row last. Target bar `subj-pos` (or `subj-neg` if negative); peer bars `peer-pos` /\n  `peer-neg`; average `avg-bar` — the class goes on the `.pbc-fill` element.\n- Append the fiscal year to each company's `pbc-name` in parentheses, e.g. `Target Co (FY2025)`,\n  using the FY identified via `getEntityFinancials_v2` for that entity; put the full name in `title`.\n- Every row shows its numeric value in `.pbc-val` (class `pos`/`neg` for company rows, `avg-val`\n  for the average). Format: ratios to 1 decimal with `x` (e.g. `2.4x`), percentages to 1 decimal.\n- Median marker: `.pbc-median-line` with a `.pbc-median-tip` reading `Median {value}`, placed in\n  the **target row's track only** (not repeated on every row, to avoid clutter).\n- A closing `.pbc-note` line: peer median, peer average (n = number of peers), company value, gap.\n- **Bar width, positive-only charts:** `maxAbs` = max absolute value across company, peers and\n  average; `width = (value / maxAbs * 88).toFixed(1) + '%'`, `left:0`; median\n  `left = (median / maxAbs * 88).toFixed(1) + '%'`.\n- **Charts that can go negative (FCF margin; any other with a negative value):** add class\n  `zero-axis` to every `.pbc-track` in that panel; zero sits at 44%. Positive bars:\n  `left:44%; width=(v/maxAbs*44)%`. Negative bars: `left=(44-|v|/maxAbs*44)%;\n  width=(|v|/maxAbs*44)%`. Median `left = (44 + median/maxAbs*44)%`.\n- Compute peer average and median across resolved peers only (exclude the target). Omit the bar\n  row for a company whose value is missing and say so in the `.pbc-note`.\n\n```html\n<div class=\"ki-fy-header\">KEY INDICATORS — FY2025 | Company vs. Peers</div>\n<div class=\"peer-bar-chart-outer\">\n  <div class=\"pbc-title\">Debt / EBITDA</div>\n  <div class=\"pbc-subtitle\">FY2025, multiple (x) — lower is stronger</div>\n  <div class=\"pbc-legend\"><span style=\"--sw:#0066cc\">Target</span><span style=\"--sw:#6f9fd3\">Peers</span><span style=\"--sw:#2e7d32\">Peer average</span><span style=\"--sw:#d9680f\">Peer median (line)</span></div>\n  <div class=\"pbc-rows\">\n    <div class=\"pbc-row\">\n      <div class=\"pbc-name subject\" title=\"Target Co\">Target Co (FY2025)</div>\n      <div class=\"pbc-track\">\n        <div class=\"pbc-median-line\" style=\"left:52.3%\"><div class=\"pbc-median-tip\">Median 2.1x</div></div>\n        <div class=\"pbc-fill subj-pos\" style=\"left:0;width:61.0%\"></div>\n      </div>\n      <div class=\"pbc-val pos\">2.4x</div>\n    </div>\n    <!-- one row per resolved peer (sorted descending), then the average row last -->\n    <div class=\"pbc-row\" style=\"margin-top:4px;padding-top:8px;border-top:1px dashed #cbd5e1\">\n      <div class=\"pbc-name average\">Peer average</div>\n      <div class=\"pbc-track\"><div class=\"pbc-fill avg-bar\" style=\"left:0;width:50.7%\"></div></div>\n      <div class=\"pbc-val avg-val\">2.0x</div>\n    </div>\n  </div>\n  <div class=\"pbc-note\">Peer median 2.1x | Peer avg 2.0x (n=3). Company: 2.4x. Gap vs. median: +0.3x.</div>\n</div>\n<!-- repeat for FCF Margin %, EBITDA Margin %, EBITA/Interest, RCF/Net Debt (HTML comments are\n     shown here for illustration only — do not leave them in the final value) -->\n```\n\n**Revenue chart** (`fi_charts_html`; same panel markup, same FY header convention, no separate\nsub-heading, unit USD billions, values formatted `$12.3B`). Always include a Peer average row\n(peer mean, excluding the target) when at least one peer resolved. `maxRevenue` = max across all\nrows including the average and the median. **Include the peer-median line exactly like every Key\nIndicators chart**: a `.pbc-median-line` with a `.pbc-median-tip` reading `Median $X.XB` in the\ntarget row's track at `left = (median / maxRevenue * 88)%`, the `Peer median (line)` legend entry\n(`style=\"--sw:#d9680f\"`), and the median in the closing `.pbc-note`. Target bar `subj-pos`, peer\nbars `peer-pos`, average `avg-bar`, each class on the `.pbc-fill` element. If a revenue value is\nmissing show `N/A` and omit the bar. Do not add a Debt/EBITDA chart here — it is already in the\nKI charts.\n\n**5) Scorecards** → `sc_col_*` and `sc_r{1-6}_c{1-4}_{curr|fwd}` (6 rows × 4 companies × Current/Forward)\n\nWrite the 4 top-level company headers (`sc_col_1`..`sc_col_4`, target first) and the 8 sub-header\nlabels (`sc_col_{1-4}_curr`, `sc_col_{1-4}_fwd`).\n\n> **FY LABEL SYNCHRONY — STRICTLY ENFORCED (Sections 4 and 5):**\n> The label in `sc_col_{n}_curr` for a company MUST be identical to the FY label appended to\n> that company's bars in the Key Indicators charts — the most recent non-null full fiscal year\n> from `getEntityFinancials_v2` (with `excludeInterimData: true`), labelled `FY{YYYY}` (e.g.\n> `FY2025`). **Never use \"LTM\", \"TTM\", \"Current\", or any label other than the specific\n> `FY{YYYY}` form.** Each entity's label is set independently (e.g. a June year-end company\n> keeps its own FY). `sc_col_{n}_fwd` is simply `Forward`. All numbers in Section 4 and the\n> Scorecard Current cells must come from the same `FY{YYYY}` period. If entities have different\n> most-recent FYs, the KI header reads `KEY INDICATORS — Most Recent FY | Company vs. Peers`.\n> Check this synchrony before writing the file; mismatched labels are a hard failure.\n\n> **`~` (tilde) prefix rule — STRICT:** `~` (e.g. `~2.5x`) means approximately estimated /\n> forecast and must ONLY appear in **Forward** (`_fwd`) cells, never in **Current** (`_curr`)\n> cells. Current cells contain actual reported or Moody's-adjusted figures; use the precise\n> value as-is (e.g. `2.3x`, `14.8%`).\n\n> **Distorted EBITDA years.** If the most recent FY has a non-cash charge (e.g. goodwill\n> impairment) that makes Debt/EBITDA not meaningful, still use that year as the reference; show\n> the reported figure with a `†` marker (e.g. `N/M†`) and use the Moody's-adjusted ratio from the\n> credit opinion's Key Indicators exhibit or the scorecard factor value for the leverage cell\n> instead.\n\nWrite the 48 body cells for the 6 rows:\n- Row 1 — Scale: Revenue/Sales (USD bn)\n- Row 2 — Profitability: EBIT(A) margin\n- Row 3 — Leverage: Debt/EBITDA\n- Row 4 — Cash flow: RCF/Net debt\n- Row 5 — Coverage: EBIT(A)/Interest\n- Row 6 — Actual rating — from `getEntityRatings`, verbatim. The Current cell is the rating\n  symbol; the Forward cell is the current outlook (e.g. `Stable`). If `getEntityRatings` returns\n  no current Long-Term Rating or an obviously stale one, show what it returned with its date and\n  do not substitute a rating from credit-opinion prose. There is no \"Scorecard-indicated\n  outcome\" row.\n\nRows 1–5 — **every resolved company's cells must show a value, never blank and never a bare\n\"N/A\" when any source has the number.** Fill in this order and stop at the first source that has it:\n1. **Current:** the Moody's-adjusted ratio for the latest fiscal year from `getEntityFinancials_v2`\n   (`reportingBasis: \"adjusted\"` when needed), then the same metric from `getEntityScorecardV2`\n   (`factors`/subfactor values), then the credit opinion `KeyIndicatorsTable` / `RatingFactors`\n   column for that FY. Compute margins/ratios yourself from reported statement lines if no\n   adjusted figure exists, and mark them `(rep.)`.\n2. **Forward:** the first projected column (or projected range) in the credit opinion\n   `KeyIndicatorsTable`; else the forward values quoted in `RatingFactors` / `Summary`; else the\n   forward scorecard value from `getEntityScorecardV2`. Format projections with a leading `~`.\n3. If an entity's latest opinion is older than 12 months or a forward column is genuinely absent,\n   re-call `getCreditOpinion` for that entity with a `publishDate` range covering the last 3 years\n   (`mode: \"range\"`, `from` and `to` both set) and use the newest opinion that has a projection,\n   adding `(as of {Mon YYYY})` to the cell.\n4. Only if every source above is exhausted, write `—` (an em dash). Never write \"N/A\", leave a\n   cell blank, or invent a projection; the template's footnote explains the dash.\n\nIf fewer than 3 peers resolved, leave the unused column cells empty — do not collapse the table.\n\n**6) Conclusion** → `conclusion_html`\n\nWrite this last, from the findings you have already produced for the financials, ratings, ESG and\nPD sections — differentiate the target among its peers; do not re-derive data. Three `<p>`\nparagraphs, oriented around the target company's differentiation:\n\n- Paragraph 1: how the target differentiates positively vs. weaker peers on quantitative\n  metrics (leverage, coverage, cash flow) — cite specific ratios.\n- Paragraph 2: business risk profile comparison — where the target is more concentrated or less\n  diversified vs. stable peers, referencing upgrade/downgrade triggers.\n- Paragraph 3: practical positioning — frame the target's \"path to stand out\" by linking back to\n  the upgrade/downgrade framework and key risk factors.\n\nAt most one citation per sentence. Cite only records you actually received from a tool result;\nnever add a generic \"Moody's Ratings result\" source.\n\n### Section 2 — Ratings Chart (± Probability of Default)\n\n> **SECTION 2 TITLE RULE — STRICTLY ENFORCED:**\n> The template reads `Section 2. Ratings Chart{{ section2_suffix }}` in both the TOC label and\n> the section heading. Set `section2_suffix` to:\n> - `\" & Probability of Default\"` if PD data is available (a real banner + chart + table is\n>   written into the PD panel)\n> - `\"\"` (empty string) if PD data is unavailable after the retry\n>\n> Keep this consistent with what the PD panel actually contains — never append\n> \"& Probability of Default\" if the panel only has the unavailable placeholder.\n\nSection 2 order: Ratings Chart → PD panel → Ratings analysis.\n\n**Chart** → `ratings_chart_html`\n\nEmit a single `<div class=\"chart-container\">…<svg>…</svg>…</div>` block, built the same way\nevery run — this is the only chart spec, do not improvise. It plots the last 5 rating actions per\ncompany as a line chart, most-recent point highlighted, x-axis labelled with actual rating dates.\n\n**Fixed constants (always use these exact numbers):**\n- `viewBox=\"0 0 780 440\"`, plot area `x: 90→740` (650px wide), `y: 50→350` (300px tall); the SVG\n  has `width=\"100%\"` and no fixed height so it scales with the page.\n- `maxPts` = the largest number of rating actions any company has, capped at 5\n- Palette (target first, colour-blind-safe and legible on white): `#0066cc`, `#d9680f`, `#1a7a4a`,\n  `#7c3aed`. Give each peer line a distinct dash pattern (`stroke-dasharray=\"6 4\"` on peers) only\n  if two lines overlap; the target line is always solid and drawn last (on top).\n- `xPos(i) = 90 + (i / (maxPts - 1)) * 650` (if `maxPts` is 1, centre at x=415)\n\n**Rating → numeric value** (higher = better), index 0 = `C` (value 1) … index 20 = `Aaa`\n(value 21):\n`[\"C\",\"Ca\",\"Caa3\",\"Caa2\",\"Caa1\",\"B3\",\"B2\",\"B1\",\"Ba3\",\"Ba2\",\"Ba1\",\"Baa3\",\"Baa2\",\"Baa1\",\"A3\",\"A2\",\"A1\",\"Aa3\",\"Aa2\",\"Aa1\",\"Aaa\"]`\n\n**Y-axis range:** `minV = clamp(min(all values) - 1, 1, 21)`, `maxV = clamp(max(all values) + 1,\n1, 21)` (if equal, `maxV = minV + 1`). One gridline + label per whole-number tier from `minV` to\n`maxV`. `yPos(v) = 50 + 300 - ((v - minV) / (maxV - minV)) * 300`.\n\n**Drawing rules:**\n- Gridlines `stroke=\"#e5e7eb\"`; y-axis tier labels `font-size=\"12\" fill=\"#475569\"\n  text-anchor=\"end\"` at `x=\"82\"`, vertically centred on the gridline (`y = yPos + 4`). Rotated\n  y-axis title \"Moody's rating\" (`font-size=\"11\" fill=\"#64748b\"`, `transform=\"rotate(-90 20 200)\"`\n  at `x=\"20\" y=\"200\"`).\n- X-axis baseline `stroke=\"#334155\" stroke-width=\"1.5\"` at `y=\"350\"`; date labels (`MMM YYYY`)\n  `font-size=\"11\" fill=\"#475569\" text-anchor=\"middle\"` at `y=\"372\"`; x-axis title \"Rating action\n  date (oldest to most recent)\" `font-size=\"11\" fill=\"#64748b\"` centred at `x=\"415\" y=\"410\"`.\n- Lines: `stroke-width=\"2.5\" stroke-linejoin=\"round\" stroke-linecap=\"round\"`.\n- Regular points: `<circle r=\"5\">` in company colour with a white 1.5px stroke. Most-recent point\n  (rightmost): `<circle r=\"8\">` in company colour with a white `<circle r=\"4\" fill=\"white\"/>`\n  stacked on top, plus `<title>{company} · {rating symbol} · {date}</title>`.\n- Value labels beside each point: rating symbol, `font-size=\"11\" font-weight=\"700\"`, company\n  colour, with a white halo (`paint-order=\"stroke\" stroke=\"#fff\" stroke-width=\"3\"`). Place the\n  target's labels above (`dy=\"-12\"`) and each peer's below (`dy=\"20\"`) so overlapping series stay\n  readable. If two points in the same series sit within 40px of each other horizontally, label\n  only the leftmost; always label the most recent point.\n- Legend below the SVG (`.chart-legend`) with each company's current rating in parens, e.g.\n  `Target Co (Baa1)`, target first.\n- Clean markup only: no scratch arithmetic, no HTML comments left in the final value.\n\n```html\n<div class=\"chart-container\">\n  <div class=\"chart-title\">Moody's Long-Term Rating History — Last 5 Actions</div>\n  <div class=\"chart-subtitle\">Higher on the axis = stronger credit quality; most recent action marked with a ringed point</div>\n  <svg viewBox=\"0 0 780 440\" width=\"100%\" preserveAspectRatio=\"xMidYMid meet\">\n    <line x1=\"90\" y1=\"50\" x2=\"740\" y2=\"50\" stroke=\"#e5e7eb\" stroke-width=\"1\"/>\n    <text x=\"82\" y=\"54\" text-anchor=\"end\" font-size=\"12\" fill=\"#475569\">Baa1</text>\n    <!-- one gridline + label per tier from minV to maxV -->\n    <line x1=\"90\" y1=\"350\" x2=\"740\" y2=\"350\" stroke=\"#334155\" stroke-width=\"1.5\"/>\n    <text x=\"90\" y=\"372\" text-anchor=\"middle\" font-size=\"11\" fill=\"#475569\">Jan 2021</text>\n    <!-- one date label per x position, then the axis titles -->\n    <path d=\"M90,202 L252,202 L415,148 L577,148 L740,148\" fill=\"none\" stroke=\"#0066cc\"\n          stroke-width=\"2.5\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/>\n    <circle cx=\"90\" cy=\"202\" r=\"5\" fill=\"#0066cc\" stroke=\"#fff\" stroke-width=\"1.5\"/>\n    <text x=\"90\" y=\"190\" text-anchor=\"middle\" font-size=\"11\" font-weight=\"700\" fill=\"#0066cc\" paint-order=\"stroke\" stroke=\"#fff\" stroke-width=\"3\">Baa2</text>\n    <circle cx=\"740\" cy=\"148\" r=\"8\" fill=\"#0066cc\"/>\n    <circle cx=\"740\" cy=\"148\" r=\"4\" fill=\"white\"/>\n    <title>Target Co · Baa1 · Mar 2025</title>\n    <!-- repeat path + circles for each peer with palette[1..3] -->\n  </svg>\n  <div class=\"chart-legend\">\n    <div class=\"chart-legend-item\"><span class=\"chart-legend-swatch\" style=\"background:#0066cc\"></span>Target Co (Baa1)</div>\n    <!-- one legend item per company -->\n  </div>\n  <div class=\"chart-source\">Source: Moody's Long-Term Ratings</div>\n</div>\n```\n\nFor companies with fewer than 5 historical ratings, either repeat the oldest available value to\nfill trailing points, or reduce `maxPts` to the largest available count and drop the\ncorresponding x-axis labels. Compute coordinates once, silently — do not leave scratch arithmetic\nor alternative options as HTML comments in the output (the comments in the snippet above are\nillustrative only).\n\n**PD panel** → `pd_panel_html`\n\nAlways write something into the PD panel — it is never silently empty.\n\nCompute the peer average (1-year PD, 5-year cumulative PD) as the arithmetic mean across resolved\npeers only (exclude the target). Map the average PD to a PD-implied rating the same way as for\nindividual companies. Always label the implied rating \"PD-implied rating\", never as a Moody's\nrating.\n\nDetermine the PD signal:\n- `red` — target 1-year PD is >2× peer average\n- `amber` — target 1-year PD is 1.25–2× peer average\n- `green` — target 1-year PD is ≤1.25× peer average\n\n**If PD is still unavailable after the retry**, set `pd_panel_html` to:\n\n```html\n<div class=\"pd-unavailable\">Probability of Default data was unavailable for this run.</div>\n```\n\nand set `section2_suffix` to an empty string.\n\n**When PD data is available**, write, in this order:\n\n1. **Signal banner** (`.pd-banner`, modifier matches the signal): `PD Signal: {SIGNAL} —\n   {Target}'s 1-year PD ({x}%) is {n}× the peer average ({y}%), {range description}.` followed by\n   one sentence of context. No emoji or icon characters — the colour modifier carries the signal.\n\n2. **1-year PD bar chart** (immediately after the banner, before the table): one\n   `.peer-bar-chart-outer` panel reusing the Key Indicators bar markup exactly. Use only the\n   template's existing classes (`pbc-title`, `pbc-subtitle`, `pbc-legend`, `pbc-rows`, `pbc-row`,\n   `pbc-name`, `pbc-track`, `pbc-fill`, `pbc-val`, `pbc-note`, plus `pbc-scale-note`, `pbc-axis`,\n   `grid`) — never invent new class names or inline swatch styles.\n   - `.pbc-title` \"1-Year Probability of Default\"; `.pbc-subtitle` \"Moody's EDF, % — lower is\n     stronger\".\n   - `.pbc-legend`: `<span style=\"--sw:#0066cc\">Target</span><span style=\"--sw:#6f9fd3\">Peers</span><span\n     style=\"--sw:#2e7d32\">Peer average</span>` (same markup as the Key Indicators legend, no median\n     entry).\n   - **Log scale (required).** PDs across a peer set routinely differ by 50x or more, so a linear\n     scale makes the investment-grade peers' bars invisible slivers. Size every bar on a\n     logarithmic scale: `lo = 10^floor(log10(min value))`, `hi = 10^ceil(log10(max value))` (across\n     all rows including the average),\n     `width = (6 + 82 * (log10(v) - log10(lo)) / (log10(hi) - log10(lo))).toFixed(1) + '%'` — so\n     the smallest bar is still at least 6% wide and the largest at most 88%. Add class `grid` to\n     every `.pbc-track` (it draws quarter-way gridlines), and directly under the rows add a\n     `<div class=\"pbc-axis\"><span class=\"pbc-axis-spacer\"></span><span class=\"pbc-axis-ticks\"><span>{lo}%</span>\n     <span>{mid1}%</span><span>{mid2}%</span><span>{hi}%</span></span><span class=\"pbc-axis-end\"></span></div>`\n     whose tick labels are the PD values at 0, 1/3, 2/3 and 100% of the log range (format with up\n     to 3 significant figures). Then `<div class=\"pbc-scale-note\">Logarithmic scale — bar length\n     is not proportional to PD.</div>` right under the subtitle.\n   - **The colour class goes on the `.pbc-fill` element itself** (never only on the row), exactly\n     as in the Key Indicators charts: `<div class=\"pbc-track grid\"><div class=\"pbc-fill subj-pos\"\n     style=\"left:0;width:50.9%\"></div></div>` for the target, `pbc-fill peer-pos` for peers,\n     `pbc-fill avg-bar` for the average. A fill with no colour class and no width renders as an\n     empty track, so every row must have both.\n   - Rows: target first (`subj-pos`), peers sorted by descending PD (`peer-pos`), then a\n     dashed-border `Peer average` row (`avg-bar`). `.pbc-name` carries the company's short name;\n     `.pbc-val` shows the 1-year PD with 3 significant figures and a `%` sign (e.g. `0.0084%`),\n     class `pos` on the target's value. Do not show a median line.\n   - `.pbc-note`: one sentence stating the target's PD as a multiple of the peer average and\n     which peer is highest/lowest.\n\n3. **Table** (`.pd-table`) — columns: Company | 1-Year PD (%) | 5-Year Cumulative PD (%) |\n   PD-Implied Rating | Moody's Rating. Target row first (`.pd-row-target`, name tagged\n   `<span class=\"pd-target-tag\">(TARGET)</span>`), then peers, then a final `.pd-row-avg` row\n   labelled `Peer Average (ex-{Target})` (Moody's Rating column shows `—` for the average row).\n   The Moody's Rating column is copied verbatim from `getEntityRatings`; never re-derive it from\n   PD data or any other source.\n\n```html\n<div class=\"pd-banner amber\">\n  <div><strong>PD Signal: AMBER</strong> — Target Co's 1-year PD (0.0234%) is 1.87× the peer\n  average (0.0125%), within the 1.25–2.0× amber range. Elevated relative to peers but consistent\n  with a strong investment-grade entity carrying elevated near-term capex.</div>\n</div>\n<!-- 1-year PD bar chart panel here -->\n<div class=\"chart-source\">PD-implied ratings are model-implied and are not Moody's ratings.</div>\n<table class=\"pd-table\">\n  <thead>\n    <tr><th>Company</th><th>1-Year PD (%)</th><th>5-Year Cumulative PD (%)</th><th>PD-Implied Rating</th><th>Moody's Rating</th></tr>\n  </thead>\n  <tbody>\n    <tr class=\"pd-row-target\">\n      <td class=\"company-name\">Target Co <span class=\"pd-target-tag\">(TARGET)</span></td>\n      <td>0.0234%</td><td>0.4009%</td><td>Aa1</td><td>A1</td>\n    </tr>\n    <tr><td class=\"company-name\">Peer A</td><td>0.0176%</td><td>0.2807%</td><td>Aaa</td><td>Aa2</td></tr>\n    <!-- one row per resolved peer -->\n    <tr class=\"pd-row-avg\">\n      <td>Peer Average (ex-Target Co)</td><td>0.0125%</td><td>0.2222%</td><td>Aaa</td><td>—</td>\n    </tr>\n  </tbody>\n</table>\n```\n\n**Analysis** → `ratings_analysis_html`\n\nOne `<p>` paragraph on rating trajectories — which companies show improvement, deterioration, or\nstability, and what that implies for relative credit positioning.\n\n### Section 3 — ESG Heatmap & Analysis\n\n**ESG heatmap** → `esg_heatmap_html`\n\nA colour-coded HTML table — the only ESG data table (there is no separate plain ESG table).\nFive columns: company name, Overall (CIS-*), Environmental (E-*), Social (S-*), Governance (G-*).\nLabel scores precisely: CIS = Credit Impact Score, E/S/G = Issuer Profile Scores. Apply a CSS\nclass to each score `<td>` based on numeric severity (lower = better): `esg-s1` (green, minimal\nrisk) … `esg-s5` (red, very high risk) — parse the numeric suffix from the score string (e.g.\n`CIS-3` → 3). If a company returns no ESG data, or a score is `N/A` or missing, show `N/A` and\nomit the colour class.\n\n```html\n<table class=\"esg-heatmap\">\n  <thead>\n    <tr><th>Company</th><th>CIS (Overall)</th><th>E Score</th><th>S Score</th><th>G Score</th></tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td>Target Co</td>\n      <td class=\"esg-s3\">CIS-3</td><td class=\"esg-s4\">E-4</td><td class=\"esg-s3\">S-3</td><td class=\"esg-s2\">G-2</td>\n    </tr>\n    <!-- one row per company, target first, same order as all other tables -->\n  </tbody>\n</table>\n<div class=\"esg-legend\">\n  <span><i style=\"background:#bbf7d0\"></i>1 Positive / minimal</span>\n  <span><i style=\"background:#d9f99d\"></i>2 Low</span>\n  <span><i style=\"background:#fde68a\"></i>3 Moderate</span>\n  <span><i style=\"background:#fdba74\"></i>4 High</span>\n  <span><i style=\"background:#fca5a5\"></i>5 Very high</span>\n</div>\n```\n\nAlways include the legend after the table. Wrap nothing else around it; the `esg-heatmap` class\n(already styled in the template) supplies fixed column widths, cell spacing and colours. Use the\ncompany's short name in the first cell (full name in `title`).\n\n**Analysis** → `esg_analysis_html`\n\nTwo `<p>` paragraphs:\n- Paragraph 1: compare ESG profiles across the peer set — which companies share similar\n  profiles and what drives the overall classification.\n- Paragraph 2: highlight the key differentiator (typically Governance) and explain which company\n  stands out as weaker/stronger and why.\n\n### Citations & Sources\n\nThe report carries **one consolidated, de-duplicated, continuously numbered Sources list** at the\nvery end, covering Sections 1–3 (there are no per-section citation recaps). Attribute\nsubstantive claims inline with numbered references:\n\n- **Inline reference:** `<a class=\"cite-ref\" href=\"{source URL}\" target=\"_blank\">[n]</a>`\n  immediately after the claim (the `cite-ref` class is styled in the template). If the tool\n  result gives no URL for the source, use `<span class=\"cite-ref\">[n]</span>` instead.\n- **Numbering:** assign `n` in order of first appearance across the finished document\n  (top-to-bottom: Section 1 → 3), one number per distinct source; reuse the same `n` whenever\n  the same source is cited again.\n- **Sources list:** fill the template's `#sources-footer` container (the template comment says it\n  is platform-filled; in this skill you fill it yourself) with one list matching the inline\n  numbers:\n  ```html\n  <aside class=\"citations\"><ol>\n    <li>{Document or record title} — Moody's, {date}</li>\n    <!-- one <li> per source, in [1], [2], … order -->\n  </ol></aside>\n  ```\n  Internal MCP tool names (e.g. `getCreditOpinion`) are NEVER rendered in the Sources list.\n- **Citation hygiene** (keep the list tidy):\n  - Cite each source once per paragraph or table row rather than after every figure; in the\n    Scorecard cite once per company column (on its Current cell) instead of on every cell.\n  - Cite the credit opinion document for qualitative statements and the financials record for\n    ratios.\n  - Cite each company's rating record once per rating card and once in the ratings analysis\n    paragraph — not on chart points, labels or legend items (the chart carries one uncited\n    \"Source\" line instead).\n  - Cite each company's ESG record once in the analysis paragraphs; do not cite individual\n    heatmap cells.\n  - Cite each company's PD record once, in the banner sentence; do not cite chart bars or table\n    cells, and do not cite rating records there.\n  - Never cite a record you did not receive from a tool result in this run. If you cannot cite a\n    fact precisely, leave it uncited — an uncited sentence is fine; a fake citation is not.\n  - Never cite a \"no data found\" statement unless a tool result actually returned a record\n    marked as no data for that lookup.\n\n### Class-selection rules\n\n**`.outlook-badge`** modifier (inside rating cards):\n\n- `stable` — outlook is \"Stable\"\n- `positive` — outlook is \"Positive\"\n- `negative` — outlook is \"Negative\"\n- `review` — outlook contains \"Review\" (e.g., \"Rating Under Review\")\n- `na` — outlook is missing or unknown\n\n**`.company-chip.target`** applies only to the target (first) chip. Remaining chips use plain\n`.company-chip`.\n\n### Conventions\n\n- Use `<p>` for paragraphs, `<ul><li>` for bullets, `<strong class=\"subsection-title\">…</strong>`\n  for bold subheaders inside prose containers.\n- Do NOT include overall section titles inside the filled values — the template already has them.\n- `rating` values: use Moody's rating symbol (e.g. `Aaa`, `Aa1`, `Baa2`, `Ba1`). If not found,\n  use `N/A`.\n- `outlook` values: `Stable`, `Positive`, `Negative`, `Rating Under Review`, or `N/A`.\n- Charts use the template's own CSS classes and inline SVG (no external chart library); colours,\n  fonts and sizing come from the template so all panels look identical. No emoji or icon glyphs\n  in any generated content.\n\n---\n\n## Guardrails (apply across the whole workflow)\n\n- **Never fabricate** rating values, outlooks, dates, financial figures, or rationale text. Every\n  rating traces back to `getEntityRatings`; every financial figure to `getEntityFinancials_v2`,\n  `getEntityScorecardV2` or the credit opinion's exhibits.\n- **The target company always appears first** — first column/row in every table and comparison.\n- If fewer than 3 peers are resolved, leave the unused column/row slots empty — do not pad with\n  invented peers, and do not collapse or restructure the pre-shaped tables.\n- If a Credit Opinion section is missing for a company, write `Not available` rather than\n  leaving the cell blank.\n- Rating consistency across sections is structural, not a final-pass check: every section that\n  shows a company's current rating takes it from the same `getEntityRatings` result, so one\n  ground-truth source feeds the Rating Cards, Ratings Chart, Scorecard \"Actual rating\" row and PD\n  table.\n\n## Tips\n\n- Run ALL data-gathering tool calls in a single parallel batch (one message, many tool calls).\n- Write the final HTML to disk as a single `.html` file and deliver it via `present_files` — do\n  not print the HTML source in the chat, do not split across multiple files.\n- The conclusion must orient around the target company — how it differentiates from its peers.\n- Before writing the file, check: no `{{ ... }}` token left; FY labels in the KI charts match the\n  Scorecard sub-headers; the Section 2 title matches the PD panel; the Scorecard has exactly 6\n  body rows; the Actual rating row matches the Rating Cards for every company; the Sources list\n  numbers match the inline references.\n\n---\n\n## Step 6 — Save and deliver the report as a downloadable file\n\nAfter assembling the complete HTML string, **write it to disk as a standalone `.html` file** and\nmake it available for the user to download. Do **not** print the raw HTML in the chat.\n\n### File naming\n\nUse the pattern: `{target_company_slug}_peer_analysis.html`\n\nWhere `{target_company_slug}` is the target company's canonical name lowercased, spaces and\nspecial characters replaced with underscores (e.g. `apple_inc_peer_analysis.html`).\n\n### Delivery\n\nAfter writing the file, use whatever file-presentation capability is available in the current\nenvironment to surface the file to the user so they can open or download it. Do not describe\nthe tool being used — just invoke it. Then add one short confirmation sentence, for example:\n`The peer analysis report for [Target Company] is ready to download above.`\n\nDo **not** print the HTML source in the chat. Do **not** emit a fenced ` ```html ` code block.\nThe saved file is the sole deliverable.\n"
}

SHA-256 of public snapshot: d729d10c86dcd81899775f06d431f89d8e1b7b42998fca46b011f1bf9f69b48f